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 #ifndef VM_CONSTANTS_DBC_H_ | 5 #ifndef VM_CONSTANTS_DBC_H_ |
6 #define VM_CONSTANTS_DBC_H_ | 6 #define VM_CONSTANTS_DBC_H_ |
7 | 7 |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 // Note: return instruction knows how many arguments to remove from the | 112 // Note: return instruction knows how many arguments to remove from the |
113 // stack because it can look at the call instruction at caller's PC and | 113 // stack because it can look at the call instruction at caller's PC and |
114 // take argument count from it. | 114 // take argument count from it. |
115 // | 115 // |
116 // - Move rA, rX | 116 // - Move rA, rX |
117 // | 117 // |
118 // FP[rA] <- FP[rX] | 118 // FP[rA] <- FP[rX] |
119 // Note: rX is signed so it can be used to address parameters which are | 119 // Note: rX is signed so it can be used to address parameters which are |
120 // at negative indices with respect to FP. | 120 // at negative indices with respect to FP. |
121 // | 121 // |
122 // - Swap rA, rX | |
123 // | |
124 // FP[rA], FP[rX] <- FP[rX], FP[rA] | |
125 // Note: rX is signed so it can be used to address parameters which are | |
126 // at negative indices with respect to FP. | |
127 // | |
122 // - Push rX | 128 // - Push rX |
123 // | 129 // |
124 // Push FP[rX] to the stack. | 130 // Push FP[rX] to the stack. |
125 // | 131 // |
126 // - LoadConstant rA, D; PushConstant D | 132 // - LoadConstant rA, D; PushConstant D |
127 // | 133 // |
128 // Load value at index D from constant pool into FP[rA] or push it onto the | 134 // Load value at index D from constant pool into FP[rA] or push it onto the |
129 // stack. | 135 // stack. |
130 // | 136 // |
131 // - StoreLocal rX; PopLocal rX | 137 // - StoreLocal rX; PopLocal rX |
132 // | 138 // |
133 // Store top of the stack into FP[rX] and pop it if needed. | 139 // Store top of the stack into FP[rX] and pop it if needed. |
134 // | 140 // |
135 // - StaticCall ArgC, D | 141 // - StaticCall ArgC, D |
136 // | 142 // |
137 // Invoke function in SP[0] with arguments SP[-(1+ArgC)], ..., SP[-1] and | 143 // Invoke function in SP[0] with arguments SP[-(1+ArgC)], ..., SP[-1] and |
138 // argument descriptor PP[D]. | 144 // argument descriptor PP[D]. |
139 // | 145 // |
140 // - InstanceCall ArgC, D; InstanceCall2 ArgC, D; InstanceCall3 ArgC, D | 146 // - InstanceCall<N> ArgC, D; InstanceCall<N>Opt ArgC, D |
zra
2016/05/19 16:24:27
Was InstanceCall3 never used?
Vyacheslav Egorov (Google)
2016/05/20 12:11:47
Yep.
Turns out we removed 3-arg ICs last year. Th
| |
141 // | 147 // |
142 // Lookup and invoke method using ICData in PP[D] with arguments | 148 // Lookup and invoke method with N checked arguments using ICData in PP[D] |
143 // SP[-(1+ArgC)], ..., SP[-1]. | 149 // with arguments SP[-(1+ArgC)], ..., SP[-1]. |
144 // | 150 // |
145 // - NativeCall, NativeBootstrapCall | 151 // - NativeCall, NativeBootstrapCall |
146 // | 152 // |
147 // Invoke native function SP[-1] with argc_tag SP[0]. | 153 // Invoke native function SP[-1] with argc_tag SP[0]. |
148 // | 154 // |
149 // - AddTOS; SubTOS; MulTOS; BitOrTOS; BitAndTOS; EqualTOS; LessThanTOS; | 155 // - AddTOS; SubTOS; MulTOS; BitOrTOS; BitAndTOS; EqualTOS; LessThanTOS; |
150 // GreaterThanTOS; | 156 // GreaterThanTOS; |
151 // | 157 // |
152 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are | 158 // Smi fast-path for a corresponding method. Checks if SP[0] and SP[-1] are |
153 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true | 159 // both smis and result of SP[0] <op> SP[-1] is a smi - if this is true |
154 // then pops operands and pushes result on the stack and skips the next | 160 // then pops operands and pushes result on the stack and skips the next |
155 // instruction (which implements a slow path fallback). | 161 // instruction (which implements a slow path fallback). |
156 // | 162 // |
157 // - StoreStaticTOS D | 163 // - StoreStaticTOS D |
158 // | 164 // |
159 // Stores TOS into the static field PP[D]. | 165 // Stores TOS into the static field PP[D]. |
160 // | 166 // |
161 // - PushStatic | 167 // - PushStatic |
162 // | 168 // |
163 // Pushes value of the static field PP[D] on to the stack. | 169 // Pushes value of the static field PP[D] on to the stack. |
164 // | 170 // |
165 // - InitStaticTOS | 171 // - InitStaticTOS |
166 // | 172 // |
167 // Takes static field from TOS and ensures that it is initialized. | 173 // Takes static field from TOS and ensures that it is initialized. |
168 // | 174 // |
169 // - IfNeStrictTOS; IfEqStrictTOS; IfNeStrictNumTOS; IfEqStrictNumTOS | 175 // - If<Cond>(Num)TOS |
176 // If<Cond>(Num) rA, rD | |
177 // | |
178 // Cond is either NeStrict or EqStrict | |
170 // | 179 // |
171 // Skips the next instruction unless the given condition holds. 'Num' | 180 // Skips the next instruction unless the given condition holds. 'Num' |
172 // variants perform number check while non-Num variants just compare | 181 // variants perform number check while non-Num variants just compare |
173 // RawObject pointers. | 182 // RawObject pointers. |
174 // | 183 // |
175 // Used to implement conditional jump: | 184 // Used to implement conditional jump: |
176 // | 185 // |
177 // IfNeStrictTOS | 186 // IfNeStrictTOS |
178 // Jump T ;; jump if not equal | 187 // Jump T ;; jump if not equal |
179 // | 188 // |
180 // - CreateArrayTOS | 189 // - CreateArrayTOS |
181 // | 190 // |
182 // Allocate array of length SP[0] with type arguments SP[-1]. | 191 // Allocate array of length SP[0] with type arguments SP[-1]. |
183 // | 192 // |
184 // - Allocate D | 193 // - Allocate D |
185 // | 194 // |
186 // Allocate object of class PP[D] with no type arguments. | 195 // Allocate object of class PP[D] with no type arguments. |
187 // | 196 // |
188 // - AllocateT | 197 // - AllocateT |
189 // | 198 // |
190 // Allocate object of class SP[0] with type arguments SP[-1]. | 199 // Allocate object of class SP[0] with type arguments SP[-1]. |
191 // | 200 // |
192 // - StoreIndexedTOS | 201 // - StoreIndexedTOS |
193 // | 202 // |
194 // Store SP[0] into array SP[-2] at index SP[-1]. No typechecking is done. | 203 // Store SP[0] into array SP[-2] at index SP[-1]. No typechecking is done. |
195 // SP[-2] is assumed to be a RawArray, SP[-1] to be a smi. | 204 // SP[-2] is assumed to be a RawArray, SP[-1] to be a smi. |
196 // | 205 // |
206 // - StoreIndexed rA, rB, rC | |
207 // | |
208 // Store rC into array rA at index rB. No typechecking is done. | |
209 // rA is assumed to be a RawArray, rB to be a smi. | |
210 // | |
197 // - StoreField rA, B, rC | 211 // - StoreField rA, B, rC |
198 // | 212 // |
199 // Store value FP[rC] into object FP[rA] at offset (in words) B. | 213 // Store value FP[rC] into object FP[rA] at offset (in words) B. |
200 // | 214 // |
201 // - StoreFieldTOS D | 215 // - StoreFieldTOS D |
202 // | 216 // |
203 // Store value SP[0] into object SP[-1] at offset (in words) D. | 217 // Store value SP[0] into object SP[-1] at offset (in words) D. |
204 // | 218 // |
205 // - LoadField rA, rB, C | 219 // - LoadField rA, rB, C |
206 // | 220 // |
(...skipping 12 matching lines...) Expand all Loading... | |
219 // Throw (Rethrow if A != 0) exception. Exception object and stack object | 233 // Throw (Rethrow if A != 0) exception. Exception object and stack object |
220 // are taken from TOS. | 234 // are taken from TOS. |
221 // | 235 // |
222 // - Entry A, B, rC | 236 // - Entry A, B, rC |
223 // | 237 // |
224 // Function prologue for the function with no optional or named arguments: | 238 // Function prologue for the function with no optional or named arguments: |
225 // A - expected number of positional arguments; | 239 // A - expected number of positional arguments; |
226 // B - number of local slots to reserve; | 240 // B - number of local slots to reserve; |
227 // rC - specifies context register to initialize with empty context. | 241 // rC - specifies context register to initialize with empty context. |
228 // | 242 // |
229 // - EntryOpt A, B, C | 243 // - EntryOptional A, B, C |
230 // | 244 // |
231 // Function prologue for the function with optional or named arguments: | 245 // Function prologue for the function with optional or named arguments: |
232 // A - expected number of positional arguments; | 246 // A - expected number of positional arguments; |
233 // B - number of optional arguments; | 247 // B - number of optional arguments; |
234 // C - number of named arguments; | 248 // C - number of named arguments; |
235 // | 249 // |
236 // Only one of B and C can be not 0. | 250 // Only one of B and C can be not 0. |
237 // | 251 // |
238 // If B is not 0 then EntryOpt bytecode is followed by B LoadConstant | 252 // If B is not 0 then EntryOptional bytecode is followed by B LoadConstant |
239 // bytecodes specifying default values for optional arguments. | 253 // bytecodes specifying default values for optional arguments. |
240 // | 254 // |
241 // If C is not 0 then EntryOpt is followed by 2 * B LoadConstant bytecodes. | 255 // If C is not 0 then EntryOptional is followed by 2 * B LoadConstant |
256 // bytecodes. | |
242 // Bytecode at 2 * i specifies name of the i-th named argument and at | 257 // Bytecode at 2 * i specifies name of the i-th named argument and at |
243 // 2 * i + 1 default value. rA part of the LoadConstant bytecode specifies | 258 // 2 * i + 1 default value. rA part of the LoadConstant bytecode specifies |
244 // the location of the parameter on the stack. Here named arguments are | 259 // the location of the parameter on the stack. Here named arguments are |
245 // sorted alphabetically to enable linear matching similar to how function | 260 // sorted alphabetically to enable linear matching similar to how function |
246 // prologues are implemented on other architectures. | 261 // prologues are implemented on other architectures. |
247 // | 262 // |
248 // Note: Unlike Entry bytecode EntryOpt does not setup the frame for | 263 // Note: Unlike Entry bytecode EntryOptional does not setup the frame for |
249 // local variables this is done by a separate bytecode Frame. | 264 // local variables this is done by a separate bytecode Frame. |
250 // | 265 // |
266 // - EntryOptimized A, D | |
267 // | |
268 // Function prologue for optimized functions with no optional or named | |
269 // arguments. | |
270 // A - expected number of positional arguments; | |
271 // B - number of local slots to reserve for registers; | |
272 // | |
273 // Note: reserved slots are not initialized because optimized code | |
274 // has stack maps attached to call sites. | |
275 // | |
276 // - HotCheck A, D | |
277 // | |
278 // Increment current function's usage counter by A and check if it | |
279 // exceeds D. If it does trigger (re)optimization of the current | |
280 // function. | |
281 // | |
251 // - Frame D | 282 // - Frame D |
252 // | 283 // |
253 // Reserve and initialize with null space for D local variables. | 284 // Reserve and initialize with null space for D local variables. |
254 // | 285 // |
255 // - SetFrame A | 286 // - SetFrame A |
256 // | 287 // |
257 // Reinitialize SP assuming that current frame has size A. | 288 // Reinitialize SP assuming that current frame has size A. |
258 // Used to drop temporaries from the stack in the exception handler. | 289 // Used to drop temporaries from the stack in the exception handler. |
259 // | 290 // |
260 // - AllocateContext D | 291 // - AllocateContext D |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 // | 326 // |
296 // - DebugStep, DebugBreak A | 327 // - DebugStep, DebugBreak A |
297 // | 328 // |
298 // Debugger support. DebugBreak is bytecode that can be patched into the | 329 // Debugger support. DebugBreak is bytecode that can be patched into the |
299 // instruction stream to trigger in place breakpoint. | 330 // instruction stream to trigger in place breakpoint. |
300 // | 331 // |
301 // When patching instance or static call with DebugBreak we set A to | 332 // When patching instance or static call with DebugBreak we set A to |
302 // match patched call's argument count so that Return instructions continue | 333 // match patched call's argument count so that Return instructions continue |
303 // to work. | 334 // to work. |
304 // | 335 // |
336 // TODO(vegorov) the way we replace calls with DebugBreak does not work | |
337 // with our smi fast paths because DebugBreak is simply skipped. | |
338 // | |
305 // - LoadClassIdTOS, LoadClassId rA, D | 339 // - LoadClassIdTOS, LoadClassId rA, D |
306 // | 340 // |
307 // LoadClassIdTOS loads the class id from the object at SP[0] and stores it | 341 // LoadClassIdTOS loads the class id from the object at SP[0] and stores it |
308 // to SP[0]. LoadClassId loads the class id from FP[rA] and stores it to | 342 // to SP[0]. LoadClassId loads the class id from FP[rA] and stores it to |
309 // FP[D]. | 343 // FP[D]. |
310 // | 344 // |
311 // TODO(vegorov) the way we replace calls with DebugBreak does not work | 345 // - Deopt A, D |
312 // with our smi fast paths because DebugBreak is simply skipped. | 346 // |
347 // If D != 0 then trigger eager deoptimization with deopt id (D - 1). | |
348 // If D == 0 then trigger lazy deoptimization. | |
349 // | |
350 // The meaning of operand A matches that of an A operand in call | |
Florian Schneider
2016/05/19 13:21:39
Do you mean the ArgC operand?
Vyacheslav Egorov (Google)
2016/05/19 15:19:40
Done.
| |
351 // instructions because we could potentially patch calls instructions with | |
352 // deopt and we need to ensure that any Return/ReturnTOS instructions | |
353 // returning from the patched calls will continue to function, | |
354 // e.g. in bytecode sequences like | |
355 // | |
356 // InstanceCall ... <- lazy deopt inside first call | |
357 // InstanceCall ... <- patches seconds call with Deopt | |
313 // | 358 // |
314 // BYTECODE LIST FORMAT | 359 // BYTECODE LIST FORMAT |
315 // | 360 // |
316 // Bytecode list below is specified using the following format: | 361 // Bytecode list below is specified using the following format: |
317 // | 362 // |
318 // V(BytecodeName, OperandForm, Op1, Op2, Op3) | 363 // V(BytecodeName, OperandForm, Op1, Op2, Op3) |
319 // | 364 // |
320 // - OperandForm specifies operand encoding and should be one of 0, A, T, A_D, | 365 // - OperandForm specifies operand encoding and should be one of 0, A, T, A_D, |
321 // A_X, X, D (see ENCODING section above). | 366 // A_X, X, D (see ENCODING section above). |
322 // | 367 // |
323 // - Op1, Op2, Op2 specify operand meaning. Possible values: | 368 // - Op1, Op2, Op2 specify operand meaning. Possible values: |
324 // | 369 // |
325 // ___ ignored / non-existent operand | 370 // ___ ignored / non-existent operand |
326 // num immediate operand | 371 // num immediate operand |
327 // lit constant literal from object pool | 372 // lit constant literal from object pool |
328 // reg register (unsigned FP relative local) | 373 // reg register (unsigned FP relative local) |
329 // xeg x-register (signed FP relative local) | 374 // xeg x-register (signed FP relative local) |
330 // tgt jump target relative to the PC of the current instruction | 375 // tgt jump target relative to the PC of the current instruction |
331 // | 376 // |
332 // TODO(vegorov) jump targets should be encoded relative to PC of the next | 377 // TODO(vegorov) jump targets should be encoded relative to PC of the next |
333 // instruction because PC is incremeted immediately after fetch | 378 // instruction because PC is incremeted immediately after fetch |
334 // and before decoding. | 379 // and before decoding. |
335 // | 380 // |
336 #define BYTECODES_LIST(V) \ | 381 #define BYTECODES_LIST(V) \ |
337 V(Trap, 0, ___, ___, ___) \ | 382 V(Trap, 0, ___, ___, ___) \ |
338 V(Compile, 0, ___, ___, ___) \ | 383 V(Compile, 0, ___, ___, ___) \ |
384 V(HotCheck, A_D, num, num, ___) \ | |
339 V(Intrinsic, A, num, ___, ___) \ | 385 V(Intrinsic, A, num, ___, ___) \ |
340 V(Drop1, 0, ___, ___, ___) \ | 386 V(Drop1, 0, ___, ___, ___) \ |
341 V(DropR, A, num, ___, ___) \ | 387 V(DropR, A, num, ___, ___) \ |
342 V(Drop, A, num, ___, ___) \ | 388 V(Drop, A, num, ___, ___) \ |
343 V(Jump, T, tgt, ___, ___) \ | 389 V(Jump, T, tgt, ___, ___) \ |
344 V(Return, A, num, ___, ___) \ | 390 V(Return, A, reg, ___, ___) \ |
345 V(ReturnTOS, 0, ___, ___, ___) \ | 391 V(ReturnTOS, 0, ___, ___, ___) \ |
346 V(Move, A_X, reg, xeg, ___) \ | 392 V(Move, A_X, reg, xeg, ___) \ |
393 V(Swap, A_X, reg, xeg, ___) \ | |
347 V(Push, X, xeg, ___, ___) \ | 394 V(Push, X, xeg, ___, ___) \ |
348 V(LoadConstant, A_D, reg, lit, ___) \ | 395 V(LoadConstant, A_D, reg, lit, ___) \ |
349 V(LoadClassId, A_D, reg, reg, ___) \ | 396 V(LoadClassId, A_D, reg, reg, ___) \ |
350 V(LoadClassIdTOS, 0, ___, ___, ___) \ | 397 V(LoadClassIdTOS, 0, ___, ___, ___) \ |
351 V(PushConstant, D, lit, ___, ___) \ | 398 V(PushConstant, D, lit, ___, ___) \ |
352 V(StoreLocal, X, xeg, ___, ___) \ | 399 V(StoreLocal, X, xeg, ___, ___) \ |
353 V(PopLocal, X, xeg, ___, ___) \ | 400 V(PopLocal, X, xeg, ___, ___) \ |
354 V(StaticCall, A_D, num, num, ___) \ | 401 V(StaticCall, A_D, num, num, ___) \ |
355 V(InstanceCall, A_D, num, num, ___) \ | 402 V(InstanceCall1, A_D, num, num, ___) \ |
356 V(InstanceCall2, A_D, num, num, ___) \ | 403 V(InstanceCall2, A_D, num, num, ___) \ |
357 V(InstanceCall3, A_D, num, num, ___) \ | 404 V(InstanceCall1Opt, A_D, num, num, ___) \ |
405 V(InstanceCall2Opt, A_D, num, num, ___) \ | |
358 V(NativeCall, 0, ___, ___, ___) \ | 406 V(NativeCall, 0, ___, ___, ___) \ |
359 V(NativeBootstrapCall, 0, ___, ___, ___) \ | 407 V(NativeBootstrapCall, 0, ___, ___, ___) \ |
360 V(AddTOS, 0, ___, ___, ___) \ | 408 V(AddTOS, 0, ___, ___, ___) \ |
361 V(SubTOS, 0, ___, ___, ___) \ | 409 V(SubTOS, 0, ___, ___, ___) \ |
362 V(MulTOS, 0, ___, ___, ___) \ | 410 V(MulTOS, 0, ___, ___, ___) \ |
363 V(BitOrTOS, 0, ___, ___, ___) \ | 411 V(BitOrTOS, 0, ___, ___, ___) \ |
364 V(BitAndTOS, 0, ___, ___, ___) \ | 412 V(BitAndTOS, 0, ___, ___, ___) \ |
365 V(EqualTOS, 0, ___, ___, ___) \ | 413 V(EqualTOS, 0, ___, ___, ___) \ |
366 V(LessThanTOS, 0, ___, ___, ___) \ | 414 V(LessThanTOS, 0, ___, ___, ___) \ |
367 V(GreaterThanTOS, 0, ___, ___, ___) \ | 415 V(GreaterThanTOS, 0, ___, ___, ___) \ |
368 V(StoreStaticTOS, D, lit, ___, ___) \ | 416 V(StoreStaticTOS, D, lit, ___, ___) \ |
369 V(PushStatic, D, lit, ___, ___) \ | 417 V(PushStatic, D, lit, ___, ___) \ |
370 V(InitStaticTOS, 0, ___, ___, ___) \ | 418 V(InitStaticTOS, 0, ___, ___, ___) \ |
371 V(IfNeStrictTOS, 0, ___, ___, ___) \ | 419 V(IfNeStrictTOS, 0, ___, ___, ___) \ |
372 V(IfEqStrictTOS, 0, ___, ___, ___) \ | 420 V(IfEqStrictTOS, 0, ___, ___, ___) \ |
373 V(IfNeStrictNumTOS, 0, ___, ___, ___) \ | 421 V(IfNeStrictNumTOS, 0, ___, ___, ___) \ |
374 V(IfEqStrictNumTOS, 0, ___, ___, ___) \ | 422 V(IfEqStrictNumTOS, 0, ___, ___, ___) \ |
423 V(IfNeStrict, A_D, reg, reg, ___) \ | |
424 V(IfEqStrict, A_D, reg, reg, ___) \ | |
425 V(IfNeStrictNum, A_D, reg, reg, ___) \ | |
426 V(IfEqStrictNum, A_D, reg, reg, ___) \ | |
375 V(CreateArrayTOS, 0, ___, ___, ___) \ | 427 V(CreateArrayTOS, 0, ___, ___, ___) \ |
376 V(Allocate, D, lit, ___, ___) \ | 428 V(Allocate, D, lit, ___, ___) \ |
377 V(AllocateT, 0, ___, ___, ___) \ | 429 V(AllocateT, 0, ___, ___, ___) \ |
378 V(StoreIndexedTOS, 0, ___, ___, ___) \ | 430 V(StoreIndexedTOS, 0, ___, ___, ___) \ |
379 V(StoreField, A_B_C, reg, reg, reg) \ | 431 V(StoreIndexed, A_B_C, reg, reg, reg) \ |
432 V(StoreField, A_B_C, reg, num, reg) \ | |
380 V(StoreFieldTOS, D, num, ___, ___) \ | 433 V(StoreFieldTOS, D, num, ___, ___) \ |
381 V(LoadField, A_B_C, reg, reg, reg) \ | 434 V(LoadField, A_B_C, reg, reg, num) \ |
382 V(LoadFieldTOS, D, num, ___, ___) \ | 435 V(LoadFieldTOS, D, num, ___, ___) \ |
383 V(BooleanNegateTOS, 0, ___, ___, ___) \ | 436 V(BooleanNegateTOS, 0, ___, ___, ___) \ |
437 V(BooleanNegate, A_D, reg, reg, ___) \ | |
zra
2016/05/19 16:24:27
Missing from comments.
Vyacheslav Egorov (Google)
2016/05/20 12:11:47
Done.
| |
384 V(Throw, A, num, ___, ___) \ | 438 V(Throw, A, num, ___, ___) \ |
385 V(Entry, A_B_C, num, num, num) \ | 439 V(Entry, A_B_C, num, num, num) \ |
386 V(EntryOpt, A_B_C, num, num, num) \ | 440 V(EntryOptional, A_B_C, num, num, num) \ |
441 V(EntryOptimized, A_D, num, num, ___) \ | |
387 V(Frame, D, num, ___, ___) \ | 442 V(Frame, D, num, ___, ___) \ |
388 V(SetFrame, A, num, ___, num) \ | 443 V(SetFrame, A, num, ___, num) \ |
389 V(AllocateContext, D, num, ___, ___) \ | 444 V(AllocateContext, D, num, ___, ___) \ |
390 V(CloneContext, 0, ___, ___, ___) \ | 445 V(CloneContext, 0, ___, ___, ___) \ |
391 V(MoveSpecial, A_D, reg, num, ___) \ | 446 V(MoveSpecial, A_D, reg, num, ___) \ |
392 V(InstantiateType, D, lit, ___, ___) \ | 447 V(InstantiateType, D, lit, ___, ___) \ |
393 V(InstantiateTypeArgumentsTOS, A_D, num, lit, ___) \ | 448 V(InstantiateTypeArgumentsTOS, A_D, num, lit, ___) \ |
394 V(AssertAssignable, D, num, lit, ___) \ | 449 V(AssertAssignable, D, num, lit, ___) \ |
395 V(AssertBoolean, A, num, ___, ___) \ | 450 V(AssertBoolean, A, num, ___, ___) \ |
396 V(CheckStack, 0, ___, ___, ___) \ | 451 V(CheckStack, 0, ___, ___, ___) \ |
397 V(DebugStep, 0, ___, ___, ___) \ | 452 V(DebugStep, 0, ___, ___, ___) \ |
398 V(DebugBreak, A, num, ___, ___) \ | 453 V(DebugBreak, A, num, ___, ___) \ |
454 V(Deopt, A_D, num, num, ___) \ | |
399 | 455 |
400 typedef uint32_t Instr; | 456 typedef uint32_t Instr; |
401 | 457 |
402 class Bytecode { | 458 class Bytecode { |
403 public: | 459 public: |
404 enum Opcode { | 460 enum Opcode { |
405 #define DECLARE_BYTECODE(name, encoding, op1, op2, op3) k##name, | 461 #define DECLARE_BYTECODE(name, encoding, op1, op2, op3) k##name, |
406 BYTECODES_LIST(DECLARE_BYTECODE) | 462 BYTECODES_LIST(DECLARE_BYTECODE) |
407 #undef DECLARE_BYTECODE | 463 #undef DECLARE_BYTECODE |
408 }; | 464 }; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 } | 506 } |
451 | 507 |
452 DART_FORCE_INLINE static uint16_t DecodeD(Instr bc) { | 508 DART_FORCE_INLINE static uint16_t DecodeD(Instr bc) { |
453 return (bc >> kDShift) & kDMask; | 509 return (bc >> kDShift) & kDMask; |
454 } | 510 } |
455 | 511 |
456 DART_FORCE_INLINE static Opcode DecodeOpcode(Instr bc) { | 512 DART_FORCE_INLINE static Opcode DecodeOpcode(Instr bc) { |
457 return static_cast<Opcode>(bc & 0xFF); | 513 return static_cast<Opcode>(bc & 0xFF); |
458 } | 514 } |
459 | 515 |
516 DART_FORCE_INLINE static bool IsCallOpcode(Instr instr) { | |
517 switch (DecodeOpcode(instr)) { | |
518 case Bytecode::kStaticCall: | |
519 case Bytecode::kInstanceCall1: | |
520 case Bytecode::kInstanceCall2: | |
521 case Bytecode::kInstanceCall1Opt: | |
522 case Bytecode::kInstanceCall2Opt: | |
523 case Bytecode::kDebugBreak: | |
524 return true; | |
525 | |
526 default: | |
527 return false; | |
528 } | |
529 } | |
530 | |
460 DART_FORCE_INLINE static uint8_t DecodeArgc(Instr call) { | 531 DART_FORCE_INLINE static uint8_t DecodeArgc(Instr call) { |
461 #if defined(DEBUG) | 532 ASSERT(IsCallOpcode(call)); |
462 const Opcode op = DecodeOpcode(call); | |
463 ASSERT((op == Bytecode::kStaticCall) || | |
464 (op == Bytecode::kInstanceCall) || | |
465 (op == Bytecode::kInstanceCall2) || | |
466 (op == Bytecode::kInstanceCall3) || | |
467 (op == Bytecode::kDebugBreak)); | |
468 #endif | |
469 return (call >> 8) & 0xFF; | 533 return (call >> 8) & 0xFF; |
470 } | 534 } |
471 | 535 |
472 static Instr At(uword pc) { return *reinterpret_cast<Instr*>(pc); } | 536 static Instr At(uword pc) { return *reinterpret_cast<Instr*>(pc); } |
473 | 537 |
474 private: | 538 private: |
475 DISALLOW_ALLOCATION(); | 539 DISALLOW_ALLOCATION(); |
476 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecode); | 540 DISALLOW_IMPLICIT_CONSTRUCTORS(Bytecode); |
477 }; | 541 }; |
478 | 542 |
479 // Various dummy declarations to make shared code compile. | 543 // Various dummy declarations to make shared code compile. |
480 // TODO(vegorov) we need to prune away as much dead code as possible instead | 544 // TODO(vegorov) we need to prune away as much dead code as possible instead |
481 // of just making it compile. | 545 // of just making it compile. |
482 typedef int16_t Register; | 546 typedef int16_t Register; |
483 | 547 |
484 const int16_t FPREG = 0; | 548 const int16_t FPREG = 0; |
485 const int16_t SPREG = 1; | 549 const int16_t SPREG = 1; |
486 const intptr_t kNumberOfCpuRegisters = 20; | 550 const intptr_t kNumberOfCpuRegisters = 20; |
487 const intptr_t kDartAvailableCpuRegs = 0; | 551 const intptr_t kDartAvailableCpuRegs = -1; |
488 const intptr_t kNoRegister = -1; | 552 const intptr_t kNoRegister = -1; |
489 const intptr_t kReservedCpuRegisters = 0; | 553 const intptr_t kReservedCpuRegisters = 0; |
490 const intptr_t ARGS_DESC_REG = 0; | 554 const intptr_t ARGS_DESC_REG = 0; |
491 const intptr_t CODE_REG = 0; | 555 const intptr_t CODE_REG = 0; |
492 const intptr_t kExceptionObjectReg = 0; | 556 const intptr_t kExceptionObjectReg = 0; |
493 const intptr_t kStackTraceObjectReg = 0; | 557 const intptr_t kStackTraceObjectReg = 0; |
494 const intptr_t CTX = 0; | 558 const intptr_t CTX = 0; |
495 | 559 |
496 enum FpuRegister { | 560 enum FpuRegister { |
497 kNoFpuRegister = -1, | 561 kNoFpuRegister = -1, |
498 kFakeFpuRegister, | 562 kFakeFpuRegister, |
499 kNumberOfDummyFpuRegisters, | 563 kNumberOfDummyFpuRegisters, |
500 }; | 564 }; |
501 const FpuRegister FpuTMP = kFakeFpuRegister; | 565 const FpuRegister FpuTMP = kFakeFpuRegister; |
502 const intptr_t kNumberOfFpuRegisters = 1; | 566 const intptr_t kNumberOfFpuRegisters = 1; |
503 | 567 |
504 enum Condition { EQ, NE }; | 568 enum Condition { EQ, NE }; |
505 | 569 |
506 } // namespace dart | 570 } // namespace dart |
507 | 571 |
508 #endif // VM_CONSTANTS_DBC_H_ | 572 #endif // VM_CONSTANTS_DBC_H_ |
OLD | NEW |