Skip to content

Commit

Permalink
git squash commit for copy_parallel_hashmap.
Browse files Browse the repository at this point in the history
74262caddfd441b1da9854fb335363653280e5cd
git squash commit for copy_parallel_hashmap.

739b19e
add parallel_hashmap

2af003e
tab

048d430
/

c1a74de
skip

33d8dc4b7089e41a7606c9a9fe0bf8e79f1c0bc4
wip

e652098bc9cb2f0a09161bdc0043bb3ad9259165
dow

bcbc1173b75ab56384658d80f29f8d4ff352d3f3
curl

e7673c2e88a4c114d8ff8a4c64c35ca849946f1c
ignore
  • Loading branch information
atetubou committed Jun 25, 2024
1 parent 0b4b43a commit de4f281
Show file tree
Hide file tree
Showing 17 changed files with 12,894 additions and 310 deletions.
1 change: 1 addition & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/third_party/parallel_hashmap/parallel_hashmap/*
1 change: 1 addition & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- uses: codespell-project/actions-codespell@master
with:
ignore_words_list: fo,wee,addin,notin
skip: ./third_party
- name: Install dependencies
run: |
dnf install -y make gcc-c++ libasan clang-analyzer cmake dnf-plugins-core epel-release
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ else()
endif()
endif()

include_directories(third_party/parallel_hashmap)

# --- optional re2c
set(RE2C_MAJOR_VERSION 0)
find_program(RE2C re2c)
Expand Down
2 changes: 2 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi
# Disable size_t -> int truncation warning.
# We never have strings or arrays larger than 2**31.
'/wd4267',
'/Ithird_party/parallel_hashmap',
'/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS',
'/D_HAS_EXCEPTIONS=0',
'/DNINJA_PYTHON="%s"' % options.with_python]
Expand All @@ -363,6 +364,7 @@ def search_system_path(file_name: str) -> Optional[str]: # type: ignore # Missi
'-fno-exceptions',
'-std=c++11',
'-fvisibility=hidden', '-pipe',
'-Ithird_party/parallel_hashmap',
'-DNINJA_PYTHON="%s"' % options.with_python]
if options.debug:
cflags += ['-D_GLIBCXX_DEBUG', '-D_GLIBCXX_DEBUG_PEDANTIC']
Expand Down
1 change: 1 addition & 0 deletions misc/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'misc/afl-fuzz-tokens/',
'src/depfile_parser.cc',
'src/lexer.cc',
'third_party/',
]

error_count = 0
Expand Down
152 changes: 76 additions & 76 deletions src/depfile_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,55 +105,55 @@ bool DepfileParser::Parse(string* content, string* err) {
};
yych = *in;
if (yybm[0+yych] & 128) {
goto yy9;
goto yy5;
}
if (yych <= '\r') {
if (yych <= '\t') {
if (yych >= 0x01) goto yy4;
if (yych >= 0x01) goto yy1;
} else {
if (yych <= '\n') goto yy6;
if (yych <= '\f') goto yy4;
goto yy8;
if (yych <= '\n') goto yy3;
if (yych <= '\f') goto yy1;
goto yy4;
}
} else {
if (yych <= '$') {
if (yych <= '#') goto yy4;
goto yy12;
if (yych <= '#') goto yy1;
goto yy7;
} else {
if (yych <= '?') goto yy4;
if (yych <= '\\') goto yy13;
goto yy4;
if (yych <= '?') goto yy1;
if (yych <= '\\') goto yy8;
goto yy1;
}
}
++in;
{
break;
}
yy4:
yy1:
++in;
yy5:
yy2:
{
// For any other character (e.g. whitespace), swallow it here,
// allowing the outer logic to loop around again.
break;
}
yy6:
yy3:
++in;
{
// A newline ends the current file name and the current rule.
have_newline = true;
break;
}
yy8:
yy4:
yych = *++in;
if (yych == '\n') goto yy6;
goto yy5;
yy9:
if (yych == '\n') goto yy3;
goto yy2;
yy5:
yych = *++in;
if (yybm[0+yych] & 128) {
goto yy9;
goto yy5;
}
yy11:
yy6:
{
// Got a span of plain text.
int len = (int)(in - start);
Expand All @@ -163,54 +163,54 @@ bool DepfileParser::Parse(string* content, string* err) {
out += len;
continue;
}
yy12:
yy7:
yych = *++in;
if (yych == '$') goto yy14;
goto yy5;
yy13:
if (yych == '$') goto yy9;
goto yy2;
yy8:
yych = *(yymarker = ++in);
if (yych <= ' ') {
if (yych <= '\n') {
if (yych <= 0x00) goto yy5;
if (yych <= '\t') goto yy16;
goto yy17;
if (yych <= 0x00) goto yy2;
if (yych <= '\t') goto yy10;
goto yy11;
} else {
if (yych == '\r') goto yy19;
if (yych <= 0x1F) goto yy16;
goto yy21;
if (yych == '\r') goto yy12;
if (yych <= 0x1F) goto yy10;
goto yy13;
}
} else {
if (yych <= '9') {
if (yych == '#') goto yy23;
goto yy16;
if (yych == '#') goto yy14;
goto yy10;
} else {
if (yych <= ':') goto yy25;
if (yych == '\\') goto yy27;
goto yy16;
if (yych <= ':') goto yy15;
if (yych == '\\') goto yy17;
goto yy10;
}
}
yy14:
yy9:
++in;
{
// De-escape dollar character.
*out++ = '$';
continue;
}
yy16:
yy10:
++in;
goto yy11;
yy17:
goto yy6;
yy11:
++in;
{
// A line continuation ends the current file name.
break;
}
yy19:
yy12:
yych = *++in;
if (yych == '\n') goto yy17;
if (yych == '\n') goto yy11;
in = yymarker;
goto yy5;
yy21:
goto yy2;
yy13:
++in;
{
// 2N+1 backslashes plus space -> N backslashes plus space.
Expand All @@ -222,7 +222,7 @@ bool DepfileParser::Parse(string* content, string* err) {
*out++ = ' ';
continue;
}
yy23:
yy14:
++in;
{
// De-escape hash sign, but preserve other leading backslashes.
Expand All @@ -233,17 +233,17 @@ bool DepfileParser::Parse(string* content, string* err) {
*out++ = '#';
continue;
}
yy25:
yy15:
yych = *++in;
if (yych <= '\f') {
if (yych <= 0x00) goto yy28;
if (yych <= 0x08) goto yy26;
if (yych <= '\n') goto yy28;
if (yych <= 0x00) goto yy18;
if (yych <= 0x08) goto yy16;
if (yych <= '\n') goto yy18;
} else {
if (yych <= '\r') goto yy28;
if (yych == ' ') goto yy28;
if (yych <= '\r') goto yy18;
if (yych == ' ') goto yy18;
}
yy26:
yy16:
{
// De-escape colon sign, but preserve other leading backslashes.
// Regular expression uses lookahead to make sure that no whitespace
Expand All @@ -255,29 +255,29 @@ bool DepfileParser::Parse(string* content, string* err) {
*out++ = ':';
continue;
}
yy27:
yy17:
yych = *++in;
if (yych <= ' ') {
if (yych <= '\n') {
if (yych <= 0x00) goto yy11;
if (yych <= '\t') goto yy16;
goto yy11;
if (yych <= 0x00) goto yy6;
if (yych <= '\t') goto yy10;
goto yy6;
} else {
if (yych == '\r') goto yy11;
if (yych <= 0x1F) goto yy16;
goto yy30;
if (yych == '\r') goto yy6;
if (yych <= 0x1F) goto yy10;
goto yy19;
}
} else {
if (yych <= '9') {
if (yych == '#') goto yy23;
goto yy16;
if (yych == '#') goto yy14;
goto yy10;
} else {
if (yych <= ':') goto yy25;
if (yych == '\\') goto yy32;
goto yy16;
if (yych <= ':') goto yy15;
if (yych == '\\') goto yy20;
goto yy10;
}
}
yy28:
yy18:
++in;
{
// Backslash followed by : and whitespace.
Expand All @@ -291,7 +291,7 @@ bool DepfileParser::Parse(string* content, string* err) {
have_newline = true;
break;
}
yy30:
yy19:
++in;
{
// 2N backslashes plus space -> 2N backslashes, end of filename.
Expand All @@ -301,26 +301,26 @@ bool DepfileParser::Parse(string* content, string* err) {
out += len - 1;
break;
}
yy32:
yy20:
yych = *++in;
if (yych <= ' ') {
if (yych <= '\n') {
if (yych <= 0x00) goto yy11;
if (yych <= '\t') goto yy16;
goto yy11;
if (yych <= 0x00) goto yy6;
if (yych <= '\t') goto yy10;
goto yy6;
} else {
if (yych == '\r') goto yy11;
if (yych <= 0x1F) goto yy16;
goto yy21;
if (yych == '\r') goto yy6;
if (yych <= 0x1F) goto yy10;
goto yy13;
}
} else {
if (yych <= '9') {
if (yych == '#') goto yy23;
goto yy16;
if (yych == '#') goto yy14;
goto yy10;
} else {
if (yych <= ':') goto yy25;
if (yych == '\\') goto yy27;
goto yy16;
if (yych <= ':') goto yy15;
if (yych == '\\') goto yy17;
goto yy10;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <algorithm>
#include <string.h>
#include "parallel_hashmap/phmap.h"
#include "parallel_hashmap/phmap_utils.h"
#include "string_piece.h"
#include "util.h"

Expand Down Expand Up @@ -53,8 +55,6 @@ unsigned int MurmurHash2(const void* key, size_t len) {
return h;
}

#include <unordered_map>

namespace std {
template<>
struct hash<StringPiece> {
Expand All @@ -73,7 +73,7 @@ struct hash<StringPiece> {
/// mapping StringPiece => Foo*.
template<typename V>
struct ExternalStringHashMap {
typedef std::unordered_map<StringPiece, V> Type;
typedef phmap::flat_hash_map<StringPiece, V> Type;
};

#endif // NINJA_MAP_H_
Loading

0 comments on commit de4f281

Please sign in to comment.