OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/globals.h" | 6 #include "vm/globals.h" |
7 #if defined(TARGET_ARCH_DBC) | 7 #if defined(TARGET_ARCH_DBC) |
8 | 8 |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
11 #include "vm/unit_test.h" | 11 #include "vm/unit_test.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 #define __ assembler-> | 15 #define __ assembler-> |
16 | 16 |
17 // Generate a simple dart code sequence. | 17 // Generate a simple dart code sequence. |
18 // This is used to test Code and Instruction object creation. | 18 // This is used to test Code and Instruction object creation. |
19 // For other architectures, this sequence does do an increment, hence the name. | 19 // For other architectures, this sequence does do an increment, hence the name. |
20 // On DBC, we don't do an increment because generating an instance call here | 20 // On DBC, we don't do an increment because generating an instance call here |
21 // would be too complex. | 21 // would be too complex. |
22 void GenerateIncrement(Assembler* assembler) { | 22 void GenerateIncrement(Assembler* assembler) { |
23 __ Frame(1); | 23 __ Frame(1); |
24 __ LoadConstant(0, Smi::Handle(Smi::New(1))); | 24 __ LoadConstant(0, Smi::Handle(Smi::New(1))); |
25 __ Return(0); | 25 __ Return(0); |
26 } | 26 } |
27 | 27 |
28 | |
29 // Generate a dart code sequence that embeds a string object in it. | 28 // Generate a dart code sequence that embeds a string object in it. |
30 // This is used to test Embedded String objects in the instructions. | 29 // This is used to test Embedded String objects in the instructions. |
31 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { | 30 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { |
32 const String& string_object = | 31 const String& string_object = |
33 String::ZoneHandle(String::New(str, Heap::kOld)); | 32 String::ZoneHandle(String::New(str, Heap::kOld)); |
34 __ PushConstant(string_object); | 33 __ PushConstant(string_object); |
35 __ ReturnTOS(); | 34 __ ReturnTOS(); |
36 } | 35 } |
37 | 36 |
38 | |
39 // Generate a dart code sequence that embeds a smi object in it. | 37 // Generate a dart code sequence that embeds a smi object in it. |
40 // This is used to test Embedded Smi objects in the instructions. | 38 // This is used to test Embedded Smi objects in the instructions. |
41 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { | 39 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { |
42 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); | 40 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); |
43 __ PushConstant(smi_object); | 41 __ PushConstant(smi_object); |
44 __ ReturnTOS(); | 42 __ ReturnTOS(); |
45 } | 43 } |
46 | 44 |
47 } // namespace dart | 45 } // namespace dart |
48 | 46 |
49 #endif // defined TARGET_ARCH_DBC | 47 #endif // defined TARGET_ARCH_DBC |
OLD | NEW |