253c3f8499
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
36 lines
879 B
C++
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
|