Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: runtime/vm/simulator_arm64.h

Issue 221133002: Begins work on ARM64, first assembler test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Fixed Rn/Rd modes for R31 Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 // Declares a Simulator for ARM64 instructions if we are not generating a native
6 // ARM64 binary. This Simulator allows us to run and debug ARM64 code generation
7 // on regular desktop machines.
8 // Dart calls into generated code by "calling" the InvokeDartCode stub,
9 // which will start execution in the Simulator or forwards to the real entry
10 // on a ARM64 HW platform.
11
12 #ifndef VM_SIMULATOR_ARM64_H_
13 #define VM_SIMULATOR_ARM64_H_
14
15 #ifndef VM_SIMULATOR_H_
16 #error Do not include simulator_arm64.h directly; use simulator.h.
17 #endif
18
19 #include "vm/constants_arm64.h"
20 #include "vm/object.h"
21
22 namespace dart {
23
24 class Isolate;
25
26 class Simulator {
27 public:
28 static const uword kSimulatorStackUnderflowSize = 64;
29
30 Simulator();
31 ~Simulator();
32
33 // The currently executing Simulator instance, which is associated to the
34 // current isolate
35 static Simulator* Current();
36
37 // Accessors for register state.
38 void set_register(Register reg, int64_t value, R31Type r31t = R31IsUndef);
39 int64_t get_register(Register reg, R31Type r31t = R31IsUndef) const;
40 void set_wregister(Register reg, int32_t value, R31Type r31t = R31IsUndef);
41 int32_t get_wregister(Register reg, R31Type r31t = R31IsUndef) const;
42
43 int64_t get_pc() const;
44 void set_pc(int64_t pc);
45
46 // Accessor to the internal simulator stack top.
47 uword StackTop() const;
48
49 // The isolate's top_exit_frame_info refers to a Dart frame in the simulator
50 // stack. The simulator's top_exit_frame_info refers to a C++ frame in the
51 // native stack.
52 uword top_exit_frame_info() const { return top_exit_frame_info_; }
53 void set_top_exit_frame_info(uword value) { top_exit_frame_info_ = value; }
54
55 // Call on program start.
56 static void InitOnce() {}
57
58 // Dart generally calls into generated code with 5 parameters. This is a
59 // convenience function, which sets up the simulator state and grabs the
60 // result on return. The return value is R0. The parameters are placed in
61 // R0-3.
62 int64_t Call(int64_t entry,
63 int64_t parameter0,
64 int64_t parameter1,
65 int64_t parameter2,
66 int64_t parameter3);
67
68 void Longjmp(uword pc,
69 uword sp,
70 uword fp,
71 RawObject* raw_exception,
72 RawObject* raw_stacktrace) {
73 UNIMPLEMENTED();
74 }
75
76 private:
77 // Known bad pc value to ensure that the simulator does not execute
78 // without being properly setup.
79 static const uword kBadLR = -1;
80 // A pc value used to signal the simulator to stop execution. Generally
81 // the lr is set to this value on transition from native C code to
82 // simulated execution, so that the simulator can "return" to the native
83 // C code.
84 static const uword kEndSimulatingPC = -2;
85
86 // CPU state.
87 int64_t registers_[kNumberOfCpuRegisters];
88 bool n_flag_;
89 bool z_flag_;
90 bool c_flag_;
91 bool v_flag_;
92
93 // Simulator support.
94 int64_t pc_;
95 char* stack_;
96 bool pc_modified_;
97 intptr_t icount_;
98 static int64_t flag_stop_sim_at_;
99 uword top_exit_frame_info_;
100
101 // Registered breakpoints.
102 Instr* break_pc_;
103 int64_t break_instr_;
104
105 // Illegal memory access support.
106 static bool IsIllegalAddress(uword addr) {
107 return addr < 64*1024;
108 }
109 void HandleIllegalAccess(uword addr, Instr* instr);
110
111 // Handles a legal instruction that the simulator does not implement.
112 void UnimplementedInstruction(Instr* instr);
113
114 // Unsupported instructions use Format to print an error and stop execution.
115 void Format(Instr* instr, const char* format);
116
117 // Helper functions to set the conditional flags in the architecture state.
118 void SetNZFlagsW(int32_t val);
119 bool CarryFromW(int32_t left, int32_t right);
120 bool BorrowFromW(int32_t left, int32_t right);
121 bool OverflowFromW(
122 int32_t alu_out, int32_t left, int32_t right, bool addition);
123
124 void SetNZFlagsX(int64_t val);
125 bool CarryFromX(int64_t left, int64_t right);
126 bool BorrowFromX(int64_t left, int64_t right);
127 bool OverflowFromX(
128 int64_t alu_out, int64_t left, int64_t right, bool addition);
129
130 void SetCFlag(bool val);
131 void SetVFlag(bool val);
132
133 int64_t ShiftOperand(uint8_t reg_size,
134 int64_t value,
135 Shift shift_type,
136 uint8_t amount);
137
138 int64_t ExtendOperand(uint8_t reg_size,
139 int64_t value,
140 Extend extend_type,
141 uint8_t amount);
142
143 int64_t DecodeShiftExtendOperand(Instr* instr);
144
145 // Decode instructions.
146 void InstructionDecode(Instr* instr);
147 #define DECODE_OP(op) \
148 void Decode##op(Instr* instr);
149 APPLY_OP_LIST(DECODE_OP)
150 #undef DECODE_OP
151
152 // Executes ARM64 instructions until the PC reaches kEndSimulatingPC.
153 void Execute();
154
155 DISALLOW_COPY_AND_ASSIGN(Simulator);
156 };
157
158 } // namespace dart
159
160 #endif // VM_SIMULATOR_ARM64_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698