| 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. |
| 20 // On DBC, we don't do an increment because generating an instance call here |
| 21 // would be too complex. |
| 19 void GenerateIncrement(Assembler* assembler) { | 22 void GenerateIncrement(Assembler* assembler) { |
| 20 __ Frame(1); | 23 __ Frame(1); |
| 21 __ LoadConstant(0, Smi::Handle(Smi::New(0))); | 24 __ LoadConstant(0, Smi::Handle(Smi::New(1))); |
| 22 __ PushConstant(Smi::Handle(Smi::New(1))); | |
| 23 __ Push(0); | |
| 24 __ AddTOS(); | |
| 25 __ Trap(); | |
| 26 __ PopLocal(0); | |
| 27 __ Return(0); | 25 __ Return(0); |
| 28 } | 26 } |
| 29 | 27 |
| 30 | 28 |
| 31 // Generate a dart code sequence that embeds a string object in it. | 29 // Generate a dart code sequence that embeds a string object in it. |
| 32 // This is used to test Embedded String objects in the instructions. | 30 // This is used to test Embedded String objects in the instructions. |
| 33 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { | 31 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { |
| 34 const String& string_object = | 32 const String& string_object = |
| 35 String::ZoneHandle(String::New(str, Heap::kOld)); | 33 String::ZoneHandle(String::New(str, Heap::kOld)); |
| 36 __ PushConstant(string_object); | 34 __ PushConstant(string_object); |
| 37 __ ReturnTOS(); | 35 __ ReturnTOS(); |
| 38 } | 36 } |
| 39 | 37 |
| 40 | 38 |
| 41 // Generate a dart code sequence that embeds a smi object in it. | 39 // Generate a dart code sequence that embeds a smi object in it. |
| 42 // This is used to test Embedded Smi objects in the instructions. | 40 // This is used to test Embedded Smi objects in the instructions. |
| 43 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { | 41 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { |
| 44 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); | 42 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); |
| 45 __ PushConstant(smi_object); | 43 __ PushConstant(smi_object); |
| 46 __ ReturnTOS(); | 44 __ ReturnTOS(); |
| 47 } | 45 } |
| 48 | 46 |
| 49 } // namespace dart | 47 } // namespace dart |
| 50 | 48 |
| 51 #endif // defined TARGET_ARCH_DBC | 49 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |