323e06222e
Original CL: http://codereview.chromium.org/10872035/ It enables elimination of redundant expressions across basic blocks. Currently used for smi checks and class checks, but will be extended to other expressions in a separate CL. Additionally, this fixes a bug in the register allocator where a blocked register was illegally assigned to an unallocated live range. It also fixes a Mac compiler issue with the constructor of DirectChainedHashMap. Review URL: https://chromiumcodereview.appspot.com//10871060 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@11302 260f80e4-7a28-3924-810f-c04153c831b5
40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "platform/assert.h"
|
|
#include "vm/unit_test.h"
|
|
#include "vm/hash_map.h"
|
|
|
|
namespace dart {
|
|
|
|
class TestValue {
|
|
public:
|
|
explicit TestValue(intptr_t x) : x_(x) { }
|
|
intptr_t Hashcode() const { return x_ & 1; }
|
|
bool Equals(TestValue* other) { return x_ == other->x_; }
|
|
private:
|
|
intptr_t x_;
|
|
};
|
|
|
|
|
|
TEST_CASE(DirectChainedHashMap) {
|
|
DirectChainedHashMap<TestValue*> map;
|
|
EXPECT(map.IsEmpty());
|
|
TestValue v1(0);
|
|
TestValue v2(1);
|
|
TestValue v3(0);
|
|
map.Insert(&v1);
|
|
EXPECT(map.Lookup(&v1) == &v1);
|
|
map.Insert(&v2);
|
|
EXPECT(map.Lookup(&v1) == &v1);
|
|
EXPECT(map.Lookup(&v2) == &v2);
|
|
EXPECT(map.Lookup(&v3) == &v1);
|
|
DirectChainedHashMap<TestValue*> map2(map);
|
|
EXPECT(map2.Lookup(&v1) == &v1);
|
|
EXPECT(map2.Lookup(&v2) == &v2);
|
|
EXPECT(map2.Lookup(&v3) == &v1);
|
|
}
|
|
|
|
} // namespace dart
|