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 |
3 | // BSD-style license that can be found in the LICENSE file. |
4 | |
5 | #include "platform/assert.h" |
6 | #include "vm/globals.h" |
7 | #if defined(TARGET_ARCH_IA32) |
8 | |
9 | #include "vm/compiler/assembler/assembler.h" |
10 | #include "vm/object.h" |
11 | #include "vm/unit_test.h" |
12 | |
13 | namespace dart { |
14 | |
15 | #define __ assembler-> |
16 | |
17 | // Generate a simple dart code sequence. |
18 | // This is used to test Code and Instruction object creation. |
19 | void GenerateIncrement(compiler::Assembler* assembler) { |
20 | __ movl(EAX, compiler::Immediate(0)); |
21 | __ pushl(EAX); |
22 | __ incl(compiler::Address(ESP, 0)); |
23 | __ movl(ECX, compiler::Address(ESP, 0)); |
24 | __ incl(ECX); |
25 | __ popl(EAX); |
26 | __ movl(EAX, ECX); |
27 | __ ret(); |
28 | } |
29 | |
30 | // Generate a dart code sequence that embeds a string object in it. |
31 | // This is used to test Embedded String objects in the instructions. |
32 | void GenerateEmbedStringInCode(compiler::Assembler* assembler, |
33 | const char* str) { |
34 | const String& string_object = |
35 | String::ZoneHandle(String::New(str, Heap::kOld)); |
36 | __ LoadObject(EAX, string_object); |
37 | __ ret(); |
38 | } |
39 | |
40 | // Generate a dart code sequence that embeds a smi object in it. |
41 | // This is used to test Embedded Smi objects in the instructions. |
42 | void GenerateEmbedSmiInCode(compiler::Assembler* assembler, intptr_t value) { |
43 | const Smi& smi_object = Smi::ZoneHandle(Smi::New(value)); |
44 | __ LoadObject(EAX, smi_object); |
45 | __ ret(); |
46 | } |
47 | |
48 | } // namespace dart |
49 | |
50 | #endif // defined TARGET_ARCH_IA32 |
51 | |