aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/skjson
Commit message (Collapse)AuthorAge
* [skjson] More short string micro-optimizationsGravatar Florin Malita2018-06-19
| | | | | | | | | | | When possible, load 8 chars and mask out the tag and \0 terminator. ~19% faster on a Z840, ~5% faster on a PixelC. Change-Id: I12d4b7d86c92c887b00f5d2480d3ff05a7042df1 Reviewed-on: https://skia-review.googlesource.com/135624 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com>
* [skjson] Detect end-of-input for unbalanced stringsGravatar Florin Malita2018-06-15
| | | | | | | | | | | | | | | | | | | | | | We currently blow through string chars without checking for end-of-input. Maybe we could avoid this upfront, when we locate the stop char: try to determine if it's part of an unterminated string, fail immediately if so. Figuring out if the tail is an unterminated string seems intractable though (requires arbitrarily deep tail parsing). That brings us to plan B: * treat scope-closing tokens (} & ]) as string terminators (we know end-of-input points to one of these for sure) * adjust matchString() to check for end-of-input Bug: oss-fuzz:8899 Change-Id: Ic0a88a405548e8724b76faca525099a7e7037341 Reviewed-on: https://skia-review.googlesource.com/135145 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Kevin Lubick <kjlubick@google.com>
* [skjson] Catch end-of-stream for unbalanced scopesGravatar Florin Malita2018-06-15
| | | | | | | | | | | | | The input is not guaranteed to contain well-formed scopes, so it's not sufficient to check for end-of-stream only when popping the top-level scope -- we have to check on every scope pop. Bug: oss-fuzz:8898 Change-Id: I7399a8872187ec6714672cac2ff8fc7fbf3c2dfe Reviewed-on: https://skia-review.googlesource.com/135059 Reviewed-by: Kevin Lubick <kjlubick@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* [skjson] Some short string optimizationsGravatar Florin Malita2018-06-15
| | | | | | | | | | | 1) skip redundant \0 terminator => Value is always zero-initialized 2) skip storing a len record => strlen is cheap for short strings Change-Id: I3c10c9b9cf6155b95124e2c0194c59e9531a7ca4 Reviewed-on: https://skia-review.googlesource.com/135049 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* [skottie] Switch to SkJSONGravatar Florin Malita2018-06-14
| | | | | | | | | | Convert to SkJSON APIs and remove RapidJSON dependency. TBR= Change-Id: I5b4fd78821a443326e3a5b370748d840b80ef279 Reviewed-on: https://skia-review.googlesource.com/134612 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Reland [skjson] Size-constrained input APIGravatar Florin Malita2018-06-14
| | | | | | | | | | | | | Pass an explicit input size instead of requiring a C string. Thanks to mtklein's clever trick, this has no measurable perf impact. TBR= Change-Id: Ic8cb1dc75f4d0814e5b2c80038d1b8d3a7b072ab Reviewed-on: https://skia-review.googlesource.com/134946 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Revert "[skjson] Size-constrained input API"Gravatar Florin Malita2018-06-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit fc792b8718cc30e9da62c9559b23c1baac3166bb. Reason for revert: New ASAN, Android failures. Original change's description: > [skjson] Size-constrained input API > > Pass an explicit input size instead of requiring a C string. > > Thanks to mtklein's clever trick, this has no measurable perf impact. > > Change-Id: I64f210a9f653a78b05ab6b58fa34479504aa35ff > Reviewed-on: https://skia-review.googlesource.com/134940 > Reviewed-by: Mike Klein <mtklein@google.com> > Commit-Queue: Florin Malita <fmalita@chromium.org> TBR=mtklein@google.com,fmalita@chromium.org Change-Id: Ic0b52398b1ce6f64c781debb858829cb64bbae58 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/135022 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* [skjson] Fix ASAN undefined behaviorGravatar Florin Malita2018-06-14
| | | | | | | | | | | | | | | | | | | ASAN opines that a nullptr memcpy dest is undefined behavior, even when n == 0. ASAN may be right. This doesn't occur internally, in the parser, but can be triggered with the DOM builder API (as do some tests currently). We could say "don't do that", but if someone wants to build an empty string/array/object, it's kind of awkward to force them to provide a valid source pointer instead of simply e.g. Array(nullptr, 0). So let's guard for this case to make ASAN happy. Change-Id: If12e39f5eb8b273f22bbb0b5fce3321bf6482173 Reviewed-on: https://skia-review.googlesource.com/134944 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* [skjson] Size-constrained input APIGravatar Florin Malita2018-06-14
| | | | | | | | | | | Pass an explicit input size instead of requiring a C string. Thanks to mtklein's clever trick, this has no measurable perf impact. Change-Id: I64f210a9f653a78b05ab6b58fa34479504aa35ff Reviewed-on: https://skia-review.googlesource.com/134940 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Reland [skjson] Implementation/API tweaksGravatar Florin Malita2018-06-14
| | | | | | | | | | | | | | | | * move most common accessor methods to the header, for inlining * drop the lazy type checking semantics in favor of explicit guarded/unguarded conversions * revisit the public class hierarchy to better constrain type-bound APIs * expose public type factories and add tests * drop the empty-vector optimization -- allocating an external size_t in these uncommon cases is better than paying for a conditional on every access. TBR= Change-Id: Ic609bb74f12cad1756865a2489ad56c03ecc5494 Reviewed-on: https://skia-review.googlesource.com/134845 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* Revert "[skjson] Implementation/API tweaks"Gravatar Florin Malita2018-06-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 03b68421cafa58428edd8ab12e0d2235c7000c3f. Reason for revert: Broke Debian9 builds Original change's description: > [skjson] Implementation/API tweaks > > * move most common accessor methods to the header, for inlining > * drop the lazy type checking semantics in favor of explicit guarded/unguarded > conversions > * revisit the public class hierarchy to better constrain type-bound APIs > * expose public type factories and add tests > * drop the empty-vector optimization -- allocating an external size_t in these > uncommon cases is better than paying for a conditional on every access. > > Change-Id: I24a7c75db3aa8b12c740c77ac7df4af4e3a1dff8 > Reviewed-on: https://skia-review.googlesource.com/134610 > Commit-Queue: Florin Malita <fmalita@chromium.org> > Reviewed-by: Mike Klein <mtklein@google.com> TBR=mtklein@google.com,fmalita@chromium.org Change-Id: I2c681ef5c8d5fc15508e58b4b0f6ab9491b7d76f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/134880 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Florin Malita <fmalita@chromium.org>
* [skjson] Implementation/API tweaksGravatar Florin Malita2018-06-14
| | | | | | | | | | | | | | | * move most common accessor methods to the header, for inlining * drop the lazy type checking semantics in favor of explicit guarded/unguarded conversions * revisit the public class hierarchy to better constrain type-bound APIs * expose public type factories and add tests * drop the empty-vector optimization -- allocating an external size_t in these uncommon cases is better than paying for a conditional on every access. Change-Id: I24a7c75db3aa8b12c740c77ac7df4af4e3a1dff8 Reviewed-on: https://skia-review.googlesource.com/134610 Commit-Queue: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@google.com>
* Revert "Revert "SkTypes: extract SkTo""Gravatar Hal Canary2018-06-14
| | | | | | | | | | | | | | | | This reverts commit fdcfb8b7c23fbf18f872d2c31d27978235033876. > Original change's description: > > SkTypes: extract SkTo > > > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > > Reviewed-on: https://skia-review.googlesource.com/133620 > > Reviewed-by: Mike Klein <mtklein@google.com> Change-Id: Ida74fbc5c21248a724a5edbf9fae18a33bcb23aa Reviewed-on: https://skia-review.googlesource.com/134506 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* Revert "SkTypes: extract SkTo"Gravatar Hal Canary2018-06-13
| | | | | | | | | | | | | | | | | | | | | | | This reverts commit 2a2f67592602b18527bc3fd449132d420cd5b62e. Reason for revert: this appears to be what is holding up the Chrome roll. Original change's description: > SkTypes: extract SkTo > > Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 > Reviewed-on: https://skia-review.googlesource.com/133620 > Reviewed-by: Mike Klein <mtklein@google.com> TBR=mtklein@google.com,halcanary@google.com No-Presubmit: true No-Tree-Checks: true No-Try: true Change-Id: Iafd738aedfb679a23c061a51afe4b98a8d4cdfae Reviewed-on: https://skia-review.googlesource.com/134504 Reviewed-by: Hal Canary <halcanary@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
* SkTypes: extract SkToGravatar Hal Canary2018-06-12
| | | | | | Change-Id: I8de790d5013db2105ad885fa2683303d7c250b09 Reviewed-on: https://skia-review.googlesource.com/133620 Reviewed-by: Mike Klein <mtklein@google.com>
* Disable module deps in Android Framework buildsGravatar Florin Malita2018-06-11
| | | | | | | | | | | | | Module-related functionality is not required in dm/bench at this point. Let's disable module deps flattening for now. As an immediate benefit we can reduce the deps visibility for some internal skjson targets. Bug: skia:8061 Change-Id: I0e09208964ca94b519121207ba1b6225059ef573 Reviewed-on: https://skia-review.googlesource.com/133822 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
* SkJsonGravatar Florin Malita2018-06-08
For now this is only wired to a bench and a couple of tests. Local numbers, for a ~500KB BM "compressed" json: micros bench 2456.54 json_rapidjson nonrendering 1192.38 json_skjson nonrendering Change-Id: I7b3514f84c7c525d1787722c43ad6095e3692563 Reviewed-on: https://skia-review.googlesource.com/127622 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>