Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/src/hotspot/share/code/codeBlob.hpp
64440 views
1
/*
2
* Copyright (c) 1998, 2021, 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_CODE_CODEBLOB_HPP
26
#define SHARE_CODE_CODEBLOB_HPP
27
28
#include "asm/codeBuffer.hpp"
29
#include "compiler/compilerDefinitions.hpp"
30
#include "runtime/javaFrameAnchor.hpp"
31
#include "runtime/frame.hpp"
32
#include "runtime/handles.hpp"
33
#include "utilities/align.hpp"
34
#include "utilities/macros.hpp"
35
36
class ImmutableOopMap;
37
class ImmutableOopMapSet;
38
class JNIHandleBlock;
39
class OopMapSet;
40
41
// CodeBlob Types
42
// Used in the CodeCache to assign CodeBlobs to different CodeHeaps
43
struct CodeBlobType {
44
enum {
45
MethodNonProfiled = 0, // Execution level 1 and 4 (non-profiled) nmethods (including native nmethods)
46
MethodProfiled = 1, // Execution level 2 and 3 (profiled) nmethods
47
NonNMethod = 2, // Non-nmethods like Buffers, Adapters and Runtime Stubs
48
All = 3, // All types (No code cache segmentation)
49
NumTypes = 4 // Number of CodeBlobTypes
50
};
51
};
52
53
// CodeBlob - superclass for all entries in the CodeCache.
54
//
55
// Subtypes are:
56
// CompiledMethod : Compiled Java methods (include method that calls to native code)
57
// nmethod : JIT Compiled Java methods
58
// RuntimeBlob : Non-compiled method code; generated glue code
59
// BufferBlob : Used for non-relocatable code such as interpreter, stubroutines, etc.
60
// AdapterBlob : Used to hold C2I/I2C adapters
61
// VtableBlob : Used for holding vtable chunks
62
// MethodHandlesAdapterBlob : Used to hold MethodHandles adapters
63
// OptimizedEntryBlob : Used for upcalls from native code
64
// RuntimeStub : Call to VM runtime methods
65
// SingletonBlob : Super-class for all blobs that exist in only one instance
66
// DeoptimizationBlob : Used for deoptimization
67
// ExceptionBlob : Used for stack unrolling
68
// SafepointBlob : Used to handle illegal instruction exceptions
69
// UncommonTrapBlob : Used to handle uncommon traps
70
//
71
//
72
// Layout : continuous in the CodeCache
73
// - header
74
// - relocation
75
// - content space
76
// - instruction space
77
// - data space
78
79
80
class CodeBlobLayout;
81
class OptimizedEntryBlob; // for as_optimized_entry_blob()
82
class JavaFrameAnchor; // for OptimizedEntryBlob::jfa_for_frame
83
84
class CodeBlob {
85
friend class VMStructs;
86
friend class JVMCIVMStructs;
87
friend class CodeCacheDumper;
88
89
protected:
90
91
const CompilerType _type; // CompilerType
92
int _size; // total size of CodeBlob in bytes
93
int _header_size; // size of header (depends on subclass)
94
int _frame_complete_offset; // instruction offsets in [0.._frame_complete_offset) have
95
// not finished setting up their frame. Beware of pc's in
96
// that range. There is a similar range(s) on returns
97
// which we don't detect.
98
int _data_offset; // offset to where data region begins
99
int _frame_size; // size of stack frame
100
101
address _code_begin;
102
address _code_end;
103
address _content_begin; // address to where content region begins (this includes consts, insts, stubs)
104
// address _content_end - not required, for all CodeBlobs _code_end == _content_end for now
105
address _data_end;
106
address _relocation_begin;
107
address _relocation_end;
108
109
ImmutableOopMapSet* _oop_maps; // OopMap for this CodeBlob
110
bool _caller_must_gc_arguments;
111
112
const char* _name;
113
S390_ONLY(int _ctable_offset;)
114
115
NOT_PRODUCT(CodeStrings _strings;)
116
117
CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments);
118
CodeBlob(const char* name, CompilerType type, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments);
119
120
public:
121
// Only used by unit test.
122
CodeBlob()
123
: _type(compiler_none) {}
124
125
// Returns the space needed for CodeBlob
126
static unsigned int allocation_size(CodeBuffer* cb, int header_size);
127
static unsigned int align_code_offset(int offset);
128
129
// Deletion
130
virtual void flush();
131
132
// Typing
133
virtual bool is_buffer_blob() const { return false; }
134
virtual bool is_nmethod() const { return false; }
135
virtual bool is_runtime_stub() const { return false; }
136
virtual bool is_deoptimization_stub() const { return false; }
137
virtual bool is_uncommon_trap_stub() const { return false; }
138
virtual bool is_exception_stub() const { return false; }
139
virtual bool is_safepoint_stub() const { return false; }
140
virtual bool is_adapter_blob() const { return false; }
141
virtual bool is_vtable_blob() const { return false; }
142
virtual bool is_method_handles_adapter_blob() const { return false; }
143
virtual bool is_compiled() const { return false; }
144
virtual bool is_optimized_entry_blob() const { return false; }
145
146
inline bool is_compiled_by_c1() const { return _type == compiler_c1; };
147
inline bool is_compiled_by_c2() const { return _type == compiler_c2; };
148
inline bool is_compiled_by_jvmci() const { return _type == compiler_jvmci; };
149
const char* compiler_name() const;
150
CompilerType compiler_type() const { return _type; }
151
152
// Casting
153
nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; }
154
nmethod* as_nmethod() { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
155
CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; }
156
CompiledMethod* as_compiled_method() { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
157
CodeBlob* as_codeblob_or_null() const { return (CodeBlob*) this; }
158
OptimizedEntryBlob* as_optimized_entry_blob() const { assert(is_optimized_entry_blob(), "must be entry blob"); return (OptimizedEntryBlob*) this; }
159
160
// Boundaries
161
address header_begin() const { return (address) this; }
162
relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; };
163
relocInfo* relocation_end() const { return (relocInfo*) _relocation_end; }
164
address content_begin() const { return _content_begin; }
165
address content_end() const { return _code_end; } // _code_end == _content_end is true for all types of blobs for now, it is also checked in the constructor
166
address code_begin() const { return _code_begin; }
167
address code_end() const { return _code_end; }
168
address data_end() const { return _data_end; }
169
170
// This field holds the beginning of the const section in the old code buffer.
171
// It is needed to fix relocations of pc-relative loads when resizing the
172
// the constant pool or moving it.
173
S390_ONLY(address ctable_begin() const { return header_begin() + _ctable_offset; })
174
void set_ctable_begin(address ctable) { S390_ONLY(_ctable_offset = ctable - header_begin();) }
175
176
// Sizes
177
int size() const { return _size; }
178
int header_size() const { return _header_size; }
179
int relocation_size() const { return (address) relocation_end() - (address) relocation_begin(); }
180
int content_size() const { return content_end() - content_begin(); }
181
int code_size() const { return code_end() - code_begin(); }
182
// Only used from CodeCache::free_unused_tail() after the Interpreter blob was trimmed
183
void adjust_size(size_t used) {
184
_size = (int)used;
185
_data_offset = (int)used;
186
_code_end = (address)this + used;
187
_data_end = (address)this + used;
188
}
189
190
// Containment
191
bool blob_contains(address addr) const { return header_begin() <= addr && addr < data_end(); }
192
bool code_contains(address addr) const { return code_begin() <= addr && addr < code_end(); }
193
bool contains(address addr) const { return content_begin() <= addr && addr < content_end(); }
194
bool is_frame_complete_at(address addr) const { return _frame_complete_offset != CodeOffsets::frame_never_safe &&
195
code_contains(addr) && addr >= code_begin() + _frame_complete_offset; }
196
int frame_complete_offset() const { return _frame_complete_offset; }
197
198
// CodeCache support: really only used by the nmethods, but in order to get
199
// asserts and certain bookkeeping to work in the CodeCache they are defined
200
// virtual here.
201
virtual bool is_zombie() const { return false; }
202
virtual bool is_locked_by_vm() const { return false; }
203
204
virtual bool is_unloaded() const { return false; }
205
virtual bool is_not_entrant() const { return false; }
206
207
// GC support
208
virtual bool is_alive() const = 0;
209
210
// OopMap for frame
211
ImmutableOopMapSet* oop_maps() const { return _oop_maps; }
212
void set_oop_maps(OopMapSet* p);
213
const ImmutableOopMap* oop_map_for_return_address(address return_address);
214
virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0;
215
216
// Frame support. Sizes are in word units.
217
int frame_size() const { return _frame_size; }
218
void set_frame_size(int size) { _frame_size = size; }
219
220
// Returns true, if the next frame is responsible for GC'ing oops passed as arguments
221
bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; }
222
223
// Naming
224
const char* name() const { return _name; }
225
void set_name(const char* name) { _name = name; }
226
227
// Debugging
228
virtual void verify() = 0;
229
virtual void print() const;
230
virtual void print_on(outputStream* st) const;
231
virtual void print_value_on(outputStream* st) const;
232
void dump_for_addr(address addr, outputStream* st, bool verbose) const;
233
void print_code();
234
235
// Print the comment associated with offset on stream, if there is one
236
virtual void print_block_comment(outputStream* stream, address block_begin) const {
237
#ifndef PRODUCT
238
intptr_t offset = (intptr_t)(block_begin - code_begin());
239
_strings.print_block_comment(stream, offset);
240
#endif
241
}
242
243
#ifndef PRODUCT
244
void set_strings(CodeStrings& strings) {
245
_strings.copy(strings);
246
}
247
#endif
248
};
249
250
class CodeBlobLayout : public StackObj {
251
private:
252
int _size;
253
int _header_size;
254
int _relocation_size;
255
int _content_offset;
256
int _code_offset;
257
int _data_offset;
258
address _code_begin;
259
address _code_end;
260
address _content_begin;
261
address _content_end;
262
address _data_end;
263
address _relocation_begin;
264
address _relocation_end;
265
266
public:
267
CodeBlobLayout(address code_begin, address code_end, address content_begin, address content_end, address data_end, address relocation_begin, address relocation_end) :
268
_size(0),
269
_header_size(0),
270
_relocation_size(0),
271
_content_offset(0),
272
_code_offset(0),
273
_data_offset(0),
274
_code_begin(code_begin),
275
_code_end(code_end),
276
_content_begin(content_begin),
277
_content_end(content_end),
278
_data_end(data_end),
279
_relocation_begin(relocation_begin),
280
_relocation_end(relocation_end)
281
{
282
}
283
284
CodeBlobLayout(const address start, int size, int header_size, int relocation_size, int data_offset) :
285
_size(size),
286
_header_size(header_size),
287
_relocation_size(relocation_size),
288
_content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)),
289
_code_offset(_content_offset),
290
_data_offset(data_offset)
291
{
292
assert(is_aligned(_relocation_size, oopSize), "unaligned size");
293
294
_code_begin = (address) start + _code_offset;
295
_code_end = (address) start + _data_offset;
296
297
_content_begin = (address) start + _content_offset;
298
_content_end = (address) start + _data_offset;
299
300
_data_end = (address) start + _size;
301
_relocation_begin = (address) start + _header_size;
302
_relocation_end = _relocation_begin + _relocation_size;
303
}
304
305
CodeBlobLayout(const address start, int size, int header_size, const CodeBuffer* cb) :
306
_size(size),
307
_header_size(header_size),
308
_relocation_size(align_up(cb->total_relocation_size(), oopSize)),
309
_content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)),
310
_code_offset(_content_offset + cb->total_offset_of(cb->insts())),
311
_data_offset(_content_offset + align_up(cb->total_content_size(), oopSize))
312
{
313
assert(is_aligned(_relocation_size, oopSize), "unaligned size");
314
315
_code_begin = (address) start + _code_offset;
316
_code_end = (address) start + _data_offset;
317
318
_content_begin = (address) start + _content_offset;
319
_content_end = (address) start + _data_offset;
320
321
_data_end = (address) start + _size;
322
_relocation_begin = (address) start + _header_size;
323
_relocation_end = _relocation_begin + _relocation_size;
324
}
325
326
int size() const { return _size; }
327
int header_size() const { return _header_size; }
328
int relocation_size() const { return _relocation_size; }
329
int content_offset() const { return _content_offset; }
330
int code_offset() const { return _code_offset; }
331
int data_offset() const { return _data_offset; }
332
address code_begin() const { return _code_begin; }
333
address code_end() const { return _code_end; }
334
address data_end() const { return _data_end; }
335
address relocation_begin() const { return _relocation_begin; }
336
address relocation_end() const { return _relocation_end; }
337
address content_begin() const { return _content_begin; }
338
address content_end() const { return _content_end; }
339
};
340
341
342
class RuntimeBlob : public CodeBlob {
343
friend class VMStructs;
344
public:
345
346
// Creation
347
// a) simple CodeBlob
348
// frame_complete is the offset from the beginning of the instructions
349
// to where the frame setup (from stackwalk viewpoint) is complete.
350
RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size);
351
352
// b) full CodeBlob
353
RuntimeBlob(
354
const char* name,
355
CodeBuffer* cb,
356
int header_size,
357
int size,
358
int frame_complete,
359
int frame_size,
360
OopMapSet* oop_maps,
361
bool caller_must_gc_arguments = false
362
);
363
364
// GC support
365
virtual bool is_alive() const = 0;
366
367
void verify();
368
369
// OopMap for frame
370
virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); }
371
372
// Debugging
373
virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); }
374
virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); }
375
376
// Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService.
377
static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = "");
378
};
379
380
class WhiteBox;
381
//----------------------------------------------------------------------------------------------------
382
// BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc.
383
384
class BufferBlob: public RuntimeBlob {
385
friend class VMStructs;
386
friend class AdapterBlob;
387
friend class VtableBlob;
388
friend class MethodHandlesAdapterBlob;
389
friend class OptimizedEntryBlob;
390
friend class WhiteBox;
391
392
private:
393
// Creation support
394
BufferBlob(const char* name, int size);
395
BufferBlob(const char* name, int size, CodeBuffer* cb);
396
397
// This ordinary operator delete is needed even though not used, so the
398
// below two-argument operator delete will be treated as a placement
399
// delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2.
400
void operator delete(void* p);
401
void* operator new(size_t s, unsigned size) throw();
402
403
public:
404
// Creation
405
static BufferBlob* create(const char* name, int buffer_size);
406
static BufferBlob* create(const char* name, CodeBuffer* cb);
407
408
static void free(BufferBlob* buf);
409
410
// Typing
411
virtual bool is_buffer_blob() const { return true; }
412
413
// GC/Verification support
414
void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
415
bool is_alive() const { return true; }
416
417
void verify();
418
void print_on(outputStream* st) const;
419
void print_value_on(outputStream* st) const;
420
};
421
422
423
//----------------------------------------------------------------------------------------------------
424
// AdapterBlob: used to hold C2I/I2C adapters
425
426
class AdapterBlob: public BufferBlob {
427
private:
428
AdapterBlob(int size, CodeBuffer* cb);
429
430
public:
431
// Creation
432
static AdapterBlob* create(CodeBuffer* cb);
433
434
// Typing
435
virtual bool is_adapter_blob() const { return true; }
436
};
437
438
//---------------------------------------------------------------------------------------------------
439
class VtableBlob: public BufferBlob {
440
private:
441
VtableBlob(const char*, int);
442
443
void* operator new(size_t s, unsigned size) throw();
444
445
public:
446
// Creation
447
static VtableBlob* create(const char* name, int buffer_size);
448
449
// Typing
450
virtual bool is_vtable_blob() const { return true; }
451
};
452
453
//----------------------------------------------------------------------------------------------------
454
// MethodHandlesAdapterBlob: used to hold MethodHandles adapters
455
456
class MethodHandlesAdapterBlob: public BufferBlob {
457
private:
458
MethodHandlesAdapterBlob(int size) : BufferBlob("MethodHandles adapters", size) {}
459
460
public:
461
// Creation
462
static MethodHandlesAdapterBlob* create(int buffer_size);
463
464
// Typing
465
virtual bool is_method_handles_adapter_blob() const { return true; }
466
};
467
468
469
//----------------------------------------------------------------------------------------------------
470
// RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine
471
472
class RuntimeStub: public RuntimeBlob {
473
friend class VMStructs;
474
private:
475
// Creation support
476
RuntimeStub(
477
const char* name,
478
CodeBuffer* cb,
479
int size,
480
int frame_complete,
481
int frame_size,
482
OopMapSet* oop_maps,
483
bool caller_must_gc_arguments
484
);
485
486
// This ordinary operator delete is needed even though not used, so the
487
// below two-argument operator delete will be treated as a placement
488
// delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2.
489
void operator delete(void* p);
490
void* operator new(size_t s, unsigned size) throw();
491
492
public:
493
// Creation
494
static RuntimeStub* new_runtime_stub(
495
const char* stub_name,
496
CodeBuffer* cb,
497
int frame_complete,
498
int frame_size,
499
OopMapSet* oop_maps,
500
bool caller_must_gc_arguments
501
);
502
503
// Typing
504
bool is_runtime_stub() const { return true; }
505
506
address entry_point() const { return code_begin(); }
507
508
// GC/Verification support
509
void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ }
510
bool is_alive() const { return true; }
511
512
void verify();
513
void print_on(outputStream* st) const;
514
void print_value_on(outputStream* st) const;
515
};
516
517
518
//----------------------------------------------------------------------------------------------------
519
// Super-class for all blobs that exist in only one instance. Implements default behaviour.
520
521
class SingletonBlob: public RuntimeBlob {
522
friend class VMStructs;
523
524
protected:
525
// This ordinary operator delete is needed even though not used, so the
526
// below two-argument operator delete will be treated as a placement
527
// delete rather than an ordinary sized delete; see C++14 3.7.4.2/p2.
528
void operator delete(void* p);
529
void* operator new(size_t s, unsigned size) throw();
530
531
public:
532
SingletonBlob(
533
const char* name,
534
CodeBuffer* cb,
535
int header_size,
536
int size,
537
int frame_size,
538
OopMapSet* oop_maps
539
)
540
: RuntimeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps)
541
{};
542
543
address entry_point() { return code_begin(); }
544
545
bool is_alive() const { return true; }
546
547
// GC/Verification support
548
void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ }
549
void verify(); // does nothing
550
void print_on(outputStream* st) const;
551
void print_value_on(outputStream* st) const;
552
};
553
554
555
//----------------------------------------------------------------------------------------------------
556
// DeoptimizationBlob
557
558
class DeoptimizationBlob: public SingletonBlob {
559
friend class VMStructs;
560
friend class JVMCIVMStructs;
561
private:
562
int _unpack_offset;
563
int _unpack_with_exception;
564
int _unpack_with_reexecution;
565
566
int _unpack_with_exception_in_tls;
567
568
#if INCLUDE_JVMCI
569
// Offsets when JVMCI calls uncommon_trap.
570
int _uncommon_trap_offset;
571
int _implicit_exception_uncommon_trap_offset;
572
#endif
573
574
// Creation support
575
DeoptimizationBlob(
576
CodeBuffer* cb,
577
int size,
578
OopMapSet* oop_maps,
579
int unpack_offset,
580
int unpack_with_exception_offset,
581
int unpack_with_reexecution_offset,
582
int frame_size
583
);
584
585
public:
586
// Creation
587
static DeoptimizationBlob* create(
588
CodeBuffer* cb,
589
OopMapSet* oop_maps,
590
int unpack_offset,
591
int unpack_with_exception_offset,
592
int unpack_with_reexecution_offset,
593
int frame_size
594
);
595
596
// Typing
597
bool is_deoptimization_stub() const { return true; }
598
599
// GC for args
600
void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* Nothing to do */ }
601
602
// Printing
603
void print_value_on(outputStream* st) const;
604
605
address unpack() const { return code_begin() + _unpack_offset; }
606
address unpack_with_exception() const { return code_begin() + _unpack_with_exception; }
607
address unpack_with_reexecution() const { return code_begin() + _unpack_with_reexecution; }
608
609
// Alternate entry point for C1 where the exception and issuing pc
610
// are in JavaThread::_exception_oop and JavaThread::_exception_pc
611
// instead of being in registers. This is needed because C1 doesn't
612
// model exception paths in a way that keeps these registers free so
613
// there may be live values in those registers during deopt.
614
void set_unpack_with_exception_in_tls_offset(int offset) {
615
_unpack_with_exception_in_tls = offset;
616
assert(code_contains(code_begin() + _unpack_with_exception_in_tls), "must be PC inside codeblob");
617
}
618
address unpack_with_exception_in_tls() const { return code_begin() + _unpack_with_exception_in_tls; }
619
620
#if INCLUDE_JVMCI
621
// Offsets when JVMCI calls uncommon_trap.
622
void set_uncommon_trap_offset(int offset) {
623
_uncommon_trap_offset = offset;
624
assert(contains(code_begin() + _uncommon_trap_offset), "must be PC inside codeblob");
625
}
626
address uncommon_trap() const { return code_begin() + _uncommon_trap_offset; }
627
628
void set_implicit_exception_uncommon_trap_offset(int offset) {
629
_implicit_exception_uncommon_trap_offset = offset;
630
assert(contains(code_begin() + _implicit_exception_uncommon_trap_offset), "must be PC inside codeblob");
631
}
632
address implicit_exception_uncommon_trap() const { return code_begin() + _implicit_exception_uncommon_trap_offset; }
633
#endif // INCLUDE_JVMCI
634
};
635
636
637
//----------------------------------------------------------------------------------------------------
638
// UncommonTrapBlob (currently only used by Compiler 2)
639
640
#ifdef COMPILER2
641
642
class UncommonTrapBlob: public SingletonBlob {
643
friend class VMStructs;
644
private:
645
// Creation support
646
UncommonTrapBlob(
647
CodeBuffer* cb,
648
int size,
649
OopMapSet* oop_maps,
650
int frame_size
651
);
652
653
public:
654
// Creation
655
static UncommonTrapBlob* create(
656
CodeBuffer* cb,
657
OopMapSet* oop_maps,
658
int frame_size
659
);
660
661
// GC for args
662
void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ }
663
664
// Typing
665
bool is_uncommon_trap_stub() const { return true; }
666
};
667
668
669
//----------------------------------------------------------------------------------------------------
670
// ExceptionBlob: used for exception unwinding in compiled code (currently only used by Compiler 2)
671
672
class ExceptionBlob: public SingletonBlob {
673
friend class VMStructs;
674
private:
675
// Creation support
676
ExceptionBlob(
677
CodeBuffer* cb,
678
int size,
679
OopMapSet* oop_maps,
680
int frame_size
681
);
682
683
public:
684
// Creation
685
static ExceptionBlob* create(
686
CodeBuffer* cb,
687
OopMapSet* oop_maps,
688
int frame_size
689
);
690
691
// GC for args
692
void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
693
694
// Typing
695
bool is_exception_stub() const { return true; }
696
};
697
#endif // COMPILER2
698
699
700
//----------------------------------------------------------------------------------------------------
701
// SafepointBlob: handles illegal_instruction exceptions during a safepoint
702
703
class SafepointBlob: public SingletonBlob {
704
friend class VMStructs;
705
private:
706
// Creation support
707
SafepointBlob(
708
CodeBuffer* cb,
709
int size,
710
OopMapSet* oop_maps,
711
int frame_size
712
);
713
714
public:
715
// Creation
716
static SafepointBlob* create(
717
CodeBuffer* cb,
718
OopMapSet* oop_maps,
719
int frame_size
720
);
721
722
// GC for args
723
void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ }
724
725
// Typing
726
bool is_safepoint_stub() const { return true; }
727
};
728
729
//----------------------------------------------------------------------------------------------------
730
731
class ProgrammableUpcallHandler;
732
733
class OptimizedEntryBlob: public BufferBlob {
734
friend class ProgrammableUpcallHandler;
735
private:
736
intptr_t _exception_handler_offset;
737
jobject _receiver;
738
ByteSize _frame_data_offset;
739
740
OptimizedEntryBlob(const char* name, int size, CodeBuffer* cb, intptr_t exception_handler_offset,
741
jobject receiver, ByteSize frame_data_offset);
742
743
struct FrameData {
744
JavaFrameAnchor jfa;
745
JavaThread* thread;
746
JNIHandleBlock* old_handles;
747
JNIHandleBlock* new_handles;
748
bool should_detach;
749
};
750
751
// defined in frame_ARCH.cpp
752
FrameData* frame_data_for_frame(const frame& frame) const;
753
public:
754
// Creation
755
static OptimizedEntryBlob* create(const char* name, CodeBuffer* cb,
756
intptr_t exception_handler_offset, jobject receiver,
757
ByteSize frame_data_offset);
758
759
address exception_handler() { return code_begin() + _exception_handler_offset; }
760
jobject receiver() { return _receiver; }
761
762
JavaFrameAnchor* jfa_for_frame(const frame& frame) const;
763
764
void oops_do(OopClosure* f, const frame& frame);
765
766
// Typing
767
virtual bool is_optimized_entry_blob() const override { return true; }
768
};
769
770
#endif // SHARE_CODE_CODEBLOB_HPP
771
772