Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
b7ad9512
Commit
b7ad9512
authored
Sep 01, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parameterize DenseMap on the minimum size
The default is 64, which is quite a lot for our uses.
parent
ec6a4c7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
19 deletions
+20
-19
src/core/from_llvm/DenseMap.h
src/core/from_llvm/DenseMap.h
+18
-17
src/core/from_llvm/DenseSet.h
src/core/from_llvm/DenseSet.h
+2
-2
No files found.
src/core/from_llvm/DenseMap.h
View file @
b7ad9512
...
@@ -73,7 +73,7 @@ template <
...
@@ -73,7 +73,7 @@ template <
class
DenseMapIterator
;
class
DenseMapIterator
;
template
<
typename
DerivedT
,
typename
KeyT
,
typename
ValueT
,
typename
KeyInfoT
,
template
<
typename
DerivedT
,
typename
KeyT
,
typename
ValueT
,
typename
KeyInfoT
,
typename
BucketT
>
typename
BucketT
,
int
MinSize
=
64
>
class
DenseMapBase
{
class
DenseMapBase
{
public:
public:
typedef
unsigned
size_type
;
typedef
unsigned
size_type
;
...
@@ -114,7 +114,7 @@ public:
...
@@ -114,7 +114,7 @@ public:
// If the capacity of the array is huge, and the # elements used is small,
// If the capacity of the array is huge, and the # elements used is small,
// shrink the array.
// shrink the array.
if
(
getNumEntries
()
*
4
<
getNumBuckets
()
&&
getNumBuckets
()
>
64
)
{
if
(
getNumEntries
()
*
4
<
getNumBuckets
()
&&
getNumBuckets
()
>
MinSize
)
{
shrink_and_clear
();
shrink_and_clear
();
return
;
return
;
}
}
...
@@ -338,7 +338,7 @@ protected:
...
@@ -338,7 +338,7 @@ protected:
template
<
typename
OtherBaseT
>
template
<
typename
OtherBaseT
>
void
copyFrom
(
void
copyFrom
(
const
DenseMapBase
<
OtherBaseT
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
&
other
)
{
const
DenseMapBase
<
OtherBaseT
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
&
other
)
{
assert
(
&
other
!=
this
);
assert
(
&
other
!=
this
);
assert
(
getNumBuckets
()
==
other
.
getNumBuckets
());
assert
(
getNumBuckets
()
==
other
.
getNumBuckets
());
...
@@ -565,13 +565,14 @@ public:
...
@@ -565,13 +565,14 @@ public:
template
<
typename
KeyT
,
typename
ValueT
,
template
<
typename
KeyT
,
typename
ValueT
,
typename
KeyInfoT
=
DenseMapInfo
<
KeyT
>,
typename
KeyInfoT
=
DenseMapInfo
<
KeyT
>,
typename
BucketT
=
detail
::
DenseMapPair
<
KeyT
,
ValueT
>>
typename
BucketT
=
detail
::
DenseMapPair
<
KeyT
,
ValueT
>
,
class
DenseMap
:
public
DenseMapBase
<
DenseMap
<
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
,
int
MinSize
=
64
>
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
{
class
DenseMap
:
public
DenseMapBase
<
DenseMap
<
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
{
// Lift some types from the dependent base class into this class for
// Lift some types from the dependent base class into this class for
// simplicity of referring to them.
// simplicity of referring to them.
typedef
DenseMapBase
<
DenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
BaseT
;
typedef
DenseMapBase
<
DenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
BaseT
;
friend
class
DenseMapBase
<
DenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
;
friend
class
DenseMapBase
<
DenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
;
BucketT
*
Buckets
;
BucketT
*
Buckets
;
unsigned
NumEntries
;
unsigned
NumEntries
;
...
@@ -649,7 +650,7 @@ public:
...
@@ -649,7 +650,7 @@ public:
unsigned
OldNumBuckets
=
NumBuckets
;
unsigned
OldNumBuckets
=
NumBuckets
;
BucketT
*
OldBuckets
=
Buckets
;
BucketT
*
OldBuckets
=
Buckets
;
allocateBuckets
(
std
::
max
<
unsigned
>
(
64
,
static_cast
<
unsigned
>
(
NextPowerOf2
(
AtLeast
-
1
))));
allocateBuckets
(
std
::
max
<
unsigned
>
(
MinSize
,
static_cast
<
unsigned
>
(
NextPowerOf2
(
AtLeast
-
1
))));
assert
(
Buckets
);
assert
(
Buckets
);
if
(
!
OldBuckets
)
{
if
(
!
OldBuckets
)
{
this
->
BaseT
::
initEmpty
();
this
->
BaseT
::
initEmpty
();
...
@@ -669,7 +670,7 @@ public:
...
@@ -669,7 +670,7 @@ public:
// Reduce the number of buckets.
// Reduce the number of buckets.
unsigned
NewNumBuckets
=
0
;
unsigned
NewNumBuckets
=
0
;
if
(
OldNumEntries
)
if
(
OldNumEntries
)
NewNumBuckets
=
std
::
max
(
64
,
1
<<
(
Log2_32_Ceil
(
OldNumEntries
)
+
1
));
NewNumBuckets
=
std
::
max
(
MinSize
,
1
<<
(
Log2_32_Ceil
(
OldNumEntries
)
+
1
));
if
(
NewNumBuckets
==
NumBuckets
)
{
if
(
NewNumBuckets
==
NumBuckets
)
{
this
->
BaseT
::
initEmpty
();
this
->
BaseT
::
initEmpty
();
return
;
return
;
...
@@ -716,15 +717,15 @@ private:
...
@@ -716,15 +717,15 @@ private:
template
<
typename
KeyT
,
typename
ValueT
,
unsigned
InlineBuckets
=
4
,
template
<
typename
KeyT
,
typename
ValueT
,
unsigned
InlineBuckets
=
4
,
typename
KeyInfoT
=
DenseMapInfo
<
KeyT
>,
typename
KeyInfoT
=
DenseMapInfo
<
KeyT
>,
typename
BucketT
=
detail
::
DenseMapPair
<
KeyT
,
ValueT
>>
typename
BucketT
=
detail
::
DenseMapPair
<
KeyT
,
ValueT
>
,
int
MinSize
=
64
>
class
SmallDenseMap
class
SmallDenseMap
:
public
DenseMapBase
<
:
public
DenseMapBase
<
SmallDenseMap
<
KeyT
,
ValueT
,
InlineBuckets
,
KeyInfoT
,
BucketT
>
,
KeyT
,
SmallDenseMap
<
KeyT
,
ValueT
,
InlineBuckets
,
KeyInfoT
,
BucketT
>
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
{
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
{
// Lift some types from the dependent base class into this class for
// Lift some types from the dependent base class into this class for
// simplicity of referring to them.
// simplicity of referring to them.
typedef
DenseMapBase
<
SmallDenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
BaseT
;
typedef
DenseMapBase
<
SmallDenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
BaseT
;
friend
class
DenseMapBase
<
SmallDenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
>
;
friend
class
DenseMapBase
<
SmallDenseMap
,
KeyT
,
ValueT
,
KeyInfoT
,
BucketT
,
MinSize
>
;
unsigned
Small
:
1
;
unsigned
Small
:
1
;
unsigned
NumEntries
:
31
;
unsigned
NumEntries
:
31
;
...
@@ -873,7 +874,7 @@ public:
...
@@ -873,7 +874,7 @@ public:
void
grow
(
unsigned
AtLeast
)
{
void
grow
(
unsigned
AtLeast
)
{
if
(
AtLeast
>=
InlineBuckets
)
if
(
AtLeast
>=
InlineBuckets
)
AtLeast
=
std
::
max
<
unsigned
>
(
64
,
NextPowerOf2
(
AtLeast
-
1
));
AtLeast
=
std
::
max
<
unsigned
>
(
MinSize
,
NextPowerOf2
(
AtLeast
-
1
));
if
(
Small
)
{
if
(
Small
)
{
if
(
AtLeast
<
InlineBuckets
)
if
(
AtLeast
<
InlineBuckets
)
...
@@ -931,8 +932,8 @@ public:
...
@@ -931,8 +932,8 @@ public:
unsigned
NewNumBuckets
=
0
;
unsigned
NewNumBuckets
=
0
;
if
(
OldSize
)
{
if
(
OldSize
)
{
NewNumBuckets
=
1
<<
(
Log2_32_Ceil
(
OldSize
)
+
1
);
NewNumBuckets
=
1
<<
(
Log2_32_Ceil
(
OldSize
)
+
1
);
if
(
NewNumBuckets
>
InlineBuckets
&&
NewNumBuckets
<
64u
)
if
(
NewNumBuckets
>
InlineBuckets
&&
NewNumBuckets
<
(
unsigned
)
MinSize
)
NewNumBuckets
=
64
;
NewNumBuckets
=
MinSize
;
}
}
if
((
Small
&&
NewNumBuckets
<=
InlineBuckets
)
||
if
((
Small
&&
NewNumBuckets
<=
InlineBuckets
)
||
(
!
Small
&&
NewNumBuckets
==
getLargeRep
()
->
NumBuckets
))
{
(
!
Small
&&
NewNumBuckets
==
getLargeRep
()
->
NumBuckets
))
{
...
...
src/core/from_llvm/DenseSet.h
View file @
b7ad9512
...
@@ -55,10 +55,10 @@ public:
...
@@ -55,10 +55,10 @@ public:
}
}
/// DenseSet - This implements a dense probed hash-table based set.
/// DenseSet - This implements a dense probed hash-table based set.
template
<
typename
ValueT
,
typename
ValueInfoT
=
DenseMapInfo
<
ValueT
>
>
template
<
typename
ValueT
,
typename
ValueInfoT
=
DenseMapInfo
<
ValueT
>
,
int
MinSize
=
64
>
class
DenseSet
{
class
DenseSet
{
typedef
DenseMap
<
ValueT
,
detail
::
DenseSetEmpty
,
ValueInfoT
,
typedef
DenseMap
<
ValueT
,
detail
::
DenseSetEmpty
,
ValueInfoT
,
detail
::
DenseSetPair
<
ValueT
>>
MapTy
;
detail
::
DenseSetPair
<
ValueT
>
,
MinSize
>
MapTy
;
static_assert
(
sizeof
(
typename
MapTy
::
value_type
)
==
sizeof
(
ValueT
),
static_assert
(
sizeof
(
typename
MapTy
::
value_type
)
==
sizeof
(
ValueT
),
"DenseMap buckets unexpectedly large!"
);
"DenseMap buckets unexpectedly large!"
);
MapTy
TheMap
;
MapTy
TheMap
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment