Commit Graph

56 Commits

Author SHA1 Message Date
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
PKEuS 62d07878d7 Fixed two issues in matchcompiler:
- Use correct findmatch or findsimplematch for verification
- Print failing pattern also for findmatch/findsimplematch
2014-07-02 15:25:54 +02:00
PKEuS ec59f1d9df matchcompiler.py: Check Token::type() before comparing Token::str() against "||" or "|" 2014-06-30 14:04:18 +02:00
PKEuS 78f0a47170 matchcompiler.py: Show pattern that caused the InternalError 2014-06-30 14:04:18 +02:00
PKEuS 47a1122eb8 Updated matchcompiler to latest changes 2014-06-14 10:57:38 +02:00
Simon Martin a3d1cac79c Ticket #5373: Keep track whether tokens come from a C or C++ file to properly handle %type% in Token::Match with "delete" 2014-03-08 21:26:06 +01:00
Matthias Krüger a9df4a3288 man, htdocs, gui, test, tools: bump a few more copyrights to 2014 2014-03-03 11:03:17 +01:00
Daniel Marjamäki 398ed973f4 matchcompiler: autopep8 formatting 2013-10-13 11:01:50 +02:00
Daniel Marjamki 45cf562212 matchcompiler: fixed find(simple)match compiler problems. 2013-06-02 13:57:25 +02:00
Daniel Marjamki 35b13da3a5 matchcompiler: find(simple)match doesn't work well. the compiled functions are not static => the wrong function can be executed. this is a quick fix that just disable find(simple)match compiled patterns. 2013-06-02 12:41:34 +02:00
Frank Zingsheim 650027a07a Fixed #4797 (matchcompiler.py cannot handle overloaded findsimplematch and findmatch) 2013-05-15 18:18:58 +02:00
XhmikosR ae73466f97 Python scripts: PEP8 fixes 2013-03-03 09:59:16 +01:00
PKEuS 2ad38c8701 Updated matchcompiler to support %cop% 2013-03-01 02:52:44 -08:00
Thomas Jarosch 4fb6751d08 MC: Enable compiled matches for Token::findmatch() and Token::findsimplematch()
Speed is exactly the same and the --verify mode of the
match compiler ensured everything works as expected.
2013-01-16 21:50:32 +01:00
Thomas Jarosch 9f9c654621 MC: Implement verify mode for compiled Token::findmatch patterns 2013-01-14 11:18:33 +01:00
Thomas Jarosch 63e18d6b1c MC: Split _replaceTokenFindMatch() into two small functions 2013-01-14 11:06:59 +01:00
Thomas Jarosch 017783a77e MC: Save one indentation level 2013-01-14 11:06:55 +01:00
Thomas Jarosch 3bb8237cdc MC: Turn MatchCompiler tests into python unit test 2013-01-14 11:06:33 +01:00
Thomas Jarosch c0044122f4 Add self test for _replaceTokenFindMatch 2013-01-12 15:28:38 +01:00
Thomas Jarosch ff9e864a07 Add self test for replaceTokenMatch 2013-01-12 15:28:38 +01:00
Thomas Jarosch a7377f180a Quote output of _assertEquals()
It's easier to detect trailing spaces this way.
2013-01-12 15:28:38 +01:00
Thomas Jarosch 4038d4b562 Place main code into own function 2013-01-12 15:28:38 +01:00
Thomas Jarosch fdcfbd5ff9 Add missing copyright header 2013-01-10 11:10:45 +01:00
Edoardo Prezioso 6236e1dc38 Token::Match: removed harmless special code for initial '!!foo' patterns. 2013-01-09 20:13:33 +01:00
Thomas Jarosch de36324d62 Match compiler: Add cmdline handling 2013-01-09 19:41:03 +01:00
Thomas Jarosch 97e1e50139 Match compiler: Workaround broken code generation for "!!foo" patterns
This is just meant for the upcoming release.
2013-01-09 19:25:24 +01:00
Thomas Jarosch e1be85a552 Match compiler: Be more user friendly on how to invoke it 2013-01-09 19:22:40 +01:00
Thomas Jarosch ade0b741b7 Match compiler: Create 'build' directory if needed 2013-01-09 19:15:13 +01:00
Thomas Jarosch 982503f457 Match compiler: Workaround broken optimizations in verify mode
If the match compiler uses the 'verify' mode and we
compile with -O2, some tests comparing the on-the-fly-parser
to the compiled match fail.

Small functions are inlined by the -O2 compile flag.
If we disable function inlining and still compile with -O2,
everything is back to normal.

