Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: runtime/vm/assembler_test.cc

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/assembler.h" 5 #include "vm/assembler.h"
6 #include "vm/globals.h" 6 #include "vm/globals.h"
7 #include "vm/os.h" 7 #include "vm/os.h"
8 #include "vm/simulator.h" 8 #include "vm/simulator.h"
9 #include "vm/unit_test.h" 9 #include "vm/unit_test.h"
10 #include "vm/virtual_memory.h" 10 #include "vm/virtual_memory.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 ASSEMBLER_TEST_EXTERN(StoreIntoObject); 14 ASSEMBLER_TEST_EXTERN(StoreIntoObject);
15 15
16 ASSEMBLER_TEST_RUN(StoreIntoObject, test) { 16 ASSEMBLER_TEST_RUN(StoreIntoObject, test) {
17 #if defined(USING_SIMULATOR) 17 #if defined(USING_SIMULATOR)
18 #define test_code(ctx, value, growable_array, thread) \ 18 #define test_code(value, growable_array, thread) \
19 Simulator::Current()->Call( \ 19 Simulator::Current()->Call( \
20 bit_cast<intptr_t, uword>(test->entry()), \ 20 bit_cast<intptr_t, uword>(test->entry()), \
21 reinterpret_cast<intptr_t>(ctx), \ 21 reinterpret_cast<intptr_t>(test->code()), \
22 reinterpret_cast<intptr_t>(value), \ 22 reinterpret_cast<intptr_t>(value), \
23 reinterpret_cast<intptr_t>(growable_array), \ 23 reinterpret_cast<intptr_t>(growable_array), \
24 reinterpret_cast<intptr_t>(thread)) 24 reinterpret_cast<intptr_t>(thread))
25 #else 25 #else
26 typedef void (*StoreData)(RawContext* ctx, 26 typedef void (*StoreData)(const Code& code,
27 RawObject* value, 27 RawObject* value,
28 RawObject* growable_array, 28 RawObject* growable_array,
29 Thread* thread); 29 Thread* thread);
30 StoreData test_code = reinterpret_cast<StoreData>(test->entry()); 30 StoreData test_code_impl = reinterpret_cast<StoreData>(test->entry());
31 #define test_code(value, growable_array, thread) \
32 test_code_impl(test->code(), value, growable_array, thread)
31 #endif 33 #endif
32 34
33 const Array& old_array = Array::Handle(Array::New(3, Heap::kOld)); 35 const Array& old_array = Array::Handle(Array::New(3, Heap::kOld));
34 const Array& new_array = Array::Handle(Array::New(3, Heap::kNew)); 36 const Array& new_array = Array::Handle(Array::New(3, Heap::kNew));
35 const GrowableObjectArray& grow_old_array = GrowableObjectArray::Handle( 37 const GrowableObjectArray& grow_old_array = GrowableObjectArray::Handle(
36 GrowableObjectArray::New(old_array, Heap::kOld)); 38 GrowableObjectArray::New(old_array, Heap::kOld));
37 const GrowableObjectArray& grow_new_array = GrowableObjectArray::Handle( 39 const GrowableObjectArray& grow_new_array = GrowableObjectArray::Handle(
38 GrowableObjectArray::New(old_array, Heap::kNew)); 40 GrowableObjectArray::New(old_array, Heap::kNew));
39 Smi& smi = Smi::Handle(); 41 Smi& smi = Smi::Handle();
40 const Context& ctx = Context::Handle(Context::New(0));
41 Thread* thread = Thread::Current(); 42 Thread* thread = Thread::Current();
42 43
43 EXPECT(old_array.raw() == grow_old_array.data()); 44 EXPECT(old_array.raw() == grow_old_array.data());
44 EXPECT(!thread->StoreBufferContains(grow_old_array.raw())); 45 EXPECT(!thread->StoreBufferContains(grow_old_array.raw()));
45 EXPECT(old_array.raw() == grow_new_array.data()); 46 EXPECT(old_array.raw() == grow_new_array.data());
46 EXPECT(!thread->StoreBufferContains(grow_new_array.raw())); 47 EXPECT(!thread->StoreBufferContains(grow_new_array.raw()));
47 48
48 // Store Smis into the old object. 49 // Store Smis into the old object.
49 for (int i = -128; i < 128; i++) { 50 for (int i = -128; i < 128; i++) {
50 smi = Smi::New(i); 51 smi = Smi::New(i);
51 test_code(ctx.raw(), smi.raw(), grow_old_array.raw(), thread); 52 test_code(smi.raw(), grow_old_array.raw(), thread);
52 EXPECT(reinterpret_cast<RawArray*>(smi.raw()) == grow_old_array.data()); 53 EXPECT(reinterpret_cast<RawArray*>(smi.raw()) == grow_old_array.data());
53 EXPECT(!thread->StoreBufferContains(grow_old_array.raw())); 54 EXPECT(!thread->StoreBufferContains(grow_old_array.raw()));
54 } 55 }
55 56
56 // Store an old object into the old object. 57 // Store an old object into the old object.
57 test_code(ctx.raw(), old_array.raw(), grow_old_array.raw(), thread); 58 test_code(old_array.raw(), grow_old_array.raw(), thread);
58 EXPECT(old_array.raw() == grow_old_array.data()); 59 EXPECT(old_array.raw() == grow_old_array.data());
59 EXPECT(!thread->StoreBufferContains(grow_old_array.raw())); 60 EXPECT(!thread->StoreBufferContains(grow_old_array.raw()));
60 61
61 // Store a new object into the old object. 62 // Store a new object into the old object.
62 test_code(ctx.raw(), new_array.raw(), grow_old_array.raw(), thread); 63 test_code(new_array.raw(), grow_old_array.raw(), thread);
63 EXPECT(new_array.raw() == grow_old_array.data()); 64 EXPECT(new_array.raw() == grow_old_array.data());
64 EXPECT(thread->StoreBufferContains(grow_old_array.raw())); 65 EXPECT(thread->StoreBufferContains(grow_old_array.raw()));
65 66
66 // Store a new object into the new object. 67 // Store a new object into the new object.
67 test_code(ctx.raw(), new_array.raw(), grow_new_array.raw(), thread); 68 test_code(new_array.raw(), grow_new_array.raw(), thread);
68 EXPECT(new_array.raw() == grow_new_array.data()); 69 EXPECT(new_array.raw() == grow_new_array.data());
69 EXPECT(!thread->StoreBufferContains(grow_new_array.raw())); 70 EXPECT(!thread->StoreBufferContains(grow_new_array.raw()));
70 71
71 // Store an old object into the new object. 72 // Store an old object into the new object.
72 test_code(ctx.raw(), old_array.raw(), grow_new_array.raw(), thread); 73 test_code(old_array.raw(), grow_new_array.raw(), thread);
73 EXPECT(old_array.raw() == grow_new_array.data()); 74 EXPECT(old_array.raw() == grow_new_array.data());
74 EXPECT(!thread->StoreBufferContains(grow_new_array.raw())); 75 EXPECT(!thread->StoreBufferContains(grow_new_array.raw()));
75 } 76 }
76 77
77 } // namespace dart 78 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/assembler.cc ('k') | runtime/vm/assembler_x64.h » ('j') | runtime/vm/assembler_x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698