[cg3] 01/02: Imported Upstream version 0.9.9~r10791
Tino Didriksen
tinodidriksen-guest at moszumanska.debian.org
Tue Jun 23 08:44:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
tinodidriksen-guest pushed a commit to branch master
in repository cg3.
commit 879f5480b652b02cb4ba521895bfdd021a41ff14
Author: Tino Didriksen <mail at tinodidriksen.com>
Date: Tue Jun 23 08:42:40 2015 +0000
Imported Upstream version 0.9.9~r10791
---
ChangeLog | 73 +++++++++++++++++++------------------------
compile-profile.sh | 4 +--
scripts/profile-revisions.php | 8 ++---
src/Cohort.cpp | 5 +++
src/Grammar.hpp | 4 +--
src/all_cg_comp.cpp | 2 +-
src/all_cg_conv.cpp | 2 +-
src/all_cg_proc.cpp | 2 +-
src/all_vislcg3.cpp | 2 +-
src/flat_unordered_map.hpp | 28 ++++++++++++-----
src/flat_unordered_set.hpp | 28 ++++++++++++-----
src/inlines.hpp | 15 +++++++++
src/sorted_vector.hpp | 4 +++
src/version.hpp | 2 +-
vapply.sh | 2 +-
vparse.sh | 2 +-
16 files changed, 113 insertions(+), 70 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f57829a..7870961 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2015-06-21 tino
+
+ * [r10787] scripts/profile-revisions.php,
+ src/flat_unordered_map.hpp, src/flat_unordered_set.hpp:
+ Consistency
+ * [r10786] compile-profile.sh, scripts/profile-revisions.php,
+ src/Cohort.cpp, src/Reading.cpp, src/all_cg_comp.cpp,
+ src/all_cg_conv.cpp, src/all_cg_proc.cpp, src/all_vislcg3.cpp,
+ src/flat_unordered_set.hpp, src/inlines.hpp, vapply.sh,
+ vparse.sh: WIP memory pooling hacks
+
+2015-06-20 tino
+
+ * [r10784] src/Tag.cpp: Clone regexes to avoid double-free
+
+2015-06-19 tino
+
+ * [r10782] include/posix/popen_plus.c,
+ src/GrammarApplicator_runContextualTest.cpp: scan-build fixes
+
+2015-06-11 tino
+
+ * [r10763] src/FSTApplicator.cpp: inf weight -> 2147483647
+
+2015-06-06 tino
+
+ * [r10754] ChangeLog, src/ApertiumApplicator.cpp,
+ src/GrammarApplicator.cpp, src/GrammarApplicator.hpp,
+ src/NicelineApplicator.cpp, src/main.cpp, src/options.hpp,
+ src/version.hpp, test/T_MapAdd_Different/args.txt,
+ test/T_MapAdd_Different/expected.txt: Add option --split-mappings
+
2015-06-04 tino
* [r10749] include/posix/popen_plus.c, src/GrammarApplicator.hpp,
@@ -2293,44 +2325,3 @@
* [r8630] src/GrammarApplicator_runGrammar.cpp, src/inlines.h: CG-3
recognize \v as newline and fix buffer growth
-2012-09-30 tino
-
- * [r8607] manual/installation.xml:
-
-2012-09-20 tino
-
- * [r8556] scripts/cg3-autobin.pl, src/GrammarApplicator.cpp,
- src/GrammarApplicator.h, src/GrammarApplicator_reflow.cpp,
- src/GrammarApplicator_runRules.cpp, src/TextualParser.cpp,
- src/version.h: Better line numbers; Warn about 'x' misuse.
-
-2012-09-10 tino
-
- * [r8543] manual/dependencies.xml: cg3
- * [r8542] scripts/cg3-autobin.pl, src/GrammarApplicator.cpp,
- src/GrammarApplicator.h,
- src/GrammarApplicator_runContextualTest.cpp,
- src/GrammarApplicator_runRules.cpp, src/version.h:
- SetParent/Child bail out if barrier met
-
-2012-09-09 tino
-
- * [r8538] scripts/cg3-autobin.pl, src/ApertiumApplicator.cpp,
- src/Cohort.cpp, src/Cohort.h,
- src/GrammarApplicator_runGrammar.cpp, src/cg_conv.cpp,
- src/cg_proc.cpp, src/version.h: Added static reading to cg-proc
- and verified it survives cg-conv -a | cg-conv
-
-2012-09-07 tino
-
- * [r8536] manual/dependencies.xml, manual/relations.xml,
- scripts/cg3-autobin.pl, src/Cohort.cpp, src/Cohort.h,
- src/GrammarApplicator.cpp, src/GrammarApplicator_matchSet.cpp,
- src/GrammarApplicator_runGrammar.cpp, src/version.h,
- test/T_BasicContextTest/expected.txt,
- test/T_BasicContextTest/grammar.cg3,
- test/T_BasicContextTest/input.txt, test/T_BasicRemove,
- test/T_CompositeSelect: Allowed tags after the wordform, which
- will be visible only to non-C contexts (so they are not ambiguous
- or valid rule targets).
-
diff --git a/compile-profile.sh b/compile-profile.sh
index b5525dc..4c28807 100755
--- a/compile-profile.sh
+++ b/compile-profile.sh
@@ -4,10 +4,10 @@ rm -fv gcov/*.gcda
rm -fv gcov/*.gcno
rm -fv gcov/vislcg3-c++$CXXV
cd gcov
-g++ -std=c++$CXXV -DHAVE_BOOST -pthread -pipe -Wall -Wextra -Wno-deprecated -Wno-unused-local-typedefs -O3 -g3 -fprofile-arcs -ftest-coverage -I../include -I../include/exec-stream ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc -ltcmalloc
+g++ -std=c++$CXXV -DHAVE_BOOST -pthread -pipe -Wall -Wextra -Wno-deprecated -Wno-unused-local-typedefs -O3 -g3 -fprofile-arcs -ftest-coverage -I../include -I../include/posix ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc -ltcmalloc
cd ..
mkdir -p gprof
rm -fv gprof/vislcg3-c++$CXXV
rm -fv gprof/gmon.out
cd gprof
-g++ -std=c++$CXXV -DHAVE_BOOST -pthread -pipe -pg -Wall -Wextra -Wno-deprecated -Wno-unused-local-typedefs -O3 -g3 -I../include -I../include/exec-stream ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc -ltcmalloc
+g++ -std=c++$CXXV -DHAVE_BOOST -pthread -pipe -pg -Wall -Wextra -Wno-deprecated -Wno-unused-local-typedefs -O3 -g3 -I../include -I../include/posix ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc -ltcmalloc
diff --git a/scripts/profile-revisions.php b/scripts/profile-revisions.php
index c9f7395..bbcf1a1 100755
--- a/scripts/profile-revisions.php
+++ b/scripts/profile-revisions.php
@@ -14,8 +14,8 @@ function profile_revision($rev) {
if (file_exists('./src/all_vislcg3.cpp')) {
echo "Using all_vislcg3.cpp and Boost...\n";
- echo shell_exec('g++ -std=c++11 -DHAVE_BOOST -DNDEBUG -pthread -pipe -Wall -Wextra -Wno-deprecated -fPIC -O3 -Iinclude -Iinclude/exec-stream ./src/all_vislcg3.cpp -o vislcg3 -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc 2>&1');
- echo shell_exec('g++ -std=c++11 -DHAVE_BOOST -DNDEBUG -pthread -pipe -Wall -Wextra -Wno-deprecated -fPIC -O3 -Iinclude -Iinclude/exec-stream ./src/all_vislcg3.cpp -o vislcg3-tc -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc -ltcmalloc 2>&1');
+ echo shell_exec('g++ -std=c++11 -DHAVE_BOOST -DNDEBUG -pthread -pipe -Wall -Wextra -Wno-deprecated -fPIC -O3 -Iinclude -Iinclude/posix ./src/all_vislcg3.cpp -o vislcg3 -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc 2>&1');
+ echo shell_exec('g++ -std=c++11 -DHAVE_BOOST -DNDEBUG -pthread -pipe -Wall -Wextra -Wno-deprecated -fPIC -O3 -Iinclude -Iinclude/posix ./src/all_vislcg3.cpp -o vislcg3-tc -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc -ltcmalloc 2>&1');
}
else {
echo "Using old-style without Boost...\n";
@@ -73,8 +73,8 @@ function profile_revision($rev) {
shell_exec('rm -rf '.$dir.' 2>&1 >/dev/null');
}
-$revs = array(10297, 10034, 10016, 9645, 9274, 9249, 8923, 8001, 7397, 7134, 7000, 6987, 6898, 6885, 6781, 6692, 6500, 6328, 6268, 6242, 6170, 5932, 5930, 5926, 5918, 5839, 5810, 5773, 5729, 5431, 5129, 5042, 4879, 4779, 4545, 4513, 4493, 4474, 4410, 4292, 4031, 3991, 3896, 3852, 3800, 3689, 3682, 3617);
-$revs = array(10373);
+$revs = array(10373, 10297, 10034, 10016, 9645, 9274, 9249, 8923, 8001, 7397, 7134, 7000, 6987, 6898, 6885, 6781, 6692, 6500, 6328, 6268, 6242, 6170, 5932, 5930, 5926, 5918, 5839, 5810, 5773, 5729, 5431, 5129, 5042, 4879, 4779, 4545, 4513, 4493, 4474, 4410, 4292, 4031, 3991, 3896, 3852, 3800, 3689, 3682, 3617);
+$revs = array(10786);
foreach ($revs as $rev) {
profile_revision($rev);
}
diff --git a/src/Cohort.cpp b/src/Cohort.cpp
index eac90ff..a7667c6 100644
--- a/src/Cohort.cpp
+++ b/src/Cohort.cpp
@@ -30,6 +30,8 @@
namespace CG3 {
+static std::vector<uint32FlatHashSet> pool_ps;
+
Cohort::Cohort(SingleWindow *p) :
type(0),
global_number(0),
@@ -46,6 +48,8 @@ next(0)
#ifdef CG_TRACE_OBJECTS
std::cerr << "OBJECT: " << __PRETTY_FUNCTION__ << std::endl;
#endif
+
+ pool_get(pool_ps, possible_sets);
}
Cohort::~Cohort() {
@@ -70,6 +74,7 @@ Cohort::~Cohort() {
parent->parent->dep_window.erase(global_number);
}
detach();
+ pool_put(pool_ps, possible_sets);
}
void Cohort::detach() {
diff --git a/src/Grammar.hpp b/src/Grammar.hpp
index 45ced04..380bd0c 100644
--- a/src/Grammar.hpp
+++ b/src/Grammar.hpp
@@ -77,11 +77,11 @@ namespace CG3 {
rules_by_set_t rules_by_set;
typedef stdext::hash_map<uint32_t, uint32IntervalVector> rules_by_tag_t;
rules_by_tag_t rules_by_tag;
- typedef stdext::hash_map<uint32_t, uint32FlatHashSet> sets_by_tag_t;
+ typedef stdext::hash_map<uint32_t, uint32SortedVector> sets_by_tag_t;
sets_by_tag_t sets_by_tag;
uint32IntervalVector *rules_any;
- uint32FlatHashSet *sets_any;
+ uint32SortedVector *sets_any;
Set *delimiters;
Set *soft_delimiters;
diff --git a/src/all_cg_comp.cpp b/src/all_cg_comp.cpp
index 16d3940..8e31e10 100644
--- a/src/all_cg_comp.cpp
+++ b/src/all_cg_comp.cpp
@@ -1,5 +1,5 @@
#include "stdafx.hpp"
-#include <exec-stream.cpp>
+#include <popen_plus.c>
#include "BinaryGrammar.cpp"
#include "ContextualTest.cpp"
#include "Grammar.cpp"
diff --git a/src/all_cg_conv.cpp b/src/all_cg_conv.cpp
index 18ea5b9..3ac923f 100644
--- a/src/all_cg_conv.cpp
+++ b/src/all_cg_conv.cpp
@@ -1,5 +1,5 @@
#include "stdafx.hpp"
-#include <exec-stream.cpp>
+#include <popen_plus.c>
#include "BinaryGrammar.cpp"
#include "ContextualTest.cpp"
#include "Grammar.cpp"
diff --git a/src/all_cg_proc.cpp b/src/all_cg_proc.cpp
index 2741a44..5276c2e 100644
--- a/src/all_cg_proc.cpp
+++ b/src/all_cg_proc.cpp
@@ -1,5 +1,5 @@
#include "stdafx.hpp"
-#include <exec-stream.cpp>
+#include <popen_plus.c>
#include "BinaryGrammar.cpp"
#include "ContextualTest.cpp"
#include "Grammar.cpp"
diff --git a/src/all_vislcg3.cpp b/src/all_vislcg3.cpp
index 1975496..c1d44e8 100644
--- a/src/all_vislcg3.cpp
+++ b/src/all_vislcg3.cpp
@@ -1,5 +1,5 @@
#include "stdafx.hpp"
-#include <exec-stream.cpp>
+#include <popen_plus.c>
#include "BinaryGrammar.cpp"
#include "ContextualTest.cpp"
#include "Grammar.cpp"
diff --git a/src/flat_unordered_map.hpp b/src/flat_unordered_map.hpp
index 34f505c..fa59798 100644
--- a/src/flat_unordered_map.hpp
+++ b/src/flat_unordered_map.hpp
@@ -128,21 +128,32 @@ public:
size_t insert(const value_type& t) {
assert(t.first != res_empty && t.first != res_del && "Key cannot be res_empty or res_del!");
- if (size_ + 1 >= capacity() / 2) {
+ if ((size_ + 1)*3/2 >= capacity() / 2) {
reserve(std::max(static_cast<size_type>(DEFAULT_CAP), capacity() * 2));
}
size_t max = capacity() - 1;
size_t spot = hash_value(t.first) & max;
- while (elements[spot].first != res_empty) {
+ while (elements[spot].first != res_empty && elements[spot].first != t.first) {
spot = (spot + 5) & max;
}
- elements[spot] = t;
- ++size_;
+ if (elements[spot].first != t.first) {
+ elements[spot] = t;
+ ++size_;
+ }
return spot;
}
template<typename It>
void insert(It b, It e) {
+ size_t d = std::distance(b, e);
+ size_t c = capacity();
+ while ((size_ + d)*3/2 >= c / 2) {
+ c = std::max(static_cast<size_type>(DEFAULT_CAP), c*2);
+ }
+ if (c != capacity()) {
+ reserve(c);
+ }
+
for (; b != e ; ++b) {
insert(*b);
}
@@ -162,6 +173,7 @@ public:
if (elements[spot].first == t) {
elements[spot].first = res_del;
elements[spot].second = V();
+ --size_;
}
}
@@ -169,6 +181,7 @@ public:
elements[it.i].first = res_del;
elements[it.i].second = V();
++it;
+ --size_;
return it;
}
@@ -247,7 +260,8 @@ public:
return;
}
- container vals;
+ static container vals;
+ vals.resize(0);
vals.reserve(size_);
for (size_type i = 0, ie = capacity(); i < ie; ++i) {
if (elements[i].first != res_empty && elements[i].first != res_del) {
@@ -260,7 +274,7 @@ public:
size_t max = capacity() - 1;
for (size_type i = 0, ie = vals.size(); i < ie; ++i) {
size_t spot = hash_value(vals[i].first) & max;
- while (elements[spot].first != res_empty) {
+ while (elements[spot].first != res_empty && elements[spot].first != vals[i].first) {
spot = (spot + 5) & max;
}
elements[spot] = vals[i];
@@ -284,7 +298,7 @@ public:
void clear(size_type n = 0) {
size_ = elements.size();
- elements.clear();
+ elements.resize(0);
elements.resize(std::max(size_, n), std::make_pair(res_empty, V()));
size_ = 0;
}
diff --git a/src/flat_unordered_set.hpp b/src/flat_unordered_set.hpp
index bc08208..5130393 100644
--- a/src/flat_unordered_set.hpp
+++ b/src/flat_unordered_set.hpp
@@ -126,20 +126,31 @@ public:
void insert(T t) {
assert(t != res_empty && t != res_del && "Value cannot be res_empty or res_del!");
- if (size_ + 1 >= capacity() / 2) {
+ if ((size_ + 1)*3/2 >= capacity() / 2) {
reserve(std::max(static_cast<size_type>(DEFAULT_CAP), capacity() * 2));
}
size_t max = capacity() - 1;
size_t spot = hash_value(t) & max;
- while (elements[spot] != res_empty) {
+ while (elements[spot] != res_empty && elements[spot] != t) {
spot = (spot + 5) & max;
}
- elements[spot] = t;
- ++size_;
+ if (elements[spot] != t) {
+ elements[spot] = t;
+ ++size_;
+ }
}
template<typename It>
void insert(It b, It e) {
+ size_t d = std::distance(b, e);
+ size_t c = capacity();
+ while ((size_ + d)*3/2 >= c / 2) {
+ c = std::max(static_cast<size_type>(DEFAULT_CAP), c*2);
+ }
+ if (c != capacity()) {
+ reserve(c);
+ }
+
for (; b != e ; ++b) {
insert(*b);
}
@@ -158,12 +169,14 @@ public:
}
if (elements[spot] == t) {
elements[spot] = res_del;
+ --size_;
}
}
const_iterator erase(const_iterator it) {
elements[it.i] = res_del;
++it;
+ --size_;
return it;
}
@@ -221,7 +234,8 @@ public:
return;
}
- container vals;
+ static container vals;
+ vals.resize(0);
vals.reserve(size_);
for (size_type i = 0, ie = capacity(); i < ie; ++i) {
if (elements[i] != res_empty && elements[i] != res_del) {
@@ -234,7 +248,7 @@ public:
size_t max = capacity() - 1;
for (size_type i = 0, ie = vals.size(); i < ie; ++i) {
size_t spot = hash_value(vals[i]) & max;
- while (elements[spot] != res_empty) {
+ while (elements[spot] != res_empty && elements[spot] != vals[i]) {
spot = (spot + 5) & max;
}
elements[spot] = vals[i];
@@ -258,7 +272,7 @@ public:
void clear(size_type n = 0) {
size_ = elements.size();
- elements.clear();
+ elements.resize(0);
elements.resize(std::max(size_, n), res_empty);
size_ = 0;
}
diff --git a/src/inlines.hpp b/src/inlines.hpp
index 51d52fb..41e0223 100644
--- a/src/inlines.hpp
+++ b/src/inlines.hpp
@@ -572,6 +572,21 @@ inline size_t fwrite_throw(const void *buffer, size_t size, size_t count, FILE *
return rv;
}
+template<typename Pool, typename Var>
+void pool_get(Pool& pool, Var& var) {
+ if (!pool.empty()) {
+ var.swap(pool.back());
+ var.clear();
+ pool.pop_back();
+ }
+}
+
+template<typename Pool, typename Var>
+void pool_put(Pool& pool, Var& var) {
+ pool.resize(pool.size()+1);
+ var.swap(pool.back());
+}
+
}
#endif
diff --git a/src/sorted_vector.hpp b/src/sorted_vector.hpp
index efa41db..4094384 100644
--- a/src/sorted_vector.hpp
+++ b/src/sorted_vector.hpp
@@ -212,6 +212,10 @@ public:
return elements.size();
}
+ size_type capacity() const {
+ return elements.capacity();
+ }
+
bool empty() const {
return elements.empty();
}
diff --git a/src/version.hpp b/src/version.hpp
index 08ab54d..656c494 100644
--- a/src/version.hpp
+++ b/src/version.hpp
@@ -30,7 +30,7 @@ const char* const CG3_COPYRIGHT_STRING = "Copyright (C) 2007-2015 GrammarSoft Ap
const uint32_t CG3_VERSION_MAJOR = 0;
const uint32_t CG3_VERSION_MINOR = 9;
const uint32_t CG3_VERSION_PATCH = 9;
-const uint32_t CG3_REVISION = 10754;
+const uint32_t CG3_REVISION = 10791;
const uint32_t CG3_FEATURE_REV = 10575;
const uint32_t CG3_TOO_OLD = 10373;
const uint32_t CG3_EXTERNAL_PROTOCOL = 7226;
diff --git a/vapply.sh b/vapply.sh
index 2590f4e..7b57547 100755
--- a/vapply.sh
+++ b/vapply.sh
@@ -9,6 +9,6 @@ cd vapply
rm -fv callgrind.*
mv -vf annotated annotated.old
mv -vf output.txt output.txt.old
-g++ -std=c++$CXXV -DNDEBUG -pthread -pipe -Wall -Wextra -Wno-deprecated -O3 -g3 -I../include -I../include/exec-stream ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV.debug -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc
+g++ -std=c++$CXXV -DNDEBUG -pthread -pipe -Wall -Wextra -Wno-deprecated -O3 -g3 -I../include -I../include/posix ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV.debug -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc
head -n 2000 ../comparison/arboretum_stripped.txt | valgrind --tool=callgrind --compress-strings=no --compress-pos=no --collect-jumps=yes --collect-systime=yes ./vislcg3-c++$CXXV.debug -v -t -C UTF-8 -g ../dancg.cg3b > output.txt
callgrind_annotate --tree=both --auto=yes > annotated
diff --git a/vparse.sh b/vparse.sh
index 395e808..f5700bc 100755
--- a/vparse.sh
+++ b/vparse.sh
@@ -6,6 +6,6 @@ mkdir -p vparse
cd vparse
rm -f callgrind.*
mv -vf annotated annotated.old
-g++ -std=c++$CXXV -DNDEBUG -Wall -Wextra -Wno-deprecated -pthread -pipe -O3 -g3 -I../include -I../include/exec-stream ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV.debug -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc
+g++ -std=c++$CXXV -DNDEBUG -Wall -Wextra -Wno-deprecated -pthread -pipe -O3 -g3 -I../include -I../include/posix ../src/all_vislcg3.cpp -o vislcg3-c++$CXXV.debug -L/usr/lib/x86_64-linux-gnu -licui18n -licudata -licuio -licuuc
valgrind --tool=callgrind --compress-strings=no --compress-pos=no --collect-jumps=yes --collect-systime=yes ./vislcg3-c++$CXXV.debug -C UTF-8 --grammar-only -g ~/parsers/dansk/etc/dancg
callgrind_annotate --tree=both --auto=yes > annotated
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cg3.git
More information about the debian-science-commits
mailing list