Chromium Code Reviews| 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 void GenerateIncrement(Assembler* assembler) { | 19 void GenerateIncrement(Assembler* assembler) { |
|
Vyacheslav Egorov (Google)
2016/06/01 22:41:10
Add a comment that we don't want to generate incre
zra
2016/06/03 16:08:57
Done.
| |
| 20 __ Frame(1); | 20 __ Frame(1); |
| 21 __ LoadConstant(0, Smi::Handle(Smi::New(0))); | 21 __ 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); | 22 __ Return(0); |
| 28 } | 23 } |
| 29 | 24 |
| 30 | 25 |
| 31 // Generate a dart code sequence that embeds a string object in it. | 26 // Generate a dart code sequence that embeds a string object in it. |
| 32 // This is used to test Embedded String objects in the instructions. | 27 // This is used to test Embedded String objects in the instructions. |
| 33 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { | 28 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { |
| 34 const String& string_object = | 29 const String& string_object = |
| 35 String::ZoneHandle(String::New(str, Heap::kOld)); | 30 String::ZoneHandle(String::New(str, Heap::kOld)); |
| 36 __ PushConstant(string_object); | 31 __ PushConstant(string_object); |
| 37 __ ReturnTOS(); | 32 __ ReturnTOS(); |
| 38 } | 33 } |
| 39 | 34 |
| 40 | 35 |
| 41 // Generate a dart code sequence that embeds a smi object in it. | 36 // Generate a dart code sequence that embeds a smi object in it. |
| 42 // This is used to test Embedded Smi objects in the instructions. | 37 // This is used to test Embedded Smi objects in the instructions. |
| 43 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { | 38 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { |
| 44 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); | 39 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); |
| 45 __ PushConstant(smi_object); | 40 __ PushConstant(smi_object); |
| 46 __ ReturnTOS(); | 41 __ ReturnTOS(); |
| 47 } | 42 } |
| 48 | 43 |
| 49 } // namespace dart | 44 } // namespace dart |
| 50 | 45 |
| 51 #endif // defined TARGET_ARCH_DBC | 46 #endif // defined TARGET_ARCH_DBC |
| OLD | NEW |