Commit 779cb5b5 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Switch BoxedDict to llvm::DenseMap

parent 7c6b5218
......@@ -94,7 +94,7 @@ struct _dictobject {
#endif
typedef struct {
PyObject_HEAD;
char _filler[SIZEOF_UNORDEREDMAP];
char _filler[24];
} PyDictObject;
// Pyston change: these are no longer static objects:
......
......@@ -479,7 +479,7 @@ Box* dictSetdefault(BoxedDict* self, Box* k, Box* v) {
if (it != self->d.end())
return it->second;
self->d.insert(it, std::make_pair(k, v));
self->d.insert(std::make_pair(k, v));
return v;
}
......
......@@ -659,9 +659,22 @@ struct PyLt {
bool operator()(Box*, Box*) const;
};
struct PythonLevelEq {
static bool isEqual(Box* lhs, Box* rhs) {
if (lhs == rhs)
return true;
if (rhs == getEmptyKey() || rhs == getTombstoneKey())
return false;
return PyEq()(lhs, rhs);
}
static Box* getEmptyKey() { return (Box*)-1; }
static Box* getTombstoneKey() { return (Box*)-2; }
static unsigned getHashValue(Box* val) { return PyHasher()(val); }
};
class BoxedDict : public Box {
public:
typedef std::unordered_map<Box*, Box*, PyHasher, PyEq> DictMap;
typedef llvm::DenseMap<Box*, Box*, PythonLevelEq> DictMap;
DictMap d;
......
......@@ -221,7 +221,7 @@ extern "C" void dumpEx(void* p, int levels) {
if (isSubclass(b->cls, dict_cls)) {
BoxedDict* d = static_cast<BoxedDict*>(b);
printf("%ld elements\n", d->d.size());
printf("%d elements\n", d->d.size());
if (levels > 0) {
int i = 0;
......
......@@ -233,6 +233,5 @@ print sorted(l)
#recursive printing test
d = dict()
d['one'] = '1'
d['two'] = d
print d
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment