Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp
32285 views
1
/*
2
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP
26
#define SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP
27
28
#include "memory/allocation.hpp"
29
#include "oops/methodData.hpp"
30
#include "oops/method.hpp"
31
#include "runtime/basicLock.hpp"
32
#include "runtime/frame.hpp"
33
#include "runtime/globals.hpp"
34
#include "utilities/globalDefinitions.hpp"
35
#ifdef TARGET_ARCH_x86
36
# include "bytes_x86.hpp"
37
#endif
38
#ifdef TARGET_ARCH_aarch32
39
# include "bytes_aarch32.hpp"
40
#endif
41
#ifdef TARGET_ARCH_aarch64
42
# include "bytes_aarch64.hpp"
43
#endif
44
#ifdef TARGET_ARCH_sparc
45
# include "bytes_sparc.hpp"
46
#endif
47
#ifdef TARGET_ARCH_zero
48
# include "bytes_zero.hpp"
49
#endif
50
#ifdef TARGET_ARCH_arm
51
# include "bytes_arm.hpp"
52
#endif
53
#ifdef TARGET_ARCH_ppc
54
# include "bytes_ppc.hpp"
55
#endif
56
57
#ifdef CC_INTERP
58
59
// JavaStack Implementation
60
#define MORE_STACK(count) \
61
(topOfStack -= ((count) * Interpreter::stackElementWords))
62
63
// CVM definitions find hotspot equivalents...
64
65
union VMJavaVal64 {
66
jlong l;
67
jdouble d;
68
uint32_t v[2];
69
};
70
71
72
typedef class BytecodeInterpreter* interpreterState;
73
74
struct call_message {
75
class Method* _callee; // method to call during call_method request
76
address _callee_entry_point; // address to jump to for call_method request
77
int _bcp_advance; // size of the invoke bytecode operation
78
};
79
80
struct osr_message {
81
address _osr_buf; // the osr buffer
82
address _osr_entry; // the entry to the osr method
83
};
84
85
struct osr_result {
86
nmethod* nm; // osr nmethod
87
address return_addr; // osr blob return address
88
};
89
90
// Result returned to frame manager
91
union frame_manager_message {
92
call_message _to_call; // describes callee
93
osr_message _osr; // describes the osr
94
osr_result _osr_result; // result of OSR request
95
};
96
97
class BytecodeInterpreter : StackObj {
98
friend class SharedRuntime;
99
friend class AbstractInterpreterGenerator;
100
friend class CppInterpreterGenerator;
101
friend class InterpreterGenerator;
102
friend class InterpreterMacroAssembler;
103
friend class frame;
104
friend class VMStructs;
105
106
public:
107
enum messages {
108
no_request = 0, // unused
109
initialize, // Perform one time interpreter initializations (assumes all switches set)
110
// status message to C++ interpreter
111
method_entry, // initial method entry to interpreter
112
method_resume, // frame manager response to return_from_method request (assuming a frame to resume)
113
deopt_resume, // returning from a native call into a deopted frame
114
deopt_resume2, // deopt resume as a result of a PopFrame
115
got_monitors, // frame manager response to more_monitors request
116
rethrow_exception, // unwinding and throwing exception
117
// requests to frame manager from C++ interpreter
118
call_method, // request for new frame from interpreter, manager responds with method_entry
119
return_from_method, // request from interpreter to unwind, manager responds with method_continue
120
more_monitors, // need a new monitor
121
throwing_exception, // unwind stack and rethrow
122
popping_frame, // unwind call and retry call
123
do_osr, // request this invocation be OSR's
124
early_return // early return as commanded by jvmti
125
};
126
127
private:
128
JavaThread* _thread; // the vm's java thread pointer
129
address _bcp; // instruction pointer
130
intptr_t* _locals; // local variable pointer
131
ConstantPoolCache* _constants; // constant pool cache
132
Method* _method; // method being executed
133
DataLayout* _mdx; // compiler profiling data for current bytecode
134
intptr_t* _stack; // expression stack
135
messages _msg; // frame manager <-> interpreter message
136
frame_manager_message _result; // result to frame manager
137
interpreterState _prev_link; // previous interpreter state
138
oop _oop_temp; // mirror for interpreted native, null otherwise
139
intptr_t* _stack_base; // base of expression stack
140
intptr_t* _stack_limit; // limit of expression stack
141
BasicObjectLock* _monitor_base; // base of monitors on the native stack
142
143
144
public:
145
// Constructor is only used by the initialization step. All other instances are created
146
// by the frame manager.
147
BytecodeInterpreter(messages msg);
148
149
//
150
// Deoptimization support
151
//
152
static void layout_interpreterState(interpreterState to_fill,
153
frame* caller,
154
frame* interpreter_frame,
155
Method* method,
156
intptr_t* locals,
157
intptr_t* stack,
158
intptr_t* stack_base,
159
intptr_t* monitor_base,
160
intptr_t* frame_bottom,
161
bool top_frame);
162
163
/*
164
* Generic 32-bit wide "Java slot" definition. This type occurs
165
* in operand stacks, Java locals, object fields, constant pools.
166
*/
167
union VMJavaVal32 {
168
jint i;
169
jfloat f;
170
class oopDesc* r;
171
uint32_t raw;
172
};
173
174
/*
175
* Generic 64-bit Java value definition
176
*/
177
union VMJavaVal64 {
178
jlong l;
179
jdouble d;
180
uint32_t v[2];
181
};
182
183
/*
184
* Generic 32-bit wide "Java slot" definition. This type occurs
185
* in Java locals, object fields, constant pools, and
186
* operand stacks (as a CVMStackVal32).
187
*/
188
typedef union VMSlotVal32 {
189
VMJavaVal32 j; /* For "Java" values */
190
address a; /* a return created by jsr or jsr_w */
191
} VMSlotVal32;
192
193
194
/*
195
* Generic 32-bit wide stack slot definition.
196
*/
197
union VMStackVal32 {
198
VMJavaVal32 j; /* For "Java" values */
199
VMSlotVal32 s; /* any value from a "slot" or locals[] */
200
};
201
202
inline JavaThread* thread() { return _thread; }
203
204
inline address bcp() { return _bcp; }
205
inline void set_bcp(address new_bcp) { _bcp = new_bcp; }
206
207
inline intptr_t* locals() { return _locals; }
208
209
inline ConstantPoolCache* constants() { return _constants; }
210
inline Method* method() { return _method; }
211
inline DataLayout* mdx() { return _mdx; }
212
inline void set_mdx(DataLayout *new_mdx) { _mdx = new_mdx; }
213
214
inline messages msg() { return _msg; }
215
inline void set_msg(messages new_msg) { _msg = new_msg; }
216
217
inline Method* callee() { return _result._to_call._callee; }
218
inline void set_callee(Method* new_callee) { _result._to_call._callee = new_callee; }
219
inline void set_callee_entry_point(address entry) { _result._to_call._callee_entry_point = entry; }
220
inline void set_osr_buf(address buf) { _result._osr._osr_buf = buf; }
221
inline void set_osr_entry(address entry) { _result._osr._osr_entry = entry; }
222
inline int bcp_advance() { return _result._to_call._bcp_advance; }
223
inline void set_bcp_advance(int count) { _result._to_call._bcp_advance = count; }
224
225
inline interpreterState prev() { return _prev_link; }
226
227
inline intptr_t* stack() { return _stack; }
228
inline void set_stack(intptr_t* new_stack) { _stack = new_stack; }
229
230
231
inline intptr_t* stack_base() { return _stack_base; }
232
inline intptr_t* stack_limit() { return _stack_limit; }
233
234
inline BasicObjectLock* monitor_base() { return _monitor_base; }
235
236
/*
237
* 64-bit Arithmetic:
238
*
239
* The functions below follow the semantics of the
240
* ladd, land, ldiv, lmul, lor, lxor, and lrem bytecodes,
241
* respectively.
242
*/
243
244
static jlong VMlongAdd(jlong op1, jlong op2);
245
static jlong VMlongAnd(jlong op1, jlong op2);
246
static jlong VMlongDiv(jlong op1, jlong op2);
247
static jlong VMlongMul(jlong op1, jlong op2);
248
static jlong VMlongOr (jlong op1, jlong op2);
249
static jlong VMlongSub(jlong op1, jlong op2);
250
static jlong VMlongXor(jlong op1, jlong op2);
251
static jlong VMlongRem(jlong op1, jlong op2);
252
253
/*
254
* Shift:
255
*
256
* The functions below follow the semantics of the
257
* lushr, lshl, and lshr bytecodes, respectively.
258
*/
259
260
static jlong VMlongUshr(jlong op1, jint op2);
261
static jlong VMlongShl (jlong op1, jint op2);
262
static jlong VMlongShr (jlong op1, jint op2);
263
264
/*
265
* Unary:
266
*
267
* Return the negation of "op" (-op), according to
268
* the semantics of the lneg bytecode.
269
*/
270
271
static jlong VMlongNeg(jlong op);
272
273
/*
274
* Return the complement of "op" (~op)
275
*/
276
277
static jlong VMlongNot(jlong op);
278
279
280
/*
281
* Comparisons to 0:
282
*/
283
284
static int32_t VMlongLtz(jlong op); /* op <= 0 */
285
static int32_t VMlongGez(jlong op); /* op >= 0 */
286
static int32_t VMlongEqz(jlong op); /* op == 0 */
287
288
/*
289
* Between operands:
290
*/
291
292
static int32_t VMlongEq(jlong op1, jlong op2); /* op1 == op2 */
293
static int32_t VMlongNe(jlong op1, jlong op2); /* op1 != op2 */
294
static int32_t VMlongGe(jlong op1, jlong op2); /* op1 >= op2 */
295
static int32_t VMlongLe(jlong op1, jlong op2); /* op1 <= op2 */
296
static int32_t VMlongLt(jlong op1, jlong op2); /* op1 < op2 */
297
static int32_t VMlongGt(jlong op1, jlong op2); /* op1 > op2 */
298
299
/*
300
* Comparisons (returning an jint value: 0, 1, or -1)
301
*
302
* Between operands:
303
*
304
* Compare "op1" and "op2" according to the semantics of the
305
* "lcmp" bytecode.
306
*/
307
308
static int32_t VMlongCompare(jlong op1, jlong op2);
309
310
/*
311
* Convert int to long, according to "i2l" bytecode semantics
312
*/
313
static jlong VMint2Long(jint val);
314
315
/*
316
* Convert long to int, according to "l2i" bytecode semantics
317
*/
318
static jint VMlong2Int(jlong val);
319
320
/*
321
* Convert long to float, according to "l2f" bytecode semantics
322
*/
323
static jfloat VMlong2Float(jlong val);
324
325
/*
326
* Convert long to double, according to "l2d" bytecode semantics
327
*/
328
static jdouble VMlong2Double(jlong val);
329
330
/*
331
* Java floating-point float value manipulation.
332
*
333
* The result argument is, once again, an lvalue.
334
*
335
* Arithmetic:
336
*
337
* The functions below follow the semantics of the
338
* fadd, fsub, fmul, fdiv, and frem bytecodes,
339
* respectively.
340
*/
341
342
static jfloat VMfloatAdd(jfloat op1, jfloat op2);
343
static jfloat VMfloatSub(jfloat op1, jfloat op2);
344
static jfloat VMfloatMul(jfloat op1, jfloat op2);
345
static jfloat VMfloatDiv(jfloat op1, jfloat op2);
346
static jfloat VMfloatRem(jfloat op1, jfloat op2);
347
348
/*
349
* Unary:
350
*
351
* Return the negation of "op" (-op), according to
352
* the semantics of the fneg bytecode.
353
*/
354
355
static jfloat VMfloatNeg(jfloat op);
356
357
/*
358
* Comparisons (returning an int value: 0, 1, or -1)
359
*
360
* Between operands:
361
*
362
* Compare "op1" and "op2" according to the semantics of the
363
* "fcmpl" (direction is -1) or "fcmpg" (direction is 1) bytecodes.
364
*/
365
366
static int32_t VMfloatCompare(jfloat op1, jfloat op2,
367
int32_t direction);
368
/*
369
* Conversion:
370
*/
371
372
/*
373
* Convert float to double, according to "f2d" bytecode semantics
374
*/
375
376
static jdouble VMfloat2Double(jfloat op);
377
378
/*
379
******************************************
380
* Java double floating-point manipulation.
381
******************************************
382
*
383
* The result argument is, once again, an lvalue.
384
*
385
* Conversions:
386
*/
387
388
/*
389
* Convert double to int, according to "d2i" bytecode semantics
390
*/
391
392
static jint VMdouble2Int(jdouble val);
393
394
/*
395
* Convert double to float, according to "d2f" bytecode semantics
396
*/
397
398
static jfloat VMdouble2Float(jdouble val);
399
400
/*
401
* Convert int to double, according to "i2d" bytecode semantics
402
*/
403
404
static jdouble VMint2Double(jint val);
405
406
/*
407
* Arithmetic:
408
*
409
* The functions below follow the semantics of the
410
* dadd, dsub, ddiv, dmul, and drem bytecodes, respectively.
411
*/
412
413
static jdouble VMdoubleAdd(jdouble op1, jdouble op2);
414
static jdouble VMdoubleSub(jdouble op1, jdouble op2);
415
static jdouble VMdoubleDiv(jdouble op1, jdouble op2);
416
static jdouble VMdoubleMul(jdouble op1, jdouble op2);
417
static jdouble VMdoubleRem(jdouble op1, jdouble op2);
418
419
/*
420
* Unary:
421
*
422
* Return the negation of "op" (-op), according to
423
* the semantics of the dneg bytecode.
424
*/
425
426
static jdouble VMdoubleNeg(jdouble op);
427
428
/*
429
* Comparisons (returning an int32_t value: 0, 1, or -1)
430
*
431
* Between operands:
432
*
433
* Compare "op1" and "op2" according to the semantics of the
434
* "dcmpl" (direction is -1) or "dcmpg" (direction is 1) bytecodes.
435
*/
436
437
static int32_t VMdoubleCompare(jdouble op1, jdouble op2, int32_t direction);
438
439
/*
440
* Copy two typeless 32-bit words from one location to another.
441
* This is semantically equivalent to:
442
*
443
* to[0] = from[0];
444
* to[1] = from[1];
445
*
446
* but this interface is provided for those platforms that could
447
* optimize this into a single 64-bit transfer.
448
*/
449
450
static void VMmemCopy64(uint32_t to[2], const uint32_t from[2]);
451
452
453
// Arithmetic operations
454
455
/*
456
* Java arithmetic methods.
457
* The functions below follow the semantics of the
458
* iadd, isub, imul, idiv, irem, iand, ior, ixor,
459
* and ineg bytecodes, respectively.
460
*/
461
462
static jint VMintAdd(jint op1, jint op2);
463
static jint VMintSub(jint op1, jint op2);
464
static jint VMintMul(jint op1, jint op2);
465
static jint VMintDiv(jint op1, jint op2);
466
static jint VMintRem(jint op1, jint op2);
467
static jint VMintAnd(jint op1, jint op2);
468
static jint VMintOr (jint op1, jint op2);
469
static jint VMintXor(jint op1, jint op2);
470
471
/*
472
* Shift Operation:
473
* The functions below follow the semantics of the
474
* iushr, ishl, and ishr bytecodes, respectively.
475
*/
476
477
static juint VMintUshr(jint op, jint num);
478
static jint VMintShl (jint op, jint num);
479
static jint VMintShr (jint op, jint num);
480
481
/*
482
* Unary Operation:
483
*
484
* Return the negation of "op" (-op), according to
485
* the semantics of the ineg bytecode.
486
*/
487
488
static jint VMintNeg(jint op);
489
490
/*
491
* Int Conversions:
492
*/
493
494
/*
495
* Convert int to float, according to "i2f" bytecode semantics
496
*/
497
498
static jfloat VMint2Float(jint val);
499
500
/*
501
* Convert int to byte, according to "i2b" bytecode semantics
502
*/
503
504
static jbyte VMint2Byte(jint val);
505
506
/*
507
* Convert int to char, according to "i2c" bytecode semantics
508
*/
509
510
static jchar VMint2Char(jint val);
511
512
/*
513
* Convert int to short, according to "i2s" bytecode semantics
514
*/
515
516
static jshort VMint2Short(jint val);
517
518
/*=========================================================================
519
* Bytecode interpreter operations
520
*=======================================================================*/
521
522
static void dup(intptr_t *tos);
523
static void dup2(intptr_t *tos);
524
static void dup_x1(intptr_t *tos); /* insert top word two down */
525
static void dup_x2(intptr_t *tos); /* insert top word three down */
526
static void dup2_x1(intptr_t *tos); /* insert top 2 slots three down */
527
static void dup2_x2(intptr_t *tos); /* insert top 2 slots four down */
528
static void swap(intptr_t *tos); /* swap top two elements */
529
530
// umm don't like this method modifies its object
531
532
// The Interpreter used when
533
static void run(interpreterState istate);
534
// The interpreter used if JVMTI needs interpreter events
535
static void runWithChecks(interpreterState istate);
536
static void End_Of_Interpreter(void);
537
538
// Inline static functions for Java Stack and Local manipulation
539
540
static address stack_slot(intptr_t *tos, int offset);
541
static jint stack_int(intptr_t *tos, int offset);
542
static jfloat stack_float(intptr_t *tos, int offset);
543
static oop stack_object(intptr_t *tos, int offset);
544
static jdouble stack_double(intptr_t *tos, int offset);
545
static jlong stack_long(intptr_t *tos, int offset);
546
547
// only used for value types
548
static void set_stack_slot(intptr_t *tos, address value, int offset);
549
static void set_stack_int(intptr_t *tos, int value, int offset);
550
static void set_stack_float(intptr_t *tos, jfloat value, int offset);
551
static void set_stack_object(intptr_t *tos, oop value, int offset);
552
553
// needs to be platform dep for the 32 bit platforms.
554
static void set_stack_double(intptr_t *tos, jdouble value, int offset);
555
static void set_stack_long(intptr_t *tos, jlong value, int offset);
556
557
static void set_stack_double_from_addr(intptr_t *tos, address addr, int offset);
558
static void set_stack_long_from_addr(intptr_t *tos, address addr, int offset);
559
560
// Locals
561
562
static address locals_slot(intptr_t* locals, int offset);
563
static jint locals_int(intptr_t* locals, int offset);
564
static jfloat locals_float(intptr_t* locals, int offset);
565
static oop locals_object(intptr_t* locals, int offset);
566
static jdouble locals_double(intptr_t* locals, int offset);
567
static jlong locals_long(intptr_t* locals, int offset);
568
569
static address locals_long_at(intptr_t* locals, int offset);
570
static address locals_double_at(intptr_t* locals, int offset);
571
572
static void set_locals_slot(intptr_t *locals, address value, int offset);
573
static void set_locals_int(intptr_t *locals, jint value, int offset);
574
static void set_locals_float(intptr_t *locals, jfloat value, int offset);
575
static void set_locals_object(intptr_t *locals, oop value, int offset);
576
static void set_locals_double(intptr_t *locals, jdouble value, int offset);
577
static void set_locals_long(intptr_t *locals, jlong value, int offset);
578
static void set_locals_double_from_addr(intptr_t *locals,
579
address addr, int offset);
580
static void set_locals_long_from_addr(intptr_t *locals,
581
address addr, int offset);
582
583
static void astore(intptr_t* topOfStack, int stack_offset,
584
intptr_t* locals, int locals_offset);
585
586
// Support for dup and swap
587
static void copy_stack_slot(intptr_t *tos, int from_offset, int to_offset);
588
589
#ifndef PRODUCT
590
static const char* C_msg(BytecodeInterpreter::messages msg);
591
void print();
592
#endif // PRODUCT
593
594
// Platform fields/methods
595
#ifdef TARGET_ARCH_x86
596
# include "bytecodeInterpreter_x86.hpp"
597
#endif
598
#ifdef TARGET_ARCH_aarch32
599
# include "bytecodeInterpreter_aarch32.hpp"
600
#endif
601
#ifdef TARGET_ARCH_aarch64
602
# include "bytecodeInterpreter_aarch64.hpp"
603
#endif
604
#ifdef TARGET_ARCH_sparc
605
# include "bytecodeInterpreter_sparc.hpp"
606
#endif
607
#ifdef TARGET_ARCH_zero
608
# include "bytecodeInterpreter_zero.hpp"
609
#endif
610
#ifdef TARGET_ARCH_arm
611
# include "bytecodeInterpreter_arm.hpp"
612
#endif
613
#ifdef TARGET_ARCH_ppc
614
# include "bytecodeInterpreter_ppc.hpp"
615
#endif
616
617
618
}; // BytecodeInterpreter
619
620
#endif // CC_INTERP
621
622
#endif // SHARE_VM_INTERPRETER_BYTECODEINTERPRETER_HPP
623
624