Flutter Engine
The Flutter Engine
object_x64_test.cc
Go to the documentation of this 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
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_X64)
8
10#include "vm/object.h"
11#include "vm/unit_test.h"
12
13namespace dart {
14
15#define __ assembler->
16
17// Generate a simple dart code sequence.
18// This is used to test Code and Instruction object creation.
19void GenerateIncrement(compiler::Assembler* assembler) {
20 __ movq(RAX, compiler::Immediate(0));
21 __ pushq(RAX);
22 __ incq(compiler::Address(RSP, 0));
23 __ movq(RCX, compiler::Address(RSP, 0));
24 __ incq(RCX);
25 __ popq(RAX);
26 __ movq(RAX, RCX);
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.
32void GenerateEmbedStringInCode(compiler::Assembler* assembler,
33 const char* str) {
34 const String& string_object =
36 __ EnterStubFrame();
37 __ LoadObject(RAX, string_object);
38 __ LeaveStubFrame();
39 __ ret();
40}
41
42// Generate a dart code sequence that embeds a smi object in it.
43// This is used to test Embedded Smi objects in the instructions.
44void GenerateEmbedSmiInCode(compiler::Assembler* assembler, intptr_t value) {
45 const Smi& smi_object = Smi::ZoneHandle(Smi::New(value));
46 __ movq(RAX, compiler::Immediate(static_cast<int64_t>(smi_object.ptr())));
47 __ ret();
48}
49
50} // namespace dart
51
52#endif // defined TARGET_ARCH_X64
#define __
@ kOld
Definition: heap.h:39
static Object & ZoneHandle()
Definition: object.h:419
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
uint8_t value
Definition: dart_vm.cc:33