| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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_X64) | 7 #if defined(TARGET_ARCH_X64) |
| 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 | |
| 18 // Generate a simple dart code sequence. | 17 // Generate a simple dart code sequence. |
| 19 // This is used to test Code and Instruction object creation. | 18 // This is used to test Code and Instruction object creation. |
| 20 void GenerateIncrement(Assembler* assembler) { | 19 void GenerateIncrement(Assembler* assembler) { |
| 21 __ movq(RAX, Immediate(0)); | 20 __ movq(RAX, Immediate(0)); |
| 22 __ pushq(RAX); | 21 __ pushq(RAX); |
| 23 __ incq(Address(RSP, 0)); | 22 __ incq(Address(RSP, 0)); |
| 24 __ movq(RCX, Address(RSP, 0)); | 23 __ movq(RCX, Address(RSP, 0)); |
| 25 __ incq(RCX); | 24 __ incq(RCX); |
| 26 __ popq(RAX); | 25 __ popq(RAX); |
| 27 __ movq(RAX, RCX); | 26 __ movq(RAX, RCX); |
| 28 __ ret(); | 27 __ ret(); |
| 29 } | 28 } |
| 30 | 29 |
| 31 | |
| 32 // Generate a dart code sequence that embeds a string object in it. | 30 // Generate a dart code sequence that embeds a string object in it. |
| 33 // This is used to test Embedded String objects in the instructions. | 31 // This is used to test Embedded String objects in the instructions. |
| 34 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { | 32 void GenerateEmbedStringInCode(Assembler* assembler, const char* str) { |
| 35 const String& string_object = | 33 const String& string_object = |
| 36 String::ZoneHandle(String::New(str, Heap::kOld)); | 34 String::ZoneHandle(String::New(str, Heap::kOld)); |
| 37 __ EnterStubFrame(); | 35 __ EnterStubFrame(); |
| 38 __ LoadObject(RAX, string_object); | 36 __ LoadObject(RAX, string_object); |
| 39 __ LeaveStubFrame(); | 37 __ LeaveStubFrame(); |
| 40 __ ret(); | 38 __ ret(); |
| 41 } | 39 } |
| 42 | 40 |
| 43 | |
| 44 // Generate a dart code sequence that embeds a smi object in it. | 41 // Generate a dart code sequence that embeds a smi object in it. |
| 45 // This is used to test Embedded Smi objects in the instructions. | 42 // This is used to test Embedded Smi objects in the instructions. |
| 46 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { | 43 void GenerateEmbedSmiInCode(Assembler* assembler, intptr_t value) { |
| 47 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); | 44 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); |
| 48 __ movq(RAX, Immediate(reinterpret_cast<int64_t>(smi_object.raw()))); | 45 __ movq(RAX, Immediate(reinterpret_cast<int64_t>(smi_object.raw()))); |
| 49 __ ret(); | 46 __ ret(); |
| 50 } | 47 } |
| 51 | 48 |
| 52 } // namespace dart | 49 } // namespace dart |
| 53 | 50 |
| 54 #endif // defined TARGET_ARCH_X64 | 51 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |