Files
sdk/runtime/vm/hash_map_test.cc
T
fschneider@google.com 253c3f8499 Implement class id checks as a separate instruction and add a local CSE optimization pass.
This CL contains:
A new CheckClassComp instruction. Currently it is used only for instance loads:
(LoadInstanceFieldComp)

A pass LocalCSE that performs block-local common subexpression elimination. To identify
redundant expressions I use a hash map per basic block. Computations that do not have
side effects can participate in CSE. For now, I only enabled it for CheckClass.
Any computation that participates in CSE must implement the AttributesEqual function.


Other smaller fixes:

Places where we can pass the correct initial size for GrowableArrays
that have a known size. We should consider having a FixedLengthArray for this purpose.

Made the accessors ic_data() and set_ic_data() use a const ICData*.
Review URL: https://chromiumcodereview.appspot.com//10824349

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10948 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-20 12:40:14 +00:00

36 lines
879 B
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);
}
} // namespace dart