gdb didn't show anything useful during the mismatch
since the needed variables are optimized out. Once
we start printing them, the problem vanishes, too.
-> Can only be diagnosed at the x86 assembly level.

The problem vanished by switching the invocation order
of Token::Match() and the compiled match, so just swap them.

Also add commented out helper code
to better diagnose mismatch problems.
2013-01-09 19:03:42 +01:00
Thomas Jarosch 9970414a2f Match compiler: Implement 'verify mode' for Token::Match
Verify mode runs the same ::Match pattern on a token
using the on-the-fly parser and the compiled match parser.
The result is compared and we abort on mismatch.

Already detected an error in our test suite, needs investigation.
2013-01-07 22:27:57 +01:00
Thomas Jarosch 9b51d81e99 Match compiler: Split _replaceTokenMatch() into two small functions 2013-01-07 21:39:49 +01:00
Thomas Jarosch 3918948dd5 Match compiler: Aggregate match functions with the same pattern / function call signature
Reduces the number of generated functions from 2290 to 1916.
2013-01-04 04:47:01 +01:00
Thomas Jarosch 5f09cb2e4d Match compiler: Store matchFunctions and matchStrs in the class instead of passing it around 2013-01-04 03:56:21 +01:00
Thomas Jarosch 542c6e82d3 Match compiler: Cosmetic changes after running pylint 2013-01-04 03:44:04 +01:00
Thomas Jarosch 71a236b3df Match compiler: Turn code into a python class
This will make passing around internal states a lot easier
2013-01-04 03:38:40 +01:00
Thomas Jarosch f9c752667e Match compiler: Inline generated pattern match code for Token::findmatch
Verified the output in build/ stayed the same
if Token::findmatch support is disabled.
2013-01-04 03:13:22 +01:00
Thomas Jarosch 4b386986fc Match compiler: Check varid on first use like Token::Match does 2013-01-04 01:14:52 +01:00
Thomas Jarosch 5d5efdf99f Match compiler: Add support for Token::findmatch
(still disabled for performance reasons)
2013-01-04 01:01:57 +01:00
Thomas Jarosch 7417144784 Match compiler: Compile Token::findsimplematch() calls
Disabled for now as it runs slowers than before.
2013-01-03 19:33:37 +01:00
Thomas Jarosch 62b05193c4 MC: Split convertFile() function into smaller pieces
Output of build/ stayed the same.
2012-12-31 15:30:27 +01:00
Thomas Jarosch 311630ac1c Match compiler: Python syntax simplification
Output in build/ stayed the same
2012-12-31 15:03:00 +01:00
Thomas Jarosch 51cff0cb9b Match compiler: Speed up Token comparison with string literals. Ticket #4451
"Cache" string literals as C++ std::string objects.
The string length gets cached and so we don't need to
call strlen() on the literals at runtime.
2012-12-31 14:45:16 +01:00
Thomas Jarosch 3c915b534d Match compiler: Collect and cache plain C-strings
Profiler runs with gperftools showed we were spending
a lot of time in strlen() even with compiled match patterns.

If you compare a std::string with a plain C-string,
the comparison operator needs to calculate the length
of the C-string via strlen().

We can avoid this by turning all C-strings into C++ strings,
which cache the string length internally.

The match compiler has been adapted to collect all
C-strings during compilation and aggregate them.

Benchmark on the 'rpm' code base on a Core i7 920 box:

cppcheck without matchcompiler:
real    0m30.977s

cppcheck with previous matchcompiler:
real    0m28.157s

cppcheck with cached C-strings:
real    0m17.823s
2012-12-30 23:24:28 +01:00
Thomas Jarosch fe5ee76165 Match compiler: No need to handle %num% twice 2012-12-30 20:33:49 +01:00
Thomas Jarosch 3d0b4a9f7e Add execute permissions to matchcompiler.py on linux 2012-12-25 13:18:24 +01:00
Thomas Jarosch a2885a1759 Python 3 compatibility for the helper scripts
print() is a function in python 3.
Works with pyhton 2.x, too.
2012-12-25 13:12:58 +01:00
Daniel Marjamäki 3b3fe1c616 matchcompiler: throw InternalError if Token::Match is called with the varid 0 2012-12-19 06:45:05 +01:00
Daniel Marjamäki b6786c87b4 matchcompiler: handle %varid% 2012-12-14 16:59:37 +01:00
Daniel Marjamäki 2d8ed65d43 compiled Token::Match patterns: refactorings,improvements 2012-12-10 20:28:11 +01:00
Daniel Marjamäki a11ec4a5ee matchcompiler: replaced regular expression with simple code that parses the code better 2012-12-08 19:29:16 +01:00