1 The following changes (change numbers refer to perforce) were
\r
2 made from version 3.1.1 to 3.1.2
\r
7 Change 5641 on 2009/02/20 by jimi@jimi.jimi.antlr3
\r
9 Release version 3.1.2 of the ANTLR C runtime.
\r
11 Updated documents and release notes will have to follow later.
\r
13 Change 5639 on 2009/02/20 by jimi@jimi.jimi.antlr3
\r
17 Ensure that code generation for C++ does not require casts
\r
19 Change 5577 on 2009/02/12 by jimi@jimi.jimi.antlr3
\r
21 C Runtime - Bug fixes.
\r
23 o Having moved to use an extract directly from a vector for returning
\r
24 tokens, it exposed a
\r
25 bug whereby the EOF boudary calculation in tokLT was incorrectly
\r
26 checking > rather than >=.
\r
27 o Changing to API initialization of tokens rather than memcmp()
\r
28 incorrectly forgot to set teh input stream pointer for the
\r
29 manufactured tokens in the token factory;
\r
30 o Rewrite streams for rewriting tree parsers did not check whether the
\r
31 rewrite stream was ever assigned before trying to free it, it is now
\r
32 in line with the ordinary parser code.
\r
34 Change 5576 on 2009/02/11 by jimi@jimi.jimi.antlr3
\r
36 C Runtime: Ensure that when we manufacture a new token for a missing
\r
37 token, that the user suplied custom information (if any) is copied
\r
38 from the current token.
\r
40 Change 5575 on 2009/02/08 by jimi@jimi.jimi.antlr3
\r
42 C Runtime - Vastly improve the reuse of allocated memory for nodes in
\r
45 A problem for all targets at the moment si that the rewrite logic
\r
46 generated by ANTLR makes no attempt
\r
47 to reuse any resources, it merely gurantees that the tree shape at the
\r
48 end is correct. To some extent this is mitigated by the garbage
\r
49 collection systems of Java and .Net, even thoguh it is still an overhead to
\r
50 keep creating so many modes.
\r
52 This change implements the first of two C runtime changes that make
\r
53 best efforst to track when a node has become orphaned and will never
\r
54 be reused, based on inherent knowledge of the rewrite logic (which in
\r
55 the long term is not a great soloution).
\r
57 Much of the rewrite logic consists of creating a niilnode into which
\r
58 child nodes are appended. At: rulePost processing time; when a rewrite
\r
59 stream is closed; and when becomeRoot is called, there are many situations
\r
60 where the root of the tree that will be manipulted, or is finished with
\r
61 (in the case of rewrtie streams), where the nilNode was just a temporary
\r
62 creation for the sake of the rewrite itself.
\r
64 In these cases we can see that the nilNode would just be left ot rot in
\r
65 the node factory that tracks all the tree nodes.
\r
66 Rather than leave these in the factory to rot, we now keep a resuse
\r
67 stck and always reuse any node on this
\r
68 stack before claimin a new node from the factory pool.
\r
70 This single change alone reduces memory usage in the test case (20,604
\r
71 line C program and a GNU C parser)
\r
72 from nearly a GB, to 276MB. This is still way more memory than we
\r
73 shoudl need to do this operation, even on such a large input file,
\r
74 but the reduction results in a huge performance increase and greatly
\r
75 reduced system time spent on allocations.
\r
77 After this optimizatoin, comparison with gcc yeilds:
\r
80 a.c:1026: warning: conflicting types for built-in function ‘vsprintf’
\r
81 a.c:1030: warning: conflicting types for built-in function ‘vsnprintf’
\r
82 a.c:1041: warning: conflicting types for built-in function ‘vsscanf’
\r
83 0.21user 0.01system 0:00.22elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
\r
84 0inputs+240outputs (0major+8345minor)pagefaults 0swaps
\r
90 0.28user 0.11system 0:00.39elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
\r
91 0inputs+0outputs (0major+66609minor)pagefaults 0swaps
\r
93 And we can now interpolate the fact that the only major differnce is
\r
94 now the huge disparity in memory allocations. A
\r
95 future optimization of vector pooling, to sepate node resue from vector
\r
96 reuse, currently looks promising for further reuse of memory.
\r
98 Finally, a static analysis of the rewrte code, plus a realtime analysis
\r
99 of the heap at runtime, may well give us a reasonable memory usage
\r
100 pattern. In reality though, it is the generated rewrite logic
\r
101 that must becom optional at not continuously rewriting things that it
\r
102 need not, as it ascends the rule chain.
\r
104 Change 5563 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
106 Allow rewrite streams to use the base adaptors vector factory and not
\r
107 try to malloc new vectors themselves.
\r
109 Change 5562 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
111 Don't use CALLOC to allocate tree pools, use malloc as there is no need
\r
114 Change 5561 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
116 Prevent warnigsn about retval.stop not being initialized when a rule
\r
117 returns eraly because it is in backtracking mode
\r
119 Change 5558 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
121 Lots of optimizations (though the next one to be checked in is the huge
\r
122 win) for AST building and vector factories.
\r
124 A large part of tree rewriting was the creation of vectors to hold AST
\r
125 nodes. Although I had created a vector factory, for some reason I never got
\r
126 around to creating a proper one, that pre-allocated the vectors in chunks and
\r
127 so on. I guess I just forgot to. Hence a big win here is prevention of calling
\r
128 malloc lots and lots of times to create vectors.
\r
130 A second inprovement was to change teh vector definition such that it
\r
131 holds a certain number of elements wihtin the vector structure itself, rather
\r
132 than malloc and freeing these. Currently this is set to 8, but may increase.
\r
133 For AST construction, this is generally a big win because AST nodes don't often
\r
134 have many individual children unless there has not been any shaping going on in
\r
135 the parser. But if you are not shaping, then you don't really need a tree.
\r
137 Other perforamnce inprovements here include not calling functions
\r
138 indirectly within token stream and common token stream. Hence tokens are
\r
139 claimed directly from the vectors. Users can override these funcitons of course
\r
140 and all this means is that if you override tokenstreams then you pretty much
\r
141 have to provide all the mehtods, but then I think you woudl have to anyway (and
\r
142 I don't know of anyone that has wanted to do this as you can carry your own
\r
143 structure around with the tokens anyway and that is much easier).
\r
145 Change 5555 on 2009/01/26 by jimi@jimi.jimi.antlr3
\r
148 Correct the interpretation of the skip token such that channel, start
\r
149 index, char pos in lie, start line and text are correctly reset to the start of
\r
150 the new token when the one that we just traversed was marked as being skipped.
\r
152 This correctly excludes the text that was matched as part of the
\r
153 SKIP()ed token from the next token in the token stream and so has the side
\r
154 effect that asking for $text of a rule no longer includes the text that shuodl
\r
155 be skipped, but DOES include the text of tokens that were merely placed off the
\r
158 Change 5551 on 2009/01/25 by jimi@jimi.jimi.antlr3
\r
161 Most of the source files did not include the BSD license. THis might
\r
162 not be that big a deal given that I don't care what people do with it
\r
163 other than take my name off it, but having the license reproduced
\r
165 at least makes things perfectly clear. Hence this mass change of
\r
166 sources and templates
\r
167 to include the license.
\r
169 Change 5550 on 2009/01/25 by jimi@jimi.jimi.antlr3
\r
172 Ensure that as soon as we known about an input stream on the lexer that
\r
173 we borrow its string factroy adn use it in our EOF token in case
\r
174 anyone tries to make it a string, such as in error messages for
\r
177 Change 5548 on 2009/01/25 by jimi@jimi.jimi.antlr3
\r
180 At some point the Java runtime default changed from discarding offchannel
\r
181 tokens to preserving them. The fix is to make the C runtime also
\r
182 default to preserving off-channel tokens.
\r
184 Change 5544 on 2009/01/24 by jimi@jimi.jimi.antlr3
\r
187 Ensure that the fillBuffer funtiion does not call any methods
\r
188 that require the cached buffer size to be recorded before we
\r
189 have actually recorded it.
\r
191 Change 5543 on 2009/01/24 by jimi@jimi.jimi.antlr3
\r
194 Some users have started using string factories themselves and
\r
195 exposed a flaw in the destroy method, that is intended to remove
\r
196 a strng htat was created by the factory and is no longer needed.
\r
197 The string was correctly removed from the vector that tracks them
\r
198 but after the first one, all the remaining strings are then numbered
\r
199 incorrectly. Hence the destroy method has been recoded to reindex
\r
200 the strings in the factory after one is removed and everythig is once
\r
202 User suggested fix rejected.
\r
204 Change 5542 on 2009/01/24 by jimi@jimi.jimi.antlr3
\r
207 The recognizer state now ensures that all fields are set to NULL upon
\r
209 and the reset does not overwrite the tokenname array
\r
211 Change 5527 on 2009/01/15 by jimi@jimi.jimi.antlr3
\r
213 Add the C runtime for 3.1.2 beta2 to perforce
\r
215 Change 5526 on 2009/01/15 by jimi@jimi.jimivista.antlr3
\r
217 Correctly define the MEMMOVE macro which was inadvertently left to be
\r
220 Change 5503 on 2008/12/12 by jimi@jimi.jimi.antlr3
\r
222 Change C runtime release number to 3.1.2 beta
\r
224 Change 5473 on 2008/12/01 by jimi@jimi.jimivista.antlr3
\r
226 Fixed: ANTLR-350 - C runtime use of memcpy
\r
227 Prior change to use memcpy instead of memmove in all cases missed the
\r
228 fact that the string factory can be in a situation where overlaps occur. We now
\r
229 have ANTLR3_MEMCPY and ANTLR3_MEMMOVE and use the two appropriately.
\r
231 Change 5471 on 2008/12/01 by jimi@jimi.jimivista.antlr3
\r
234 - Ensure that ANTLR3_BOOLEAN is typedef'ed correctly when building for
\r
240 Change 5637 on 2009/02/20 by jimi@jimi.jimi.antlr3
\r
242 C rtunime - make sure that ADAPTOR results are cast to the tree type on
\r
245 Change 5620 on 2009/02/18 by jimi@jimi.jimi.antlr3
\r
248 From: //depot/code/antlr/main/src/org/antlr/codegen/templates/...
\r
249 To: //depot/code/antlr/main/src/main/resources/org/antlr/codegen/templates/...
\r
251 Relocate the code generating templates to exist in the directory set
\r
252 that maven expects.
\r
254 When checking in your templates, you may find it easiest to make a copy
\r
255 of what you have, revert the change in perforce, then just check out the
\r
256 template in the new location, and copy the changes back over. Nobody has oore
\r
257 than two files open at the moment.
\r
259 Change 5578 on 2009/02/12 by jimi@jimi.jimi.antlr3
\r
261 Correct the string template escape sequences for generating scope
\r
262 code in the C templates.
\r
264 Change 5577 on 2009/02/12 by jimi@jimi.jimi.antlr3
\r
266 C Runtime - Bug fixes.
\r
268 o Having moved to use an extract directly from a vector for returning
\r
269 tokens, it exposed a
\r
270 bug whereby the EOF boudary calculation in tokLT was incorrectly
\r
271 checking > rather than
\r
273 o Changing to API initialization of tokens rather than memcmp()
\r
274 incorrectly forgot to
\r
275 set teh input stream pointer for the manufactured tokens in the
\r
277 o Rewrite streams for rewriting tree parsers did not check whether the
\r
279 was ever assigned before trying to free it, it is now in line with
\r
280 the ordinary parser code.
\r
282 Change 5567 on 2009/01/29 by jimi@jimi.jimi.antlr3
\r
284 C Runtime - Further Optimizations
\r
286 Within grammars that used scopes and were intended to parse large
\r
287 inputs with many rule nests,
\r
288 the creation anf deletion of the scopes themselves became significant.
\r
289 Careful analysis shows that
\r
290 for most grammars, while a parse could create and delete 20,000 scopes,
\r
291 the maxium depth of
\r
292 any scope was only 8.
\r
294 This change therefore changes the scope implementation so that it does
\r
295 not free scope memory when
\r
296 it is popped but just tracks it in a C runtime stack, eventually
\r
297 freeing it when the stack is freed. This change
\r
298 caused the allocation of only 12 scope structures instead of 20,000 for
\r
299 the extreme example case.
\r
301 This change means that scope users must be carefule (as ever in C) to
\r
302 initializae their scope elements
\r
305 1) If not you may inherit values from a prior use of the scope
\r
307 2) SCope structure are now allocated with malloc and not calloc;
\r
309 Also, when using a custom free function to clean a scope when it is
\r
310 popped, it is probably a good idea
\r
311 to set any free'd pointers to NULL (this is generally good C programmig
\r
312 practice in any case)
\r
314 Change 5566 on 2009/01/29 by jimi@jimi.jimi.antlr3
\r
316 Remove redundant BACKTRACK checking so that MSVC9 does not get confused
\r
317 about possibly uninitialized variables
\r
319 Change 5565 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
321 Use malloc rather than calloc to allocate memory for new scopes. Note
\r
322 that this means users will have to be careful to initialize any values in their
\r
323 scopes that they expect to be 0 or NULL and I must document this.
\r
325 Change 5564 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
327 Use malloc rather than calloc for copying list lable tokens for
\r
330 Change 5561 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
332 Prevent warnigsn about retval.stop not being initialized when a rule
\r
333 returns eraly because it is in backtracking mode
\r
335 Change 5560 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
337 Add a NULL check before freeing rewrite streams used in AST rewrites
\r
338 rather than auto-rewrites.
\r
340 While the NULL check is redundant as the free cannot be called unless
\r
341 it is assigned, Visual Studio C 2008
\r
342 gets it wrong and thinks that there is a PATH than can arrive at the
\r
343 free wihtout it being assigned and that is too annoying to ignore.
\r
345 Change 5559 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
347 C target Tree rewrite optimization
\r
349 There is only one optimization in this change, but it is a huge one.
\r
351 The code generation templates were set up so that at the start of a rule,
\r
352 any rewrite streams mentioned in the rule wer pre-created. However, this
\r
353 is a massive overhead for rules where only one or two of the streams are
\r
354 actually used, as we create them then free them without ever using them.
\r
355 This was copied from the Java templates basically.
\r
356 This caused literally millions of extra calls and vector allocations
\r
357 in the case of the GNU C parser given to me for testing with a 20,000
\r
360 After this change, the following comparison is avaiable against the gcc
\r
363 Before (different machines here so use the relative difference for
\r
377 After the previous optimizations for vector pooling via a factory,
\r
378 plus this huge win in removing redundant code, we have the following
\r
379 (different machine to the one above):
\r
382 0.21user 0.01system 0:00.23elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
\r
383 0inputs+328outputs (0major+9922minor)pagefaults 0swaps
\r
387 0.37user 0.26system 0:00.64elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
\r
388 0inputs+0outputs (0major+130944minor)pagefaults 0swaps
\r
390 The extra system time coming from the fact that although the tree
\r
391 rewriting is now optimal in terms of not allocating things it does
\r
392 not need, there is still a lot more overhead in a parser that is generated
\r
393 for generic use, including much more use of structures for tokens and extra
\r
394 copying and so on. I will
\r
395 continue to work on improviing things where I can, but the next big
\r
396 improvement will come from Ter's optimization of the actual code structures we
\r
397 generate including not doing things with rewrite streams that we do not need to
\r
400 The second machine I used is about twice as fast CPU wise as the system
\r
401 that was used originally by the user that asked about this performance.
\r
403 Change 5558 on 2009/01/28 by jimi@jimi.jimi.antlr3
\r
405 Lots of optimizations (though the next one to be checked in is the huge
\r
406 win) for AST building and vector factories.
\r
408 A large part of tree rewriting was the creation of vectors to hold AST
\r
409 nodes. Although I had created a vector factory, for some reason I never got
\r
410 around to creating a proper one, that pre-allocated the vectors in chunks and
\r
411 so on. I guess I just forgot to. Hence a big win here is prevention of calling
\r
412 malloc lots and lots of times to create vectors.
\r
414 A second inprovement was to change teh vector definition such that it
\r
415 holds a certain number of elements wihtin the vector structure itself, rather
\r
416 than malloc and freeing these. Currently this is set to 8, but may increase.
\r
417 For AST construction, this is generally a big win because AST nodes don't often
\r
418 have many individual children unless there has not been any shaping going on in
\r
419 the parser. But if you are not shaping, then you don't really need a tree.
\r
421 Other perforamnce inprovements here include not calling functions
\r
422 indirectly within token stream and common token stream. Hence tokens are
\r
423 claimed directly from the vectors. Users can override these funcitons of course
\r
424 and all this means is that if you override tokenstreams then you pretty much
\r
425 have to provide all the mehtods, but then I think you woudl have to anyway (and
\r
426 I don't know of anyone that has wanted to do this as you can carry your own
\r
427 structure around with the tokens anyway and that is much easier).
\r
429 Change 5554 on 2009/01/26 by jimi@jimi.jimi.antlr3
\r
432 For some reason in the past, the ruleMemozation() template had required
\r
433 that the name parameter be set to the rule name. This does not seem to be a
\r
434 requirement any more. The name=xxx override when invoking the template was
\r
435 causing all the scope names derived when cleaning up in memoization to be
\r
436 called after the rule name, which was not correct. Howver, this only affected
\r
437 the output when in output=AST mode.
\r
439 This template invocation is now corrected.
\r
441 Change 5553 on 2009/01/26 by jimi@jimi.jimi.antlr3
\r
444 Managed to get the one rule that could not see the ASTLabelType to call
\r
445 back in to the super template C.stg and ask it to construct hte name. I am not
\r
446 100% sure that this fixes all cases, but I cannot find any that fail. PLease
\r
447 let me know if you find any exampoles of being unable to default the
\r
448 ASTLabelType option in the C target.
\r
450 Change 5552 on 2009/01/25 by jimi@jimi.jimi.antlr3
\r
452 Progress: ANTLR-327
\r
453 Fix debug code generation templates when output=AST such that code
\r
454 can at least be generated and I can debug the output code correctly.
\r
455 Note that this checkin does not implement the debugging requirements
\r
456 for tree generating parsers.
\r
458 Change 5551 on 2009/01/25 by jimi@jimi.jimi.antlr3
\r
461 Most of the source files did not include the BSD license. THis might
\r
462 not be that big a deal given that I don't care what people do with it
\r
463 other than take my name off it, but having the license reproduced
\r
464 everywhere at least makes things perfectly clear. Hence this mass change of
\r
465 sources and templates to include the license.
\r
467 Change 5549 on 2009/01/25 by jimi@jimi.jimi.antlr3
\r
470 Using 0.0D as the default initialize value for a double caused
\r
471 VS 2003 C compiler to bomb out. There seesm to be no reason other
\r
472 than force of habit to set this to 0.0D so I have dropped the D so
\r
473 that older compilers do not complain.
\r
475 Change 5547 on 2009/01/25 by jimi@jimi.jimi.antlr3
\r
478 All references are now unadorned with any type of NULL check for the
\r
481 1) A NULL reference means that there is a problem with the
\r
482 grammar and we need the program to fail immediately so
\r
483 that the programmer can work out where the problem occured;
\r
484 2) Most of the time, the only sensible value that can be
\r
485 returned is NULL or 0 which
\r
486 obviates the NULL check in the first place;
\r
487 3) If we replace a NULL reference with some value such as 0,
\r
488 then the program may blithely continue but just do something
\r
489 logically wrong, which will be very difficult for the
\r
490 grammar programmer to detect and correct.
\r
492 Change 5545 on 2009/01/24 by jimi@jimi.jimi.antlr3
\r
495 The bug report was correct in that the types of references to things
\r
496 like $start were being incorrectly cast as they wer not changed from
\r
497 Java style casts (and the casts are unneccessary). this is now fixed
\r
498 and references are referencing the correct, uncast, types.
\r
499 However, the bug report was wrong in that the reference in the bok to
\r
500 $start.pos will only work for Java and really, it is incorrect in the
\r
501 book because it shoudl not access the .pos member directly but shudl
\r
502 be using $start.getCharPositionInLine().
\r
503 Because there is no access qualification in C, one could use
\r
504 $start.charPosition, however
\r
505 really this should be $start->getCharPositionInLine($start);
\r
507 Change 5541 on 2009/01/24 by jimi@jimi.jimi.antlr3
\r
510 The code generation for the free method of a recognizer was not
\r
511 distinguishing tree parsers from parsers when it came to calling delegate free
\r
513 This is now corrected.
\r
515 Change 5540 on 2009/01/24 by jimi@jimi.jimi.antlr3
\r
518 Ensure that we do not attempt to free any memory that we did not
\r
519 actually allocate because the parser rule was being executed in
\r
522 Change 5539 on 2009/01/24 by jimi@jimi.jimivista.antlr3
\r
525 When a C targetted parser is producing in backtracking mode, then the
\r
526 creation of new stream rewrite structures shoudl not happen if the rule is
\r
527 currently backtracking
\r
529 Change 5502 on 2008/12/11 by jimi@jimi.jimi.antlr3
\r
531 Fixed: ANTLR-349 Ensure that all marker labels in the lexer are 64 bit
\r
534 Change 5473 on 2008/12/01 by jimi@jimi.jimivista.antlr3
\r
536 Fixed: ANTLR-350 - C runtime use of memcpy
\r
537 Prior change to use memcpy instead of memmove in all cases missed the
\r
538 fact that the string factory can be in a situation where overlaps occur. We now
\r
539 have ANTLR3_MEMCPY and ANTLR3_MEMMOVE and use the two appropriately.
\r
541 Change 5387 on 2008/11/05 by parrt@parrt.spork
\r
543 Fixed x+=. issue with tree grammars; added unit test
\r
545 Change 5325 on 2008/10/23 by parrt@parrt.spork
\r
547 We were all ref'ing backtracking==0 hardcoded instead checking the
\r
548 @synpredgate action.
\r