OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 #include "vm/assembler.h" | |
6 #include "vm/globals.h" | |
7 #include "vm/os.h" | |
8 #include "vm/unit_test.h" | |
9 #include "vm/virtual_memory.h" | |
10 | |
11 namespace dart { | |
12 | |
13 ASSEMBLER_TEST_EXTERN(StoreIntoObject); | |
14 | |
15 ASSEMBLER_TEST_RUN(StoreIntoObject, entry) { | |
cshapiro
2012/06/22 23:22:40
This test only needs to test StoreIntoObjectFilter
cshapiro
2012/06/22 23:46:42
FYI: an example of this will be with tracing which
| |
16 typedef void (*StoreData)(RawContext* ctx, | |
17 RawObject* value, | |
18 RawObject* growable_array); | |
19 StoreData test_code = reinterpret_cast<StoreData>(entry); | |
20 | |
21 const Array& old_array = Array::Handle(Array::New(3, Heap::kOld)); | |
22 const Array& new_array = Array::Handle(Array::New(3, Heap::kNew)); | |
23 const GrowableObjectArray& grow_old_array = GrowableObjectArray::Handle( | |
24 GrowableObjectArray::New(old_array, Heap::kOld)); | |
25 const GrowableObjectArray& grow_new_array = GrowableObjectArray::Handle( | |
26 GrowableObjectArray::New(old_array, Heap::kNew)); | |
27 Smi& smi = Smi::Handle(); | |
28 const Context& ctx = Context::Handle(Context::New(0)); | |
29 | |
30 EXPECT(old_array.raw() == grow_old_array.data()); | |
31 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
32 reinterpret_cast<uword>(grow_old_array.raw()) + | |
33 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
34 EXPECT(old_array.raw() == grow_new_array.data()); | |
35 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
36 reinterpret_cast<uword>(grow_new_array.raw()) + | |
37 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
38 | |
39 // Store Smis into the old object. | |
40 for (int i = -32; i < 32; i++) { | |
cshapiro
2012/06/22 23:22:40
Testing the full range of 8-bit immediate values r
Ivan Posva
2012/06/22 23:42:21
Changed to test from -128 to 128.
| |
41 smi = Smi::New(i); | |
42 test_code(ctx.raw(), smi.raw(), grow_old_array.raw()); | |
43 EXPECT(reinterpret_cast<RawArray*>(smi.raw()) == grow_old_array.data()); | |
44 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
45 reinterpret_cast<uword>(grow_old_array.raw()) + | |
46 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
47 } | |
48 | |
49 // Store an old object into the old object. | |
50 test_code(ctx.raw(), old_array.raw(), grow_old_array.raw()); | |
51 EXPECT(old_array.raw() == grow_old_array.data()); | |
52 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
53 reinterpret_cast<uword>(grow_old_array.raw()) + | |
54 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
55 | |
56 // Store a new object into the old object. | |
57 test_code(ctx.raw(), new_array.raw(), grow_old_array.raw()); | |
58 EXPECT(new_array.raw() == grow_old_array.data()); | |
59 EXPECT(Isolate::Current()->store_buffer()->Contains( | |
60 reinterpret_cast<uword>(grow_old_array.raw()) + | |
61 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
62 | |
63 // Store a new object into the new object. | |
64 test_code(ctx.raw(), new_array.raw(), grow_new_array.raw()); | |
65 EXPECT(new_array.raw() == grow_new_array.data()); | |
66 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
67 reinterpret_cast<uword>(grow_new_array.raw()) + | |
68 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
69 | |
70 // Store an old object into the new object. | |
71 test_code(ctx.raw(), old_array.raw(), grow_new_array.raw()); | |
72 EXPECT(old_array.raw() == grow_new_array.data()); | |
73 EXPECT(!Isolate::Current()->store_buffer()->Contains( | |
74 reinterpret_cast<uword>(grow_new_array.raw()) + | |
75 GrowableObjectArray::data_offset() - kHeapObjectTag)); | |
76 } | |
77 | |
78 } // namespace dart | |
OLD | NEW |