diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-11-29 00:03:40 +0100 |
---|---|---|
committer | Adriaan Moors <adriaanm@gmail.com> | 2011-12-24 17:36:52 +0100 |
commit | 08ec6ba4e4aeb94f6505ecb462b94362ff0af096 (patch) | |
tree | a54bad8e6b329e672b64835c5eaa1fae9d25272b /test/files/run/virtpatmat_opt_sharing.flags | |
parent | fc0c123e3560da190a3daae35214c2be50fd59e6 (diff) | |
download | scala-08ec6ba4e4aeb94f6505ecb462b94362ff0af096.tar.gz scala-08ec6ba4e4aeb94f6505ecb462b94362ff0af096.tar.bz2 scala-08ec6ba4e4aeb94f6505ecb462b94362ff0af096.zip |
[vpm] optimized codegen avoids option-boxing
introducing two mutable variables per pattern match: matchRes and keepGoing
keepGoing denotes whether the result was Some or None,
and matchRes holds the Some's contents or the right zero for the match's type
Race(() => fastMatch(list), () => virtMatch_no_option(list))(100000).converge() is a virtual tie on my machine after this
see https://gist.github.com/1400910
conveniently also works around SI-5245
don't assign to Unit-typed var's, in fact, make matchRes a val when its only prospect in life is to be unit-valued
propagate eventual type for matchRes thru codegen
so that we can have more robust checks for unit¬hing, when assignment makes no sense
also, added a hack to caseResult to avoid boxed units in
if(keepGoing) { matchRes = ... } else zero
after erasure, we get
if(keepGoing) { matchRes = ...; BoxedUNIT } else zero
genicode broke because i was sharing trees:
[scalacfork] error: java.lang.AssertionError: assertion failed: type error: can't convert from UNIT to REF(class Object) in unit ScalaSig.scala at source-/Users/adriaan/git/scala-dev/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala,line-26,offset=868
fixed by duplicating -- so be it (for now -- make this more fine-grained, more efficient)
dodging inliner issues with one/zero (it won't inline, so also directly inline those methods)
Diffstat (limited to 'test/files/run/virtpatmat_opt_sharing.flags')
0 files changed, 0 insertions, 0 deletions