current/compiler/js-calc.xsl: Replace all preproc:symtable XPaths with map
This uses the already-available symtable-map to avoid expensive XPaths resulting in (what I assume to be) linear scans of the symbol table. This effectively makes the fragment compilation time vanish. This had the effect of shaving ~4.5m total off of our largest system (if I were to do `-j1`), and a couple minutes when run in parallel. DEV-15095main
parent
b7372fe7cd
commit
50e31f4616
|
@ -133,6 +133,8 @@
|
||||||
|
|
||||||
<template mode="js-name-ref" priority="5"
|
<template mode="js-name-ref" priority="5"
|
||||||
match="c:sum[@of]|c:product[@of]">
|
match="c:sum[@of]|c:product[@of]">
|
||||||
|
<param name="symtable-map" as="map(*)" tunnel="yes" />
|
||||||
|
|
||||||
<variable name="of" select="@of" />
|
<variable name="of" select="@of" />
|
||||||
<variable name="func" select="ancestor::lv:function" />
|
<variable name="func" select="ancestor::lv:function" />
|
||||||
|
|
||||||
|
@ -142,9 +144,8 @@
|
||||||
<!-- is @of a function param? -->
|
<!-- is @of a function param? -->
|
||||||
<when test="
|
<when test="
|
||||||
$func
|
$func
|
||||||
and root(.)/preproc:symtable/preproc:sym[
|
and $symtable-map( concat( ':', $func/@name, ':', $of ) )[
|
||||||
@type='lparam'
|
@type='lparam'
|
||||||
and @name=concat( ':', $func/@name, ':', $of )
|
|
||||||
]
|
]
|
||||||
">
|
">
|
||||||
|
|
||||||
|
@ -157,13 +158,7 @@
|
||||||
</when>
|
</when>
|
||||||
|
|
||||||
<!-- maybe a constant? -->
|
<!-- maybe a constant? -->
|
||||||
<when test="
|
<when test="$symtable-map( $of )[ @type = 'const' ]">
|
||||||
root(.)/preproc:symtable/preproc:sym[
|
|
||||||
@type='const'
|
|
||||||
and @name=$of
|
|
||||||
]
|
|
||||||
">
|
|
||||||
|
|
||||||
<text>C['</text>
|
<text>C['</text>
|
||||||
<value-of select="@of" />
|
<value-of select="@of" />
|
||||||
<text>']</text>
|
<text>']</text>
|
||||||
|
@ -477,6 +472,8 @@
|
||||||
<!-- TODO: this should really be decoupled -->
|
<!-- TODO: this should really be decoupled -->
|
||||||
<!-- TODO: does not properly support matrices -->
|
<!-- TODO: does not properly support matrices -->
|
||||||
<template match="c:value-of[ ancestor::lv:match ]" mode="compile-calc" priority="5">
|
<template match="c:value-of[ ancestor::lv:match ]" mode="compile-calc" priority="5">
|
||||||
|
<param name="symtable-map" as="map(*)" tunnel="yes" />
|
||||||
|
|
||||||
<param name="noindex" as="xs:boolean" tunnel="yes"
|
<param name="noindex" as="xs:boolean" tunnel="yes"
|
||||||
select="false()" />
|
select="false()" />
|
||||||
|
|
||||||
|
@ -485,8 +482,7 @@
|
||||||
<choose>
|
<choose>
|
||||||
<!-- scalar -->
|
<!-- scalar -->
|
||||||
<when test="
|
<when test="
|
||||||
$noindex
|
$noindex or $symtable-map( $name )/@dim = '0'
|
||||||
or root(.)/preproc:symtable/preproc:sym[ @name=$name ]/@dim = '0'
|
|
||||||
">
|
">
|
||||||
<apply-templates select="." mode="compile-calc-value" />
|
<apply-templates select="." mode="compile-calc-value" />
|
||||||
</when>
|
</when>
|
||||||
|
@ -642,11 +638,16 @@
|
||||||
@return index (including brackets), if one was provided
|
@return index (including brackets), if one was provided
|
||||||
-->
|
-->
|
||||||
<template match="c:*" mode="compile-calc-index">
|
<template match="c:*" mode="compile-calc-index">
|
||||||
|
<param name="symtable-map" as="map(*)" tunnel="yes" />
|
||||||
<param name="value" />
|
<param name="value" />
|
||||||
|
|
||||||
<variable name="index" select="@index" />
|
<variable name="index" select="@index" />
|
||||||
|
|
||||||
<choose>
|
<choose>
|
||||||
<when test="@index">
|
<when test="$index">
|
||||||
|
<variable name="index-sym" as="element( preproc:sym )?"
|
||||||
|
select="$symtable-map( $index )" />
|
||||||
|
|
||||||
<text>(</text>
|
<text>(</text>
|
||||||
<value-of select="$value" />
|
<value-of select="$value" />
|
||||||
|
|
||||||
|
@ -666,13 +667,11 @@
|
||||||
</when>
|
</when>
|
||||||
|
|
||||||
<!-- scalar constant -->
|
<!-- scalar constant -->
|
||||||
<when test="@index = root(.)/preproc:symtable/preproc:sym
|
<when test="$index-sym[ @type='const' and @dim='0' ]">
|
||||||
[ @type='const'
|
<variable name="value" as="xs:string"
|
||||||
and @dim='0' ]
|
select="$index-sym/@value" />
|
||||||
/@name">
|
|
||||||
<value-of select="root(.)/preproc:symtable
|
<value-of select="$value" />
|
||||||
/preproc:sym[ @name=$index ]
|
|
||||||
/@value" />
|
|
||||||
</when>
|
</when>
|
||||||
|
|
||||||
<!-- otherwise, it's a variable -->
|
<!-- otherwise, it's a variable -->
|
||||||
|
@ -779,8 +778,12 @@
|
||||||
@return generated function application
|
@return generated function application
|
||||||
-->
|
-->
|
||||||
<template match="c:apply" mode="compile-calc" priority="5">
|
<template match="c:apply" mode="compile-calc" priority="5">
|
||||||
|
<param name="symtable-map" as="map(*)" tunnel="yes" />
|
||||||
|
|
||||||
<variable name="name" select="@name" />
|
<variable name="name" select="@name" />
|
||||||
<variable name="self" select="." />
|
<variable name="self" select="." />
|
||||||
|
<variable name="func-sym" as="element( preproc:sym )"
|
||||||
|
select="$symtable-map( $name )[ @type = 'func' ]" />
|
||||||
|
|
||||||
<call-template name="calc-compiler:gen-func-name">
|
<call-template name="calc-compiler:gen-func-name">
|
||||||
<with-param name="name" select="@name" />
|
<with-param name="name" select="@name" />
|
||||||
|
@ -792,13 +795,7 @@
|
||||||
|
|
||||||
<!-- generate argument list in the order that the arguments are expected (they
|
<!-- generate argument list in the order that the arguments are expected (they
|
||||||
can be entered in the XML in any order) -->
|
can be entered in the XML in any order) -->
|
||||||
<for-each select="
|
<for-each select="$func-sym/preproc:sym-ref">
|
||||||
root(.)/preproc:symtable/preproc:sym[
|
|
||||||
@type='func'
|
|
||||||
and @name=$name
|
|
||||||
]/preproc:sym-ref
|
|
||||||
">
|
|
||||||
|
|
||||||
<text>, </text>
|
<text>, </text>
|
||||||
|
|
||||||
<variable name="pname" select="substring-after( @name, $arg-prefix )" />
|
<variable name="pname" select="substring-after( @name, $arg-prefix )" />
|
||||||
|
@ -877,8 +874,12 @@
|
||||||
-->
|
-->
|
||||||
<template mode="compile-calc" priority="7"
|
<template mode="compile-calc" priority="7"
|
||||||
match="c:apply[ compiler:apply-uses-tco( . ) ]">
|
match="c:apply[ compiler:apply-uses-tco( . ) ]">
|
||||||
|
<param name="symtable-map" as="map(*)" tunnel="yes" />
|
||||||
|
|
||||||
<variable name="name" select="@name" />
|
<variable name="name" select="@name" />
|
||||||
<variable name="self" select="." />
|
<variable name="self" select="." />
|
||||||
|
<variable name="func-sym" as="element( preproc:sym )"
|
||||||
|
select="$symtable-map( $name )[ @type = 'func' ]" />
|
||||||
|
|
||||||
<message select="concat('warning: ', $name, ' recursing with experimental guided TCO')" />
|
<message select="concat('warning: ', $name, ' recursing with experimental guided TCO')" />
|
||||||
|
|
||||||
|
@ -888,13 +889,7 @@
|
||||||
|
|
||||||
<!-- reassign function arguments -->
|
<!-- reassign function arguments -->
|
||||||
<variable name="args" as="element(c:arg)*">
|
<variable name="args" as="element(c:arg)*">
|
||||||
<for-each select="
|
<for-each select="$func-sym/preproc:sym-ref">
|
||||||
root(.)/preproc:symtable/preproc:sym[
|
|
||||||
@type='func'
|
|
||||||
and @name=$name
|
|
||||||
]/preproc:sym-ref
|
|
||||||
">
|
|
||||||
|
|
||||||
<variable name="pname" select="substring-after( @name, $arg-prefix )" />
|
<variable name="pname" select="substring-after( @name, $arg-prefix )" />
|
||||||
<variable name="arg" select="$self/c:arg[@name=$pname]" />
|
<variable name="arg" select="$self/c:arg[@name=$pname]" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue