1 /* 2 * Copyright (c) 1998, 2025, 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 #include "precompiled.hpp" 26 #include "classfile/vmClasses.hpp" 27 #include "classfile/vmSymbols.hpp" 28 #include "code/codeCache.hpp" 29 #include "code/compiledIC.hpp" 30 #include "code/nmethod.hpp" 31 #include "code/pcDesc.hpp" 32 #include "code/scopeDesc.hpp" 33 #include "code/vtableStubs.hpp" 34 #include "compiler/compileBroker.hpp" 35 #include "compiler/oopMap.hpp" 36 #include "gc/g1/g1HeapRegion.hpp" 37 #include "gc/shared/barrierSet.hpp" 38 #include "gc/shared/collectedHeap.hpp" 39 #include "gc/shared/gcLocker.hpp" 40 #include "interpreter/bytecode.hpp" 41 #include "interpreter/interpreter.hpp" 42 #include "interpreter/linkResolver.hpp" 43 #include "logging/log.hpp" 44 #include "logging/logStream.hpp" 45 #include "memory/oopFactory.hpp" 46 #include "memory/resourceArea.hpp" 47 #include "oops/flatArrayKlass.hpp" 48 #include "oops/flatArrayOop.inline.hpp" 49 #include "oops/objArrayKlass.hpp" 50 #include "oops/klass.inline.hpp" 51 #include "oops/oop.inline.hpp" 52 #include "oops/typeArrayOop.inline.hpp" 53 #include "opto/ad.hpp" 54 #include "opto/addnode.hpp" 55 #include "opto/callnode.hpp" 56 #include "opto/cfgnode.hpp" 57 #include "opto/graphKit.hpp" 58 #include "opto/machnode.hpp" 59 #include "opto/matcher.hpp" 60 #include "opto/memnode.hpp" 61 #include "opto/mulnode.hpp" 62 #include "opto/output.hpp" 63 #include "opto/runtime.hpp" 64 #include "opto/subnode.hpp" 65 #include "prims/jvmtiExport.hpp" 66 #include "runtime/atomic.hpp" 67 #include "runtime/frame.inline.hpp" 68 #include "runtime/handles.inline.hpp" 69 #include "runtime/interfaceSupport.inline.hpp" 70 #include "runtime/javaCalls.hpp" 71 #include "runtime/sharedRuntime.hpp" 72 #include "runtime/signature.hpp" 73 #include "runtime/stackWatermarkSet.hpp" 74 #include "runtime/synchronizer.hpp" 75 #include "runtime/threadCritical.hpp" 76 #include "runtime/threadWXSetters.inline.hpp" 77 #include "runtime/vframe.hpp" 78 #include "runtime/vframeArray.hpp" 79 #include "runtime/vframe_hp.hpp" 80 #include "utilities/copy.hpp" 81 #include "utilities/preserveException.hpp" 82 83 84 // For debugging purposes: 85 // To force FullGCALot inside a runtime function, add the following two lines 86 // 87 // Universe::release_fullgc_alot_dummy(); 88 // Universe::heap()->collect(); 89 // 90 // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000 91 92 93 #define C2_BLOB_FIELD_DEFINE(name, type) \ 94 type OptoRuntime:: BLOB_FIELD_NAME(name) = nullptr; 95 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java 96 #define C2_STUB_FIELD_DEFINE(name, f, t, r) \ 97 address OptoRuntime:: C2_STUB_FIELD_NAME(name) = nullptr; 98 #define C2_JVMTI_STUB_FIELD_DEFINE(name) \ 99 address OptoRuntime:: STUB_FIELD_NAME(name) = nullptr; 100 C2_STUBS_DO(C2_BLOB_FIELD_DEFINE, C2_STUB_FIELD_DEFINE, C2_JVMTI_STUB_FIELD_DEFINE) 101 #undef C2_BLOB_FIELD_DEFINE 102 #undef C2_STUB_FIELD_DEFINE 103 #undef C2_JVMTI_STUB_FIELD_DEFINE 104 105 #define C2_BLOB_NAME_DEFINE(name, type) "C2 Runtime " # name "_blob", 106 #define C2_STUB_NAME_DEFINE(name, f, t, r) "C2 Runtime " # name, 107 #define C2_JVMTI_STUB_NAME_DEFINE(name) "C2 Runtime " # name, 108 const char* OptoRuntime::_stub_names[] = { 109 C2_STUBS_DO(C2_BLOB_NAME_DEFINE, C2_STUB_NAME_DEFINE, C2_JVMTI_STUB_NAME_DEFINE) 110 }; 111 #undef C2_BLOB_NAME_DEFINE 112 #undef C2_STUB_NAME_DEFINE 113 #undef C2_JVMTI_STUB_NAME_DEFINE 114 115 // This should be called in an assertion at the start of OptoRuntime routines 116 // which are entered from compiled code (all of them) 117 #ifdef ASSERT 118 static bool check_compiled_frame(JavaThread* thread) { 119 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code"); 120 RegisterMap map(thread, 121 RegisterMap::UpdateMap::skip, 122 RegisterMap::ProcessFrames::include, 123 RegisterMap::WalkContinuation::skip); 124 frame caller = thread->last_frame().sender(&map); 125 assert(caller.is_compiled_frame(), "not being called from compiled like code"); 126 return true; 127 } 128 #endif // ASSERT 129 130 /* 131 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, return_pc) \ 132 var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, return_pc); \ 133 if (var == nullptr) { return false; } 134 */ 135 136 #define GEN_C2_BLOB(name, type) \ 137 generate_ ## name ## _blob(); 138 139 // a few helper macros to conjure up generate_stub call arguments 140 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java 141 #define C2_STUB_TYPEFUNC(name) name ## _Type 142 #define C2_STUB_C_FUNC(name) CAST_FROM_FN_PTR(address, name ## _C) 143 #define C2_STUB_NAME(name) stub_name(OptoStubId::name ## _id) 144 145 // Almost all the C functions targeted from the generated stubs are 146 // implemented locally to OptoRuntime with names that can be generated 147 // from the stub name by appending suffix '_C'. However, in two cases 148 // a common target method also needs to be called from shared runtime 149 // stubs. In these two cases the opto stubs rely on method 150 // imlementations defined in class SharedRuntime. The following 151 // defines temporarily rebind the generated names to reference the 152 // relevant implementations. 153 154 #define GEN_C2_STUB(name, fancy_jump, pass_tls, pass_retpc ) \ 155 C2_STUB_FIELD_NAME(name) = \ 156 generate_stub(env, \ 157 C2_STUB_TYPEFUNC(name), \ 158 C2_STUB_C_FUNC(name), \ 159 C2_STUB_NAME(name), \ 160 fancy_jump, \ 161 pass_tls, \ 162 pass_retpc); \ 163 if (C2_STUB_FIELD_NAME(name) == nullptr) { return false; } \ 164 165 #define C2_JVMTI_STUB_C_FUNC(name) CAST_FROM_FN_PTR(address, SharedRuntime::name) 166 167 #define GEN_C2_JVMTI_STUB(name) \ 168 STUB_FIELD_NAME(name) = \ 169 generate_stub(env, \ 170 notify_jvmti_vthread_Type, \ 171 C2_JVMTI_STUB_C_FUNC(name), \ 172 C2_STUB_NAME(name), \ 173 0, \ 174 true, \ 175 false); \ 176 if (STUB_FIELD_NAME(name) == nullptr) { return false; } \ 177 178 bool OptoRuntime::generate(ciEnv* env) { 179 180 C2_STUBS_DO(GEN_C2_BLOB, GEN_C2_STUB, GEN_C2_JVMTI_STUB) 181 182 return true; 183 } 184 185 #undef GEN_C2_BLOB 186 187 #undef C2_STUB_FIELD_NAME 188 #undef C2_STUB_TYPEFUNC 189 #undef C2_STUB_C_FUNC 190 #undef C2_STUB_NAME 191 #undef GEN_C2_STUB 192 193 #undef C2_JVMTI_STUB_C_FUNC 194 #undef GEN_C2_JVMTI_STUB 195 // #undef gen 196 197 198 // Helper method to do generation of RunTimeStub's 199 address OptoRuntime::generate_stub(ciEnv* env, 200 TypeFunc_generator gen, address C_function, 201 const char *name, int is_fancy_jump, 202 bool pass_tls, 203 bool return_pc) { 204 205 // Matching the default directive, we currently have no method to match. 206 DirectiveSet* directive = DirectivesStack::getDefaultDirective(CompileBroker::compiler(CompLevel_full_optimization)); 207 ResourceMark rm; 208 Compile C(env, gen, C_function, name, is_fancy_jump, pass_tls, return_pc, directive); 209 DirectivesStack::release(directive); 210 return C.stub_entry_point(); 211 } 212 213 const char* OptoRuntime::stub_name(address entry) { 214 #ifndef PRODUCT 215 CodeBlob* cb = CodeCache::find_blob(entry); 216 RuntimeStub* rs =(RuntimeStub *)cb; 217 assert(rs != nullptr && rs->is_runtime_stub(), "not a runtime stub"); 218 return rs->name(); 219 #else 220 // Fast implementation for product mode (maybe it should be inlined too) 221 return "runtime stub"; 222 #endif 223 } 224 225 // local methods passed as arguments to stub generator that forward 226 // control to corresponding JRT methods of SharedRuntime 227 228 void OptoRuntime::slow_arraycopy_C(oopDesc* src, jint src_pos, 229 oopDesc* dest, jint dest_pos, 230 jint length, JavaThread* thread) { 231 SharedRuntime::slow_arraycopy_C(src, src_pos, dest, dest_pos, length, thread); 232 } 233 234 void OptoRuntime::complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current) { 235 SharedRuntime::complete_monitor_locking_C(obj, lock, current); 236 } 237 238 239 //============================================================================= 240 // Opto compiler runtime routines 241 //============================================================================= 242 243 244 //=============================allocation====================================== 245 // We failed the fast-path allocation. Now we need to do a scavenge or GC 246 // and try allocation again. 247 248 // object allocation 249 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, bool is_larval, JavaThread* current)) 250 JRT_BLOCK; 251 #ifndef PRODUCT 252 SharedRuntime::_new_instance_ctr++; // new instance requires GC 253 #endif 254 assert(check_compiled_frame(current), "incorrect caller"); 255 256 // These checks are cheap to make and support reflective allocation. 257 int lh = klass->layout_helper(); 258 if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) { 259 Handle holder(current, klass->klass_holder()); // keep the klass alive 260 klass->check_valid_for_instantiation(false, THREAD); 261 if (!HAS_PENDING_EXCEPTION) { 262 InstanceKlass::cast(klass)->initialize(THREAD); 263 } 264 } 265 266 if (!HAS_PENDING_EXCEPTION) { 267 // Scavenge and allocate an instance. 268 Handle holder(current, klass->klass_holder()); // keep the klass alive 269 instanceOop result = InstanceKlass::cast(klass)->allocate_instance(THREAD); 270 if (is_larval) { 271 // Check if this is a larval buffer allocation 272 result->set_mark(result->mark().enter_larval_state()); 273 } 274 current->set_vm_result(result); 275 276 // Pass oops back through thread local storage. Our apparent type to Java 277 // is that we return an oop, but we can block on exit from this routine and 278 // a GC can trash the oop in C's return register. The generated stub will 279 // fetch the oop from TLS after any possible GC. 280 } 281 282 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 283 JRT_BLOCK_END; 284 285 // inform GC that we won't do card marks for initializing writes. 286 SharedRuntime::on_slowpath_allocation_exit(current); 287 JRT_END 288 289 290 // array allocation 291 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread* current)) 292 JRT_BLOCK; 293 #ifndef PRODUCT 294 SharedRuntime::_new_array_ctr++; // new array requires GC 295 #endif 296 assert(check_compiled_frame(current), "incorrect caller"); 297 298 // Scavenge and allocate an instance. 299 oop result; 300 301 if (array_type->is_flatArray_klass()) { 302 Handle holder(current, array_type->klass_holder()); // keep the array klass alive 303 FlatArrayKlass* fak = FlatArrayKlass::cast(array_type); 304 Klass* elem_type = fak->element_klass(); 305 result = oopFactory::new_flatArray(elem_type, len, fak->layout_kind(), THREAD); 306 } else if (array_type->is_typeArray_klass()) { 307 // The oopFactory likes to work with the element type. 308 // (We could bypass the oopFactory, since it doesn't add much value.) 309 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); 310 result = oopFactory::new_typeArray(elem_type, len, THREAD); 311 } else { 312 Handle holder(current, array_type->klass_holder()); // keep the array klass alive 313 result = ObjArrayKlass::cast(array_type)->allocate(len, THREAD); 314 } 315 316 // Pass oops back through thread local storage. Our apparent type to Java 317 // is that we return an oop, but we can block on exit from this routine and 318 // a GC can trash the oop in C's return register. The generated stub will 319 // fetch the oop from TLS after any possible GC. 320 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 321 current->set_vm_result(result); 322 JRT_BLOCK_END; 323 324 // inform GC that we won't do card marks for initializing writes. 325 SharedRuntime::on_slowpath_allocation_exit(current); 326 JRT_END 327 328 // array allocation without zeroing 329 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread* current)) 330 JRT_BLOCK; 331 #ifndef PRODUCT 332 SharedRuntime::_new_array_ctr++; // new array requires GC 333 #endif 334 assert(check_compiled_frame(current), "incorrect caller"); 335 336 // Scavenge and allocate an instance. 337 oop result; 338 339 assert(array_type->is_typeArray_klass(), "should be called only for type array"); 340 // The oopFactory likes to work with the element type. 341 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); 342 result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD); 343 344 // Pass oops back through thread local storage. Our apparent type to Java 345 // is that we return an oop, but we can block on exit from this routine and 346 // a GC can trash the oop in C's return register. The generated stub will 347 // fetch the oop from TLS after any possible GC. 348 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 349 current->set_vm_result(result); 350 JRT_BLOCK_END; 351 352 353 // inform GC that we won't do card marks for initializing writes. 354 SharedRuntime::on_slowpath_allocation_exit(current); 355 356 oop result = current->vm_result(); 357 if ((len > 0) && (result != nullptr) && 358 is_deoptimized_caller_frame(current)) { 359 // Zero array here if the caller is deoptimized. 360 const size_t size = TypeArrayKlass::cast(array_type)->oop_size(result); 361 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type(); 362 size_t hs_bytes = arrayOopDesc::base_offset_in_bytes(elem_type); 363 assert(is_aligned(hs_bytes, BytesPerInt), "must be 4 byte aligned"); 364 HeapWord* obj = cast_from_oop<HeapWord*>(result); 365 if (!is_aligned(hs_bytes, BytesPerLong)) { 366 *reinterpret_cast<jint*>(reinterpret_cast<char*>(obj) + hs_bytes) = 0; 367 hs_bytes += BytesPerInt; 368 } 369 370 // Optimized zeroing. 371 assert(is_aligned(hs_bytes, BytesPerLong), "must be 8-byte aligned"); 372 const size_t aligned_hs = hs_bytes / BytesPerLong; 373 Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs); 374 } 375 376 JRT_END 377 378 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array. 379 380 // multianewarray for 2 dimensions 381 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread* current)) 382 #ifndef PRODUCT 383 SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension 384 #endif 385 assert(check_compiled_frame(current), "incorrect caller"); 386 assert(elem_type->is_klass(), "not a class"); 387 jint dims[2]; 388 dims[0] = len1; 389 dims[1] = len2; 390 Handle holder(current, elem_type->klass_holder()); // keep the klass alive 391 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD); 392 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 393 current->set_vm_result(obj); 394 JRT_END 395 396 // multianewarray for 3 dimensions 397 JRT_ENTRY(void, OptoRuntime::multianewarray3_C(Klass* elem_type, int len1, int len2, int len3, JavaThread* current)) 398 #ifndef PRODUCT 399 SharedRuntime::_multi3_ctr++; // multianewarray for 1 dimension 400 #endif 401 assert(check_compiled_frame(current), "incorrect caller"); 402 assert(elem_type->is_klass(), "not a class"); 403 jint dims[3]; 404 dims[0] = len1; 405 dims[1] = len2; 406 dims[2] = len3; 407 Handle holder(current, elem_type->klass_holder()); // keep the klass alive 408 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD); 409 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 410 current->set_vm_result(obj); 411 JRT_END 412 413 // multianewarray for 4 dimensions 414 JRT_ENTRY(void, OptoRuntime::multianewarray4_C(Klass* elem_type, int len1, int len2, int len3, int len4, JavaThread* current)) 415 #ifndef PRODUCT 416 SharedRuntime::_multi4_ctr++; // multianewarray for 1 dimension 417 #endif 418 assert(check_compiled_frame(current), "incorrect caller"); 419 assert(elem_type->is_klass(), "not a class"); 420 jint dims[4]; 421 dims[0] = len1; 422 dims[1] = len2; 423 dims[2] = len3; 424 dims[3] = len4; 425 Handle holder(current, elem_type->klass_holder()); // keep the klass alive 426 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD); 427 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 428 current->set_vm_result(obj); 429 JRT_END 430 431 // multianewarray for 5 dimensions 432 JRT_ENTRY(void, OptoRuntime::multianewarray5_C(Klass* elem_type, int len1, int len2, int len3, int len4, int len5, JavaThread* current)) 433 #ifndef PRODUCT 434 SharedRuntime::_multi5_ctr++; // multianewarray for 1 dimension 435 #endif 436 assert(check_compiled_frame(current), "incorrect caller"); 437 assert(elem_type->is_klass(), "not a class"); 438 jint dims[5]; 439 dims[0] = len1; 440 dims[1] = len2; 441 dims[2] = len3; 442 dims[3] = len4; 443 dims[4] = len5; 444 Handle holder(current, elem_type->klass_holder()); // keep the klass alive 445 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD); 446 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 447 current->set_vm_result(obj); 448 JRT_END 449 450 JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread* current)) 451 assert(check_compiled_frame(current), "incorrect caller"); 452 assert(elem_type->is_klass(), "not a class"); 453 assert(oop(dims)->is_typeArray(), "not an array"); 454 455 ResourceMark rm; 456 jint len = dims->length(); 457 assert(len > 0, "Dimensions array should contain data"); 458 jint *c_dims = NEW_RESOURCE_ARRAY(jint, len); 459 ArrayAccess<>::arraycopy_to_native<>(dims, typeArrayOopDesc::element_offset<jint>(0), 460 c_dims, len); 461 462 Handle holder(current, elem_type->klass_holder()); // keep the klass alive 463 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD); 464 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 465 current->set_vm_result(obj); 466 JRT_END 467 468 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notify_C(oopDesc* obj, JavaThread* current)) 469 470 // Very few notify/notifyAll operations find any threads on the waitset, so 471 // the dominant fast-path is to simply return. 472 // Relatedly, it's critical that notify/notifyAll be fast in order to 473 // reduce lock hold times. 474 if (!SafepointSynchronize::is_synchronizing()) { 475 if (ObjectSynchronizer::quick_notify(obj, current, false)) { 476 return; 477 } 478 } 479 480 // This is the case the fast-path above isn't provisioned to handle. 481 // The fast-path is designed to handle frequently arising cases in an efficient manner. 482 // (The fast-path is just a degenerate variant of the slow-path). 483 // Perform the dreaded state transition and pass control into the slow-path. 484 JRT_BLOCK; 485 Handle h_obj(current, obj); 486 ObjectSynchronizer::notify(h_obj, CHECK); 487 JRT_BLOCK_END; 488 JRT_END 489 490 JRT_BLOCK_ENTRY(void, OptoRuntime::monitor_notifyAll_C(oopDesc* obj, JavaThread* current)) 491 492 if (!SafepointSynchronize::is_synchronizing() ) { 493 if (ObjectSynchronizer::quick_notify(obj, current, true)) { 494 return; 495 } 496 } 497 498 // This is the case the fast-path above isn't provisioned to handle. 499 // The fast-path is designed to handle frequently arising cases in an efficient manner. 500 // (The fast-path is just a degenerate variant of the slow-path). 501 // Perform the dreaded state transition and pass control into the slow-path. 502 JRT_BLOCK; 503 Handle h_obj(current, obj); 504 ObjectSynchronizer::notifyall(h_obj, CHECK); 505 JRT_BLOCK_END; 506 JRT_END 507 508 const TypeFunc *OptoRuntime::new_instance_Type() { 509 // create input type (domain) 510 const Type **fields = TypeTuple::fields(2); 511 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated 512 fields[TypeFunc::Parms+1] = TypeInt::BOOL; // is_larval 513 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); 514 515 // create result type (range) 516 fields = TypeTuple::fields(1); 517 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop 518 519 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 520 521 return TypeFunc::make(domain, range); 522 } 523 524 #if INCLUDE_JVMTI 525 const TypeFunc *OptoRuntime::notify_jvmti_vthread_Type() { 526 // create input type (domain) 527 const Type **fields = TypeTuple::fields(2); 528 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // VirtualThread oop 529 fields[TypeFunc::Parms+1] = TypeInt::BOOL; // jboolean 530 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 531 532 // no result type needed 533 fields = TypeTuple::fields(1); 534 fields[TypeFunc::Parms+0] = nullptr; // void 535 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 536 537 return TypeFunc::make(domain,range); 538 } 539 #endif 540 541 const TypeFunc *OptoRuntime::athrow_Type() { 542 // create input type (domain) 543 const Type **fields = TypeTuple::fields(1); 544 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated 545 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 546 547 // create result type (range) 548 fields = TypeTuple::fields(0); 549 550 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 551 552 return TypeFunc::make(domain, range); 553 } 554 555 556 const TypeFunc *OptoRuntime::new_array_Type() { 557 // create input type (domain) 558 const Type **fields = TypeTuple::fields(2); 559 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass 560 fields[TypeFunc::Parms+1] = TypeInt::INT; // array size 561 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); 562 563 // create result type (range) 564 fields = TypeTuple::fields(1); 565 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop 566 567 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 568 569 return TypeFunc::make(domain, range); 570 } 571 572 const TypeFunc *OptoRuntime::new_array_nozero_Type() { 573 return new_array_Type(); 574 } 575 576 const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) { 577 // create input type (domain) 578 const int nargs = ndim + 1; 579 const Type **fields = TypeTuple::fields(nargs); 580 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass 581 for( int i = 1; i < nargs; i++ ) 582 fields[TypeFunc::Parms + i] = TypeInt::INT; // array size 583 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+nargs, fields); 584 585 // create result type (range) 586 fields = TypeTuple::fields(1); 587 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop 588 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 589 590 return TypeFunc::make(domain, range); 591 } 592 593 const TypeFunc *OptoRuntime::multianewarray2_Type() { 594 return multianewarray_Type(2); 595 } 596 597 const TypeFunc *OptoRuntime::multianewarray3_Type() { 598 return multianewarray_Type(3); 599 } 600 601 const TypeFunc *OptoRuntime::multianewarray4_Type() { 602 return multianewarray_Type(4); 603 } 604 605 const TypeFunc *OptoRuntime::multianewarray5_Type() { 606 return multianewarray_Type(5); 607 } 608 609 const TypeFunc *OptoRuntime::multianewarrayN_Type() { 610 // create input type (domain) 611 const Type **fields = TypeTuple::fields(2); 612 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass 613 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // array of dim sizes 614 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); 615 616 // create result type (range) 617 fields = TypeTuple::fields(1); 618 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop 619 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 620 621 return TypeFunc::make(domain, range); 622 } 623 624 const TypeFunc *OptoRuntime::uncommon_trap_Type() { 625 // create input type (domain) 626 const Type **fields = TypeTuple::fields(1); 627 fields[TypeFunc::Parms+0] = TypeInt::INT; // trap_reason (deopt reason and action) 628 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 629 630 // create result type (range) 631 fields = TypeTuple::fields(0); 632 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 633 634 return TypeFunc::make(domain, range); 635 } 636 637 //----------------------------------------------------------------------------- 638 // Monitor Handling 639 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() { 640 // create input type (domain) 641 const Type **fields = TypeTuple::fields(2); 642 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 643 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock 644 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 645 646 // create result type (range) 647 fields = TypeTuple::fields(0); 648 649 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 650 651 return TypeFunc::make(domain, range); 652 } 653 654 const TypeFunc *OptoRuntime::complete_monitor_locking_Type() { 655 return complete_monitor_enter_Type(); 656 } 657 658 //----------------------------------------------------------------------------- 659 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() { 660 // create input type (domain) 661 const Type **fields = TypeTuple::fields(3); 662 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 663 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock - BasicLock 664 fields[TypeFunc::Parms+2] = TypeRawPtr::BOTTOM; // Thread pointer (Self) 665 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+3, fields); 666 667 // create result type (range) 668 fields = TypeTuple::fields(0); 669 670 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 671 672 return TypeFunc::make(domain, range); 673 } 674 675 const TypeFunc *OptoRuntime::monitor_notify_Type() { 676 // create input type (domain) 677 const Type **fields = TypeTuple::fields(1); 678 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked 679 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 680 681 // create result type (range) 682 fields = TypeTuple::fields(0); 683 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 684 return TypeFunc::make(domain, range); 685 } 686 687 const TypeFunc *OptoRuntime::monitor_notifyAll_Type() { 688 return monitor_notify_Type(); 689 } 690 691 const TypeFunc* OptoRuntime::flush_windows_Type() { 692 // create input type (domain) 693 const Type** fields = TypeTuple::fields(1); 694 fields[TypeFunc::Parms+0] = nullptr; // void 695 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); 696 697 // create result type 698 fields = TypeTuple::fields(1); 699 fields[TypeFunc::Parms+0] = nullptr; // void 700 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 701 702 return TypeFunc::make(domain, range); 703 } 704 705 const TypeFunc* OptoRuntime::l2f_Type() { 706 // create input type (domain) 707 const Type **fields = TypeTuple::fields(2); 708 fields[TypeFunc::Parms+0] = TypeLong::LONG; 709 fields[TypeFunc::Parms+1] = Type::HALF; 710 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); 711 712 // create result type (range) 713 fields = TypeTuple::fields(1); 714 fields[TypeFunc::Parms+0] = Type::FLOAT; 715 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 716 717 return TypeFunc::make(domain, range); 718 } 719 720 const TypeFunc* OptoRuntime::modf_Type() { 721 const Type **fields = TypeTuple::fields(2); 722 fields[TypeFunc::Parms+0] = Type::FLOAT; 723 fields[TypeFunc::Parms+1] = Type::FLOAT; 724 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); 725 726 // create result type (range) 727 fields = TypeTuple::fields(1); 728 fields[TypeFunc::Parms+0] = Type::FLOAT; 729 730 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 731 732 return TypeFunc::make(domain, range); 733 } 734 735 const TypeFunc *OptoRuntime::Math_D_D_Type() { 736 // create input type (domain) 737 const Type **fields = TypeTuple::fields(2); 738 // Symbol* name of class to be loaded 739 fields[TypeFunc::Parms+0] = Type::DOUBLE; 740 fields[TypeFunc::Parms+1] = Type::HALF; 741 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); 742 743 // create result type (range) 744 fields = TypeTuple::fields(2); 745 fields[TypeFunc::Parms+0] = Type::DOUBLE; 746 fields[TypeFunc::Parms+1] = Type::HALF; 747 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields); 748 749 return TypeFunc::make(domain, range); 750 } 751 752 const TypeFunc *OptoRuntime::Math_Vector_Vector_Type(uint num_arg, const TypeVect* in_type, const TypeVect* out_type) { 753 // create input type (domain) 754 const Type **fields = TypeTuple::fields(num_arg); 755 // Symbol* name of class to be loaded 756 assert(num_arg > 0, "must have at least 1 input"); 757 for (uint i = 0; i < num_arg; i++) { 758 fields[TypeFunc::Parms+i] = in_type; 759 } 760 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+num_arg, fields); 761 762 // create result type (range) 763 const uint num_ret = 1; 764 fields = TypeTuple::fields(num_ret); 765 fields[TypeFunc::Parms+0] = out_type; 766 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+num_ret, fields); 767 768 return TypeFunc::make(domain, range); 769 } 770 771 const TypeFunc* OptoRuntime::Math_DD_D_Type() { 772 const Type **fields = TypeTuple::fields(4); 773 fields[TypeFunc::Parms+0] = Type::DOUBLE; 774 fields[TypeFunc::Parms+1] = Type::HALF; 775 fields[TypeFunc::Parms+2] = Type::DOUBLE; 776 fields[TypeFunc::Parms+3] = Type::HALF; 777 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+4, fields); 778 779 // create result type (range) 780 fields = TypeTuple::fields(2); 781 fields[TypeFunc::Parms+0] = Type::DOUBLE; 782 fields[TypeFunc::Parms+1] = Type::HALF; 783 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields); 784 785 return TypeFunc::make(domain, range); 786 } 787 788 //-------------- currentTimeMillis, currentTimeNanos, etc 789 790 const TypeFunc* OptoRuntime::void_long_Type() { 791 // create input type (domain) 792 const Type **fields = TypeTuple::fields(0); 793 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields); 794 795 // create result type (range) 796 fields = TypeTuple::fields(2); 797 fields[TypeFunc::Parms+0] = TypeLong::LONG; 798 fields[TypeFunc::Parms+1] = Type::HALF; 799 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields); 800 801 return TypeFunc::make(domain, range); 802 } 803 804 const TypeFunc* OptoRuntime::void_void_Type() { 805 // create input type (domain) 806 const Type **fields = TypeTuple::fields(0); 807 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields); 808 809 // create result type (range) 810 fields = TypeTuple::fields(0); 811 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields); 812 return TypeFunc::make(domain, range); 813 } 814 815 const TypeFunc* OptoRuntime::jfr_write_checkpoint_Type() { 816 // create input type (domain) 817 const Type **fields = TypeTuple::fields(0); 818 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields); 819 820 // create result type (range) 821 fields = TypeTuple::fields(0); 822 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 823 return TypeFunc::make(domain, range); 824 } 825 826 827 // Takes as parameters: 828 // void *dest 829 // long size 830 // uchar byte 831 const TypeFunc* OptoRuntime::make_setmemory_Type() { 832 // create input type (domain) 833 int argcnt = NOT_LP64(3) LP64_ONLY(4); 834 const Type** fields = TypeTuple::fields(argcnt); 835 int argp = TypeFunc::Parms; 836 fields[argp++] = TypePtr::NOTNULL; // dest 837 fields[argp++] = TypeX_X; // size 838 LP64_ONLY(fields[argp++] = Type::HALF); // size 839 fields[argp++] = TypeInt::UBYTE; // bytevalue 840 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 841 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 842 843 // no result type needed 844 fields = TypeTuple::fields(1); 845 fields[TypeFunc::Parms+0] = nullptr; // void 846 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 847 return TypeFunc::make(domain, range); 848 } 849 850 // arraycopy stub variations: 851 enum ArrayCopyType { 852 ac_fast, // void(ptr, ptr, size_t) 853 ac_checkcast, // int(ptr, ptr, size_t, size_t, ptr) 854 ac_slow, // void(ptr, int, ptr, int, int) 855 ac_generic // int(ptr, int, ptr, int, int) 856 }; 857 858 static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) { 859 // create input type (domain) 860 int num_args = (act == ac_fast ? 3 : 5); 861 int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0); 862 int argcnt = num_args; 863 LP64_ONLY(argcnt += num_size_args); // halfwords for lengths 864 const Type** fields = TypeTuple::fields(argcnt); 865 int argp = TypeFunc::Parms; 866 fields[argp++] = TypePtr::NOTNULL; // src 867 if (num_size_args == 0) { 868 fields[argp++] = TypeInt::INT; // src_pos 869 } 870 fields[argp++] = TypePtr::NOTNULL; // dest 871 if (num_size_args == 0) { 872 fields[argp++] = TypeInt::INT; // dest_pos 873 fields[argp++] = TypeInt::INT; // length 874 } 875 while (num_size_args-- > 0) { 876 fields[argp++] = TypeX_X; // size in whatevers (size_t) 877 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length 878 } 879 if (act == ac_checkcast) { 880 fields[argp++] = TypePtr::NOTNULL; // super_klass 881 } 882 assert(argp == TypeFunc::Parms+argcnt, "correct decoding of act"); 883 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 884 885 // create result type if needed 886 int retcnt = (act == ac_checkcast || act == ac_generic ? 1 : 0); 887 fields = TypeTuple::fields(1); 888 if (retcnt == 0) 889 fields[TypeFunc::Parms+0] = nullptr; // void 890 else 891 fields[TypeFunc::Parms+0] = TypeInt::INT; // status result, if needed 892 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+retcnt, fields); 893 return TypeFunc::make(domain, range); 894 } 895 896 const TypeFunc* OptoRuntime::fast_arraycopy_Type() { 897 // This signature is simple: Two base pointers and a size_t. 898 return make_arraycopy_Type(ac_fast); 899 } 900 901 const TypeFunc* OptoRuntime::checkcast_arraycopy_Type() { 902 // An extension of fast_arraycopy_Type which adds type checking. 903 return make_arraycopy_Type(ac_checkcast); 904 } 905 906 const TypeFunc* OptoRuntime::slow_arraycopy_Type() { 907 // This signature is exactly the same as System.arraycopy. 908 // There are no intptr_t (int/long) arguments. 909 return make_arraycopy_Type(ac_slow); 910 } 911 912 const TypeFunc* OptoRuntime::generic_arraycopy_Type() { 913 // This signature is like System.arraycopy, except that it returns status. 914 return make_arraycopy_Type(ac_generic); 915 } 916 917 918 const TypeFunc* OptoRuntime::array_fill_Type() { 919 const Type** fields; 920 int argp = TypeFunc::Parms; 921 // create input type (domain): pointer, int, size_t 922 fields = TypeTuple::fields(3 LP64_ONLY( + 1)); 923 fields[argp++] = TypePtr::NOTNULL; 924 fields[argp++] = TypeInt::INT; 925 fields[argp++] = TypeX_X; // size in whatevers (size_t) 926 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length 927 const TypeTuple *domain = TypeTuple::make(argp, fields); 928 929 // create result type 930 fields = TypeTuple::fields(1); 931 fields[TypeFunc::Parms+0] = nullptr; // void 932 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 933 934 return TypeFunc::make(domain, range); 935 } 936 937 const TypeFunc* OptoRuntime::array_partition_Type() { 938 // create input type (domain) 939 int num_args = 7; 940 int argcnt = num_args; 941 const Type** fields = TypeTuple::fields(argcnt); 942 int argp = TypeFunc::Parms; 943 fields[argp++] = TypePtr::NOTNULL; // array 944 fields[argp++] = TypeInt::INT; // element type 945 fields[argp++] = TypeInt::INT; // low 946 fields[argp++] = TypeInt::INT; // end 947 fields[argp++] = TypePtr::NOTNULL; // pivot_indices (int array) 948 fields[argp++] = TypeInt::INT; // indexPivot1 949 fields[argp++] = TypeInt::INT; // indexPivot2 950 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 951 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 952 953 // no result type needed 954 fields = TypeTuple::fields(1); 955 fields[TypeFunc::Parms+0] = nullptr; // void 956 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 957 return TypeFunc::make(domain, range); 958 } 959 960 const TypeFunc* OptoRuntime::array_sort_Type() { 961 // create input type (domain) 962 int num_args = 4; 963 int argcnt = num_args; 964 const Type** fields = TypeTuple::fields(argcnt); 965 int argp = TypeFunc::Parms; 966 fields[argp++] = TypePtr::NOTNULL; // array 967 fields[argp++] = TypeInt::INT; // element type 968 fields[argp++] = TypeInt::INT; // fromIndex 969 fields[argp++] = TypeInt::INT; // toIndex 970 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 971 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 972 973 // no result type needed 974 fields = TypeTuple::fields(1); 975 fields[TypeFunc::Parms+0] = nullptr; // void 976 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 977 return TypeFunc::make(domain, range); 978 } 979 980 // for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant) 981 const TypeFunc* OptoRuntime::aescrypt_block_Type() { 982 // create input type (domain) 983 int num_args = 3; 984 int argcnt = num_args; 985 const Type** fields = TypeTuple::fields(argcnt); 986 int argp = TypeFunc::Parms; 987 fields[argp++] = TypePtr::NOTNULL; // src 988 fields[argp++] = TypePtr::NOTNULL; // dest 989 fields[argp++] = TypePtr::NOTNULL; // k array 990 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 991 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 992 993 // no result type needed 994 fields = TypeTuple::fields(1); 995 fields[TypeFunc::Parms+0] = nullptr; // void 996 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 997 return TypeFunc::make(domain, range); 998 } 999 1000 /** 1001 * int updateBytesCRC32(int crc, byte* b, int len) 1002 */ 1003 const TypeFunc* OptoRuntime::updateBytesCRC32_Type() { 1004 // create input type (domain) 1005 int num_args = 3; 1006 int argcnt = num_args; 1007 const Type** fields = TypeTuple::fields(argcnt); 1008 int argp = TypeFunc::Parms; 1009 fields[argp++] = TypeInt::INT; // crc 1010 fields[argp++] = TypePtr::NOTNULL; // src 1011 fields[argp++] = TypeInt::INT; // len 1012 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1013 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1014 1015 // result type needed 1016 fields = TypeTuple::fields(1); 1017 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result 1018 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); 1019 return TypeFunc::make(domain, range); 1020 } 1021 1022 /** 1023 * int updateBytesCRC32C(int crc, byte* buf, int len, int* table) 1024 */ 1025 const TypeFunc* OptoRuntime::updateBytesCRC32C_Type() { 1026 // create input type (domain) 1027 int num_args = 4; 1028 int argcnt = num_args; 1029 const Type** fields = TypeTuple::fields(argcnt); 1030 int argp = TypeFunc::Parms; 1031 fields[argp++] = TypeInt::INT; // crc 1032 fields[argp++] = TypePtr::NOTNULL; // buf 1033 fields[argp++] = TypeInt::INT; // len 1034 fields[argp++] = TypePtr::NOTNULL; // table 1035 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1036 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1037 1038 // result type needed 1039 fields = TypeTuple::fields(1); 1040 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result 1041 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); 1042 return TypeFunc::make(domain, range); 1043 } 1044 1045 /** 1046 * int updateBytesAdler32(int adler, bytes* b, int off, int len) 1047 */ 1048 const TypeFunc* OptoRuntime::updateBytesAdler32_Type() { 1049 // create input type (domain) 1050 int num_args = 3; 1051 int argcnt = num_args; 1052 const Type** fields = TypeTuple::fields(argcnt); 1053 int argp = TypeFunc::Parms; 1054 fields[argp++] = TypeInt::INT; // crc 1055 fields[argp++] = TypePtr::NOTNULL; // src + offset 1056 fields[argp++] = TypeInt::INT; // len 1057 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1058 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1059 1060 // result type needed 1061 fields = TypeTuple::fields(1); 1062 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result 1063 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); 1064 return TypeFunc::make(domain, range); 1065 } 1066 1067 // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int 1068 const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() { 1069 // create input type (domain) 1070 int num_args = 5; 1071 int argcnt = num_args; 1072 const Type** fields = TypeTuple::fields(argcnt); 1073 int argp = TypeFunc::Parms; 1074 fields[argp++] = TypePtr::NOTNULL; // src 1075 fields[argp++] = TypePtr::NOTNULL; // dest 1076 fields[argp++] = TypePtr::NOTNULL; // k array 1077 fields[argp++] = TypePtr::NOTNULL; // r array 1078 fields[argp++] = TypeInt::INT; // src len 1079 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1080 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1081 1082 // returning cipher len (int) 1083 fields = TypeTuple::fields(1); 1084 fields[TypeFunc::Parms+0] = TypeInt::INT; 1085 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); 1086 return TypeFunc::make(domain, range); 1087 } 1088 1089 // for electronicCodeBook calls of aescrypt encrypt/decrypt, three pointers and a length, returning int 1090 const TypeFunc* OptoRuntime::electronicCodeBook_aescrypt_Type() { 1091 // create input type (domain) 1092 int num_args = 4; 1093 int argcnt = num_args; 1094 const Type** fields = TypeTuple::fields(argcnt); 1095 int argp = TypeFunc::Parms; 1096 fields[argp++] = TypePtr::NOTNULL; // src 1097 fields[argp++] = TypePtr::NOTNULL; // dest 1098 fields[argp++] = TypePtr::NOTNULL; // k array 1099 fields[argp++] = TypeInt::INT; // src len 1100 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1101 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); 1102 1103 // returning cipher len (int) 1104 fields = TypeTuple::fields(1); 1105 fields[TypeFunc::Parms + 0] = TypeInt::INT; 1106 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); 1107 return TypeFunc::make(domain, range); 1108 } 1109 1110 //for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int 1111 const TypeFunc* OptoRuntime::counterMode_aescrypt_Type() { 1112 // create input type (domain) 1113 int num_args = 7; 1114 int argcnt = num_args; 1115 const Type** fields = TypeTuple::fields(argcnt); 1116 int argp = TypeFunc::Parms; 1117 fields[argp++] = TypePtr::NOTNULL; // src 1118 fields[argp++] = TypePtr::NOTNULL; // dest 1119 fields[argp++] = TypePtr::NOTNULL; // k array 1120 fields[argp++] = TypePtr::NOTNULL; // counter array 1121 fields[argp++] = TypeInt::INT; // src len 1122 fields[argp++] = TypePtr::NOTNULL; // saved_encCounter 1123 fields[argp++] = TypePtr::NOTNULL; // saved used addr 1124 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1125 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); 1126 // returning cipher len (int) 1127 fields = TypeTuple::fields(1); 1128 fields[TypeFunc::Parms + 0] = TypeInt::INT; 1129 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); 1130 return TypeFunc::make(domain, range); 1131 } 1132 1133 //for counterMode calls of aescrypt encrypt/decrypt, four pointers and a length, returning int 1134 const TypeFunc* OptoRuntime::galoisCounterMode_aescrypt_Type() { 1135 // create input type (domain) 1136 int num_args = 8; 1137 int argcnt = num_args; 1138 const Type** fields = TypeTuple::fields(argcnt); 1139 int argp = TypeFunc::Parms; 1140 fields[argp++] = TypePtr::NOTNULL; // byte[] in + inOfs 1141 fields[argp++] = TypeInt::INT; // int len 1142 fields[argp++] = TypePtr::NOTNULL; // byte[] ct + ctOfs 1143 fields[argp++] = TypePtr::NOTNULL; // byte[] out + outOfs 1144 fields[argp++] = TypePtr::NOTNULL; // byte[] key from AESCrypt obj 1145 fields[argp++] = TypePtr::NOTNULL; // long[] state from GHASH obj 1146 fields[argp++] = TypePtr::NOTNULL; // long[] subkeyHtbl from GHASH obj 1147 fields[argp++] = TypePtr::NOTNULL; // byte[] counter from GCTR obj 1148 1149 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1150 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); 1151 // returning cipher len (int) 1152 fields = TypeTuple::fields(1); 1153 fields[TypeFunc::Parms + 0] = TypeInt::INT; 1154 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); 1155 return TypeFunc::make(domain, range); 1156 } 1157 1158 /* 1159 * void implCompress(byte[] buf, int ofs) 1160 */ 1161 const TypeFunc* OptoRuntime::digestBase_implCompress_Type(bool is_sha3) { 1162 // create input type (domain) 1163 int num_args = is_sha3 ? 3 : 2; 1164 int argcnt = num_args; 1165 const Type** fields = TypeTuple::fields(argcnt); 1166 int argp = TypeFunc::Parms; 1167 fields[argp++] = TypePtr::NOTNULL; // buf 1168 fields[argp++] = TypePtr::NOTNULL; // state 1169 if (is_sha3) fields[argp++] = TypeInt::INT; // block_size 1170 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1171 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1172 1173 // no result type needed 1174 fields = TypeTuple::fields(1); 1175 fields[TypeFunc::Parms+0] = nullptr; // void 1176 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1177 return TypeFunc::make(domain, range); 1178 } 1179 1180 /* 1181 * int implCompressMultiBlock(byte[] b, int ofs, int limit) 1182 */ 1183 const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type(bool is_sha3) { 1184 // create input type (domain) 1185 int num_args = is_sha3 ? 5 : 4; 1186 int argcnt = num_args; 1187 const Type** fields = TypeTuple::fields(argcnt); 1188 int argp = TypeFunc::Parms; 1189 fields[argp++] = TypePtr::NOTNULL; // buf 1190 fields[argp++] = TypePtr::NOTNULL; // state 1191 if (is_sha3) fields[argp++] = TypeInt::INT; // block_size 1192 fields[argp++] = TypeInt::INT; // ofs 1193 fields[argp++] = TypeInt::INT; // limit 1194 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1195 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1196 1197 // returning ofs (int) 1198 fields = TypeTuple::fields(1); 1199 fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs 1200 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); 1201 return TypeFunc::make(domain, range); 1202 } 1203 1204 const TypeFunc* OptoRuntime::multiplyToLen_Type() { 1205 // create input type (domain) 1206 int num_args = 5; 1207 int argcnt = num_args; 1208 const Type** fields = TypeTuple::fields(argcnt); 1209 int argp = TypeFunc::Parms; 1210 fields[argp++] = TypePtr::NOTNULL; // x 1211 fields[argp++] = TypeInt::INT; // xlen 1212 fields[argp++] = TypePtr::NOTNULL; // y 1213 fields[argp++] = TypeInt::INT; // ylen 1214 fields[argp++] = TypePtr::NOTNULL; // z 1215 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1216 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1217 1218 // no result type needed 1219 fields = TypeTuple::fields(1); 1220 fields[TypeFunc::Parms+0] = nullptr; 1221 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1222 return TypeFunc::make(domain, range); 1223 } 1224 1225 const TypeFunc* OptoRuntime::squareToLen_Type() { 1226 // create input type (domain) 1227 int num_args = 4; 1228 int argcnt = num_args; 1229 const Type** fields = TypeTuple::fields(argcnt); 1230 int argp = TypeFunc::Parms; 1231 fields[argp++] = TypePtr::NOTNULL; // x 1232 fields[argp++] = TypeInt::INT; // len 1233 fields[argp++] = TypePtr::NOTNULL; // z 1234 fields[argp++] = TypeInt::INT; // zlen 1235 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1236 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1237 1238 // no result type needed 1239 fields = TypeTuple::fields(1); 1240 fields[TypeFunc::Parms+0] = nullptr; 1241 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1242 return TypeFunc::make(domain, range); 1243 } 1244 1245 // for mulAdd calls, 2 pointers and 3 ints, returning int 1246 const TypeFunc* OptoRuntime::mulAdd_Type() { 1247 // create input type (domain) 1248 int num_args = 5; 1249 int argcnt = num_args; 1250 const Type** fields = TypeTuple::fields(argcnt); 1251 int argp = TypeFunc::Parms; 1252 fields[argp++] = TypePtr::NOTNULL; // out 1253 fields[argp++] = TypePtr::NOTNULL; // in 1254 fields[argp++] = TypeInt::INT; // offset 1255 fields[argp++] = TypeInt::INT; // len 1256 fields[argp++] = TypeInt::INT; // k 1257 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1258 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1259 1260 // returning carry (int) 1261 fields = TypeTuple::fields(1); 1262 fields[TypeFunc::Parms+0] = TypeInt::INT; 1263 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); 1264 return TypeFunc::make(domain, range); 1265 } 1266 1267 const TypeFunc* OptoRuntime::montgomeryMultiply_Type() { 1268 // create input type (domain) 1269 int num_args = 7; 1270 int argcnt = num_args; 1271 const Type** fields = TypeTuple::fields(argcnt); 1272 int argp = TypeFunc::Parms; 1273 fields[argp++] = TypePtr::NOTNULL; // a 1274 fields[argp++] = TypePtr::NOTNULL; // b 1275 fields[argp++] = TypePtr::NOTNULL; // n 1276 fields[argp++] = TypeInt::INT; // len 1277 fields[argp++] = TypeLong::LONG; // inv 1278 fields[argp++] = Type::HALF; 1279 fields[argp++] = TypePtr::NOTNULL; // result 1280 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1281 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1282 1283 // result type needed 1284 fields = TypeTuple::fields(1); 1285 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL; 1286 1287 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1288 return TypeFunc::make(domain, range); 1289 } 1290 1291 const TypeFunc* OptoRuntime::montgomerySquare_Type() { 1292 // create input type (domain) 1293 int num_args = 6; 1294 int argcnt = num_args; 1295 const Type** fields = TypeTuple::fields(argcnt); 1296 int argp = TypeFunc::Parms; 1297 fields[argp++] = TypePtr::NOTNULL; // a 1298 fields[argp++] = TypePtr::NOTNULL; // n 1299 fields[argp++] = TypeInt::INT; // len 1300 fields[argp++] = TypeLong::LONG; // inv 1301 fields[argp++] = Type::HALF; 1302 fields[argp++] = TypePtr::NOTNULL; // result 1303 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1304 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1305 1306 // result type needed 1307 fields = TypeTuple::fields(1); 1308 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL; 1309 1310 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1311 return TypeFunc::make(domain, range); 1312 } 1313 1314 const TypeFunc * OptoRuntime::bigIntegerShift_Type() { 1315 int argcnt = 5; 1316 const Type** fields = TypeTuple::fields(argcnt); 1317 int argp = TypeFunc::Parms; 1318 fields[argp++] = TypePtr::NOTNULL; // newArr 1319 fields[argp++] = TypePtr::NOTNULL; // oldArr 1320 fields[argp++] = TypeInt::INT; // newIdx 1321 fields[argp++] = TypeInt::INT; // shiftCount 1322 fields[argp++] = TypeInt::INT; // numIter 1323 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1324 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); 1325 1326 // no result type needed 1327 fields = TypeTuple::fields(1); 1328 fields[TypeFunc::Parms + 0] = nullptr; 1329 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1330 return TypeFunc::make(domain, range); 1331 } 1332 1333 const TypeFunc* OptoRuntime::vectorizedMismatch_Type() { 1334 // create input type (domain) 1335 int num_args = 4; 1336 int argcnt = num_args; 1337 const Type** fields = TypeTuple::fields(argcnt); 1338 int argp = TypeFunc::Parms; 1339 fields[argp++] = TypePtr::NOTNULL; // obja 1340 fields[argp++] = TypePtr::NOTNULL; // objb 1341 fields[argp++] = TypeInt::INT; // length, number of elements 1342 fields[argp++] = TypeInt::INT; // log2scale, element size 1343 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1344 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); 1345 1346 //return mismatch index (int) 1347 fields = TypeTuple::fields(1); 1348 fields[TypeFunc::Parms + 0] = TypeInt::INT; 1349 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); 1350 return TypeFunc::make(domain, range); 1351 } 1352 1353 // GHASH block processing 1354 const TypeFunc* OptoRuntime::ghash_processBlocks_Type() { 1355 int argcnt = 4; 1356 1357 const Type** fields = TypeTuple::fields(argcnt); 1358 int argp = TypeFunc::Parms; 1359 fields[argp++] = TypePtr::NOTNULL; // state 1360 fields[argp++] = TypePtr::NOTNULL; // subkeyH 1361 fields[argp++] = TypePtr::NOTNULL; // data 1362 fields[argp++] = TypeInt::INT; // blocks 1363 assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); 1364 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1365 1366 // result type needed 1367 fields = TypeTuple::fields(1); 1368 fields[TypeFunc::Parms+0] = nullptr; // void 1369 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1370 return TypeFunc::make(domain, range); 1371 } 1372 1373 // ChaCha20 Block function 1374 const TypeFunc* OptoRuntime::chacha20Block_Type() { 1375 int argcnt = 2; 1376 1377 const Type** fields = TypeTuple::fields(argcnt); 1378 int argp = TypeFunc::Parms; 1379 fields[argp++] = TypePtr::NOTNULL; // state 1380 fields[argp++] = TypePtr::NOTNULL; // result 1381 1382 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1383 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + argcnt, fields); 1384 1385 // result type needed 1386 fields = TypeTuple::fields(1); 1387 fields[TypeFunc::Parms + 0] = TypeInt::INT; // key stream outlen as int 1388 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); 1389 return TypeFunc::make(domain, range); 1390 } 1391 1392 // Base64 encode function 1393 const TypeFunc* OptoRuntime::base64_encodeBlock_Type() { 1394 int argcnt = 6; 1395 1396 const Type** fields = TypeTuple::fields(argcnt); 1397 int argp = TypeFunc::Parms; 1398 fields[argp++] = TypePtr::NOTNULL; // src array 1399 fields[argp++] = TypeInt::INT; // offset 1400 fields[argp++] = TypeInt::INT; // length 1401 fields[argp++] = TypePtr::NOTNULL; // dest array 1402 fields[argp++] = TypeInt::INT; // dp 1403 fields[argp++] = TypeInt::BOOL; // isURL 1404 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1405 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1406 1407 // result type needed 1408 fields = TypeTuple::fields(1); 1409 fields[TypeFunc::Parms + 0] = nullptr; // void 1410 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1411 return TypeFunc::make(domain, range); 1412 } 1413 1414 // String IndexOf function 1415 const TypeFunc* OptoRuntime::string_IndexOf_Type() { 1416 int argcnt = 4; 1417 1418 const Type** fields = TypeTuple::fields(argcnt); 1419 int argp = TypeFunc::Parms; 1420 fields[argp++] = TypePtr::NOTNULL; // haystack array 1421 fields[argp++] = TypeInt::INT; // haystack length 1422 fields[argp++] = TypePtr::NOTNULL; // needle array 1423 fields[argp++] = TypeInt::INT; // needle length 1424 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1425 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1426 1427 // result type needed 1428 fields = TypeTuple::fields(1); 1429 fields[TypeFunc::Parms + 0] = TypeInt::INT; // Index of needle in haystack 1430 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); 1431 return TypeFunc::make(domain, range); 1432 } 1433 1434 // Base64 decode function 1435 const TypeFunc* OptoRuntime::base64_decodeBlock_Type() { 1436 int argcnt = 7; 1437 1438 const Type** fields = TypeTuple::fields(argcnt); 1439 int argp = TypeFunc::Parms; 1440 fields[argp++] = TypePtr::NOTNULL; // src array 1441 fields[argp++] = TypeInt::INT; // src offset 1442 fields[argp++] = TypeInt::INT; // src length 1443 fields[argp++] = TypePtr::NOTNULL; // dest array 1444 fields[argp++] = TypeInt::INT; // dest offset 1445 fields[argp++] = TypeInt::BOOL; // isURL 1446 fields[argp++] = TypeInt::BOOL; // isMIME 1447 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1448 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1449 1450 // result type needed 1451 fields = TypeTuple::fields(1); 1452 fields[TypeFunc::Parms + 0] = TypeInt::INT; // count of bytes written to dst 1453 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 1, fields); 1454 return TypeFunc::make(domain, range); 1455 } 1456 1457 // Poly1305 processMultipleBlocks function 1458 const TypeFunc* OptoRuntime::poly1305_processBlocks_Type() { 1459 int argcnt = 4; 1460 1461 const Type** fields = TypeTuple::fields(argcnt); 1462 int argp = TypeFunc::Parms; 1463 fields[argp++] = TypePtr::NOTNULL; // input array 1464 fields[argp++] = TypeInt::INT; // input length 1465 fields[argp++] = TypePtr::NOTNULL; // accumulator array 1466 fields[argp++] = TypePtr::NOTNULL; // r array 1467 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1468 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1469 1470 // result type needed 1471 fields = TypeTuple::fields(1); 1472 fields[TypeFunc::Parms + 0] = nullptr; // void 1473 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1474 return TypeFunc::make(domain, range); 1475 } 1476 1477 // MontgomeryIntegerPolynomialP256 multiply function 1478 const TypeFunc* OptoRuntime::intpoly_montgomeryMult_P256_Type() { 1479 int argcnt = 3; 1480 1481 const Type** fields = TypeTuple::fields(argcnt); 1482 int argp = TypeFunc::Parms; 1483 fields[argp++] = TypePtr::NOTNULL; // a array 1484 fields[argp++] = TypePtr::NOTNULL; // b array 1485 fields[argp++] = TypePtr::NOTNULL; // r(esult) array 1486 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1487 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1488 1489 // result type needed 1490 fields = TypeTuple::fields(1); 1491 fields[TypeFunc::Parms + 0] = nullptr; // void 1492 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1493 return TypeFunc::make(domain, range); 1494 } 1495 1496 // IntegerPolynomial constant time assignment function 1497 const TypeFunc* OptoRuntime::intpoly_assign_Type() { 1498 int argcnt = 4; 1499 1500 const Type** fields = TypeTuple::fields(argcnt); 1501 int argp = TypeFunc::Parms; 1502 fields[argp++] = TypeInt::INT; // set flag 1503 fields[argp++] = TypePtr::NOTNULL; // a array (result) 1504 fields[argp++] = TypePtr::NOTNULL; // b array (if set is set) 1505 fields[argp++] = TypeInt::INT; // array length 1506 assert(argp == TypeFunc::Parms + argcnt, "correct decoding"); 1507 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); 1508 1509 // result type needed 1510 fields = TypeTuple::fields(1); 1511 fields[TypeFunc::Parms + 0] = nullptr; // void 1512 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 1513 return TypeFunc::make(domain, range); 1514 } 1515 1516 //------------- Interpreter state access for on stack replacement 1517 const TypeFunc* OptoRuntime::osr_end_Type() { 1518 // create input type (domain) 1519 const Type **fields = TypeTuple::fields(1); 1520 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf 1521 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields); 1522 1523 // create result type 1524 fields = TypeTuple::fields(1); 1525 // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop 1526 fields[TypeFunc::Parms+0] = nullptr; // void 1527 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields); 1528 return TypeFunc::make(domain, range); 1529 } 1530 1531 //------------------------------------------------------------------------------------- 1532 // register policy 1533 1534 bool OptoRuntime::is_callee_saved_register(MachRegisterNumbers reg) { 1535 assert(reg >= 0 && reg < _last_Mach_Reg, "must be a machine register"); 1536 switch (register_save_policy[reg]) { 1537 case 'C': return false; //SOC 1538 case 'E': return true ; //SOE 1539 case 'N': return false; //NS 1540 case 'A': return false; //AS 1541 } 1542 ShouldNotReachHere(); 1543 return false; 1544 } 1545 1546 //----------------------------------------------------------------------- 1547 // Exceptions 1548 // 1549 1550 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg); 1551 1552 // The method is an entry that is always called by a C++ method not 1553 // directly from compiled code. Compiled code will call the C++ method following. 1554 // We can't allow async exception to be installed during exception processing. 1555 JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* current, nmethod* &nm)) 1556 // The frame we rethrow the exception to might not have been processed by the GC yet. 1557 // The stack watermark barrier takes care of detecting that and ensuring the frame 1558 // has updated oops. 1559 StackWatermarkSet::after_unwind(current); 1560 1561 // Do not confuse exception_oop with pending_exception. The exception_oop 1562 // is only used to pass arguments into the method. Not for general 1563 // exception handling. DO NOT CHANGE IT to use pending_exception, since 1564 // the runtime stubs checks this on exit. 1565 assert(current->exception_oop() != nullptr, "exception oop is found"); 1566 address handler_address = nullptr; 1567 1568 Handle exception(current, current->exception_oop()); 1569 address pc = current->exception_pc(); 1570 1571 // Clear out the exception oop and pc since looking up an 1572 // exception handler can cause class loading, which might throw an 1573 // exception and those fields are expected to be clear during 1574 // normal bytecode execution. 1575 current->clear_exception_oop_and_pc(); 1576 1577 LogTarget(Info, exceptions) lt; 1578 if (lt.is_enabled()) { 1579 ResourceMark rm; 1580 LogStream ls(lt); 1581 trace_exception(&ls, exception(), pc, ""); 1582 } 1583 1584 // for AbortVMOnException flag 1585 Exceptions::debug_check_abort(exception); 1586 1587 #ifdef ASSERT 1588 if (!(exception->is_a(vmClasses::Throwable_klass()))) { 1589 // should throw an exception here 1590 ShouldNotReachHere(); 1591 } 1592 #endif 1593 1594 // new exception handling: this method is entered only from adapters 1595 // exceptions from compiled java methods are handled in compiled code 1596 // using rethrow node 1597 1598 nm = CodeCache::find_nmethod(pc); 1599 assert(nm != nullptr, "No NMethod found"); 1600 if (nm->is_native_method()) { 1601 fatal("Native method should not have path to exception handling"); 1602 } else { 1603 // we are switching to old paradigm: search for exception handler in caller_frame 1604 // instead in exception handler of caller_frame.sender() 1605 1606 if (JvmtiExport::can_post_on_exceptions()) { 1607 // "Full-speed catching" is not necessary here, 1608 // since we're notifying the VM on every catch. 1609 // Force deoptimization and the rest of the lookup 1610 // will be fine. 1611 deoptimize_caller_frame(current); 1612 } 1613 1614 // Check the stack guard pages. If enabled, look for handler in this frame; 1615 // otherwise, forcibly unwind the frame. 1616 // 1617 // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate. 1618 bool force_unwind = !current->stack_overflow_state()->reguard_stack(); 1619 bool deopting = false; 1620 if (nm->is_deopt_pc(pc)) { 1621 deopting = true; 1622 RegisterMap map(current, 1623 RegisterMap::UpdateMap::skip, 1624 RegisterMap::ProcessFrames::include, 1625 RegisterMap::WalkContinuation::skip); 1626 frame deoptee = current->last_frame().sender(&map); 1627 assert(deoptee.is_deoptimized_frame(), "must be deopted"); 1628 // Adjust the pc back to the original throwing pc 1629 pc = deoptee.pc(); 1630 } 1631 1632 // If we are forcing an unwind because of stack overflow then deopt is 1633 // irrelevant since we are throwing the frame away anyway. 1634 1635 if (deopting && !force_unwind) { 1636 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception(); 1637 } else { 1638 1639 handler_address = 1640 force_unwind ? nullptr : nm->handler_for_exception_and_pc(exception, pc); 1641 1642 if (handler_address == nullptr) { 1643 bool recursive_exception = false; 1644 handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception); 1645 assert (handler_address != nullptr, "must have compiled handler"); 1646 // Update the exception cache only when the unwind was not forced 1647 // and there didn't happen another exception during the computation of the 1648 // compiled exception handler. Checking for exception oop equality is not 1649 // sufficient because some exceptions are pre-allocated and reused. 1650 if (!force_unwind && !recursive_exception) { 1651 nm->add_handler_for_exception_and_pc(exception,pc,handler_address); 1652 } 1653 } else { 1654 #ifdef ASSERT 1655 bool recursive_exception = false; 1656 address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception); 1657 vmassert(recursive_exception || (handler_address == computed_address), "Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT, 1658 p2i(handler_address), p2i(computed_address)); 1659 #endif 1660 } 1661 } 1662 1663 current->set_exception_pc(pc); 1664 current->set_exception_handler_pc(handler_address); 1665 1666 // Check if the exception PC is a MethodHandle call site. 1667 current->set_is_method_handle_return(nm->is_method_handle_return(pc)); 1668 } 1669 1670 // Restore correct return pc. Was saved above. 1671 current->set_exception_oop(exception()); 1672 return handler_address; 1673 1674 JRT_END 1675 1676 // We are entering here from exception_blob 1677 // If there is a compiled exception handler in this method, we will continue there; 1678 // otherwise we will unwind the stack and continue at the caller of top frame method 1679 // Note we enter without the usual JRT wrapper. We will call a helper routine that 1680 // will do the normal VM entry. We do it this way so that we can see if the nmethod 1681 // we looked up the handler for has been deoptimized in the meantime. If it has been 1682 // we must not use the handler and instead return the deopt blob. 1683 address OptoRuntime::handle_exception_C(JavaThread* current) { 1684 // 1685 // We are in Java not VM and in debug mode we have a NoHandleMark 1686 // 1687 #ifndef PRODUCT 1688 SharedRuntime::_find_handler_ctr++; // find exception handler 1689 #endif 1690 debug_only(NoHandleMark __hm;) 1691 nmethod* nm = nullptr; 1692 address handler_address = nullptr; 1693 { 1694 // Enter the VM 1695 1696 ResetNoHandleMark rnhm; 1697 handler_address = handle_exception_C_helper(current, nm); 1698 } 1699 1700 // Back in java: Use no oops, DON'T safepoint 1701 1702 // Now check to see if the handler we are returning is in a now 1703 // deoptimized frame 1704 1705 if (nm != nullptr) { 1706 RegisterMap map(current, 1707 RegisterMap::UpdateMap::skip, 1708 RegisterMap::ProcessFrames::skip, 1709 RegisterMap::WalkContinuation::skip); 1710 frame caller = current->last_frame().sender(&map); 1711 #ifdef ASSERT 1712 assert(caller.is_compiled_frame(), "must be"); 1713 #endif // ASSERT 1714 if (caller.is_deoptimized_frame()) { 1715 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception(); 1716 } 1717 } 1718 return handler_address; 1719 } 1720 1721 //------------------------------rethrow---------------------------------------- 1722 // We get here after compiled code has executed a 'RethrowNode'. The callee 1723 // is either throwing or rethrowing an exception. The callee-save registers 1724 // have been restored, synchronized objects have been unlocked and the callee 1725 // stack frame has been removed. The return address was passed in. 1726 // Exception oop is passed as the 1st argument. This routine is then called 1727 // from the stub. On exit, we know where to jump in the caller's code. 1728 // After this C code exits, the stub will pop his frame and end in a jump 1729 // (instead of a return). We enter the caller's default handler. 1730 // 1731 // This must be JRT_LEAF: 1732 // - caller will not change its state as we cannot block on exit, 1733 // therefore raw_exception_handler_for_return_address is all it takes 1734 // to handle deoptimized blobs 1735 // 1736 // However, there needs to be a safepoint check in the middle! So compiled 1737 // safepoints are completely watertight. 1738 // 1739 // Thus, it cannot be a leaf since it contains the NoSafepointVerifier. 1740 // 1741 // *THIS IS NOT RECOMMENDED PROGRAMMING STYLE* 1742 // 1743 address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) { 1744 // ret_pc will have been loaded from the stack, so for AArch64 will be signed. 1745 AARCH64_PORT_ONLY(ret_pc = pauth_strip_verifiable(ret_pc)); 1746 1747 #ifndef PRODUCT 1748 SharedRuntime::_rethrow_ctr++; // count rethrows 1749 #endif 1750 assert (exception != nullptr, "should have thrown a NullPointerException"); 1751 #ifdef ASSERT 1752 if (!(exception->is_a(vmClasses::Throwable_klass()))) { 1753 // should throw an exception here 1754 ShouldNotReachHere(); 1755 } 1756 #endif 1757 1758 thread->set_vm_result(exception); 1759 // Frame not compiled (handles deoptimization blob) 1760 return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc); 1761 } 1762 1763 1764 const TypeFunc *OptoRuntime::rethrow_Type() { 1765 // create input type (domain) 1766 const Type **fields = TypeTuple::fields(1); 1767 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop 1768 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields); 1769 1770 // create result type (range) 1771 fields = TypeTuple::fields(1); 1772 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop 1773 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); 1774 1775 return TypeFunc::make(domain, range); 1776 } 1777 1778 1779 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) { 1780 // Deoptimize the caller before continuing, as the compiled 1781 // exception handler table may not be valid. 1782 if (!StressCompiledExceptionHandlers && doit) { 1783 deoptimize_caller_frame(thread); 1784 } 1785 } 1786 1787 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) { 1788 // Called from within the owner thread, so no need for safepoint 1789 RegisterMap reg_map(thread, 1790 RegisterMap::UpdateMap::include, 1791 RegisterMap::ProcessFrames::include, 1792 RegisterMap::WalkContinuation::skip); 1793 frame stub_frame = thread->last_frame(); 1794 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check"); 1795 frame caller_frame = stub_frame.sender(®_map); 1796 1797 // Deoptimize the caller frame. 1798 Deoptimization::deoptimize_frame(thread, caller_frame.id()); 1799 } 1800 1801 1802 bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) { 1803 // Called from within the owner thread, so no need for safepoint 1804 RegisterMap reg_map(thread, 1805 RegisterMap::UpdateMap::include, 1806 RegisterMap::ProcessFrames::include, 1807 RegisterMap::WalkContinuation::skip); 1808 frame stub_frame = thread->last_frame(); 1809 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check"); 1810 frame caller_frame = stub_frame.sender(®_map); 1811 return caller_frame.is_deoptimized_frame(); 1812 } 1813 1814 const TypeFunc *OptoRuntime::register_finalizer_Type() { 1815 // create input type (domain) 1816 const Type **fields = TypeTuple::fields(1); 1817 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver 1818 // // The JavaThread* is passed to each routine as the last argument 1819 // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread 1820 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields); 1821 1822 // create result type (range) 1823 fields = TypeTuple::fields(0); 1824 1825 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 1826 1827 return TypeFunc::make(domain, range); 1828 } 1829 1830 #if INCLUDE_JFR 1831 const TypeFunc *OptoRuntime::class_id_load_barrier_Type() { 1832 // create input type (domain) 1833 const Type **fields = TypeTuple::fields(1); 1834 fields[TypeFunc::Parms+0] = TypeInstPtr::KLASS; 1835 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms + 1, fields); 1836 1837 // create result type (range) 1838 fields = TypeTuple::fields(0); 1839 1840 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms + 0, fields); 1841 1842 return TypeFunc::make(domain,range); 1843 } 1844 #endif 1845 1846 //----------------------------------------------------------------------------- 1847 // Dtrace support. entry and exit probes have the same signature 1848 const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() { 1849 // create input type (domain) 1850 const Type **fields = TypeTuple::fields(2); 1851 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage 1852 fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering 1853 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 1854 1855 // create result type (range) 1856 fields = TypeTuple::fields(0); 1857 1858 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 1859 1860 return TypeFunc::make(domain, range); 1861 } 1862 1863 const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() { 1864 // create input type (domain) 1865 const Type **fields = TypeTuple::fields(2); 1866 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage 1867 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // oop; newly allocated object 1868 1869 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields); 1870 1871 // create result type (range) 1872 fields = TypeTuple::fields(0); 1873 1874 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields); 1875 1876 return TypeFunc::make(domain, range); 1877 } 1878 1879 1880 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current)) 1881 assert(oopDesc::is_oop(obj), "must be a valid oop"); 1882 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise"); 1883 InstanceKlass::register_finalizer(instanceOop(obj), CHECK); 1884 JRT_END 1885 1886 //----------------------------------------------------------------------------- 1887 1888 NamedCounter * volatile OptoRuntime::_named_counters = nullptr; 1889 1890 // 1891 // dump the collected NamedCounters. 1892 // 1893 void OptoRuntime::print_named_counters() { 1894 int total_lock_count = 0; 1895 int eliminated_lock_count = 0; 1896 1897 NamedCounter* c = _named_counters; 1898 while (c) { 1899 if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) { 1900 int count = c->count(); 1901 if (count > 0) { 1902 bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter; 1903 if (Verbose) { 1904 tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : ""); 1905 } 1906 total_lock_count += count; 1907 if (eliminated) { 1908 eliminated_lock_count += count; 1909 } 1910 } 1911 } 1912 c = c->next(); 1913 } 1914 if (total_lock_count > 0) { 1915 tty->print_cr("dynamic locks: %d", total_lock_count); 1916 if (eliminated_lock_count) { 1917 tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count, 1918 (int)(eliminated_lock_count * 100.0 / total_lock_count)); 1919 } 1920 } 1921 } 1922 1923 // 1924 // Allocate a new NamedCounter. The JVMState is used to generate the 1925 // name which consists of method@line for the inlining tree. 1926 // 1927 1928 NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) { 1929 int max_depth = youngest_jvms->depth(); 1930 1931 // Visit scopes from youngest to oldest. 1932 bool first = true; 1933 stringStream st; 1934 for (int depth = max_depth; depth >= 1; depth--) { 1935 JVMState* jvms = youngest_jvms->of_depth(depth); 1936 ciMethod* m = jvms->has_method() ? jvms->method() : nullptr; 1937 if (!first) { 1938 st.print(" "); 1939 } else { 1940 first = false; 1941 } 1942 int bci = jvms->bci(); 1943 if (bci < 0) bci = 0; 1944 if (m != nullptr) { 1945 st.print("%s.%s", m->holder()->name()->as_utf8(), m->name()->as_utf8()); 1946 } else { 1947 st.print("no method"); 1948 } 1949 st.print("@%d", bci); 1950 // To print linenumbers instead of bci use: m->line_number_from_bci(bci) 1951 } 1952 NamedCounter* c = new NamedCounter(st.freeze(), tag); 1953 1954 // atomically add the new counter to the head of the list. We only 1955 // add counters so this is safe. 1956 NamedCounter* head; 1957 do { 1958 c->set_next(nullptr); 1959 head = _named_counters; 1960 c->set_next(head); 1961 } while (Atomic::cmpxchg(&_named_counters, head, c) != head); 1962 return c; 1963 } 1964 1965 int trace_exception_counter = 0; 1966 static void trace_exception(outputStream* st, oop exception_oop, address exception_pc, const char* msg) { 1967 trace_exception_counter++; 1968 stringStream tempst; 1969 1970 tempst.print("%d [Exception (%s): ", trace_exception_counter, msg); 1971 exception_oop->print_value_on(&tempst); 1972 tempst.print(" in "); 1973 CodeBlob* blob = CodeCache::find_blob(exception_pc); 1974 if (blob->is_nmethod()) { 1975 blob->as_nmethod()->method()->print_value_on(&tempst); 1976 } else if (blob->is_runtime_stub()) { 1977 tempst.print("<runtime-stub>"); 1978 } else { 1979 tempst.print("<unknown>"); 1980 } 1981 tempst.print(" at " INTPTR_FORMAT, p2i(exception_pc)); 1982 tempst.print("]"); 1983 1984 st->print_raw_cr(tempst.freeze()); 1985 } 1986 1987 const TypeFunc *OptoRuntime::store_inline_type_fields_Type() { 1988 // create input type (domain) 1989 uint total = SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2; 1990 const Type **fields = TypeTuple::fields(total); 1991 // We don't know the number of returned values and their 1992 // types. Assume all registers available to the return convention 1993 // are used. 1994 fields[TypeFunc::Parms] = TypePtr::BOTTOM; 1995 uint i = 1; 1996 for (; i < SharedRuntime::java_return_convention_max_int; i++) { 1997 fields[TypeFunc::Parms+i] = TypeInt::INT; 1998 } 1999 for (; i < total; i+=2) { 2000 fields[TypeFunc::Parms+i] = Type::DOUBLE; 2001 fields[TypeFunc::Parms+i+1] = Type::HALF; 2002 } 2003 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields); 2004 2005 // create result type (range) 2006 fields = TypeTuple::fields(1); 2007 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; 2008 2009 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields); 2010 2011 return TypeFunc::make(domain, range); 2012 } 2013 2014 const TypeFunc *OptoRuntime::pack_inline_type_Type() { 2015 // create input type (domain) 2016 uint total = 1 + SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2; 2017 const Type **fields = TypeTuple::fields(total); 2018 // We don't know the number of returned values and their 2019 // types. Assume all registers available to the return convention 2020 // are used. 2021 fields[TypeFunc::Parms] = TypeRawPtr::BOTTOM; 2022 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; 2023 uint i = 2; 2024 for (; i < SharedRuntime::java_return_convention_max_int+1; i++) { 2025 fields[TypeFunc::Parms+i] = TypeInt::INT; 2026 } 2027 for (; i < total; i+=2) { 2028 fields[TypeFunc::Parms+i] = Type::DOUBLE; 2029 fields[TypeFunc::Parms+i+1] = Type::HALF; 2030 } 2031 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields); 2032 2033 // create result type (range) 2034 fields = TypeTuple::fields(1); 2035 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; 2036 2037 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields); 2038 2039 return TypeFunc::make(domain, range); 2040 } 2041 2042 JRT_BLOCK_ENTRY(void, OptoRuntime::load_unknown_inline_C(flatArrayOopDesc* array, int index, JavaThread* current)) 2043 JRT_BLOCK; 2044 oop buffer = array->read_value_from_flat_array(index, THREAD); 2045 deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION); 2046 current->set_vm_result(buffer); 2047 JRT_BLOCK_END; 2048 JRT_END 2049 2050 const TypeFunc* OptoRuntime::load_unknown_inline_Type() { 2051 // create input type (domain) 2052 const Type** fields = TypeTuple::fields(2); 2053 fields[TypeFunc::Parms] = TypeOopPtr::NOTNULL; 2054 fields[TypeFunc::Parms+1] = TypeInt::POS; 2055 2056 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+2, fields); 2057 2058 // create result type (range) 2059 fields = TypeTuple::fields(1); 2060 fields[TypeFunc::Parms] = TypeInstPtr::NOTNULL; 2061 2062 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); 2063 2064 return TypeFunc::make(domain, range); 2065 } 2066 2067 JRT_BLOCK_ENTRY(void, OptoRuntime::store_unknown_inline_C(instanceOopDesc* buffer, flatArrayOopDesc* array, int index, JavaThread* current)) 2068 JRT_BLOCK; 2069 assert(buffer != nullptr, "can't store null into flat array"); 2070 array->write_value_to_flat_array(buffer, index, THREAD); 2071 if (HAS_PENDING_EXCEPTION) { 2072 fatal("This entry must be changed to be a non-leaf entry because writing to a flat array can now throw an exception"); 2073 } 2074 JRT_BLOCK_END; 2075 JRT_END 2076 2077 const TypeFunc* OptoRuntime::store_unknown_inline_Type() { 2078 // create input type (domain) 2079 const Type** fields = TypeTuple::fields(3); 2080 fields[TypeFunc::Parms] = TypeInstPtr::NOTNULL; 2081 fields[TypeFunc::Parms+1] = TypeOopPtr::NOTNULL; 2082 fields[TypeFunc::Parms+2] = TypeInt::POS; 2083 2084 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+3, fields); 2085 2086 // create result type (range) 2087 fields = TypeTuple::fields(0); 2088 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); 2089 2090 return TypeFunc::make(domain, range); 2091 }