github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/jit-interp.c (about) 1 /* 2 * jit-interp.c - Fallback interpreter implementation. 3 * 4 * Copyright (C) 2004 Southern Storm Software, Pty Ltd. 5 * 6 * This file is part of the libjit library. 7 * 8 * The libjit library is free software: you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public License 10 * as published by the Free Software Foundation, either version 2.1 of 11 * the License, or (at your option) any later version. 12 * 13 * The libjit library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with the libjit library. If not, see 20 * <http://www.gnu.org/licenses/>. 21 */ 22 23 /* 24 25 This file must be compiled with a C++ compiler, because it uses 26 C++ exceptions to manage JIT exception throws. It is otherwise 27 straight vanilla ANSI C. 28 29 */ 30 31 #include "jit-interp.h" 32 #include "jit-rules.h" 33 #if HAVE_STDLIB_H 34 #include <stdlib.h> 35 #endif 36 #if HAVE_ALLOCA_H 37 #include <alloca.h> 38 #endif 39 #ifdef JIT_WIN32_PLATFORM 40 #include <malloc.h> 41 #ifndef alloca 42 #define alloca _alloca 43 #endif 44 #endif 45 #include "jit-setjmp.h" 46 47 #if defined(JIT_BACKEND_INTERP) 48 49 /* 50 * Determine what kind of interpreter dispatch to use. 51 */ 52 #ifdef HAVE_COMPUTED_GOTO 53 #if defined(PIC) && defined(HAVE_PIC_COMPUTED_GOTO) 54 #define JIT_INTERP_TOKEN_PIC 1 55 #elif defined(PIC) 56 #define JIT_INTERP_SWITCH 1 57 #else 58 #define JIT_INTERP_TOKEN 1 59 #endif 60 #else /* !HAVE_COMPUTED_GOTO */ 61 #define JIT_INTERP_SWITCH 1 62 #endif /* !HAVE_COMPUTED_GOTO */ 63 64 /* 65 * Modify the program counter and stack pointer. 66 */ 67 #define VM_MODIFY_PC_AND_STACK(pcmod,stkmod) \ 68 do { \ 69 pc += (jit_nint)(int)(pcmod); \ 70 stacktop += (jit_nint)(int)(stkmod); \ 71 } while (0) 72 #define VM_MODIFY_PC(pcmod) \ 73 do { \ 74 pc += (jit_nint)(int)(pcmod); \ 75 } while (0) 76 #define VM_MODIFY_STACK(stkmod) \ 77 do { \ 78 stacktop += (jit_nint)(int)(stkmod); \ 79 } while (0) 80 81 /* 82 * Fetch arguments of various types from the instruction stream. 83 */ 84 #define VM_NINT_ARG (((jit_nint *)(pc))[1]) 85 #define VM_NINT_ARG2 (((jit_nint *)(pc))[2]) 86 #define VM_NINT_ARG3 (((jit_nint *)(pc))[3]) 87 #define VM_BR_TARGET (pc + VM_NINT_ARG) 88 89 /* 90 * Fetch registers of various types. 91 */ 92 #define VM_R0_INT (r0.int_value) 93 #define VM_R0_UINT (r0.uint_value) 94 #define VM_R0_LONG (r0.long_value) 95 #define VM_R0_ULONG (r0.ulong_value) 96 #define VM_R0_FLOAT32 (r0.float32_value) 97 #define VM_R0_FLOAT64 (r0.float64_value) 98 #define VM_R0_NFLOAT (r0.nfloat_value) 99 #define VM_R0_PTR (r0.ptr_value) 100 #define VM_R1_INT (r1.int_value) 101 #define VM_R1_UINT (r1.uint_value) 102 #define VM_R1_LONG (r1.long_value) 103 #define VM_R1_ULONG (r1.ulong_value) 104 #define VM_R1_FLOAT32 (r1.float32_value) 105 #define VM_R1_FLOAT64 (r1.float64_value) 106 #define VM_R1_NFLOAT (r1.nfloat_value) 107 #define VM_R1_PTR (r1.ptr_value) 108 #define VM_R2_INT (r2.int_value) 109 #define VM_R2_UINT (r2.uint_value) 110 #define VM_R2_LONG (r2.long_value) 111 #define VM_R2_ULONG (r2.ulong_value) 112 #define VM_R2_FLOAT32 (r2.float32_value) 113 #define VM_R2_FLOAT64 (r2.float64_value) 114 #define VM_R2_NFLOAT (r2.nfloat_value) 115 #define VM_R2_PTR (r2.ptr_value) 116 #ifdef JIT_NATIVE_INT32 117 #define VM_R0_NINT VM_RO_INT 118 #define VM_R0_NUINT VM_RO_UINT 119 #define VM_R1_NINT VM_R1_INT 120 #define VM_R1_NUINT VM_R1_UINT 121 #define VM_R2_NINT VM_R2_INT 122 #define VM_R2_NUINT VM_R2_UINT 123 #else 124 #define VM_R0_NINT VM_RO_LONG 125 #define VM_R0_NUINT VM_RO_ULONG 126 #define VM_R1_NINT VM_R1_LONG 127 #define VM_R1_NUINT VM_R1_ULONG 128 #define VM_R2_NINT VM_R2_LONG 129 #define VM_R2_NUINT VM_R2_LONG 130 #endif 131 132 /* 133 * Fetch stack items from various positions. 134 */ 135 #define VM_STK_INT0 (stacktop[0].int_value) 136 #define VM_STK_INT1 (stacktop[1].int_value) 137 #define VM_STK_INTP (stacktop[-1].int_value) 138 #define VM_STK_UINT0 (stacktop[0].uint_value) 139 #define VM_STK_UINT1 (stacktop[1].uint_value) 140 #define VM_STK_UINTP (stacktop[-1].uint_value) 141 #define VM_STK_LONG0 (stacktop[0].long_value) 142 #define VM_STK_LONG1 (stacktop[1].long_value) 143 #define VM_STK_LONGP (stacktop[-1].long_value) 144 #define VM_STK_ULONG0 (stacktop[0].ulong_value) 145 #define VM_STK_ULONG1 (stacktop[1].ulong_value) 146 #define VM_STK_ULONGP (stacktop[-1].ulong_value) 147 #define VM_STK_FLOAT320 (stacktop[0].float32_value) 148 #define VM_STK_FLOAT321 (stacktop[1].float32_value) 149 #define VM_STK_FLOAT32P (stacktop[-1].float32_value) 150 #define VM_STK_FLOAT640 (stacktop[0].float64_value) 151 #define VM_STK_FLOAT641 (stacktop[1].float64_value) 152 #define VM_STK_FLOAT64P (stacktop[-1].float64_value) 153 #define VM_STK_NFLOAT0 (stacktop[0].nfloat_value) 154 #define VM_STK_NFLOAT1 (stacktop[1].nfloat_value) 155 #define VM_STK_NFLOATP (stacktop[-1].nfloat_value) 156 #define VM_STK_PTR0 (stacktop[0].ptr_value) 157 #define VM_STK_PTR1 (stacktop[1].ptr_value) 158 #define VM_STK_PTR2 (stacktop[2].ptr_value) 159 #define VM_STK_PTRP (stacktop[-1].ptr_value) 160 #define VM_STK_PTRP2 (stacktop[-2].ptr_value) 161 #ifdef JIT_NATIVE_INT32 162 #define VM_STK_NINT0 VM_STK_INT0 163 #define VM_STK_NINT1 VM_STK_INT1 164 #define VM_STK_NUINT0 VM_STK_UINT0 165 #define VM_STK_NUINT1 VM_STK_UINT1 166 #else 167 #define VM_STK_NINT0 VM_STK_LONG0 168 #define VM_STK_NINT1 VM_STK_LONG1 169 #define VM_STK_NUINT0 VM_STK_ULONG0 170 #define VM_STK_NUINT1 VM_STK_ULONG1 171 #endif 172 173 /* 174 * Apply a relative adjustment to a pointer and cast to a specific type. 175 */ 176 #define VM_REL(type,ptr) \ 177 ((type *)(((unsigned char *)(ptr)) + VM_NINT_ARG)) 178 179 /* 180 * Apply an array adjustment to a pointer. 181 */ 182 #define VM_LOAD_ELEM(type) \ 183 (*(((type *)VM_R1_PTR) + VM_R2_NINT)) 184 #define VM_STORE_ELEM(type,value) \ 185 (*(((type *)VM_R0_PTR) + VM_R1_NINT) = (type)(value)) 186 187 /* 188 * Get the address of an argument or local variable at a particular offset. 189 */ 190 #define VM_ARG(type) \ 191 ((type *)(((jit_item *)args) + VM_NINT_ARG)) 192 #define VM_LOC(type) \ 193 ((type *)(((jit_item *)frame) + VM_NINT_ARG)) 194 195 /* 196 * Handle the return value from a function that reports a builtin exception. 197 */ 198 #define VM_BUILTIN(value) \ 199 do { \ 200 builtin_exception = (value); \ 201 if(builtin_exception < JIT_RESULT_OK) \ 202 { \ 203 goto handle_builtin; \ 204 } \ 205 } while (0) 206 207 /* 208 * Perform a tail call to a new function. 209 */ 210 #define VM_PERFORM_TAIL(newfunc) \ 211 { \ 212 if(jbuf) \ 213 { \ 214 _jit_unwind_pop_setjmp(); \ 215 } \ 216 func = (newfunc); \ 217 if(func->frame_size > current_frame_size) \ 218 { \ 219 current_frame_size = func->frame_size; \ 220 frame_base = (jit_item *)alloca(current_frame_size); \ 221 } \ 222 stacktop = frame_base + func->working_area; \ 223 frame = stacktop; \ 224 goto restart_tail; \ 225 } 226 227 /* 228 * Call "jit_apply" from the interpreter, to invoke a native function. 229 */ 230 static void apply_from_interpreter 231 (jit_type_t signature, void *func, 232 jit_item *args, unsigned int num_fixed_args, 233 void *return_area) 234 { 235 unsigned int num_params; 236 unsigned int param; 237 jit_type_t type; 238 void **apply_args; 239 240 /* Allocate space for the apply arguments and initialize them */ 241 num_params = jit_type_num_params(signature); 242 apply_args = (void **)alloca(sizeof(void *) * num_params); 243 for(param = 0; param < num_params; ++param) 244 { 245 type = jit_type_normalize(jit_type_get_param(signature, param)); 246 switch(type->kind) 247 { 248 case JIT_TYPE_SBYTE: 249 case JIT_TYPE_UBYTE: 250 { 251 apply_args[param] = 252 ((unsigned char *)args) + _jit_int_lowest_byte(); 253 ++args; 254 } 255 break; 256 257 case JIT_TYPE_SHORT: 258 case JIT_TYPE_USHORT: 259 { 260 apply_args[param] = 261 ((unsigned char *)args) + _jit_int_lowest_short(); 262 ++args; 263 } 264 break; 265 266 case JIT_TYPE_INT: 267 case JIT_TYPE_UINT: 268 case JIT_TYPE_LONG: 269 case JIT_TYPE_ULONG: 270 case JIT_TYPE_FLOAT32: 271 case JIT_TYPE_FLOAT64: 272 case JIT_TYPE_NFLOAT: 273 { 274 apply_args[param] = args; 275 ++args; 276 } 277 break; 278 279 case JIT_TYPE_STRUCT: 280 case JIT_TYPE_UNION: 281 { 282 apply_args[param] = args; 283 args += JIT_NUM_ITEMS_IN_STRUCT(jit_type_get_size(type)); 284 } 285 break; 286 287 default: 288 { 289 /* Shouldn't happen, but do something sane */ 290 apply_args[param] = args; 291 } 292 break; 293 } 294 } 295 296 /* Apply the function */ 297 jit_apply(signature, func, apply_args, num_fixed_args, return_area); 298 } 299 300 void _jit_run_function(jit_function_interp_t func, jit_item *args, 301 jit_item *return_area) 302 { 303 jit_item *frame_base; 304 jit_item *frame; 305 jit_item *stacktop; 306 jit_item r0, r1, r2; 307 void **pc; 308 jit_int builtin_exception; 309 jit_nint temparg; 310 void *tempptr; 311 void *tempptr2; 312 jit_nint arguments_pointer_offset; 313 jit_function_t call_func; 314 struct jit_backtrace call_trace; 315 void *entry; 316 void *exception_object = 0; 317 void *exception_pc = 0; 318 void *handler; 319 jit_jmp_buf *jbuf; 320 jit_nint current_frame_size; 321 322 /* Define the label table for computed goto dispatch */ 323 #include "jit-interp-labels.h" 324 325 /* Set up the stack frame for this function */ 326 current_frame_size = func->frame_size; 327 frame_base = (jit_item *)alloca(current_frame_size); 328 stacktop = frame_base + func->working_area; 329 frame = stacktop; 330 331 /* Get the initial program counter */ 332 restart_tail: 333 pc = jit_function_interp_entry_pc(func); 334 335 /* Create a "setjmp" point if this function has a "try" block. 336 This is used to catch exceptions on their way up the stack */ 337 if(func->func->has_try) 338 { 339 jbuf = (jit_jmp_buf *)alloca(sizeof(jit_jmp_buf)); 340 _jit_unwind_push_setjmp(jbuf); 341 if(setjmp(jbuf->buf)) 342 { 343 /* An exception has been thrown by lower-level code */ 344 exception_object = jit_exception_get_last_and_clear(); 345 exception_pc = pc - 1; 346 goto handle_exception; 347 } 348 } 349 else 350 { 351 jbuf = 0; 352 } 353 354 arguments_pointer_offset = func->func->arguments_pointer_offset; 355 if(arguments_pointer_offset >= 0) 356 { 357 frame[arguments_pointer_offset].ptr_value = args; 358 } 359 360 /* Enter the instruction dispatch loop */ 361 VMSWITCH(pc) 362 { 363 /****************************************************************** 364 * Simple opcodes. 365 ******************************************************************/ 366 367 VMCASE(JIT_OP_NOP): 368 { 369 /* Nothing to do except move on to the next instruction */ 370 VM_MODIFY_PC(1); 371 } 372 VMBREAK; 373 374 /****************************************************************** 375 * Conversion opcodes. 376 ******************************************************************/ 377 378 VMCASE(JIT_OP_TRUNC_SBYTE): 379 { 380 /* Truncate an integer to a signed 8-bit value */ 381 VM_R0_INT = (jit_int)(jit_sbyte)VM_R1_INT; 382 VM_MODIFY_PC(1); 383 } 384 VMBREAK; 385 386 VMCASE(JIT_OP_TRUNC_UBYTE): 387 { 388 /* Truncate an integer to an unsigned 8-bit value */ 389 VM_R0_INT = (jit_int)(jit_ubyte)VM_R1_INT; 390 VM_MODIFY_PC(1); 391 } 392 VMBREAK; 393 394 VMCASE(JIT_OP_TRUNC_SHORT): 395 { 396 /* Truncate an integer to a signed 16-bit value */ 397 VM_R0_INT = (jit_int)(jit_short)VM_R1_INT; 398 VM_MODIFY_PC(1); 399 } 400 VMBREAK; 401 402 VMCASE(JIT_OP_TRUNC_USHORT): 403 { 404 /* Truncate an integer to an unsigned 16-bit value */ 405 VM_R0_INT = (jit_int)(jit_ushort)VM_R1_INT; 406 VM_MODIFY_PC(1); 407 } 408 VMBREAK; 409 410 VMCASE(JIT_OP_TRUNC_INT): 411 { 412 /* Truncate an integer to a signed 32-bit value */ 413 VM_R0_INT = VM_R1_INT; 414 VM_MODIFY_PC(1); 415 } 416 VMBREAK; 417 418 VMCASE(JIT_OP_TRUNC_UINT): 419 { 420 /* Truncate an integer to an unsigned 32-bit value */ 421 VM_R0_INT = VM_R1_INT; 422 VM_MODIFY_PC(1); 423 } 424 VMBREAK; 425 426 VMCASE(JIT_OP_CHECK_SBYTE): 427 { 428 /* Truncate an integer to a signed 8-bit value, and check */ 429 VM_BUILTIN(jit_int_to_sbyte_ovf(&VM_R0_INT, VM_R1_INT)); 430 VM_MODIFY_PC(1); 431 } 432 VMBREAK; 433 434 VMCASE(JIT_OP_CHECK_UBYTE): 435 { 436 /* Truncate an integer to an unsigned 8-bit value, and check */ 437 VM_BUILTIN(jit_int_to_ubyte_ovf(&VM_R0_INT, VM_R1_INT)); 438 VM_MODIFY_PC(1); 439 } 440 VMBREAK; 441 442 VMCASE(JIT_OP_CHECK_SHORT): 443 { 444 /* Truncate an integer to a signed 16-bit value, and check */ 445 VM_BUILTIN(jit_int_to_short_ovf(&VM_R0_INT, VM_R1_INT)); 446 VM_MODIFY_PC(1); 447 } 448 VMBREAK; 449 450 VMCASE(JIT_OP_CHECK_USHORT): 451 { 452 /* Truncate an integer to an unsigned 16-bit value, and check */ 453 VM_BUILTIN(jit_int_to_ushort_ovf(&VM_R0_INT, VM_R1_INT)); 454 VM_MODIFY_PC(1); 455 } 456 VMBREAK; 457 458 VMCASE(JIT_OP_CHECK_INT): 459 { 460 /* Truncate an integer to a signed 32-bit value, and check */ 461 VM_BUILTIN(jit_uint_to_int_ovf(&VM_R0_INT, VM_R1_UINT)); 462 VM_MODIFY_PC(1); 463 } 464 VMBREAK; 465 466 VMCASE(JIT_OP_CHECK_UINT): 467 { 468 /* Truncate an integer to an unsigned 32-bit value, and check */ 469 VM_BUILTIN(jit_int_to_uint_ovf(&VM_R0_UINT, VM_R1_INT)); 470 VM_MODIFY_PC(1); 471 } 472 VMBREAK; 473 474 VMCASE(JIT_OP_LOW_WORD): 475 { 476 /* Fetch the low word of a 64-bit value */ 477 VM_R0_UINT = (jit_uint)VM_R1_LONG; 478 VM_MODIFY_PC(1); 479 } 480 VMBREAK; 481 482 VMCASE(JIT_OP_EXPAND_INT): 483 { 484 /* Expand a signed 32-bit value to a 64-bit value */ 485 VM_R0_LONG = (jit_long)VM_R1_INT; 486 VM_MODIFY_PC(1); 487 } 488 VMBREAK; 489 490 VMCASE(JIT_OP_EXPAND_UINT): 491 { 492 /* Expand an unsigned 32-bit value to a 64-bit value */ 493 VM_R0_ULONG = (jit_ulong)VM_R1_UINT; 494 VM_MODIFY_PC(1); 495 } 496 VMBREAK; 497 498 VMCASE(JIT_OP_CHECK_LOW_WORD): 499 { 500 /* Fetch the low word of a 64-bit value, and check */ 501 VM_BUILTIN(jit_long_to_uint_ovf(&VM_R0_UINT, VM_R1_LONG)); 502 VM_MODIFY_PC(1); 503 } 504 VMBREAK; 505 506 VMCASE(JIT_OP_CHECK_SIGNED_LOW_WORD): 507 { 508 /* Fetch the signed low word of a 64-bit value, and check */ 509 VM_BUILTIN(jit_long_to_int_ovf(&VM_R0_INT, VM_R1_LONG)); 510 VM_MODIFY_PC(1); 511 } 512 VMBREAK; 513 514 VMCASE(JIT_OP_CHECK_LONG): 515 { 516 /* Convert unsigned 64-bit into signed, and check */ 517 VM_BUILTIN(jit_ulong_to_long_ovf(&VM_R0_LONG, VM_R1_ULONG)); 518 VM_MODIFY_PC(1); 519 } 520 VMBREAK; 521 522 VMCASE(JIT_OP_CHECK_ULONG): 523 { 524 /* Convert signed 64-bit into unsigned, and check */ 525 VM_BUILTIN(jit_long_to_ulong_ovf(&VM_R0_ULONG, VM_R1_LONG)); 526 VM_MODIFY_PC(1); 527 } 528 VMBREAK; 529 530 VMCASE(JIT_OP_FLOAT32_TO_INT): 531 { 532 /* Convert 32-bit float into 32-bit signed integer */ 533 VM_R0_INT = jit_float32_to_int(VM_R1_FLOAT32); 534 VM_MODIFY_PC(1); 535 } 536 VMBREAK; 537 538 VMCASE(JIT_OP_FLOAT32_TO_UINT): 539 { 540 /* Convert 32-bit float into 32-bit unsigned integer */ 541 VM_R0_UINT = jit_float32_to_uint(VM_R1_FLOAT32); 542 VM_MODIFY_PC(1); 543 } 544 VMBREAK; 545 546 VMCASE(JIT_OP_FLOAT32_TO_LONG): 547 { 548 /* Convert 32-bit float into 64-bit signed integer */ 549 VM_R0_LONG = jit_float32_to_long(VM_R1_FLOAT32); 550 VM_MODIFY_PC(1); 551 } 552 VMBREAK; 553 554 VMCASE(JIT_OP_FLOAT32_TO_ULONG): 555 { 556 /* Convert 32-bit float into 64-bit unsigned integer */ 557 VM_R0_ULONG = jit_float32_to_ulong(VM_R1_FLOAT32); 558 VM_MODIFY_PC(1); 559 } 560 VMBREAK; 561 562 VMCASE(JIT_OP_CHECK_FLOAT32_TO_INT): 563 { 564 /* Convert 32-bit float into 32-bit signed integer, and check */ 565 VM_BUILTIN(jit_float32_to_int_ovf(&VM_R0_INT, VM_R1_FLOAT32)); 566 VM_MODIFY_PC(1); 567 } 568 VMBREAK; 569 570 VMCASE(JIT_OP_CHECK_FLOAT32_TO_UINT): 571 { 572 /* Convert 32-bit float into 32-bit unsigned integer, and check */ 573 VM_BUILTIN(jit_float32_to_uint_ovf(&VM_R0_UINT, VM_R1_FLOAT32)); 574 VM_MODIFY_PC(1); 575 } 576 VMBREAK; 577 578 VMCASE(JIT_OP_CHECK_FLOAT32_TO_LONG): 579 { 580 /* Convert 32-bit float into 64-bit signed integer, and check */ 581 VM_BUILTIN(jit_float32_to_long_ovf(&VM_R0_LONG, VM_R1_FLOAT32)); 582 VM_MODIFY_PC(1); 583 } 584 VMBREAK; 585 586 VMCASE(JIT_OP_CHECK_FLOAT32_TO_ULONG): 587 { 588 /* Convert 32-bit float into 64-bit unsigned integer, and check */ 589 VM_BUILTIN(jit_float32_to_ulong_ovf(&VM_R0_ULONG, VM_R1_FLOAT32)); 590 VM_MODIFY_PC(1); 591 } 592 VMBREAK; 593 594 VMCASE(JIT_OP_INT_TO_FLOAT32): 595 { 596 /* Convert 32-bit signed integer into 32-bit float */ 597 VM_R0_FLOAT32 = jit_int_to_float32(VM_R1_INT); 598 VM_MODIFY_PC(1); 599 } 600 VMBREAK; 601 602 VMCASE(JIT_OP_UINT_TO_FLOAT32): 603 { 604 /* Convert 32-bit unsigned integer into 32-bit float */ 605 VM_R0_FLOAT32 = jit_uint_to_float32(VM_R1_UINT); 606 VM_MODIFY_PC(1); 607 } 608 VMBREAK; 609 610 VMCASE(JIT_OP_LONG_TO_FLOAT32): 611 { 612 /* Convert 64-bit signed integer into 32-bit float */ 613 VM_R0_FLOAT32 = jit_long_to_float32(VM_R1_LONG); 614 VM_MODIFY_PC(1); 615 } 616 VMBREAK; 617 618 VMCASE(JIT_OP_ULONG_TO_FLOAT32): 619 { 620 /* Convert 64-bit unsigned integer into 32-bit float */ 621 VM_R0_FLOAT32 = jit_ulong_to_float32(VM_R1_ULONG); 622 VM_MODIFY_PC(1); 623 } 624 VMBREAK; 625 626 VMCASE(JIT_OP_FLOAT32_TO_FLOAT64): 627 { 628 /* Convert 32-bit float into 64-bit float */ 629 VM_R0_FLOAT64 = jit_float32_to_float64(VM_R1_FLOAT32); 630 VM_MODIFY_PC(1); 631 } 632 VMBREAK; 633 634 VMCASE(JIT_OP_FLOAT64_TO_INT): 635 { 636 /* Convert 64-bit float into 32-bit signed integer */ 637 VM_R0_INT = jit_float64_to_int(VM_R1_FLOAT64); 638 VM_MODIFY_PC(1); 639 } 640 VMBREAK; 641 642 VMCASE(JIT_OP_FLOAT64_TO_UINT): 643 { 644 /* Convert 64-bit float into 32-bit unsigned integer */ 645 VM_R0_UINT = jit_float64_to_uint(VM_R1_FLOAT64); 646 VM_MODIFY_PC(1); 647 } 648 VMBREAK; 649 650 VMCASE(JIT_OP_FLOAT64_TO_LONG): 651 { 652 /* Convert 64-bit float into 64-bit signed integer */ 653 VM_R0_LONG = jit_float64_to_long(VM_R1_FLOAT64); 654 VM_MODIFY_PC(1); 655 } 656 VMBREAK; 657 658 VMCASE(JIT_OP_FLOAT64_TO_ULONG): 659 { 660 /* Convert 64-bit float into 64-bit unsigned integer */ 661 VM_R0_ULONG = jit_float64_to_ulong(VM_R1_FLOAT64); 662 VM_MODIFY_PC(1); 663 } 664 VMBREAK; 665 666 VMCASE(JIT_OP_CHECK_FLOAT64_TO_INT): 667 { 668 /* Convert 64-bit float into 32-bit signed integer, and check */ 669 VM_BUILTIN(jit_float64_to_int_ovf(&VM_R0_INT, VM_R1_FLOAT64)); 670 VM_MODIFY_PC(1); 671 } 672 VMBREAK; 673 674 VMCASE(JIT_OP_CHECK_FLOAT64_TO_UINT): 675 { 676 /* Convert 64-bit float into 32-bit unsigned integer, and check */ 677 VM_BUILTIN(jit_float64_to_uint_ovf(&VM_R0_UINT, VM_R1_FLOAT64)); 678 VM_MODIFY_PC(1); 679 } 680 VMBREAK; 681 682 VMCASE(JIT_OP_CHECK_FLOAT64_TO_LONG): 683 { 684 /* Convert 64-bit float into 64-bit signed integer, and check */ 685 VM_BUILTIN(jit_float64_to_long_ovf(&VM_R0_LONG, VM_R1_FLOAT64)); 686 VM_MODIFY_PC(1); 687 } 688 VMBREAK; 689 690 VMCASE(JIT_OP_CHECK_FLOAT64_TO_ULONG): 691 { 692 /* Convert 64-bit float into 64-bit unsigned integer, and check */ 693 VM_BUILTIN(jit_float64_to_ulong_ovf(&VM_R0_ULONG, VM_R1_FLOAT64)); 694 VM_MODIFY_PC(1); 695 } 696 VMBREAK; 697 698 VMCASE(JIT_OP_INT_TO_FLOAT64): 699 { 700 /* Convert 32-bit signed integer into 64-bit float */ 701 VM_R0_FLOAT64 = jit_int_to_float64(VM_R1_INT); 702 VM_MODIFY_PC(1); 703 } 704 VMBREAK; 705 706 VMCASE(JIT_OP_UINT_TO_FLOAT64): 707 { 708 /* Convert 32-bit unsigned integer into 64-bit float */ 709 VM_R0_FLOAT64 = jit_uint_to_float64(VM_R1_UINT); 710 VM_MODIFY_PC(1); 711 } 712 VMBREAK; 713 714 VMCASE(JIT_OP_LONG_TO_FLOAT64): 715 { 716 /* Convert 64-bit signed integer into 64-bit float */ 717 VM_R0_FLOAT64 = jit_long_to_float64(VM_R1_LONG); 718 VM_MODIFY_PC(1); 719 } 720 VMBREAK; 721 722 VMCASE(JIT_OP_ULONG_TO_FLOAT64): 723 { 724 /* Convert 64-bit unsigned integer into 64-bit float */ 725 VM_R0_FLOAT64 = jit_ulong_to_float64(VM_R1_ULONG); 726 VM_MODIFY_PC(1); 727 } 728 VMBREAK; 729 730 VMCASE(JIT_OP_FLOAT64_TO_FLOAT32): 731 { 732 /* Convert 64-bit float into 32-bit float */ 733 VM_R0_FLOAT32 = jit_float64_to_float32(VM_R1_FLOAT64); 734 VM_MODIFY_PC(1); 735 } 736 VMBREAK; 737 738 VMCASE(JIT_OP_NFLOAT_TO_INT): 739 { 740 /* Convert native float into 32-bit signed integer */ 741 VM_R0_INT = jit_nfloat_to_int(VM_R1_NFLOAT); 742 VM_MODIFY_PC(1); 743 } 744 VMBREAK; 745 746 VMCASE(JIT_OP_NFLOAT_TO_UINT): 747 { 748 /* Convert native float into 32-bit unsigned integer */ 749 VM_R0_UINT = jit_nfloat_to_uint(VM_R1_NFLOAT); 750 VM_MODIFY_PC(1); 751 } 752 VMBREAK; 753 754 VMCASE(JIT_OP_NFLOAT_TO_LONG): 755 { 756 /* Convert native float into 64-bit signed integer */ 757 VM_R0_LONG = jit_nfloat_to_long(VM_R1_NFLOAT); 758 VM_MODIFY_PC(1); 759 } 760 VMBREAK; 761 762 VMCASE(JIT_OP_NFLOAT_TO_ULONG): 763 { 764 /* Convert native float into 64-bit unsigned integer */ 765 VM_R0_ULONG = jit_nfloat_to_ulong(VM_R1_NFLOAT); 766 VM_MODIFY_PC(1); 767 } 768 VMBREAK; 769 770 VMCASE(JIT_OP_CHECK_NFLOAT_TO_INT): 771 { 772 /* Convert native float into 32-bit signed integer, and check */ 773 VM_BUILTIN(jit_nfloat_to_int_ovf(&VM_R0_INT, VM_R1_NFLOAT)); 774 VM_MODIFY_PC(1); 775 } 776 VMBREAK; 777 778 VMCASE(JIT_OP_CHECK_NFLOAT_TO_UINT): 779 { 780 /* Convert native float into 32-bit unsigned integer, and check */ 781 VM_BUILTIN(jit_nfloat_to_uint_ovf(&VM_R0_UINT, VM_R1_NFLOAT)); 782 VM_MODIFY_PC(1); 783 } 784 VMBREAK; 785 786 VMCASE(JIT_OP_CHECK_NFLOAT_TO_LONG): 787 { 788 /* Convert native float into 64-bit signed integer, and check */ 789 VM_BUILTIN(jit_nfloat_to_long_ovf(&VM_R0_LONG, VM_R1_NFLOAT)); 790 VM_MODIFY_PC(1); 791 } 792 VMBREAK; 793 794 VMCASE(JIT_OP_CHECK_NFLOAT_TO_ULONG): 795 { 796 /* Convert native float into 64-bit unsigned integer, and check */ 797 VM_BUILTIN(jit_nfloat_to_ulong_ovf(&VM_R0_ULONG, VM_R1_NFLOAT)); 798 VM_MODIFY_PC(1); 799 } 800 VMBREAK; 801 802 VMCASE(JIT_OP_INT_TO_NFLOAT): 803 { 804 /* Convert 32-bit signed integer into native float */ 805 VM_R0_NFLOAT = jit_int_to_nfloat(VM_R1_INT); 806 VM_MODIFY_PC(1); 807 } 808 VMBREAK; 809 810 VMCASE(JIT_OP_UINT_TO_NFLOAT): 811 { 812 /* Convert 32-bit unsigned integer into native float */ 813 VM_R0_NFLOAT = jit_uint_to_nfloat(VM_R1_UINT); 814 VM_MODIFY_PC(1); 815 } 816 VMBREAK; 817 818 VMCASE(JIT_OP_LONG_TO_NFLOAT): 819 { 820 /* Convert 64-bit signed integer into native float */ 821 VM_R0_NFLOAT = jit_long_to_nfloat(VM_R1_LONG); 822 VM_MODIFY_PC(1); 823 } 824 VMBREAK; 825 826 VMCASE(JIT_OP_ULONG_TO_NFLOAT): 827 { 828 /* Convert 64-bit unsigned integer into native float */ 829 VM_R0_NFLOAT = jit_ulong_to_nfloat(VM_R1_ULONG); 830 VM_MODIFY_PC(1); 831 } 832 VMBREAK; 833 834 VMCASE(JIT_OP_NFLOAT_TO_FLOAT32): 835 { 836 /* Convert native float into 32-bit float */ 837 VM_R0_FLOAT32 = jit_nfloat_to_float32(VM_R1_NFLOAT); 838 VM_MODIFY_PC(1); 839 } 840 VMBREAK; 841 842 VMCASE(JIT_OP_NFLOAT_TO_FLOAT64): 843 { 844 /* Convert native float into 64-bit float */ 845 VM_R0_FLOAT64 = jit_nfloat_to_float64(VM_R1_NFLOAT); 846 VM_MODIFY_PC(1); 847 } 848 VMBREAK; 849 850 VMCASE(JIT_OP_FLOAT32_TO_NFLOAT): 851 { 852 /* Convert 32-bit float into native float */ 853 VM_R0_NFLOAT = jit_float32_to_nfloat(VM_R1_FLOAT32); 854 VM_MODIFY_PC(1); 855 } 856 VMBREAK; 857 858 VMCASE(JIT_OP_FLOAT64_TO_NFLOAT): 859 { 860 /* Convert 64-bit float into native float */ 861 VM_R0_NFLOAT = jit_float64_to_nfloat(VM_R1_FLOAT64); 862 VM_MODIFY_PC(1); 863 } 864 VMBREAK; 865 866 /****************************************************************** 867 * Arithmetic opcodes. 868 ******************************************************************/ 869 870 VMCASE(JIT_OP_IADD): 871 { 872 /* Add signed 32-bit integers */ 873 VM_R0_INT = VM_R1_INT + VM_R2_INT; 874 VM_MODIFY_PC(1); 875 } 876 VMBREAK; 877 878 VMCASE(JIT_OP_IADD_OVF): 879 { 880 /* Add signed 32-bit integers, and check */ 881 VM_BUILTIN(jit_int_add_ovf(&VM_R0_INT, VM_R1_INT, VM_R2_INT)); 882 VM_MODIFY_PC(1); 883 } 884 VMBREAK; 885 886 VMCASE(JIT_OP_IADD_OVF_UN): 887 { 888 /* Add unsigned 32-bit integers, and check */ 889 VM_BUILTIN(jit_uint_add_ovf(&VM_R0_UINT, VM_R1_UINT, VM_R2_UINT)); 890 VM_MODIFY_PC(1); 891 } 892 VMBREAK; 893 894 VMCASE(JIT_OP_ISUB): 895 { 896 /* Subtract signed 32-bit integers */ 897 VM_R0_INT = VM_R1_INT - VM_R2_INT; 898 VM_MODIFY_PC(1); 899 } 900 VMBREAK; 901 902 VMCASE(JIT_OP_ISUB_OVF): 903 { 904 /* Subtract signed 32-bit integers, and check */ 905 VM_BUILTIN(jit_int_sub_ovf(&VM_R0_INT, VM_R1_INT, VM_R2_INT)); 906 VM_MODIFY_PC(1); 907 } 908 VMBREAK; 909 910 VMCASE(JIT_OP_ISUB_OVF_UN): 911 { 912 /* Subtract unsigned 32-bit integers, and check */ 913 VM_BUILTIN(jit_uint_sub_ovf(&VM_R0_UINT, VM_R1_UINT, VM_R2_UINT)); 914 VM_MODIFY_PC(1); 915 } 916 VMBREAK; 917 918 VMCASE(JIT_OP_IMUL): 919 { 920 /* Multiply signed 32-bit integers */ 921 VM_R0_INT = VM_R1_INT * VM_R2_INT; 922 VM_MODIFY_PC(1); 923 } 924 VMBREAK; 925 926 VMCASE(JIT_OP_IMUL_OVF): 927 { 928 /* Multiply signed 32-bit integers, and check */ 929 VM_BUILTIN(jit_int_mul_ovf(&VM_R0_INT, VM_R1_INT, VM_R2_INT)); 930 VM_MODIFY_PC(1); 931 } 932 VMBREAK; 933 934 VMCASE(JIT_OP_IMUL_OVF_UN): 935 { 936 /* Multiply unsigned 32-bit integers, and check */ 937 VM_BUILTIN(jit_uint_mul_ovf(&VM_R0_UINT, VM_R1_UINT, VM_R2_UINT)); 938 VM_MODIFY_PC(1); 939 } 940 VMBREAK; 941 942 VMCASE(JIT_OP_IDIV): 943 { 944 /* Divide signed 32-bit integers */ 945 VM_BUILTIN(jit_int_div(&VM_R0_INT, VM_R1_INT, VM_R2_INT)); 946 VM_MODIFY_PC(1); 947 } 948 VMBREAK; 949 950 VMCASE(JIT_OP_IDIV_UN): 951 { 952 /* Divide unsigned 32-bit integers */ 953 VM_BUILTIN(jit_uint_div(&VM_R0_UINT, VM_R1_UINT, VM_R2_UINT)); 954 VM_MODIFY_PC(1); 955 } 956 VMBREAK; 957 958 VMCASE(JIT_OP_IREM): 959 { 960 /* Remainder signed 32-bit integers */ 961 VM_BUILTIN(jit_int_rem(&VM_R0_INT, VM_R1_INT, VM_R2_INT)); 962 VM_MODIFY_PC(1); 963 } 964 VMBREAK; 965 966 VMCASE(JIT_OP_IREM_UN): 967 { 968 /* Remainder unsigned 32-bit integers */ 969 VM_BUILTIN(jit_uint_rem(&VM_R0_UINT, VM_R1_UINT, VM_R2_UINT)); 970 VM_MODIFY_PC(1); 971 } 972 VMBREAK; 973 974 VMCASE(JIT_OP_INEG): 975 { 976 /* Negate signed 32-bit integer */ 977 VM_R0_INT = -VM_R1_INT; 978 VM_MODIFY_PC(1); 979 } 980 VMBREAK; 981 982 VMCASE(JIT_OP_LADD): 983 { 984 /* Add signed 64-bit integers */ 985 VM_R0_LONG = VM_R1_LONG + VM_R2_LONG; 986 VM_MODIFY_PC(1); 987 } 988 VMBREAK; 989 990 VMCASE(JIT_OP_LADD_OVF): 991 { 992 /* Add signed 64-bit integers, and check */ 993 VM_BUILTIN(jit_long_add_ovf(&VM_R0_LONG, VM_R1_LONG, VM_R2_LONG)); 994 VM_MODIFY_PC(1); 995 } 996 VMBREAK; 997 998 VMCASE(JIT_OP_LADD_OVF_UN): 999 { 1000 /* Add unsigned 64-bit integers, and check */ 1001 VM_BUILTIN(jit_ulong_add_ovf(&VM_R0_ULONG, VM_R1_ULONG, VM_R2_ULONG)); 1002 VM_MODIFY_PC(1); 1003 } 1004 VMBREAK; 1005 1006 VMCASE(JIT_OP_LSUB): 1007 { 1008 /* Subtract signed 64-bit integers */ 1009 VM_R0_LONG = VM_R1_LONG - VM_R2_LONG; 1010 VM_MODIFY_PC(1); 1011 } 1012 VMBREAK; 1013 1014 VMCASE(JIT_OP_LSUB_OVF): 1015 { 1016 /* Subtract signed 64-bit integers, and check */ 1017 VM_BUILTIN(jit_long_sub_ovf(&VM_R0_LONG, VM_R1_LONG, VM_R2_LONG)); 1018 VM_MODIFY_PC(1); 1019 } 1020 VMBREAK; 1021 1022 VMCASE(JIT_OP_LSUB_OVF_UN): 1023 { 1024 /* Subtract unsigned 64-bit integers, and check */ 1025 VM_BUILTIN(jit_ulong_sub_ovf(&VM_R0_ULONG, VM_R1_ULONG, VM_R2_ULONG)); 1026 VM_MODIFY_PC(1); 1027 } 1028 VMBREAK; 1029 1030 VMCASE(JIT_OP_LMUL): 1031 { 1032 /* Multiply signed 64-bit integers */ 1033 VM_R0_LONG = VM_R1_LONG * VM_R2_LONG; 1034 VM_MODIFY_PC(1); 1035 } 1036 VMBREAK; 1037 1038 VMCASE(JIT_OP_LMUL_OVF): 1039 { 1040 /* Multiply signed 64-bit integers, and check */ 1041 VM_BUILTIN(jit_long_mul_ovf(&VM_R0_LONG, VM_R1_LONG, VM_R2_LONG)); 1042 VM_MODIFY_PC(1); 1043 } 1044 VMBREAK; 1045 1046 VMCASE(JIT_OP_LMUL_OVF_UN): 1047 { 1048 /* Multiply unsigned 64-bit integers, and check */ 1049 VM_BUILTIN(jit_ulong_mul_ovf(&VM_R0_ULONG, VM_R1_ULONG, VM_R2_ULONG)); 1050 VM_MODIFY_PC(1); 1051 } 1052 VMBREAK; 1053 1054 VMCASE(JIT_OP_LDIV): 1055 { 1056 /* Divide signed 64-bit integers */ 1057 VM_BUILTIN(jit_long_div (&VM_R0_LONG, VM_R1_LONG, VM_R2_LONG)); 1058 VM_MODIFY_PC(1); 1059 } 1060 VMBREAK; 1061 1062 VMCASE(JIT_OP_LDIV_UN): 1063 { 1064 /* Divide unsigned 64-bit integers */ 1065 VM_BUILTIN(jit_ulong_div(&VM_R0_ULONG, VM_R1_ULONG, VM_R2_ULONG)); 1066 VM_MODIFY_PC(1); 1067 } 1068 VMBREAK; 1069 1070 VMCASE(JIT_OP_LREM): 1071 { 1072 /* Remainder signed 64-bit integers */ 1073 VM_BUILTIN(jit_long_rem(&VM_R0_LONG, VM_R1_LONG, VM_R2_LONG)); 1074 VM_MODIFY_PC(1); 1075 } 1076 VMBREAK; 1077 1078 VMCASE(JIT_OP_LREM_UN): 1079 { 1080 /* Remainder unsigned 64-bit integers */ 1081 VM_BUILTIN(jit_ulong_rem(&VM_R0_ULONG, VM_R1_ULONG, VM_R2_ULONG)); 1082 VM_MODIFY_PC(1); 1083 } 1084 VMBREAK; 1085 1086 VMCASE(JIT_OP_LNEG): 1087 { 1088 /* Negate signed 64-bit integer */ 1089 VM_R0_LONG = -VM_R1_LONG; 1090 VM_MODIFY_PC(1); 1091 } 1092 VMBREAK; 1093 1094 VMCASE(JIT_OP_FADD): 1095 { 1096 /* Add 32-bit floats */ 1097 VM_R0_FLOAT32 = VM_R1_FLOAT32 + VM_R2_FLOAT32; 1098 VM_MODIFY_PC(1); 1099 } 1100 VMBREAK; 1101 1102 VMCASE(JIT_OP_FSUB): 1103 { 1104 /* Subtract 32-bit floats */ 1105 VM_R0_FLOAT32 = VM_R1_FLOAT32 - VM_R2_FLOAT32; 1106 VM_MODIFY_PC(1); 1107 } 1108 VMBREAK; 1109 1110 VMCASE(JIT_OP_FMUL): 1111 { 1112 /* Multiply 32-bit floats */ 1113 VM_R0_FLOAT32 = VM_R1_FLOAT32 * VM_R2_FLOAT32; 1114 VM_MODIFY_PC(1); 1115 } 1116 VMBREAK; 1117 1118 VMCASE(JIT_OP_FDIV): 1119 { 1120 /* Divide 32-bit floats */ 1121 VM_R0_FLOAT32 = VM_R1_FLOAT32 / VM_R2_FLOAT32; 1122 VM_MODIFY_PC(1); 1123 } 1124 VMBREAK; 1125 1126 VMCASE(JIT_OP_FREM): 1127 { 1128 /* Remainder 32-bit floats */ 1129 VM_R0_FLOAT32 = jit_float32_rem(VM_R1_FLOAT32, VM_R2_FLOAT32); 1130 VM_MODIFY_PC(1); 1131 } 1132 VMBREAK; 1133 1134 VMCASE(JIT_OP_FREM_IEEE): 1135 { 1136 /* Remainder 32-bit floats, with IEEE rules */ 1137 VM_R0_FLOAT32 = jit_float32_ieee_rem(VM_R1_FLOAT32, VM_R2_FLOAT32); 1138 VM_MODIFY_PC(1); 1139 } 1140 VMBREAK; 1141 1142 VMCASE(JIT_OP_FNEG): 1143 { 1144 /* Negate 32-bit float */ 1145 VM_R0_FLOAT32 = -VM_R1_FLOAT32; 1146 VM_MODIFY_PC(1); 1147 } 1148 VMBREAK; 1149 1150 VMCASE(JIT_OP_DADD): 1151 { 1152 /* Add 64-bit floats */ 1153 VM_R0_FLOAT64 = VM_R1_FLOAT64 + VM_R2_FLOAT64; 1154 VM_MODIFY_PC(1); 1155 } 1156 VMBREAK; 1157 1158 VMCASE(JIT_OP_DSUB): 1159 { 1160 /* Subtract 64-bit floats */ 1161 VM_R0_FLOAT64 = VM_R1_FLOAT64 - VM_R2_FLOAT64; 1162 VM_MODIFY_PC(1); 1163 } 1164 VMBREAK; 1165 1166 VMCASE(JIT_OP_DMUL): 1167 { 1168 /* Multiply 64-bit floats */ 1169 VM_R0_FLOAT64 = VM_R1_FLOAT64 * VM_R2_FLOAT64; 1170 VM_MODIFY_PC(1); 1171 } 1172 VMBREAK; 1173 1174 VMCASE(JIT_OP_DDIV): 1175 { 1176 /* Divide 64-bit floats */ 1177 VM_R0_FLOAT64 = VM_R1_FLOAT64 / VM_R2_FLOAT64; 1178 VM_MODIFY_PC(1); 1179 } 1180 VMBREAK; 1181 1182 VMCASE(JIT_OP_DREM): 1183 { 1184 /* Remainder 64-bit floats */ 1185 VM_R0_FLOAT64 = jit_float64_rem(VM_R1_FLOAT64, VM_R2_FLOAT64); 1186 VM_MODIFY_PC(1); 1187 } 1188 VMBREAK; 1189 1190 VMCASE(JIT_OP_DREM_IEEE): 1191 { 1192 /* Remainder 64-bit floats, with IEEE rules */ 1193 VM_R0_FLOAT64 = jit_float64_ieee_rem(VM_R1_FLOAT64, VM_R2_FLOAT64); 1194 VM_MODIFY_PC(1); 1195 } 1196 VMBREAK; 1197 1198 VMCASE(JIT_OP_DNEG): 1199 { 1200 /* Negate 64-bit float */ 1201 VM_R0_FLOAT64 = -VM_R1_FLOAT64; 1202 VM_MODIFY_PC(1); 1203 } 1204 VMBREAK; 1205 1206 VMCASE(JIT_OP_NFADD): 1207 { 1208 /* Add native floats */ 1209 VM_R0_NFLOAT = VM_R1_NFLOAT + VM_R2_NFLOAT; 1210 VM_MODIFY_PC(1); 1211 } 1212 VMBREAK; 1213 1214 VMCASE(JIT_OP_NFSUB): 1215 { 1216 /* Subtract native floats */ 1217 VM_R0_NFLOAT = VM_R1_NFLOAT - VM_R2_NFLOAT; 1218 VM_MODIFY_PC(1); 1219 } 1220 VMBREAK; 1221 1222 VMCASE(JIT_OP_NFMUL): 1223 { 1224 /* Multiply native floats */ 1225 VM_R0_NFLOAT = VM_R1_NFLOAT * VM_R2_NFLOAT; 1226 VM_MODIFY_PC(1); 1227 } 1228 VMBREAK; 1229 1230 VMCASE(JIT_OP_NFDIV): 1231 { 1232 /* Divide native floats */ 1233 VM_R0_NFLOAT = VM_R1_NFLOAT / VM_R2_NFLOAT; 1234 VM_MODIFY_PC(1); 1235 } 1236 VMBREAK; 1237 1238 VMCASE(JIT_OP_NFREM): 1239 { 1240 /* Remainder native floats */ 1241 VM_R0_NFLOAT = jit_nfloat_rem(VM_R1_NFLOAT, VM_R2_NFLOAT); 1242 VM_MODIFY_PC(1); 1243 } 1244 VMBREAK; 1245 1246 VMCASE(JIT_OP_NFREM_IEEE): 1247 { 1248 /* Remainder native floats, with IEEE rules */ 1249 VM_R0_NFLOAT = jit_nfloat_ieee_rem(VM_R1_NFLOAT, VM_R2_NFLOAT); 1250 VM_MODIFY_PC(1); 1251 } 1252 VMBREAK; 1253 1254 VMCASE(JIT_OP_NFNEG): 1255 { 1256 /* Negate native float */ 1257 VM_R0_NFLOAT = -VM_R1_NFLOAT; 1258 VM_MODIFY_PC(1); 1259 } 1260 VMBREAK; 1261 1262 /****************************************************************** 1263 * Bitwise opcodes. 1264 ******************************************************************/ 1265 1266 VMCASE(JIT_OP_IAND): 1267 { 1268 /* Bitwise and signed 32-bit integers */ 1269 VM_R0_INT = VM_R1_INT & VM_R2_INT; 1270 VM_MODIFY_PC(1); 1271 } 1272 VMBREAK; 1273 1274 VMCASE(JIT_OP_IOR): 1275 { 1276 /* Bitwise or signed 32-bit integers */ 1277 VM_R0_INT = VM_R1_INT | VM_R2_INT; 1278 VM_MODIFY_PC(1); 1279 } 1280 VMBREAK; 1281 1282 VMCASE(JIT_OP_IXOR): 1283 { 1284 /* Bitwise xor signed 32-bit integers */ 1285 VM_R0_INT = VM_R1_INT ^ VM_R2_INT; 1286 VM_MODIFY_PC(1); 1287 } 1288 VMBREAK; 1289 1290 VMCASE(JIT_OP_INOT): 1291 { 1292 /* Bitwise not signed 32-bit integers */ 1293 VM_R0_INT = ~VM_R1_INT; 1294 VM_MODIFY_PC(1); 1295 } 1296 VMBREAK; 1297 1298 VMCASE(JIT_OP_ISHL): 1299 { 1300 /* Shift left signed 32-bit integers */ 1301 VM_R0_INT = VM_R1_INT << (VM_R2_INT & 0x1F); 1302 VM_MODIFY_PC(1); 1303 } 1304 VMBREAK; 1305 1306 VMCASE(JIT_OP_ISHR): 1307 { 1308 /* Shift right signed 32-bit integers */ 1309 VM_R0_INT = VM_R1_INT >> (VM_R2_UINT & 0x1F); 1310 VM_MODIFY_PC(1); 1311 } 1312 VMBREAK; 1313 1314 VMCASE(JIT_OP_ISHR_UN): 1315 { 1316 /* Shift right unsigned 32-bit integers */ 1317 VM_R0_UINT = VM_R1_UINT >> (VM_R2_UINT & 0x1F); 1318 VM_MODIFY_PC(1); 1319 } 1320 VMBREAK; 1321 1322 VMCASE(JIT_OP_LAND): 1323 { 1324 /* Bitwise and signed 64-bit integers */ 1325 VM_R0_LONG = VM_R1_LONG & VM_R2_LONG; 1326 VM_MODIFY_PC(1); 1327 } 1328 VMBREAK; 1329 1330 VMCASE(JIT_OP_LOR): 1331 { 1332 /* Bitwise or signed 64-bit integers */ 1333 VM_R0_LONG = VM_R1_LONG | VM_R2_LONG; 1334 VM_MODIFY_PC(1); 1335 } 1336 VMBREAK; 1337 1338 VMCASE(JIT_OP_LXOR): 1339 { 1340 /* Bitwise xor signed 64-bit integers */ 1341 VM_R0_LONG = VM_R1_LONG ^ VM_R2_LONG; 1342 VM_MODIFY_PC(1); 1343 } 1344 VMBREAK; 1345 1346 VMCASE(JIT_OP_LNOT): 1347 { 1348 /* Bitwise not signed 64-bit integers */ 1349 VM_R0_LONG = ~VM_R1_LONG; 1350 VM_MODIFY_PC(1); 1351 } 1352 VMBREAK; 1353 1354 VMCASE(JIT_OP_LSHL): 1355 { 1356 /* Shift left signed 64-bit integers */ 1357 VM_R0_LONG = (VM_R1_LONG << (VM_R2_UINT & 0x3F)); 1358 VM_MODIFY_PC(1); 1359 } 1360 VMBREAK; 1361 1362 VMCASE(JIT_OP_LSHR): 1363 { 1364 /* Shift right signed 64-bit integers */ 1365 VM_R0_LONG = (VM_R1_LONG >> (VM_R2_UINT & 0x3F)); 1366 VM_MODIFY_PC(1); 1367 } 1368 VMBREAK; 1369 1370 VMCASE(JIT_OP_LSHR_UN): 1371 { 1372 /* Shift right unsigned 64-bit integers */ 1373 VM_R0_ULONG = (VM_R1_ULONG >> (VM_R2_UINT & 0x3F)); 1374 VM_MODIFY_PC(1); 1375 } 1376 VMBREAK; 1377 1378 /****************************************************************** 1379 * Branch opcodes. 1380 ******************************************************************/ 1381 1382 VMCASE(JIT_OP_BR): 1383 { 1384 /* Unconditional branch */ 1385 pc = VM_BR_TARGET; 1386 } 1387 VMBREAK; 1388 1389 VMCASE(JIT_OP_BR_IFALSE): 1390 { 1391 /* Branch if signed 32-bit integer is false */ 1392 if(VM_R1_INT == 0) 1393 { 1394 pc = VM_BR_TARGET; 1395 } 1396 else 1397 { 1398 VM_MODIFY_PC(2); 1399 } 1400 } 1401 VMBREAK; 1402 1403 VMCASE(JIT_OP_BR_ITRUE): 1404 { 1405 /* Branch if signed 32-bit integer is true */ 1406 if(VM_R1_INT != 0) 1407 { 1408 pc = VM_BR_TARGET; 1409 } 1410 else 1411 { 1412 VM_MODIFY_PC(2); 1413 } 1414 } 1415 VMBREAK; 1416 1417 VMCASE(JIT_OP_BR_IEQ): 1418 { 1419 /* Branch if signed 32-bit integers are equal */ 1420 if(VM_R1_INT == VM_R2_INT) 1421 { 1422 pc = VM_BR_TARGET; 1423 } 1424 else 1425 { 1426 VM_MODIFY_PC(2); 1427 } 1428 } 1429 VMBREAK; 1430 1431 VMCASE(JIT_OP_BR_INE): 1432 { 1433 /* Branch if signed 32-bit integers are not equal */ 1434 if(VM_R1_INT != VM_R2_INT) 1435 { 1436 pc = VM_BR_TARGET; 1437 } 1438 else 1439 { 1440 VM_MODIFY_PC(2); 1441 } 1442 } 1443 VMBREAK; 1444 1445 VMCASE(JIT_OP_BR_ILT): 1446 { 1447 /* Branch if signed 32-bit integers are less than */ 1448 if(VM_R1_INT < VM_R2_INT) 1449 { 1450 pc = VM_BR_TARGET; 1451 } 1452 else 1453 { 1454 VM_MODIFY_PC(2); 1455 } 1456 } 1457 VMBREAK; 1458 1459 VMCASE(JIT_OP_BR_ILT_UN): 1460 { 1461 /* Branch if unsigned 32-bit integers are less than */ 1462 if(VM_R1_UINT < VM_R2_UINT) 1463 { 1464 pc = VM_BR_TARGET; 1465 } 1466 else 1467 { 1468 VM_MODIFY_PC(2); 1469 } 1470 } 1471 VMBREAK; 1472 1473 VMCASE(JIT_OP_BR_ILE): 1474 { 1475 /* Branch if signed 32-bit integers are less than or equal */ 1476 if(VM_R1_INT <= VM_R2_INT) 1477 { 1478 pc = VM_BR_TARGET; 1479 } 1480 else 1481 { 1482 VM_MODIFY_PC(2); 1483 } 1484 } 1485 VMBREAK; 1486 1487 VMCASE(JIT_OP_BR_ILE_UN): 1488 { 1489 /* Branch if unsigned 32-bit integers are less than or equal */ 1490 if(VM_R1_UINT <= VM_R2_UINT) 1491 { 1492 pc = VM_BR_TARGET; 1493 } 1494 else 1495 { 1496 VM_MODIFY_PC(2); 1497 } 1498 } 1499 VMBREAK; 1500 1501 VMCASE(JIT_OP_BR_IGT): 1502 { 1503 /* Branch if signed 32-bit integers are greater than */ 1504 if(VM_R1_INT > VM_R2_INT) 1505 { 1506 pc = VM_BR_TARGET; 1507 } 1508 else 1509 { 1510 VM_MODIFY_PC(2); 1511 } 1512 } 1513 VMBREAK; 1514 1515 VMCASE(JIT_OP_BR_IGT_UN): 1516 { 1517 /* Branch if unsigned 32-bit integers are greater than */ 1518 if(VM_R1_UINT > VM_R2_UINT) 1519 { 1520 pc = VM_BR_TARGET; 1521 } 1522 else 1523 { 1524 VM_MODIFY_PC(2); 1525 } 1526 } 1527 VMBREAK; 1528 1529 VMCASE(JIT_OP_BR_IGE): 1530 { 1531 /* Branch if signed 32-bit integers are greater than or equal */ 1532 if(VM_R1_INT >= VM_R2_INT) 1533 { 1534 pc = VM_BR_TARGET; 1535 } 1536 else 1537 { 1538 VM_MODIFY_PC(2); 1539 } 1540 } 1541 VMBREAK; 1542 1543 VMCASE(JIT_OP_BR_IGE_UN): 1544 { 1545 /* Branch if unsigned 32-bit integers are greater than or equal */ 1546 if(VM_R1_UINT >= VM_R2_UINT) 1547 { 1548 pc = VM_BR_TARGET; 1549 } 1550 else 1551 { 1552 VM_MODIFY_PC(2); 1553 } 1554 } 1555 VMBREAK; 1556 1557 VMCASE(JIT_OP_BR_LFALSE): 1558 { 1559 /* Branch if signed 64-bit integer is false */ 1560 if(VM_R1_LONG == 0) 1561 { 1562 pc = VM_BR_TARGET; 1563 } 1564 else 1565 { 1566 VM_MODIFY_PC(2); 1567 } 1568 } 1569 VMBREAK; 1570 1571 VMCASE(JIT_OP_BR_LTRUE): 1572 { 1573 /* Branch if signed 64-bit integer is true */ 1574 if(VM_R1_LONG != 0) 1575 { 1576 pc = VM_BR_TARGET; 1577 } 1578 else 1579 { 1580 VM_MODIFY_PC(2); 1581 } 1582 } 1583 VMBREAK; 1584 1585 VMCASE(JIT_OP_BR_LEQ): 1586 { 1587 /* Branch if signed 64-bit integers are equal */ 1588 if(VM_R1_LONG == VM_R2_LONG) 1589 { 1590 pc = VM_BR_TARGET; 1591 } 1592 else 1593 { 1594 VM_MODIFY_PC(2); 1595 } 1596 } 1597 VMBREAK; 1598 1599 VMCASE(JIT_OP_BR_LNE): 1600 { 1601 /* Branch if signed 64-bit integers are not equal */ 1602 if(VM_R1_LONG != VM_R2_LONG) 1603 { 1604 pc = VM_BR_TARGET; 1605 } 1606 else 1607 { 1608 VM_MODIFY_PC(2); 1609 } 1610 } 1611 VMBREAK; 1612 1613 VMCASE(JIT_OP_BR_LLT): 1614 { 1615 /* Branch if signed 64-bit integers are less than */ 1616 if(VM_R1_LONG < VM_R2_LONG) 1617 { 1618 pc = VM_BR_TARGET; 1619 } 1620 else 1621 { 1622 VM_MODIFY_PC(2); 1623 } 1624 } 1625 VMBREAK; 1626 1627 VMCASE(JIT_OP_BR_LLT_UN): 1628 { 1629 /* Branch if unsigned 64-bit integers are less than */ 1630 if(VM_R1_ULONG < VM_R2_ULONG) 1631 { 1632 pc = VM_BR_TARGET; 1633 } 1634 else 1635 { 1636 VM_MODIFY_PC(2); 1637 } 1638 } 1639 VMBREAK; 1640 1641 VMCASE(JIT_OP_BR_LLE): 1642 { 1643 /* Branch if signed 64-bit integers are less than or equal */ 1644 if(VM_R1_LONG <= VM_R2_LONG) 1645 { 1646 pc = VM_BR_TARGET; 1647 } 1648 else 1649 { 1650 VM_MODIFY_PC(2); 1651 } 1652 } 1653 VMBREAK; 1654 1655 VMCASE(JIT_OP_BR_LLE_UN): 1656 { 1657 /* Branch if unsigned 64-bit integers are less than or equal */ 1658 if(VM_R1_ULONG <= VM_R2_ULONG) 1659 { 1660 pc = VM_BR_TARGET; 1661 } 1662 else 1663 { 1664 VM_MODIFY_PC(2); 1665 } 1666 } 1667 VMBREAK; 1668 1669 VMCASE(JIT_OP_BR_LGT): 1670 { 1671 /* Branch if signed 64-bit integers are greater than */ 1672 if(VM_R1_LONG > VM_R2_LONG) 1673 { 1674 pc = VM_BR_TARGET; 1675 } 1676 else 1677 { 1678 VM_MODIFY_PC(2); 1679 } 1680 } 1681 VMBREAK; 1682 1683 VMCASE(JIT_OP_BR_LGT_UN): 1684 { 1685 /* Branch if unsigned 64-bit integers are greater than */ 1686 if(VM_R1_ULONG > VM_R2_ULONG) 1687 { 1688 pc = VM_BR_TARGET; 1689 } 1690 else 1691 { 1692 VM_MODIFY_PC(2); 1693 } 1694 } 1695 VMBREAK; 1696 1697 VMCASE(JIT_OP_BR_LGE): 1698 { 1699 /* Branch if signed 64-bit integers are greater than or equal */ 1700 if(VM_R1_LONG >= VM_R2_LONG) 1701 { 1702 pc = VM_BR_TARGET; 1703 } 1704 else 1705 { 1706 VM_MODIFY_PC(2); 1707 } 1708 } 1709 VMBREAK; 1710 1711 VMCASE(JIT_OP_BR_LGE_UN): 1712 { 1713 /* Branch if unsigned 64-bit integers are greater than or equal */ 1714 if(VM_R1_ULONG >= VM_R2_ULONG) 1715 { 1716 pc = VM_BR_TARGET; 1717 } 1718 else 1719 { 1720 VM_MODIFY_PC(2); 1721 } 1722 } 1723 VMBREAK; 1724 1725 VMCASE(JIT_OP_BR_FEQ): 1726 { 1727 /* Branch if 32-bit floats are equal */ 1728 if(jit_float32_eq(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1729 { 1730 pc = VM_BR_TARGET; 1731 } 1732 else 1733 { 1734 VM_MODIFY_PC(2); 1735 } 1736 } 1737 VMBREAK; 1738 1739 VMCASE(JIT_OP_BR_FNE): 1740 { 1741 /* Branch if 32-bit floats are not equal */ 1742 if(jit_float32_ne(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1743 { 1744 pc = VM_BR_TARGET; 1745 } 1746 else 1747 { 1748 VM_MODIFY_PC(2); 1749 } 1750 } 1751 VMBREAK; 1752 1753 VMCASE(JIT_OP_BR_FLT): 1754 { 1755 /* Branch if 32-bit floats are less than */ 1756 if(jit_float32_lt(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1757 { 1758 pc = VM_BR_TARGET; 1759 } 1760 else 1761 { 1762 VM_MODIFY_PC(2); 1763 } 1764 } 1765 VMBREAK; 1766 1767 VMCASE(JIT_OP_BR_FLE): 1768 { 1769 /* Branch if 32-bit floats are less than or equal */ 1770 if(jit_float32_le(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1771 { 1772 pc = VM_BR_TARGET; 1773 } 1774 else 1775 { 1776 VM_MODIFY_PC(2); 1777 } 1778 } 1779 VMBREAK; 1780 1781 VMCASE(JIT_OP_BR_FGT): 1782 { 1783 /* Branch if 32-bit floats are greater than */ 1784 if(jit_float32_gt(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1785 { 1786 pc = VM_BR_TARGET; 1787 } 1788 else 1789 { 1790 VM_MODIFY_PC(2); 1791 } 1792 } 1793 VMBREAK; 1794 1795 VMCASE(JIT_OP_BR_FGE): 1796 { 1797 /* Branch if 32-bit floats are greater than or equal */ 1798 if(jit_float32_ge(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1799 { 1800 pc = VM_BR_TARGET; 1801 } 1802 else 1803 { 1804 VM_MODIFY_PC(2); 1805 } 1806 } 1807 VMBREAK; 1808 1809 VMCASE(JIT_OP_BR_FLT_INV): 1810 { 1811 /* Branch if 32-bit floats are less than; invert nan test */ 1812 if(!jit_float32_ge(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1813 { 1814 pc = VM_BR_TARGET; 1815 } 1816 else 1817 { 1818 VM_MODIFY_PC(2); 1819 } 1820 } 1821 VMBREAK; 1822 1823 VMCASE(JIT_OP_BR_FLE_INV): 1824 { 1825 /* Branch if 32-bit floats are less or equal; invert nan test */ 1826 if(!jit_float32_gt(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1827 { 1828 pc = VM_BR_TARGET; 1829 } 1830 else 1831 { 1832 VM_MODIFY_PC(2); 1833 } 1834 } 1835 VMBREAK; 1836 1837 VMCASE(JIT_OP_BR_FGT_INV): 1838 { 1839 /* Branch if 32-bit floats are greater than; invert nan test */ 1840 if(!jit_float32_le(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1841 { 1842 pc = VM_BR_TARGET; 1843 } 1844 else 1845 { 1846 VM_MODIFY_PC(2); 1847 } 1848 } 1849 VMBREAK; 1850 1851 VMCASE(JIT_OP_BR_FGE_INV): 1852 { 1853 /* Branch if 32-bit floats are greater or equal; invert nan test */ 1854 if(!jit_float32_lt(VM_R1_FLOAT32, VM_R2_FLOAT32)) 1855 { 1856 pc = VM_BR_TARGET; 1857 } 1858 else 1859 { 1860 VM_MODIFY_PC(2); 1861 } 1862 } 1863 VMBREAK; 1864 1865 VMCASE(JIT_OP_BR_DEQ): 1866 { 1867 /* Branch if 64-bit floats are equal */ 1868 if(jit_float64_eq(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1869 { 1870 pc = VM_BR_TARGET; 1871 } 1872 else 1873 { 1874 VM_MODIFY_PC(2); 1875 } 1876 } 1877 VMBREAK; 1878 1879 VMCASE(JIT_OP_BR_DNE): 1880 { 1881 /* Branch if 64-bit floats are not equal */ 1882 if(jit_float64_ne(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1883 { 1884 pc = VM_BR_TARGET; 1885 } 1886 else 1887 { 1888 VM_MODIFY_PC(2); 1889 } 1890 } 1891 VMBREAK; 1892 1893 VMCASE(JIT_OP_BR_DLT): 1894 { 1895 /* Branch if 64-bit floats are less than */ 1896 if(jit_float64_lt(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1897 { 1898 pc = VM_BR_TARGET; 1899 } 1900 else 1901 { 1902 VM_MODIFY_PC(2); 1903 } 1904 } 1905 VMBREAK; 1906 1907 VMCASE(JIT_OP_BR_DLE): 1908 { 1909 /* Branch if 64-bit floats are less than or equal */ 1910 if(jit_float64_le(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1911 { 1912 pc = VM_BR_TARGET; 1913 } 1914 else 1915 { 1916 VM_MODIFY_PC(2); 1917 } 1918 } 1919 VMBREAK; 1920 1921 VMCASE(JIT_OP_BR_DGT): 1922 { 1923 /* Branch if 64-bit floats are greater than */ 1924 if(jit_float64_gt(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1925 { 1926 pc = VM_BR_TARGET; 1927 } 1928 else 1929 { 1930 VM_MODIFY_PC(2); 1931 } 1932 } 1933 VMBREAK; 1934 1935 VMCASE(JIT_OP_BR_DGE): 1936 { 1937 /* Branch if 64-bit floats are greater than or equal */ 1938 if(jit_float64_ge(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1939 { 1940 pc = VM_BR_TARGET; 1941 } 1942 else 1943 { 1944 VM_MODIFY_PC(2); 1945 } 1946 } 1947 VMBREAK; 1948 1949 VMCASE(JIT_OP_BR_DLT_INV): 1950 { 1951 /* Branch if 64-bit floats are less than; invert nan test */ 1952 if(!jit_float64_ge(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1953 { 1954 pc = VM_BR_TARGET; 1955 } 1956 else 1957 { 1958 VM_MODIFY_PC(2); 1959 } 1960 } 1961 VMBREAK; 1962 1963 VMCASE(JIT_OP_BR_DLE_INV): 1964 { 1965 /* Branch if 64-bit floats are less or equal; invert nan test */ 1966 if(!jit_float64_gt(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1967 { 1968 pc = VM_BR_TARGET; 1969 } 1970 else 1971 { 1972 VM_MODIFY_PC(2); 1973 } 1974 } 1975 VMBREAK; 1976 1977 VMCASE(JIT_OP_BR_DGT_INV): 1978 { 1979 /* Branch if 64-bit floats are greater than; invert nan test */ 1980 if(!jit_float64_le(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1981 { 1982 pc = VM_BR_TARGET; 1983 } 1984 else 1985 { 1986 VM_MODIFY_PC(2); 1987 } 1988 } 1989 VMBREAK; 1990 1991 VMCASE(JIT_OP_BR_DGE_INV): 1992 { 1993 /* Branch if 64-bit floats are greater or equal; invert nan test */ 1994 if(!jit_float64_lt(VM_R1_FLOAT64, VM_R2_FLOAT64)) 1995 { 1996 pc = VM_BR_TARGET; 1997 } 1998 else 1999 { 2000 VM_MODIFY_PC(2); 2001 } 2002 } 2003 VMBREAK; 2004 2005 VMCASE(JIT_OP_BR_NFEQ): 2006 { 2007 /* Branch if native floats are equal */ 2008 if(jit_nfloat_eq(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2009 { 2010 pc = VM_BR_TARGET; 2011 } 2012 else 2013 { 2014 VM_MODIFY_PC(2); 2015 } 2016 } 2017 VMBREAK; 2018 2019 VMCASE(JIT_OP_BR_NFNE): 2020 { 2021 /* Branch if native floats are not equal */ 2022 if(jit_nfloat_ne(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2023 { 2024 pc = VM_BR_TARGET; 2025 } 2026 else 2027 { 2028 VM_MODIFY_PC(2); 2029 } 2030 } 2031 VMBREAK; 2032 2033 VMCASE(JIT_OP_BR_NFLT): 2034 { 2035 /* Branch if native floats are less than */ 2036 if(jit_nfloat_lt(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2037 { 2038 pc = VM_BR_TARGET; 2039 } 2040 else 2041 { 2042 VM_MODIFY_PC(2); 2043 } 2044 } 2045 VMBREAK; 2046 2047 VMCASE(JIT_OP_BR_NFLE): 2048 { 2049 /* Branch if native floats are less than or equal */ 2050 if(jit_nfloat_le(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2051 { 2052 pc = VM_BR_TARGET; 2053 } 2054 else 2055 { 2056 VM_MODIFY_PC(2); 2057 } 2058 } 2059 VMBREAK; 2060 2061 VMCASE(JIT_OP_BR_NFGT): 2062 { 2063 /* Branch if native floats are greater than */ 2064 if(jit_nfloat_gt(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2065 { 2066 pc = VM_BR_TARGET; 2067 } 2068 else 2069 { 2070 VM_MODIFY_PC(2); 2071 } 2072 } 2073 VMBREAK; 2074 2075 VMCASE(JIT_OP_BR_NFGE): 2076 { 2077 /* Branch if native floats are greater than or equal */ 2078 if(jit_nfloat_ge(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2079 { 2080 pc = VM_BR_TARGET; 2081 } 2082 else 2083 { 2084 VM_MODIFY_PC(2); 2085 } 2086 } 2087 VMBREAK; 2088 2089 VMCASE(JIT_OP_BR_NFLT_INV): 2090 { 2091 /* Branch if native floats are less than; invert nan test */ 2092 if(!jit_nfloat_ge(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2093 { 2094 pc = VM_BR_TARGET; 2095 } 2096 else 2097 { 2098 VM_MODIFY_PC(2); 2099 } 2100 } 2101 VMBREAK; 2102 2103 VMCASE(JIT_OP_BR_NFLE_INV): 2104 { 2105 /* Branch if native floats are less or equal; invert nan test */ 2106 if(!jit_nfloat_gt(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2107 { 2108 pc = VM_BR_TARGET; 2109 } 2110 else 2111 { 2112 VM_MODIFY_PC(2); 2113 } 2114 } 2115 VMBREAK; 2116 2117 VMCASE(JIT_OP_BR_NFGT_INV): 2118 { 2119 /* Branch if native floats are greater than; invert nan test */ 2120 if(!jit_nfloat_le(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2121 { 2122 pc = VM_BR_TARGET; 2123 } 2124 else 2125 { 2126 VM_MODIFY_PC(2); 2127 } 2128 } 2129 VMBREAK; 2130 2131 VMCASE(JIT_OP_BR_NFGE_INV): 2132 { 2133 /* Branch if native floats are greater or equal; invert nan test */ 2134 if(!jit_nfloat_lt(VM_R1_NFLOAT, VM_R2_NFLOAT)) 2135 { 2136 pc = VM_BR_TARGET; 2137 } 2138 else 2139 { 2140 VM_MODIFY_PC(2); 2141 } 2142 } 2143 VMBREAK; 2144 2145 VMCASE(JIT_OP_JUMP_TABLE): 2146 { 2147 if(VM_R0_INT < VM_NINT_ARG && VM_R0_INT >= 0) 2148 { 2149 pc = pc[2 + VM_R0_INT]; 2150 } 2151 else 2152 { 2153 VM_MODIFY_PC(2 + VM_NINT_ARG); 2154 } 2155 } 2156 VMBREAK; 2157 2158 /****************************************************************** 2159 * Comparison opcodes. 2160 ******************************************************************/ 2161 2162 VMCASE(JIT_OP_ICMP): 2163 { 2164 /* Compare signed 32-bit integers */ 2165 VM_R0_INT = jit_int_cmp(VM_R1_INT, VM_R2_INT); 2166 VM_MODIFY_PC(1); 2167 } 2168 VMBREAK; 2169 2170 VMCASE(JIT_OP_ICMP_UN): 2171 { 2172 /* Compare unsigned 32-bit integers */ 2173 VM_R0_UINT = jit_uint_cmp(VM_R1_UINT, VM_R2_UINT); 2174 VM_MODIFY_PC(1); 2175 } 2176 VMBREAK; 2177 2178 VMCASE(JIT_OP_LCMP): 2179 { 2180 /* Compare signed 64-bit integers */ 2181 VM_R0_INT = jit_long_cmp(VM_R1_LONG, VM_R2_LONG); 2182 VM_MODIFY_PC(1); 2183 } 2184 VMBREAK; 2185 2186 VMCASE(JIT_OP_LCMP_UN): 2187 { 2188 /* Compare unsigned 64-bit integers */ 2189 VM_R0_INT = jit_ulong_cmp(VM_R1_ULONG, VM_R2_ULONG); 2190 VM_MODIFY_PC(1); 2191 } 2192 VMBREAK; 2193 2194 VMCASE(JIT_OP_FCMPL): 2195 { 2196 /* Compare 32-bit floats, with less nan */ 2197 VM_R0_INT = jit_float32_cmpl(VM_R1_FLOAT32, VM_R2_FLOAT32); 2198 VM_MODIFY_PC(1); 2199 } 2200 VMBREAK; 2201 2202 VMCASE(JIT_OP_FCMPG): 2203 { 2204 /* Compare 32-bit floats, with greater nan */ 2205 VM_R0_INT = jit_float32_cmpg(VM_R1_FLOAT32, VM_R2_FLOAT32); 2206 VM_MODIFY_PC(1); 2207 } 2208 VMBREAK; 2209 2210 VMCASE(JIT_OP_DCMPL): 2211 { 2212 /* Compare 64-bit floats, with less nan */ 2213 VM_R0_INT = jit_float64_cmpl(VM_R1_FLOAT64, VM_R2_FLOAT64); 2214 VM_MODIFY_PC(1); 2215 } 2216 VMBREAK; 2217 2218 VMCASE(JIT_OP_DCMPG): 2219 { 2220 /* Compare 64-bit floats, with greater nan */ 2221 VM_R0_INT = jit_float64_cmpg(VM_R1_FLOAT64, VM_R2_FLOAT64); 2222 VM_MODIFY_PC(1); 2223 } 2224 VMBREAK; 2225 2226 VMCASE(JIT_OP_NFCMPL): 2227 { 2228 /* Compare native floats, with less nan */ 2229 VM_R0_INT = jit_float64_cmpl(VM_R1_NFLOAT, VM_R2_NFLOAT); 2230 VM_MODIFY_PC(1); 2231 } 2232 VMBREAK; 2233 2234 VMCASE(JIT_OP_NFCMPG): 2235 { 2236 /* Compare native floats, with greater nan */ 2237 VM_R0_INT = jit_float64_cmpg(VM_R1_NFLOAT, VM_R2_NFLOAT); 2238 VM_MODIFY_PC(1); 2239 } 2240 VMBREAK; 2241 2242 VMCASE(JIT_OP_IEQ): 2243 { 2244 /* Compare signed 32-bit integers for equal */ 2245 VM_R0_INT = (jit_int)(VM_R1_INT == VM_R2_INT); 2246 VM_MODIFY_PC(1); 2247 } 2248 VMBREAK; 2249 2250 VMCASE(JIT_OP_INE): 2251 { 2252 /* Compare signed 32-bit integers for not equal */ 2253 VM_R0_INT = (jit_int)(VM_R1_INT != VM_R2_INT); 2254 VM_MODIFY_PC(1); 2255 } 2256 VMBREAK; 2257 2258 VMCASE(JIT_OP_ILT): 2259 { 2260 /* Compare signed 32-bit integers for less than */ 2261 VM_R0_INT = (jit_int)(VM_R1_INT < VM_R2_INT); 2262 VM_MODIFY_PC(1); 2263 } 2264 VMBREAK; 2265 2266 VMCASE(JIT_OP_ILT_UN): 2267 { 2268 /* Compare unsigned 32-bit integers for less than */ 2269 VM_R0_INT = (jit_int)(VM_R1_UINT < VM_R2_UINT); 2270 VM_MODIFY_PC(1); 2271 } 2272 VMBREAK; 2273 2274 VMCASE(JIT_OP_ILE): 2275 { 2276 /* Compare signed 32-bit integers for less than or equal */ 2277 VM_R0_INT = (jit_int)(VM_R1_INT <= VM_R2_INT); 2278 VM_MODIFY_PC(1); 2279 } 2280 VMBREAK; 2281 2282 VMCASE(JIT_OP_ILE_UN): 2283 { 2284 /* Compare unsigned 32-bit integers for less than or equal */ 2285 VM_R0_INT = (jit_int)(VM_R1_UINT <= VM_R2_UINT); 2286 VM_MODIFY_PC(1); 2287 } 2288 VMBREAK; 2289 2290 VMCASE(JIT_OP_IGT): 2291 { 2292 /* Compare signed 32-bit integers for greater than */ 2293 VM_R0_INT = (jit_int)(VM_R1_INT > VM_R2_INT); 2294 VM_MODIFY_PC(1); 2295 } 2296 VMBREAK; 2297 2298 VMCASE(JIT_OP_IGT_UN): 2299 { 2300 /* Compare unsigned 32-bit integers for greater than */ 2301 VM_R0_INT = (jit_int)(VM_R1_UINT > VM_R2_UINT); 2302 VM_MODIFY_PC(1); 2303 } 2304 VMBREAK; 2305 2306 VMCASE(JIT_OP_IGE): 2307 { 2308 /* Compare signed 32-bit integers for greater than or equal */ 2309 VM_R0_INT = (jit_int)(VM_R1_INT >= VM_R2_INT); 2310 VM_MODIFY_PC(1); 2311 } 2312 VMBREAK; 2313 2314 VMCASE(JIT_OP_IGE_UN): 2315 { 2316 /* Compare unsigned 32-bit integers for greater than or equal */ 2317 VM_R0_INT = (jit_int)(VM_R1_UINT >= VM_R2_UINT); 2318 VM_MODIFY_PC(1); 2319 } 2320 VMBREAK; 2321 2322 VMCASE(JIT_OP_LEQ): 2323 { 2324 /* Compare signed 64-bit integers for equal */ 2325 VM_R0_INT = (jit_int)(VM_R1_LONG == VM_R2_LONG); 2326 VM_MODIFY_PC(1); 2327 } 2328 VMBREAK; 2329 2330 VMCASE(JIT_OP_LNE): 2331 { 2332 /* Compare signed 64-bit integers for not equal */ 2333 VM_R0_INT = (jit_int)(VM_R1_LONG != VM_R2_LONG); 2334 VM_MODIFY_PC(1); 2335 } 2336 VMBREAK; 2337 2338 VMCASE(JIT_OP_LLT): 2339 { 2340 /* Compare signed 64-bit integers for less than */ 2341 VM_R0_INT = (jit_int)(VM_R1_LONG < VM_R2_LONG); 2342 VM_MODIFY_PC(1); 2343 } 2344 VMBREAK; 2345 2346 VMCASE(JIT_OP_LLT_UN): 2347 { 2348 /* Compare unsigned 64-bit integers for less than */ 2349 VM_R0_INT = (jit_int)(VM_R1_ULONG < VM_R2_ULONG); 2350 VM_MODIFY_PC(1); 2351 } 2352 VMBREAK; 2353 2354 VMCASE(JIT_OP_LLE): 2355 { 2356 /* Compare signed 64-bit integers for less than or equal */ 2357 VM_R0_INT = (jit_int)(VM_R1_LONG <= VM_R2_LONG); 2358 VM_MODIFY_PC(1); 2359 } 2360 VMBREAK; 2361 2362 VMCASE(JIT_OP_LLE_UN): 2363 { 2364 /* Compare unsigned 64-bit integers for less than or equal */ 2365 VM_R0_INT = (jit_int)(VM_R1_ULONG <= VM_R2_ULONG); 2366 VM_MODIFY_PC(1); 2367 } 2368 VMBREAK; 2369 2370 VMCASE(JIT_OP_LGT): 2371 { 2372 /* Compare signed 64-bit integers for greater than */ 2373 VM_R0_INT = (jit_int)(VM_R1_LONG > VM_R2_LONG); 2374 VM_MODIFY_PC(1); 2375 } 2376 VMBREAK; 2377 2378 VMCASE(JIT_OP_LGT_UN): 2379 { 2380 /* Compare unsigned 64-bit integers for greater than */ 2381 VM_R0_INT = (jit_int)(VM_R1_ULONG > VM_R2_ULONG); 2382 VM_MODIFY_PC(1); 2383 } 2384 VMBREAK; 2385 2386 VMCASE(JIT_OP_LGE): 2387 { 2388 /* Compare signed 64-bit integers for greater than or equal */ 2389 VM_R0_INT = (jit_int)(VM_R1_LONG >= VM_R2_LONG); 2390 VM_MODIFY_PC(1); 2391 } 2392 VMBREAK; 2393 2394 VMCASE(JIT_OP_LGE_UN): 2395 { 2396 /* Compare unsigned 64-bit integers for greater than or equal */ 2397 VM_R0_INT = (jit_int)(VM_R1_ULONG >= VM_R2_ULONG); 2398 VM_MODIFY_PC(1); 2399 } 2400 VMBREAK; 2401 2402 VMCASE(JIT_OP_FEQ): 2403 { 2404 /* Compare 32-bit floats for equal */ 2405 VM_R0_INT = jit_float32_eq(VM_R1_FLOAT32, VM_R2_FLOAT32); 2406 VM_MODIFY_PC(1); 2407 } 2408 VMBREAK; 2409 2410 VMCASE(JIT_OP_FNE): 2411 { 2412 /* Compare 32-bit floats for not equal */ 2413 VM_R0_INT = jit_float32_ne(VM_R1_FLOAT32, VM_R2_FLOAT32); 2414 VM_MODIFY_PC(1); 2415 } 2416 VMBREAK; 2417 2418 VMCASE(JIT_OP_FLT): 2419 { 2420 /* Compare 32-bit floats for less than */ 2421 VM_R0_INT = jit_float32_lt(VM_R1_FLOAT32, VM_R2_FLOAT32); 2422 VM_MODIFY_PC(1); 2423 } 2424 VMBREAK; 2425 2426 VMCASE(JIT_OP_FLE): 2427 { 2428 /* Compare 32-bit floats for less than or equal */ 2429 VM_R0_INT = jit_float32_le(VM_R1_FLOAT32, VM_R2_FLOAT32); 2430 VM_MODIFY_PC(1); 2431 } 2432 VMBREAK; 2433 2434 VMCASE(JIT_OP_FGT): 2435 { 2436 /* Compare 32-bit floats for greater than */ 2437 VM_R0_INT = jit_float32_gt(VM_R1_FLOAT32, VM_R2_FLOAT32); 2438 VM_MODIFY_PC(1); 2439 } 2440 VMBREAK; 2441 2442 VMCASE(JIT_OP_FGE): 2443 { 2444 /* Compare 32-bit floats for greater than or equal */ 2445 VM_R0_INT = jit_float32_ge(VM_R1_FLOAT32, VM_R2_FLOAT32); 2446 VM_MODIFY_PC(1); 2447 } 2448 VMBREAK; 2449 2450 VMCASE(JIT_OP_FLT_INV): 2451 { 2452 /* Compare 32-bit floats for less than; invert nan test */ 2453 VM_R0_INT = !jit_float32_ge(VM_R1_FLOAT32, VM_R2_FLOAT32); 2454 VM_MODIFY_PC(1); 2455 } 2456 VMBREAK; 2457 2458 VMCASE(JIT_OP_FLE_INV): 2459 { 2460 /* Compare 32-bit floats for less than or equal; invert nan test */ 2461 VM_R0_INT = !jit_float32_gt(VM_R1_FLOAT32, VM_R2_FLOAT32); 2462 VM_MODIFY_PC(1); 2463 } 2464 VMBREAK; 2465 2466 VMCASE(JIT_OP_FGT_INV): 2467 { 2468 /* Compare 32-bit floats for greater than; invert nan test */ 2469 VM_R0_INT = !jit_float32_le(VM_R1_FLOAT32, VM_R2_FLOAT32); 2470 VM_MODIFY_PC(1); 2471 } 2472 VMBREAK; 2473 2474 VMCASE(JIT_OP_FGE_INV): 2475 { 2476 /* Compare 32-bit floats for greater or equal; invert nan test */ 2477 VM_R0_INT = !jit_float32_lt(VM_R1_FLOAT32, VM_R2_FLOAT32); 2478 VM_MODIFY_PC(1); 2479 } 2480 VMBREAK; 2481 2482 VMCASE(JIT_OP_DEQ): 2483 { 2484 /* Compare 64-bit floats for equal */ 2485 VM_R0_INT = jit_float64_eq(VM_R1_FLOAT64, VM_R2_FLOAT64); 2486 VM_MODIFY_PC(1); 2487 } 2488 VMBREAK; 2489 2490 VMCASE(JIT_OP_DNE): 2491 { 2492 /* Compare 64-bit floats for not equal */ 2493 VM_R0_INT = jit_float64_ne(VM_R1_FLOAT64, VM_R2_FLOAT64); 2494 VM_MODIFY_PC(1); 2495 } 2496 VMBREAK; 2497 2498 VMCASE(JIT_OP_DLT): 2499 { 2500 /* Compare 64-bit floats for less than */ 2501 VM_R0_INT = jit_float64_lt(VM_R1_FLOAT64, VM_R2_FLOAT64); 2502 VM_MODIFY_PC(1); 2503 } 2504 VMBREAK; 2505 2506 VMCASE(JIT_OP_DLE): 2507 { 2508 /* Compare 64-bit floats for less than or equal */ 2509 VM_R0_INT = jit_float64_le(VM_R1_FLOAT64, VM_R2_FLOAT64); 2510 VM_MODIFY_PC(1); 2511 } 2512 VMBREAK; 2513 2514 VMCASE(JIT_OP_DGT): 2515 { 2516 /* Compare 64-bit floats for greater than */ 2517 VM_R0_INT = jit_float64_gt(VM_R1_FLOAT64, VM_R2_FLOAT64); 2518 VM_MODIFY_PC(1); 2519 } 2520 VMBREAK; 2521 2522 VMCASE(JIT_OP_DGE): 2523 { 2524 /* Compare 64-bit floats for greater than or equal */ 2525 VM_R0_INT = jit_float64_ge(VM_R1_FLOAT64, VM_R2_FLOAT64); 2526 VM_MODIFY_PC(1); 2527 } 2528 VMBREAK; 2529 2530 VMCASE(JIT_OP_DLT_INV): 2531 { 2532 /* Compare 64-bit floats for equal; invert nan test */ 2533 VM_R0_INT = !jit_float64_ge(VM_R1_FLOAT64, VM_R2_FLOAT64); 2534 VM_MODIFY_PC(1); 2535 } 2536 VMBREAK; 2537 2538 VMCASE(JIT_OP_DLE_INV): 2539 { 2540 /* Compare 64-bit floats for equal; invert nan test */ 2541 VM_R0_INT = !jit_float64_gt(VM_R1_FLOAT64, VM_R2_FLOAT64); 2542 VM_MODIFY_PC(1); 2543 } 2544 VMBREAK; 2545 2546 VMCASE(JIT_OP_DGT_INV): 2547 { 2548 /* Compare 64-bit floats for equal; invert nan test */ 2549 VM_R0_INT = !jit_float64_le(VM_R1_FLOAT64, VM_R2_FLOAT64); 2550 VM_MODIFY_PC(1); 2551 } 2552 VMBREAK; 2553 2554 VMCASE(JIT_OP_DGE_INV): 2555 { 2556 /* Compare 64-bit floats for equal; invert nan test */ 2557 VM_R0_INT = !jit_float64_lt(VM_R1_FLOAT64, VM_R2_FLOAT64); 2558 VM_MODIFY_PC(1); 2559 } 2560 VMBREAK; 2561 2562 VMCASE(JIT_OP_NFEQ): 2563 { 2564 /* Compare native floats for equal */ 2565 VM_R0_INT = jit_nfloat_eq(VM_R1_NFLOAT, VM_R2_NFLOAT); 2566 VM_MODIFY_PC(1); 2567 } 2568 VMBREAK; 2569 2570 VMCASE(JIT_OP_NFNE): 2571 { 2572 /* Compare native floats for not equal */ 2573 VM_R0_INT = jit_nfloat_ne(VM_R1_NFLOAT, VM_R2_NFLOAT); 2574 VM_MODIFY_PC(1); 2575 } 2576 VMBREAK; 2577 2578 VMCASE(JIT_OP_NFLT): 2579 { 2580 /* Compare native floats for less than */ 2581 VM_R0_INT = jit_nfloat_lt(VM_R1_NFLOAT, VM_R2_NFLOAT); 2582 VM_MODIFY_PC(1); 2583 } 2584 VMBREAK; 2585 2586 VMCASE(JIT_OP_NFLE): 2587 { 2588 /* Compare native floats for less than or equal */ 2589 VM_R0_INT = jit_nfloat_le(VM_R1_NFLOAT, VM_R2_NFLOAT); 2590 VM_MODIFY_PC(1); 2591 } 2592 VMBREAK; 2593 2594 VMCASE(JIT_OP_NFGT): 2595 { 2596 /* Compare native floats for greater than */ 2597 VM_R0_INT = jit_nfloat_gt(VM_R1_NFLOAT, VM_R2_NFLOAT); 2598 VM_MODIFY_PC(1); 2599 } 2600 VMBREAK; 2601 2602 VMCASE(JIT_OP_NFGE): 2603 { 2604 /* Compare native floats for greater than or equal */ 2605 VM_R0_INT = jit_nfloat_ge(VM_R1_NFLOAT, VM_R2_NFLOAT); 2606 VM_MODIFY_PC(1); 2607 } 2608 VMBREAK; 2609 2610 VMCASE(JIT_OP_NFLT_INV): 2611 { 2612 /* Compare native floats for less than; invert nan test */ 2613 VM_R0_INT = !jit_nfloat_ge(VM_R1_NFLOAT, VM_R2_NFLOAT); 2614 VM_MODIFY_PC(1); 2615 } 2616 VMBREAK; 2617 2618 VMCASE(JIT_OP_NFLE_INV): 2619 { 2620 /* Compare native floats for less than or equal; invert nan test */ 2621 VM_R0_INT = !jit_nfloat_gt(VM_R1_NFLOAT, VM_R2_NFLOAT); 2622 VM_MODIFY_PC(1); 2623 } 2624 VMBREAK; 2625 2626 VMCASE(JIT_OP_NFGT_INV): 2627 { 2628 /* Compare native floats for greater than; invert nan test */ 2629 VM_R0_INT = !jit_nfloat_le(VM_R1_NFLOAT, VM_R2_NFLOAT); 2630 VM_MODIFY_PC(1); 2631 } 2632 VMBREAK; 2633 2634 VMCASE(JIT_OP_NFGE_INV): 2635 { 2636 /* Compare native floats for greater or equal; invert nan test */ 2637 VM_R0_INT = !jit_nfloat_lt(VM_R1_NFLOAT, VM_R2_NFLOAT); 2638 VM_MODIFY_PC(1); 2639 } 2640 VMBREAK; 2641 2642 VMCASE(JIT_OP_IS_FNAN): 2643 { 2644 /* Check a 32-bit float for "not a number" */ 2645 VM_R0_INT = jit_float32_is_nan(VM_R1_FLOAT32); 2646 VM_MODIFY_PC(1); 2647 } 2648 VMBREAK; 2649 2650 VMCASE(JIT_OP_IS_FINF): 2651 { 2652 /* Check a 32-bit float for "infinity" */ 2653 VM_R0_INT = jit_float32_is_inf(VM_R1_FLOAT32); 2654 VM_MODIFY_PC(1); 2655 } 2656 VMBREAK; 2657 2658 VMCASE(JIT_OP_IS_FFINITE): 2659 { 2660 /* Check a 32-bit float for "finite" */ 2661 VM_R0_INT = jit_float32_is_finite(VM_R1_FLOAT32); 2662 VM_MODIFY_PC(1); 2663 } 2664 VMBREAK; 2665 2666 VMCASE(JIT_OP_IS_DNAN): 2667 { 2668 /* Check a 64-bit float for "not a number" */ 2669 VM_R0_INT = jit_float64_is_nan(VM_R1_FLOAT64); 2670 VM_MODIFY_PC(1); 2671 } 2672 VMBREAK; 2673 2674 VMCASE(JIT_OP_IS_DINF): 2675 { 2676 /* Check a 64-bit float for "infinity" */ 2677 VM_R0_INT = jit_float64_is_inf(VM_R1_FLOAT64); 2678 VM_MODIFY_PC(1); 2679 } 2680 VMBREAK; 2681 2682 VMCASE(JIT_OP_IS_DFINITE): 2683 { 2684 /* Check a 64-bit float for "finite" */ 2685 VM_R0_INT = jit_float64_is_finite(VM_R1_FLOAT64); 2686 VM_MODIFY_PC(1); 2687 } 2688 VMBREAK; 2689 2690 VMCASE(JIT_OP_IS_NFNAN): 2691 { 2692 /* Check a native float for "not a number" */ 2693 VM_R0_INT = jit_nfloat_is_nan(VM_R1_NFLOAT); 2694 VM_MODIFY_PC(1); 2695 } 2696 VMBREAK; 2697 2698 VMCASE(JIT_OP_IS_NFINF): 2699 { 2700 /* Check a native float for "infinity" */ 2701 VM_R0_INT = jit_nfloat_is_inf(VM_R1_NFLOAT); 2702 VM_MODIFY_PC(1); 2703 } 2704 VMBREAK; 2705 2706 VMCASE(JIT_OP_IS_NFFINITE): 2707 { 2708 /* Check a native float for "finite" */ 2709 VM_R0_INT = jit_nfloat_is_finite(VM_R1_NFLOAT); 2710 VM_MODIFY_PC(1); 2711 } 2712 VMBREAK; 2713 2714 /****************************************************************** 2715 * Mathematical functions. 2716 ******************************************************************/ 2717 2718 VMCASE(JIT_OP_FACOS): 2719 { 2720 /* Compute 32-bit float "acos" */ 2721 VM_R0_FLOAT32 = jit_float32_acos(VM_R1_FLOAT32); 2722 VM_MODIFY_PC(1); 2723 } 2724 VMBREAK; 2725 2726 VMCASE(JIT_OP_FASIN): 2727 { 2728 /* Compute 32-bit float "asin" */ 2729 VM_R0_FLOAT32 = jit_float32_asin(VM_R1_FLOAT32); 2730 VM_MODIFY_PC(1); 2731 } 2732 VMBREAK; 2733 2734 VMCASE(JIT_OP_FATAN): 2735 { 2736 /* Compute 32-bit float "atan" */ 2737 VM_R0_FLOAT32 = jit_float32_atan(VM_R1_FLOAT32); 2738 VM_MODIFY_PC(1); 2739 } 2740 VMBREAK; 2741 2742 VMCASE(JIT_OP_FATAN2): 2743 { 2744 /* Compute 32-bit float "atan2" */ 2745 VM_R0_FLOAT32 = jit_float32_atan2(VM_R1_FLOAT32, VM_R2_FLOAT32); 2746 VM_MODIFY_PC(1); 2747 } 2748 VMBREAK; 2749 2750 VMCASE(JIT_OP_FCEIL): 2751 { 2752 /* Compute 32-bit float "ceil" */ 2753 VM_R0_FLOAT32 = jit_float32_ceil(VM_R1_FLOAT32); 2754 VM_MODIFY_PC(1); 2755 } 2756 VMBREAK; 2757 2758 VMCASE(JIT_OP_FCOS): 2759 { 2760 /* Compute 32-bit float "cos" */ 2761 VM_R0_FLOAT32 = jit_float32_cos(VM_R1_FLOAT32); 2762 VM_MODIFY_PC(1); 2763 } 2764 VMBREAK; 2765 2766 VMCASE(JIT_OP_FCOSH): 2767 { 2768 /* Compute 32-bit float "cosh" */ 2769 VM_R0_FLOAT32 = jit_float32_cosh(VM_R1_FLOAT32); 2770 VM_MODIFY_PC(1); 2771 } 2772 VMBREAK; 2773 2774 VMCASE(JIT_OP_FEXP): 2775 { 2776 /* Compute 32-bit float "exp" */ 2777 VM_R0_FLOAT32 = jit_float32_exp(VM_R1_FLOAT32); 2778 VM_MODIFY_PC(1); 2779 } 2780 VMBREAK; 2781 2782 VMCASE(JIT_OP_FFLOOR): 2783 { 2784 /* Compute 32-bit float "floor" */ 2785 VM_R0_FLOAT32 = jit_float32_floor(VM_R1_FLOAT32); 2786 VM_MODIFY_PC(1); 2787 } 2788 VMBREAK; 2789 2790 VMCASE(JIT_OP_FLOG): 2791 { 2792 /* Compute 32-bit float "log" */ 2793 VM_R0_FLOAT32 = jit_float32_log(VM_R1_FLOAT32); 2794 VM_MODIFY_PC(1); 2795 } 2796 VMBREAK; 2797 2798 VMCASE(JIT_OP_FLOG10): 2799 { 2800 /* Compute 32-bit float "log10" */ 2801 VM_R0_FLOAT32 = jit_float32_log10(VM_R1_FLOAT32); 2802 VM_MODIFY_PC(1); 2803 } 2804 VMBREAK; 2805 2806 VMCASE(JIT_OP_FPOW): 2807 { 2808 /* Compute 32-bit float "pow" */ 2809 VM_R0_FLOAT32 = jit_float32_pow(VM_R1_FLOAT32, VM_R2_FLOAT32); 2810 VM_MODIFY_PC(1); 2811 } 2812 VMBREAK; 2813 2814 VMCASE(JIT_OP_FRINT): 2815 { 2816 /* Compute 32-bit float "rint" */ 2817 VM_R0_FLOAT32 = jit_float32_rint(VM_R1_FLOAT32); 2818 VM_MODIFY_PC(1); 2819 } 2820 VMBREAK; 2821 2822 VMCASE(JIT_OP_FROUND): 2823 { 2824 /* Compute 32-bit float "round" */ 2825 VM_R0_FLOAT32 = jit_float32_round(VM_R1_FLOAT32); 2826 VM_MODIFY_PC(1); 2827 } 2828 VMBREAK; 2829 2830 VMCASE(JIT_OP_FSIN): 2831 { 2832 /* Compute 32-bit float "sin" */ 2833 VM_R0_FLOAT32 = jit_float32_sin(VM_R1_FLOAT32); 2834 VM_MODIFY_PC(1); 2835 } 2836 VMBREAK; 2837 2838 VMCASE(JIT_OP_FSINH): 2839 { 2840 /* Compute 32-bit float "sinh" */ 2841 VM_R0_FLOAT32 = jit_float32_sinh(VM_R1_FLOAT32); 2842 VM_MODIFY_PC(1); 2843 } 2844 VMBREAK; 2845 2846 VMCASE(JIT_OP_FSQRT): 2847 { 2848 /* Compute 32-bit float "sqrt" */ 2849 VM_R0_FLOAT32 = jit_float32_sqrt(VM_R1_FLOAT32); 2850 VM_MODIFY_PC(1); 2851 } 2852 VMBREAK; 2853 2854 VMCASE(JIT_OP_FTAN): 2855 { 2856 /* Compute 32-bit float "tan" */ 2857 VM_R0_FLOAT32 = jit_float32_tan(VM_R1_FLOAT32); 2858 VM_MODIFY_PC(1); 2859 } 2860 VMBREAK; 2861 2862 VMCASE(JIT_OP_FTANH): 2863 { 2864 /* Compute 32-bit float "tanh" */ 2865 VM_R0_FLOAT32 = jit_float32_tanh(VM_R1_FLOAT32); 2866 VM_MODIFY_PC(1); 2867 } 2868 VMBREAK; 2869 2870 VMCASE(JIT_OP_FTRUNC): 2871 { 2872 /* Compute 32-bit float "trunc" */ 2873 VM_R0_FLOAT32 = jit_float32_trunc(VM_R1_FLOAT32); 2874 VM_MODIFY_PC(1); 2875 } 2876 VMBREAK; 2877 2878 VMCASE(JIT_OP_DACOS): 2879 { 2880 /* Compute 64-bit float "acos" */ 2881 VM_R0_FLOAT64 = jit_float64_acos(VM_R1_FLOAT64); 2882 VM_MODIFY_PC(1); 2883 } 2884 VMBREAK; 2885 2886 VMCASE(JIT_OP_DASIN): 2887 { 2888 /* Compute 64-bit float "asin" */ 2889 VM_R0_FLOAT64 = jit_float64_asin(VM_R1_FLOAT64); 2890 VM_MODIFY_PC(1); 2891 } 2892 VMBREAK; 2893 2894 VMCASE(JIT_OP_DATAN): 2895 { 2896 /* Compute 64-bit float "atan" */ 2897 VM_R0_FLOAT64 = jit_float64_atan(VM_R1_FLOAT64); 2898 VM_MODIFY_PC(1); 2899 } 2900 VMBREAK; 2901 2902 VMCASE(JIT_OP_DATAN2): 2903 { 2904 /* Compute 64-bit float "atan2" */ 2905 VM_R0_FLOAT64 = jit_float64_atan2(VM_R1_FLOAT64, VM_R2_FLOAT64); 2906 VM_MODIFY_PC(1); 2907 } 2908 VMBREAK; 2909 2910 VMCASE(JIT_OP_DCEIL): 2911 { 2912 /* Compute 64-bit float "ceil" */ 2913 VM_R0_FLOAT64 = jit_float64_ceil(VM_R1_FLOAT64); 2914 VM_MODIFY_PC(1); 2915 } 2916 VMBREAK; 2917 2918 VMCASE(JIT_OP_DCOS): 2919 { 2920 /* Compute 64-bit float "cos" */ 2921 VM_R0_FLOAT64 = jit_float64_cos(VM_R1_FLOAT64); 2922 VM_MODIFY_PC(1); 2923 } 2924 VMBREAK; 2925 2926 VMCASE(JIT_OP_DCOSH): 2927 { 2928 /* Compute 64-bit float "cosh" */ 2929 VM_R0_FLOAT64 = jit_float64_cosh(VM_R1_FLOAT64); 2930 VM_MODIFY_PC(1); 2931 } 2932 VMBREAK; 2933 2934 VMCASE(JIT_OP_DEXP): 2935 { 2936 /* Compute 64-bit float "exp" */ 2937 VM_R0_FLOAT64 = jit_float64_exp(VM_R1_FLOAT64); 2938 VM_MODIFY_PC(1); 2939 } 2940 VMBREAK; 2941 2942 VMCASE(JIT_OP_DFLOOR): 2943 { 2944 /* Compute 64-bit float "floor" */ 2945 VM_R0_FLOAT64 = jit_float64_floor(VM_R1_FLOAT64); 2946 VM_MODIFY_PC(1); 2947 } 2948 VMBREAK; 2949 2950 VMCASE(JIT_OP_DLOG): 2951 { 2952 /* Compute 64-bit float "log" */ 2953 VM_R0_FLOAT64 = jit_float64_log(VM_R1_FLOAT64); 2954 VM_MODIFY_PC(1); 2955 } 2956 VMBREAK; 2957 2958 VMCASE(JIT_OP_DLOG10): 2959 { 2960 /* Compute 64-bit float "log10" */ 2961 VM_R0_FLOAT64 = jit_float64_log10(VM_R1_FLOAT64); 2962 VM_MODIFY_PC(1); 2963 } 2964 VMBREAK; 2965 2966 VMCASE(JIT_OP_DPOW): 2967 { 2968 /* Compute 64-bit float "pow" */ 2969 VM_R0_FLOAT64 = jit_float64_pow(VM_R1_FLOAT64, VM_R2_FLOAT64); 2970 VM_MODIFY_PC(1); 2971 } 2972 VMBREAK; 2973 2974 VMCASE(JIT_OP_DRINT): 2975 { 2976 /* Compute 64-bit float "rint" */ 2977 VM_R0_FLOAT64 = jit_float64_rint(VM_R1_FLOAT64); 2978 VM_MODIFY_PC(1); 2979 } 2980 VMBREAK; 2981 2982 VMCASE(JIT_OP_DROUND): 2983 { 2984 /* Compute 64-bit float "round" */ 2985 VM_R0_FLOAT64 = jit_float64_round(VM_R1_FLOAT64); 2986 VM_MODIFY_PC(1); 2987 } 2988 VMBREAK; 2989 2990 VMCASE(JIT_OP_DSIN): 2991 { 2992 /* Compute 64-bit float "sin" */ 2993 VM_R0_FLOAT64 = jit_float64_sin(VM_R1_FLOAT64); 2994 VM_MODIFY_PC(1); 2995 } 2996 VMBREAK; 2997 2998 VMCASE(JIT_OP_DSINH): 2999 { 3000 /* Compute 64-bit float "sinh" */ 3001 VM_R0_FLOAT64 = jit_float64_sinh(VM_R1_FLOAT64); 3002 VM_MODIFY_PC(1); 3003 } 3004 VMBREAK; 3005 3006 VMCASE(JIT_OP_DSQRT): 3007 { 3008 /* Compute 64-bit float "sqrt" */ 3009 VM_R0_FLOAT64 = jit_float64_sqrt(VM_R1_FLOAT64); 3010 VM_MODIFY_PC(1); 3011 } 3012 VMBREAK; 3013 3014 VMCASE(JIT_OP_DTAN): 3015 { 3016 /* Compute 64-bit float "tan" */ 3017 VM_R0_FLOAT64 = jit_float64_tan(VM_R1_FLOAT64); 3018 VM_MODIFY_PC(1); 3019 } 3020 VMBREAK; 3021 3022 VMCASE(JIT_OP_DTANH): 3023 { 3024 /* Compute 64-bit float "tanh" */ 3025 VM_R0_FLOAT64 = jit_float64_tanh(VM_R1_FLOAT64); 3026 VM_MODIFY_PC(1); 3027 } 3028 VMBREAK; 3029 3030 VMCASE(JIT_OP_DTRUNC): 3031 { 3032 /* Compute 64-bit float "trunc" */ 3033 VM_R0_FLOAT64 = jit_float64_trunc(VM_R1_FLOAT64); 3034 VM_MODIFY_PC(1); 3035 } 3036 VMBREAK; 3037 3038 VMCASE(JIT_OP_NFACOS): 3039 { 3040 /* Compute native float "acos" */ 3041 VM_R0_NFLOAT = jit_nfloat_acos(VM_R1_NFLOAT); 3042 VM_MODIFY_PC(1); 3043 } 3044 VMBREAK; 3045 3046 VMCASE(JIT_OP_NFASIN): 3047 { 3048 /* Compute native float "asin" */ 3049 VM_R0_NFLOAT = jit_nfloat_asin(VM_R1_NFLOAT); 3050 VM_MODIFY_PC(1); 3051 } 3052 VMBREAK; 3053 3054 VMCASE(JIT_OP_NFATAN): 3055 { 3056 /* Compute native float "atan" */ 3057 VM_R0_NFLOAT = jit_nfloat_atan(VM_R1_NFLOAT); 3058 VM_MODIFY_PC(1); 3059 } 3060 VMBREAK; 3061 3062 VMCASE(JIT_OP_NFATAN2): 3063 { 3064 /* Compute native float "atan2" */ 3065 VM_R0_NFLOAT = jit_nfloat_atan2(VM_R1_NFLOAT, VM_R2_NFLOAT); 3066 VM_MODIFY_PC(1); 3067 } 3068 VMBREAK; 3069 3070 VMCASE(JIT_OP_NFCEIL): 3071 { 3072 /* Compute native float "ceil" */ 3073 VM_R0_NFLOAT = jit_nfloat_ceil(VM_R1_NFLOAT); 3074 VM_MODIFY_PC(1); 3075 } 3076 VMBREAK; 3077 3078 VMCASE(JIT_OP_NFCOS): 3079 { 3080 /* Compute native float "cos" */ 3081 VM_R0_NFLOAT = jit_nfloat_cos(VM_R1_NFLOAT); 3082 VM_MODIFY_PC(1); 3083 } 3084 VMBREAK; 3085 3086 VMCASE(JIT_OP_NFCOSH): 3087 { 3088 /* Compute native float "cosh" */ 3089 VM_R0_NFLOAT = jit_nfloat_cosh(VM_R1_NFLOAT); 3090 VM_MODIFY_PC(1); 3091 } 3092 VMBREAK; 3093 3094 VMCASE(JIT_OP_NFEXP): 3095 { 3096 /* Compute native float "exp" */ 3097 VM_R0_NFLOAT = jit_nfloat_exp(VM_R1_NFLOAT); 3098 VM_MODIFY_PC(1); 3099 } 3100 VMBREAK; 3101 3102 VMCASE(JIT_OP_NFFLOOR): 3103 { 3104 /* Compute native float "floor" */ 3105 VM_R0_NFLOAT = jit_nfloat_floor(VM_R1_NFLOAT); 3106 VM_MODIFY_PC(1); 3107 } 3108 VMBREAK; 3109 3110 VMCASE(JIT_OP_NFLOG): 3111 { 3112 /* Compute native float "log" */ 3113 VM_R0_NFLOAT = jit_nfloat_log(VM_R1_NFLOAT); 3114 VM_MODIFY_PC(1); 3115 } 3116 VMBREAK; 3117 3118 VMCASE(JIT_OP_NFLOG10): 3119 { 3120 /* Compute native float "log10" */ 3121 VM_R0_NFLOAT = jit_nfloat_log10(VM_R1_NFLOAT); 3122 VM_MODIFY_PC(1); 3123 } 3124 VMBREAK; 3125 3126 VMCASE(JIT_OP_NFPOW): 3127 { 3128 /* Compute native float "pow" */ 3129 VM_R0_NFLOAT = jit_nfloat_pow(VM_R1_NFLOAT, VM_R2_NFLOAT); 3130 VM_MODIFY_PC(1); 3131 } 3132 VMBREAK; 3133 3134 VMCASE(JIT_OP_NFRINT): 3135 { 3136 /* Compute native float "rint" */ 3137 VM_R0_NFLOAT = jit_nfloat_rint(VM_R1_NFLOAT); 3138 VM_MODIFY_PC(1); 3139 } 3140 VMBREAK; 3141 3142 VMCASE(JIT_OP_NFROUND): 3143 { 3144 /* Compute native float "round" */ 3145 VM_R0_NFLOAT = jit_nfloat_round(VM_R1_NFLOAT); 3146 VM_MODIFY_PC(1); 3147 } 3148 VMBREAK; 3149 3150 VMCASE(JIT_OP_NFSIN): 3151 { 3152 /* Compute native float "sin" */ 3153 VM_R0_NFLOAT = jit_nfloat_sin(VM_R1_NFLOAT); 3154 VM_MODIFY_PC(1); 3155 } 3156 VMBREAK; 3157 3158 VMCASE(JIT_OP_NFSINH): 3159 { 3160 /* Compute native float "sinh" */ 3161 VM_R0_NFLOAT = jit_nfloat_sinh(VM_R1_NFLOAT); 3162 VM_MODIFY_PC(1); 3163 } 3164 VMBREAK; 3165 3166 VMCASE(JIT_OP_NFSQRT): 3167 { 3168 /* Compute native float "sqrt" */ 3169 VM_R0_NFLOAT = jit_nfloat_sqrt(VM_R1_NFLOAT); 3170 VM_MODIFY_PC(1); 3171 } 3172 VMBREAK; 3173 3174 VMCASE(JIT_OP_NFTAN): 3175 { 3176 /* Compute native float "tan" */ 3177 VM_R0_NFLOAT = jit_nfloat_tan(VM_R1_NFLOAT); 3178 VM_MODIFY_PC(1); 3179 } 3180 VMBREAK; 3181 3182 VMCASE(JIT_OP_NFTANH): 3183 { 3184 /* Compute native float "tanh" */ 3185 VM_R0_NFLOAT = jit_nfloat_tanh(VM_R1_NFLOAT); 3186 VM_MODIFY_PC(1); 3187 } 3188 VMBREAK; 3189 3190 VMCASE(JIT_OP_NFTRUNC): 3191 { 3192 /* Compute native float "trunc" */ 3193 VM_R0_NFLOAT = jit_nfloat_trunc(VM_R1_NFLOAT); 3194 VM_MODIFY_PC(1); 3195 } 3196 VMBREAK; 3197 3198 /****************************************************************** 3199 * Absolute, minimum, maximum, and sign. 3200 ******************************************************************/ 3201 3202 VMCASE(JIT_OP_IABS): 3203 { 3204 /* Compute the absolute value of a signed 32-bit integer value */ 3205 VM_R0_INT = jit_int_abs(VM_R1_INT); 3206 VM_MODIFY_PC(1); 3207 } 3208 VMBREAK; 3209 3210 VMCASE(JIT_OP_LABS): 3211 { 3212 /* Compute the absolute value of a signed 64-bit integer value */ 3213 VM_R0_LONG = jit_long_abs(VM_R1_LONG); 3214 VM_MODIFY_PC(1); 3215 } 3216 VMBREAK; 3217 3218 VMCASE(JIT_OP_FABS): 3219 { 3220 /* Compute the absolute value of a 32-bit float value */ 3221 VM_R0_FLOAT32 = jit_float32_abs(VM_R1_FLOAT32); 3222 VM_MODIFY_PC(1); 3223 } 3224 VMBREAK; 3225 3226 VMCASE(JIT_OP_DABS): 3227 { 3228 /* Compute the absolute value of a 64-bit float value */ 3229 VM_R0_FLOAT64 = jit_float64_abs(VM_R1_FLOAT64); 3230 VM_MODIFY_PC(1); 3231 } 3232 VMBREAK; 3233 3234 VMCASE(JIT_OP_NFABS): 3235 { 3236 /* Compute the absolute value of a native float value */ 3237 VM_R0_NFLOAT = jit_nfloat_abs(VM_R1_NFLOAT); 3238 VM_MODIFY_PC(1); 3239 } 3240 VMBREAK; 3241 3242 VMCASE(JIT_OP_IMIN): 3243 { 3244 /* Compute the minimum of two signed 32-bit integer values */ 3245 VM_R0_INT = jit_int_min(VM_R1_INT, VM_R2_INT); 3246 VM_MODIFY_PC(1); 3247 } 3248 VMBREAK; 3249 3250 VMCASE(JIT_OP_IMIN_UN): 3251 { 3252 /* Compute the minimum of two unsigned 32-bit integer values */ 3253 VM_R0_UINT = jit_uint_min(VM_R1_UINT, VM_R2_UINT); 3254 VM_MODIFY_PC(1); 3255 } 3256 VMBREAK; 3257 3258 VMCASE(JIT_OP_LMIN): 3259 { 3260 /* Compute the minimum of two signed 64-bit integer values */ 3261 VM_R0_LONG = jit_long_min(VM_R1_LONG, VM_R2_LONG); 3262 VM_MODIFY_PC(1); 3263 } 3264 VMBREAK; 3265 3266 VMCASE(JIT_OP_LMIN_UN): 3267 { 3268 /* Compute the minimum of two unsigned 64-bit integer values */ 3269 VM_R0_ULONG = jit_ulong_min(VM_R1_ULONG, VM_R2_ULONG); 3270 VM_MODIFY_PC(1); 3271 } 3272 VMBREAK; 3273 3274 VMCASE(JIT_OP_FMIN): 3275 { 3276 /* Compute the minimum of two 32-bit float values */ 3277 VM_R0_FLOAT32 = jit_float32_min(VM_R1_FLOAT32, VM_R2_FLOAT32); 3278 VM_MODIFY_PC(1); 3279 } 3280 VMBREAK; 3281 3282 VMCASE(JIT_OP_DMIN): 3283 { 3284 /* Compute the minimum of two 64-bit float values */ 3285 VM_R0_FLOAT64 = jit_float64_min(VM_R1_FLOAT64, VM_R2_FLOAT64); 3286 VM_MODIFY_PC(1); 3287 } 3288 VMBREAK; 3289 3290 VMCASE(JIT_OP_NFMIN): 3291 { 3292 /* Compute the minimum of two native float values */ 3293 VM_R0_NFLOAT = jit_nfloat_min(VM_R1_NFLOAT, VM_R2_NFLOAT); 3294 VM_MODIFY_PC(1); 3295 } 3296 VMBREAK; 3297 3298 VMCASE(JIT_OP_IMAX): 3299 { 3300 /* Compute the maximum of two signed 32-bit integer values */ 3301 VM_R0_INT = jit_int_max(VM_R1_INT, VM_R2_INT); 3302 VM_MODIFY_PC(1); 3303 } 3304 VMBREAK; 3305 3306 VMCASE(JIT_OP_IMAX_UN): 3307 { 3308 /* Compute the maximum of two unsigned 32-bit integer values */ 3309 VM_R0_UINT = jit_uint_max(VM_R1_UINT, VM_R2_UINT); 3310 VM_MODIFY_PC(1); 3311 } 3312 VMBREAK; 3313 3314 VMCASE(JIT_OP_LMAX): 3315 { 3316 /* Compute the maximum of two signed 64-bit integer values */ 3317 VM_R0_LONG = jit_long_max(VM_R1_LONG, VM_R2_LONG); 3318 VM_MODIFY_PC(1); 3319 } 3320 VMBREAK; 3321 3322 VMCASE(JIT_OP_LMAX_UN): 3323 { 3324 /* Compute the maximum of two unsigned 64-bit integer values */ 3325 VM_R0_ULONG = jit_ulong_max(VM_R1_ULONG, VM_R2_ULONG); 3326 VM_MODIFY_PC(1); 3327 } 3328 VMBREAK; 3329 3330 VMCASE(JIT_OP_FMAX): 3331 { 3332 /* Compute the maximum of two 32-bit float values */ 3333 VM_R0_FLOAT32 = jit_float32_max(VM_R1_FLOAT32, VM_R2_FLOAT32); 3334 VM_MODIFY_PC(1); 3335 } 3336 VMBREAK; 3337 3338 VMCASE(JIT_OP_DMAX): 3339 { 3340 /* Compute the maximum of two 64-bit float values */ 3341 VM_R0_FLOAT64 = jit_float64_max(VM_R1_FLOAT64, VM_R2_FLOAT64); 3342 VM_MODIFY_PC(1); 3343 } 3344 VMBREAK; 3345 3346 VMCASE(JIT_OP_NFMAX): 3347 { 3348 /* Compute the maximum of two native float values */ 3349 VM_R0_NFLOAT = jit_nfloat_max(VM_R1_NFLOAT, VM_R2_NFLOAT); 3350 VM_MODIFY_PC(1); 3351 } 3352 VMBREAK; 3353 3354 VMCASE(JIT_OP_ISIGN): 3355 { 3356 /* Compute the sign of a signed 32-bit integer value */ 3357 VM_R0_INT = jit_int_sign(VM_R1_INT); 3358 VM_MODIFY_PC(1); 3359 } 3360 VMBREAK; 3361 3362 VMCASE(JIT_OP_LSIGN): 3363 { 3364 /* Compute the sign of a signed 64-bit integer value */ 3365 VM_R0_INT = jit_long_sign(VM_R1_LONG); 3366 VM_MODIFY_PC(1); 3367 } 3368 VMBREAK; 3369 3370 VMCASE(JIT_OP_FSIGN): 3371 { 3372 /* Compute the sign of a 32-bit float value */ 3373 VM_R0_INT = jit_float32_sign(VM_R1_FLOAT32); 3374 VM_MODIFY_PC(1); 3375 } 3376 VMBREAK; 3377 3378 VMCASE(JIT_OP_DSIGN): 3379 { 3380 /* Compute the sign of a 64-bit float value */ 3381 VM_R0_INT = jit_float64_sign(VM_R1_FLOAT64); 3382 VM_MODIFY_PC(1); 3383 } 3384 VMBREAK; 3385 3386 VMCASE(JIT_OP_NFSIGN): 3387 { 3388 /* Compute the sign of a native float value */ 3389 VM_R0_INT = jit_nfloat_sign(VM_R1_NFLOAT); 3390 VM_MODIFY_PC(1); 3391 } 3392 VMBREAK; 3393 3394 /****************************************************************** 3395 * Pointer check opcodes. 3396 ******************************************************************/ 3397 3398 VMCASE(JIT_OP_CHECK_NULL): 3399 { 3400 /* Check the top of stack to see if it is null */ 3401 if(!VM_R1_PTR) 3402 { 3403 VM_BUILTIN(JIT_RESULT_NULL_REFERENCE); 3404 } 3405 VM_MODIFY_PC(1); 3406 } 3407 VMBREAK; 3408 3409 /****************************************************************** 3410 * Function calls. 3411 ******************************************************************/ 3412 3413 VMCASE(JIT_OP_CALL): 3414 { 3415 /* Call a function that is under the control of the JIT */ 3416 call_func = (jit_function_t)VM_NINT_ARG; 3417 VM_MODIFY_PC(2); 3418 entry = call_func->entry_point; 3419 _jit_backtrace_push(&call_trace, pc); 3420 if(!entry) 3421 { 3422 entry = (*call_func->context->on_demand_driver)(call_func); 3423 } 3424 _jit_run_function((jit_function_interp_t)entry, 3425 stacktop, 3426 return_area); 3427 _jit_backtrace_pop(); 3428 } 3429 VMBREAK; 3430 3431 VMCASE(JIT_OP_CALL_TAIL): 3432 { 3433 /* Tail call a function that is under the control of the JIT */ 3434 call_func = (jit_function_t)VM_NINT_ARG; 3435 entry = call_func->entry_point; 3436 if(!entry) 3437 { 3438 entry = (*call_func->context->on_demand_driver)(call_func); 3439 } 3440 VM_PERFORM_TAIL((jit_function_interp_t)entry); 3441 } 3442 /* Not reached */ 3443 3444 VMCASE(JIT_OP_CALL_INDIRECT): 3445 VMCASE(JIT_OP_CALL_INDIRECT_TAIL): /* Indirect tail not possible */ 3446 { 3447 /* Call a native function via an indirect pointer */ 3448 tempptr = (void *)VM_NINT_ARG; 3449 temparg = VM_NINT_ARG2; 3450 VM_MODIFY_PC_AND_STACK(3, 1); 3451 _jit_backtrace_push(&call_trace, pc); 3452 apply_from_interpreter((jit_type_t)tempptr, 3453 (void *)VM_R1_PTR, 3454 stacktop, 3455 (unsigned int)temparg, 3456 VM_STK_PTRP); 3457 _jit_backtrace_pop(); 3458 } 3459 VMBREAK; 3460 3461 VMCASE(JIT_OP_CALL_VTABLE_PTR): 3462 { 3463 /* Call a JIT-managed function via an indirect vtable pointer */ 3464 call_func = (jit_function_t)(VM_R1_PTR); 3465 if(!call_func) 3466 { 3467 VM_BUILTIN(JIT_RESULT_NULL_FUNCTION); 3468 } 3469 VM_MODIFY_PC(1); 3470 entry = call_func->entry_point; 3471 _jit_backtrace_push(&call_trace, pc); 3472 if(!entry) 3473 { 3474 entry = (*call_func->context->on_demand_driver)(call_func); 3475 } 3476 _jit_run_function((jit_function_interp_t)entry, 3477 stacktop, 3478 return_area); 3479 _jit_backtrace_pop(); 3480 } 3481 VMBREAK; 3482 3483 VMCASE(JIT_OP_CALL_VTABLE_PTR_TAIL): 3484 { 3485 /* Tail call a JIT-managed function via indirect vtable pointer */ 3486 call_func = (jit_function_t)(VM_R1_PTR); 3487 if(!call_func) 3488 { 3489 VM_BUILTIN(JIT_RESULT_NULL_FUNCTION); 3490 } 3491 entry = call_func->entry_point; 3492 if(!entry) 3493 { 3494 entry = (*call_func->context->on_demand_driver)(call_func); 3495 } 3496 VM_PERFORM_TAIL((jit_function_interp_t)entry); 3497 } 3498 /* Not reached */ 3499 3500 VMCASE(JIT_OP_CALL_EXTERNAL): 3501 VMCASE(JIT_OP_CALL_EXTERNAL_TAIL): /* External tail not possible */ 3502 { 3503 /* Call an external native function */ 3504 tempptr = (void *)VM_NINT_ARG; 3505 tempptr2 = (void *)VM_NINT_ARG2; 3506 temparg = VM_NINT_ARG3; 3507 VM_MODIFY_PC_AND_STACK(4, 1); 3508 _jit_backtrace_push(&call_trace, pc); 3509 apply_from_interpreter((jit_type_t)tempptr, 3510 (void *)tempptr2, 3511 stacktop, 3512 (unsigned int)temparg, 3513 VM_STK_PTRP); 3514 _jit_backtrace_pop(); 3515 } 3516 VMBREAK; 3517 3518 VMCASE(JIT_OP_RETURN): 3519 { 3520 /* Return from the current function, with no result */ 3521 if(jbuf) 3522 { 3523 _jit_unwind_pop_setjmp(); 3524 } 3525 return; 3526 } 3527 /* Not reached */ 3528 3529 VMCASE(JIT_OP_RETURN_INT): 3530 { 3531 /* Return from the current function, with an integer result */ 3532 return_area->int_value = VM_R1_INT; 3533 if(jbuf) 3534 { 3535 _jit_unwind_pop_setjmp(); 3536 } 3537 return; 3538 } 3539 /* Not reached */ 3540 3541 VMCASE(JIT_OP_RETURN_LONG): 3542 { 3543 /* Return from the current function, with a long result */ 3544 return_area->long_value = VM_R1_LONG; 3545 if(jbuf) 3546 { 3547 _jit_unwind_pop_setjmp(); 3548 } 3549 return; 3550 } 3551 /* Not reached */ 3552 3553 VMCASE(JIT_OP_RETURN_FLOAT32): 3554 { 3555 /* Return from the current function, with a 32-bit float result */ 3556 return_area->float32_value = VM_R1_FLOAT32; 3557 if(jbuf) 3558 { 3559 _jit_unwind_pop_setjmp(); 3560 } 3561 return; 3562 } 3563 /* Not reached */ 3564 3565 VMCASE(JIT_OP_RETURN_FLOAT64): 3566 { 3567 /* Return from the current function, with a 64-bit float result */ 3568 return_area->float64_value = VM_R1_FLOAT64; 3569 if(jbuf) 3570 { 3571 _jit_unwind_pop_setjmp(); 3572 } 3573 return; 3574 } 3575 /* Not reached */ 3576 3577 VMCASE(JIT_OP_RETURN_NFLOAT): 3578 { 3579 /* Return from the current function, with a native float result */ 3580 return_area->nfloat_value = VM_R1_NFLOAT; 3581 if(jbuf) 3582 { 3583 _jit_unwind_pop_setjmp(); 3584 } 3585 return; 3586 } 3587 /* Not reached */ 3588 3589 VMCASE(JIT_OP_RETURN_SMALL_STRUCT): 3590 { 3591 /* Return from the current function, with a small structure */ 3592 #if JIT_APPLY_MAX_STRUCT_IN_REG != 0 3593 jit_memcpy(return_area->struct_value, 3594 VM_R1_PTR, 3595 (unsigned int)VM_NINT_ARG); 3596 #endif 3597 if(jbuf) 3598 { 3599 _jit_unwind_pop_setjmp(); 3600 } 3601 return; 3602 } 3603 /* Not reached */ 3604 3605 VMCASE(JIT_OP_PUSH_INT): 3606 { 3607 VM_STK_INTP = VM_R1_INT; 3608 VM_MODIFY_PC_AND_STACK(1, -1); 3609 } 3610 VMBREAK; 3611 3612 VMCASE(JIT_OP_PUSH_LONG): 3613 { 3614 VM_STK_LONGP = VM_R1_LONG; 3615 VM_MODIFY_PC_AND_STACK(1, -1); 3616 } 3617 VMBREAK; 3618 3619 VMCASE(JIT_OP_PUSH_FLOAT32): 3620 { 3621 VM_STK_FLOAT32P = VM_R1_FLOAT32; 3622 VM_MODIFY_PC_AND_STACK(1, -1); 3623 } 3624 VMBREAK; 3625 3626 VMCASE(JIT_OP_PUSH_FLOAT64): 3627 { 3628 VM_STK_FLOAT64P = VM_R1_FLOAT64; 3629 VM_MODIFY_PC_AND_STACK(1, -1); 3630 } 3631 VMBREAK; 3632 3633 VMCASE(JIT_OP_PUSH_NFLOAT): 3634 { 3635 VM_STK_NFLOATP = VM_R1_NFLOAT; 3636 VM_MODIFY_PC_AND_STACK(1, -1); 3637 } 3638 VMBREAK; 3639 3640 VMCASE(JIT_OP_PUSH_STRUCT): 3641 { 3642 /* Push a structure value onto the stack, given a pointer to it */ 3643 temparg = VM_NINT_ARG; 3644 stacktop -= JIT_NUM_ITEMS_IN_STRUCT(temparg); 3645 jit_memcpy(stacktop, VM_R1_PTR, (unsigned int)temparg); 3646 VM_MODIFY_PC(2); 3647 } 3648 VMBREAK; 3649 3650 VMCASE(JIT_OP_FLUSH_SMALL_STRUCT): 3651 { 3652 #if JIT_APPLY_MAX_STRUCT_IN_REG != 0 3653 jit_memcpy(VM_R0_PTR, return_area->struct_value, VM_NINT_ARG); 3654 #endif 3655 VM_MODIFY_PC(2); 3656 } 3657 VMBREAK; 3658 3659 /****************************************************************** 3660 * Exception handling. 3661 ******************************************************************/ 3662 3663 VMCASE(JIT_OP_THROW): 3664 { 3665 /* Throw an exception, which may be handled in this function */ 3666 exception_object = VM_R1_PTR; 3667 exception_pc = pc; 3668 handle_exception: 3669 tempptr = jit_function_from_pc(func->func->context, pc, &handler); 3670 if(tempptr == func->func && handler != 0) 3671 { 3672 /* We have an appropriate "catch" handler in this function */ 3673 pc = (void **)handler; 3674 stacktop = frame; 3675 VM_R0_PTR = exception_object; 3676 } 3677 else 3678 { 3679 /* Throw the exception up to the next level */ 3680 if(jbuf) 3681 { 3682 _jit_unwind_pop_setjmp(); 3683 } 3684 jit_exception_throw(exception_object); 3685 } 3686 } 3687 VMBREAK; 3688 3689 VMCASE(JIT_OP_RETHROW): 3690 { 3691 /* Rethrow an exception to the caller */ 3692 if(jbuf) 3693 { 3694 _jit_unwind_pop_setjmp(); 3695 } 3696 jit_exception_throw(VM_R1_PTR); 3697 } 3698 VMBREAK; 3699 3700 VMCASE(JIT_OP_LOAD_PC): 3701 { 3702 /* Load the current program counter onto the stack */ 3703 VM_R0_PTR = (void *)pc; 3704 VM_MODIFY_PC(1); 3705 } 3706 VMBREAK; 3707 3708 VMCASE(JIT_OP_LOAD_EXCEPTION_PC): 3709 { 3710 /* Load the address where the exception occurred onto the stack */ 3711 VM_R0_PTR = (void *)exception_pc; 3712 VM_MODIFY_PC(1); 3713 } 3714 VMBREAK; 3715 3716 VMCASE(JIT_OP_LEAVE_FINALLY): 3717 { 3718 /* Return from a "finally" handler */ 3719 pc = (void **)VM_STK_PTR0; 3720 VM_MODIFY_STACK(1); 3721 } 3722 VMBREAK; 3723 3724 VMCASE(JIT_OP_LEAVE_FILTER): 3725 { 3726 /* Return from a "filter" handler: pc on stack */ 3727 pc = (void **)(stacktop[0].ptr_value); 3728 VM_MODIFY_STACK(1); 3729 } 3730 VMBREAK; 3731 3732 VMCASE(JIT_OP_CALL_FILTER): 3733 { 3734 /* Call a "filter" handler with pc and value on stack */ 3735 stacktop[-1].ptr_value = (void *)(pc + 2); 3736 VM_MODIFY_STACK(-1); 3737 pc = VM_BR_TARGET; 3738 } 3739 VMBREAK; 3740 3741 VMCASE(JIT_OP_CALL_FINALLY): 3742 { 3743 /* Call a "finally" handler */ 3744 VM_STK_PTRP = (void *)(pc + 2); 3745 VM_MODIFY_STACK(-1); 3746 pc = VM_BR_TARGET; 3747 } 3748 VMBREAK; 3749 3750 VMCASE(JIT_OP_ADDRESS_OF_LABEL): 3751 { 3752 /* Load the address of a label onto the stack */ 3753 VM_R0_PTR = VM_BR_TARGET; 3754 VM_MODIFY_PC(2); 3755 } 3756 VMBREAK; 3757 3758 /****************************************************************** 3759 * Data manipulation. 3760 ******************************************************************/ 3761 3762 VMCASE(JIT_OP_COPY_STRUCT): 3763 { 3764 /* Copy a structure from one address to another */ 3765 jit_memcpy(VM_R0_PTR, VM_R1_PTR, VM_NINT_ARG); 3766 VM_MODIFY_PC(2); 3767 } 3768 VMBREAK; 3769 3770 /****************************************************************** 3771 * Pointer-relative loads and stores. 3772 ******************************************************************/ 3773 3774 VMCASE(JIT_OP_LOAD_RELATIVE_SBYTE): 3775 { 3776 /* Load a signed 8-bit integer from a relative pointer */ 3777 VM_R0_INT = *VM_REL(jit_sbyte, VM_R1_PTR); 3778 VM_MODIFY_PC(2); 3779 } 3780 VMBREAK; 3781 3782 VMCASE(JIT_OP_LOAD_RELATIVE_UBYTE): 3783 { 3784 /* Load an unsigned 8-bit integer from a relative pointer */ 3785 VM_R0_INT = *VM_REL(jit_ubyte, VM_R1_PTR); 3786 VM_MODIFY_PC(2); 3787 } 3788 VMBREAK; 3789 3790 VMCASE(JIT_OP_LOAD_RELATIVE_SHORT): 3791 { 3792 /* Load a signed 16-bit integer from a relative pointer */ 3793 VM_R0_INT = *VM_REL(jit_short, VM_R1_PTR); 3794 VM_MODIFY_PC(2); 3795 } 3796 VMBREAK; 3797 3798 VMCASE(JIT_OP_LOAD_RELATIVE_USHORT): 3799 { 3800 /* Load an unsigned 16-bit integer from a relative pointer */ 3801 VM_R0_INT = *VM_REL(jit_ushort, VM_R1_PTR); 3802 VM_MODIFY_PC(2); 3803 } 3804 VMBREAK; 3805 3806 VMCASE(JIT_OP_LOAD_RELATIVE_INT): 3807 { 3808 /* Load a 32-bit integer from a relative pointer */ 3809 VM_R0_INT = *VM_REL(jit_int, VM_R1_PTR); 3810 VM_MODIFY_PC(2); 3811 } 3812 VMBREAK; 3813 3814 VMCASE(JIT_OP_LOAD_RELATIVE_LONG): 3815 { 3816 /* Load a 64-bit integer from a relative pointer */ 3817 VM_R0_LONG = *VM_REL(jit_long, VM_R1_PTR); 3818 VM_MODIFY_PC(2); 3819 } 3820 VMBREAK; 3821 3822 VMCASE(JIT_OP_LOAD_RELATIVE_FLOAT32): 3823 { 3824 /* Load a 32-bit float from a relative pointer */ 3825 VM_R0_FLOAT32 = *VM_REL(jit_float32, VM_R1_PTR); 3826 VM_MODIFY_PC(2); 3827 } 3828 VMBREAK; 3829 3830 VMCASE(JIT_OP_LOAD_RELATIVE_FLOAT64): 3831 { 3832 /* Load a 64-bit float from a relative pointer */ 3833 VM_R0_FLOAT64 = *VM_REL(jit_float64, VM_R1_PTR); 3834 VM_MODIFY_PC(2); 3835 } 3836 VMBREAK; 3837 3838 VMCASE(JIT_OP_LOAD_RELATIVE_NFLOAT): 3839 { 3840 /* Load a native float from a relative pointer */ 3841 VM_R0_NFLOAT = *VM_REL(jit_nfloat, VM_R1_PTR); 3842 VM_MODIFY_PC(2); 3843 } 3844 VMBREAK; 3845 3846 VMCASE(JIT_OP_LOAD_RELATIVE_STRUCT): 3847 { 3848 /* Load a structure from a relative pointer */ 3849 jit_memcpy(VM_R0_PTR, VM_REL(void, VM_R1_PTR), VM_NINT_ARG2); 3850 VM_MODIFY_PC(3); 3851 } 3852 VMBREAK; 3853 3854 VMCASE(JIT_OP_STORE_RELATIVE_BYTE): 3855 { 3856 /* Store an 8-bit integer value to a relative pointer */ 3857 *VM_REL(jit_sbyte, VM_R0_PTR) = (jit_sbyte)VM_R1_INT; 3858 VM_MODIFY_PC(2); 3859 } 3860 VMBREAK; 3861 3862 VMCASE(JIT_OP_STORE_RELATIVE_SHORT): 3863 { 3864 /* Store a 16-bit integer value to a relative pointer */ 3865 *VM_REL(jit_short, VM_R0_PTR) = (jit_short)VM_R1_INT; 3866 VM_MODIFY_PC(2); 3867 } 3868 VMBREAK; 3869 3870 VMCASE(JIT_OP_STORE_RELATIVE_INT): 3871 { 3872 /* Store a 32-bit integer value to a relative pointer */ 3873 *VM_REL(jit_int, VM_R0_PTR) = VM_R1_INT; 3874 VM_MODIFY_PC(2); 3875 } 3876 VMBREAK; 3877 3878 VMCASE(JIT_OP_STORE_RELATIVE_LONG): 3879 { 3880 /* Store a 64-bit integer value to a relative pointer */ 3881 *VM_REL(jit_long, VM_R0_PTR) = VM_R1_LONG; 3882 VM_MODIFY_PC(2); 3883 } 3884 VMBREAK; 3885 3886 VMCASE(JIT_OP_STORE_RELATIVE_FLOAT32): 3887 { 3888 /* Store a 32-bit float value to a relative pointer */ 3889 *VM_REL(jit_float32, VM_R0_PTR) = VM_R1_FLOAT32; 3890 VM_MODIFY_PC(2); 3891 } 3892 VMBREAK; 3893 3894 VMCASE(JIT_OP_STORE_RELATIVE_FLOAT64): 3895 { 3896 /* Store a 64-bit float value to a relative pointer */ 3897 *VM_REL(jit_float64, VM_R0_PTR) = VM_R1_FLOAT64; 3898 VM_MODIFY_PC(2); 3899 } 3900 VMBREAK; 3901 3902 VMCASE(JIT_OP_STORE_RELATIVE_NFLOAT): 3903 { 3904 /* Store a native float value to a relative pointer */ 3905 *VM_REL(jit_nfloat, VM_R0_PTR) = VM_R1_NFLOAT; 3906 VM_MODIFY_PC(2); 3907 } 3908 VMBREAK; 3909 3910 VMCASE(JIT_OP_STORE_RELATIVE_STRUCT): 3911 { 3912 /* Store a structure value to a relative pointer */ 3913 jit_memcpy(VM_REL(void, VM_R0_PTR), VM_R1_PTR, VM_NINT_ARG2); 3914 VM_MODIFY_PC(3); 3915 } 3916 VMBREAK; 3917 3918 VMCASE(JIT_OP_ADD_RELATIVE): 3919 { 3920 /* Add a relative offset to a pointer */ 3921 VM_R0_PTR = VM_REL(void, VM_R1_PTR); 3922 VM_MODIFY_PC(2); 3923 } 3924 VMBREAK; 3925 3926 /****************************************************************** 3927 * Array element loads and stores. 3928 ******************************************************************/ 3929 3930 VMCASE(JIT_OP_LOAD_ELEMENT_SBYTE): 3931 { 3932 /* Load a signed 8-bit integer value from an array */ 3933 VM_R0_INT = VM_LOAD_ELEM(jit_sbyte); 3934 VM_MODIFY_PC(1); 3935 } 3936 VMBREAK; 3937 3938 VMCASE(JIT_OP_LOAD_ELEMENT_UBYTE): 3939 { 3940 /* Load an unsigned 8-bit integer value from an array */ 3941 VM_R0_INT = VM_LOAD_ELEM(jit_ubyte); 3942 VM_MODIFY_PC(1); 3943 } 3944 VMBREAK; 3945 3946 VMCASE(JIT_OP_LOAD_ELEMENT_SHORT): 3947 { 3948 /* Load a signed 16-bit integer value from an array */ 3949 VM_R0_INT = VM_LOAD_ELEM(jit_short); 3950 VM_MODIFY_PC(1); 3951 } 3952 VMBREAK; 3953 3954 VMCASE(JIT_OP_LOAD_ELEMENT_USHORT): 3955 { 3956 /* Load an unsigned 16-bit integer value from an array */ 3957 VM_R0_INT = VM_LOAD_ELEM(jit_ushort); 3958 VM_MODIFY_PC(1); 3959 } 3960 VMBREAK; 3961 3962 VMCASE(JIT_OP_LOAD_ELEMENT_INT): 3963 { 3964 /* Load a signed 32-bit integer value from an array */ 3965 VM_R0_INT = VM_LOAD_ELEM(jit_int); 3966 VM_MODIFY_PC(1); 3967 } 3968 VMBREAK; 3969 3970 VMCASE(JIT_OP_LOAD_ELEMENT_LONG): 3971 { 3972 /* Load a signed 64-bit integer value from an array */ 3973 VM_R0_LONG = VM_LOAD_ELEM(jit_long); 3974 VM_MODIFY_PC(1); 3975 } 3976 VMBREAK; 3977 3978 VMCASE(JIT_OP_LOAD_ELEMENT_FLOAT32): 3979 { 3980 /* Load a 32-bit float value from an array */ 3981 VM_R0_FLOAT32 = VM_LOAD_ELEM(jit_float32); 3982 VM_MODIFY_PC(1); 3983 } 3984 VMBREAK; 3985 3986 VMCASE(JIT_OP_LOAD_ELEMENT_FLOAT64): 3987 { 3988 /* Load a 64-bit float value from an array */ 3989 VM_R0_FLOAT64 = VM_LOAD_ELEM(jit_float64); 3990 VM_MODIFY_PC(1); 3991 } 3992 VMBREAK; 3993 3994 VMCASE(JIT_OP_LOAD_ELEMENT_NFLOAT): 3995 { 3996 /* Load a native float value from an array */ 3997 VM_R0_NFLOAT = VM_LOAD_ELEM(jit_nfloat); 3998 VM_MODIFY_PC(1); 3999 } 4000 VMBREAK; 4001 4002 VMCASE(JIT_OP_STORE_ELEMENT_BYTE): 4003 { 4004 /* Store a 8-bit integer value to an array */ 4005 VM_STORE_ELEM(jit_sbyte, VM_R2_INT); 4006 VM_MODIFY_PC(1); 4007 } 4008 VMBREAK; 4009 4010 VMCASE(JIT_OP_STORE_ELEMENT_SHORT): 4011 { 4012 /* Store a 16-bit integer value to an array */ 4013 VM_STORE_ELEM(jit_short, VM_R2_INT); 4014 VM_MODIFY_PC(1); 4015 } 4016 VMBREAK; 4017 4018 VMCASE(JIT_OP_STORE_ELEMENT_INT): 4019 { 4020 /* Store a 32-bit integer value to an array */ 4021 VM_STORE_ELEM(jit_int, VM_R2_INT); 4022 VM_MODIFY_PC(1); 4023 } 4024 VMBREAK; 4025 4026 VMCASE(JIT_OP_STORE_ELEMENT_LONG): 4027 { 4028 /* Store a 64-bit integer value to an array */ 4029 VM_STORE_ELEM(jit_long, VM_R2_LONG); 4030 VM_MODIFY_PC(1); 4031 } 4032 VMBREAK; 4033 4034 VMCASE(JIT_OP_STORE_ELEMENT_FLOAT32): 4035 { 4036 /* Store a 32-bit float value to an array */ 4037 VM_STORE_ELEM(jit_float32, VM_R2_FLOAT32); 4038 VM_MODIFY_PC(1); 4039 } 4040 VMBREAK; 4041 4042 VMCASE(JIT_OP_STORE_ELEMENT_FLOAT64): 4043 { 4044 /* Store a 64-bit float value to an array */ 4045 VM_STORE_ELEM(jit_float64, VM_R2_FLOAT64); 4046 VM_MODIFY_PC(1); 4047 } 4048 VMBREAK; 4049 4050 VMCASE(JIT_OP_STORE_ELEMENT_NFLOAT): 4051 { 4052 /* Store a native float value to an array */ 4053 VM_STORE_ELEM(jit_nfloat, VM_R2_NFLOAT); 4054 VM_MODIFY_PC(1); 4055 } 4056 VMBREAK; 4057 4058 /****************************************************************** 4059 * Block operations. 4060 ******************************************************************/ 4061 4062 VMCASE(JIT_OP_MEMCPY): 4063 { 4064 /* Copy a block of memory */ 4065 jit_memcpy(VM_R0_PTR, VM_R1_PTR, VM_R2_NUINT); 4066 VM_MODIFY_PC(1); 4067 } 4068 VMBREAK; 4069 4070 VMCASE(JIT_OP_MEMMOVE): 4071 { 4072 /* Move a block of memory */ 4073 jit_memmove(VM_R0_PTR, VM_R1_PTR, VM_R2_NUINT); 4074 VM_MODIFY_PC(1); 4075 } 4076 VMBREAK; 4077 4078 VMCASE(JIT_OP_MEMSET): 4079 { 4080 /* Set a block of memory to a value */ 4081 jit_memset(VM_R0_PTR, (int)VM_R1_INT, VM_R2_NUINT); 4082 VM_MODIFY_PC(1); 4083 } 4084 VMBREAK; 4085 4086 /****************************************************************** 4087 * Allocate memory from the stack. 4088 ******************************************************************/ 4089 4090 VMCASE(JIT_OP_ALLOCA): 4091 { 4092 /* Allocate memory from the stack */ 4093 VM_R0_PTR = (void *)alloca(VM_R1_NUINT); 4094 VM_MODIFY_PC(1); 4095 4096 /* We need to reset the "setjmp" point for this function 4097 because the saved stack pointer is no longer the same. 4098 If we don't do this, then an exception throw will pop 4099 the alloca'ed memory, causing dangling pointer problems */ 4100 if(jbuf) 4101 { 4102 if(setjmp(jbuf->buf)) 4103 { 4104 exception_object = jit_exception_get_last_and_clear(); 4105 exception_pc = pc - 1; 4106 goto handle_exception; 4107 } 4108 } 4109 } 4110 VMBREAK; 4111 4112 /****************************************************************** 4113 * Argument variable access opcodes. 4114 ******************************************************************/ 4115 4116 VMCASE(JIT_INTERP_OP_LDA_0_SBYTE): 4117 { 4118 /* Load a signed 8-bit integer argument into the register 0 */ 4119 VM_R0_INT = *VM_ARG(jit_sbyte); 4120 VM_MODIFY_PC(2); 4121 } 4122 VMBREAK; 4123 4124 VMCASE(JIT_INTERP_OP_LDA_0_UBYTE): 4125 { 4126 /* Load an unsigned 8-bit integer argument into the register 0 */ 4127 VM_R0_INT = *VM_ARG(jit_ubyte); 4128 VM_MODIFY_PC(2); 4129 } 4130 VMBREAK; 4131 4132 VMCASE(JIT_INTERP_OP_LDA_0_SHORT): 4133 { 4134 /* Load a signed 16-bit integer argument into the register 0 */ 4135 VM_R0_INT = *VM_ARG(jit_short); 4136 VM_MODIFY_PC(2); 4137 } 4138 VMBREAK; 4139 4140 VMCASE(JIT_INTERP_OP_LDA_0_USHORT): 4141 { 4142 /* Load am unsigned 16-bit argument local into the register 0 */ 4143 VM_R0_INT = *VM_ARG(jit_ushort); 4144 VM_MODIFY_PC(2); 4145 } 4146 VMBREAK; 4147 4148 VMCASE(JIT_INTERP_OP_LDA_0_INT): 4149 { 4150 /* Load a 32-bit integer argument into the register 0 */ 4151 VM_R0_INT = *VM_ARG(jit_int); 4152 VM_MODIFY_PC(2); 4153 } 4154 VMBREAK; 4155 4156 VMCASE(JIT_INTERP_OP_LDA_0_LONG): 4157 { 4158 /* Load a 64-bit integer argument into the register 0 */ 4159 VM_R0_LONG = *VM_ARG(jit_long); 4160 VM_MODIFY_PC(2); 4161 } 4162 VMBREAK; 4163 4164 VMCASE(JIT_INTERP_OP_LDA_0_FLOAT32): 4165 { 4166 /* Load a 32-bit float argument into the register 0 */ 4167 VM_R0_FLOAT32 = *VM_ARG(jit_float32); 4168 VM_MODIFY_PC(2); 4169 } 4170 VMBREAK; 4171 4172 VMCASE(JIT_INTERP_OP_LDA_0_FLOAT64): 4173 { 4174 /* Load a 64-bit float argument into the register 0 */ 4175 VM_R0_FLOAT64 = *VM_ARG(jit_float64); 4176 VM_MODIFY_PC(2); 4177 } 4178 VMBREAK; 4179 4180 VMCASE(JIT_INTERP_OP_LDA_0_NFLOAT): 4181 { 4182 /* Load a native float argument into the register 0 */ 4183 VM_R0_NFLOAT = *VM_ARG(jit_nfloat); 4184 VM_MODIFY_PC(2); 4185 } 4186 VMBREAK; 4187 4188 VMCASE(JIT_INTERP_OP_LDAA_0): 4189 { 4190 /* Load the address of an argument into the register 0 */ 4191 VM_R0_PTR = VM_ARG(void); 4192 VM_MODIFY_PC(2); 4193 } 4194 VMBREAK; 4195 4196 VMCASE(JIT_INTERP_OP_LDA_1_SBYTE): 4197 { 4198 /* Load a signed 8-bit integer argument into the register 1 */ 4199 VM_R1_INT = *VM_ARG(jit_sbyte); 4200 VM_MODIFY_PC(2); 4201 } 4202 VMBREAK; 4203 4204 VMCASE(JIT_INTERP_OP_LDA_1_UBYTE): 4205 { 4206 /* Load an unsigned 8-bit integer argument into the register 1 */ 4207 VM_R1_INT = *VM_ARG(jit_ubyte); 4208 VM_MODIFY_PC(2); 4209 } 4210 VMBREAK; 4211 4212 VMCASE(JIT_INTERP_OP_LDA_1_SHORT): 4213 { 4214 /* Load a signed 16-bit integer argument into the register 1 */ 4215 VM_R1_INT = *VM_ARG(jit_short); 4216 VM_MODIFY_PC(2); 4217 } 4218 VMBREAK; 4219 4220 VMCASE(JIT_INTERP_OP_LDA_1_USHORT): 4221 { 4222 /* Load am unsigned 16-bit argument local into the register 1 */ 4223 VM_R1_INT = *VM_ARG(jit_ushort); 4224 VM_MODIFY_PC(2); 4225 } 4226 VMBREAK; 4227 4228 VMCASE(JIT_INTERP_OP_LDA_1_INT): 4229 { 4230 /* Load a 32-bit integer argument into the register 1 */ 4231 VM_R1_INT = *VM_ARG(jit_int); 4232 VM_MODIFY_PC(2); 4233 } 4234 VMBREAK; 4235 4236 VMCASE(JIT_INTERP_OP_LDA_1_LONG): 4237 { 4238 /* Load a 64-bit integer argument into the register 1 */ 4239 VM_R1_LONG = *VM_ARG(jit_long); 4240 VM_MODIFY_PC(2); 4241 } 4242 VMBREAK; 4243 4244 VMCASE(JIT_INTERP_OP_LDA_1_FLOAT32): 4245 { 4246 /* Load a 32-bit float argument into the register 1 */ 4247 VM_R1_FLOAT32 = *VM_ARG(jit_float32); 4248 VM_MODIFY_PC(2); 4249 } 4250 VMBREAK; 4251 4252 VMCASE(JIT_INTERP_OP_LDA_1_FLOAT64): 4253 { 4254 /* Load a 64-bit float argument into the register 1 */ 4255 VM_R1_FLOAT64 = *VM_ARG(jit_float64); 4256 VM_MODIFY_PC(2); 4257 } 4258 VMBREAK; 4259 4260 VMCASE(JIT_INTERP_OP_LDA_1_NFLOAT): 4261 { 4262 /* Load a native float argument into the register 1 */ 4263 VM_R1_NFLOAT = *VM_ARG(jit_nfloat); 4264 VM_MODIFY_PC(2); 4265 } 4266 VMBREAK; 4267 4268 VMCASE(JIT_INTERP_OP_LDAA_1): 4269 { 4270 /* Load the address of an argument into the register 1 */ 4271 VM_R1_PTR = VM_ARG(void); 4272 VM_MODIFY_PC(2); 4273 } 4274 VMBREAK; 4275 4276 VMCASE(JIT_INTERP_OP_LDA_2_SBYTE): 4277 { 4278 /* Load a signed 8-bit integer argument into the register 2 */ 4279 VM_R2_INT = *VM_ARG(jit_sbyte); 4280 VM_MODIFY_PC(2); 4281 } 4282 VMBREAK; 4283 4284 VMCASE(JIT_INTERP_OP_LDA_2_UBYTE): 4285 { 4286 /* Load an unsigned 8-bit integer argument into the register 2 */ 4287 VM_R2_INT = *VM_ARG(jit_ubyte); 4288 VM_MODIFY_PC(2); 4289 } 4290 VMBREAK; 4291 4292 VMCASE(JIT_INTERP_OP_LDA_2_SHORT): 4293 { 4294 /* Load a signed 16-bit integer argument into the register 2 */ 4295 VM_R2_INT = *VM_ARG(jit_short); 4296 VM_MODIFY_PC(2); 4297 } 4298 VMBREAK; 4299 4300 VMCASE(JIT_INTERP_OP_LDA_2_USHORT): 4301 { 4302 /* Load am unsigned 16-bit argument local into the register 2 */ 4303 VM_R2_INT = *VM_ARG(jit_ushort); 4304 VM_MODIFY_PC(2); 4305 } 4306 VMBREAK; 4307 4308 VMCASE(JIT_INTERP_OP_LDA_2_INT): 4309 { 4310 /* Load a 32-bit integer argument into the register 2 */ 4311 VM_R2_INT = *VM_ARG(jit_int); 4312 VM_MODIFY_PC(2); 4313 } 4314 VMBREAK; 4315 4316 VMCASE(JIT_INTERP_OP_LDA_2_LONG): 4317 { 4318 /* Load a 64-bit integer argument into the register 2 */ 4319 VM_R2_LONG = *VM_ARG(jit_long); 4320 VM_MODIFY_PC(2); 4321 } 4322 VMBREAK; 4323 4324 VMCASE(JIT_INTERP_OP_LDA_2_FLOAT32): 4325 { 4326 /* Load a 32-bit float argument into the register 2 */ 4327 VM_R2_FLOAT32 = *VM_ARG(jit_float32); 4328 VM_MODIFY_PC(2); 4329 } 4330 VMBREAK; 4331 4332 VMCASE(JIT_INTERP_OP_LDA_2_FLOAT64): 4333 { 4334 /* Load a 64-bit float argument into the register 2 */ 4335 VM_R2_FLOAT64 = *VM_ARG(jit_float64); 4336 VM_MODIFY_PC(2); 4337 } 4338 VMBREAK; 4339 4340 VMCASE(JIT_INTERP_OP_LDA_2_NFLOAT): 4341 { 4342 /* Load a native float argument into the register 2 */ 4343 VM_R2_NFLOAT = *VM_ARG(jit_nfloat); 4344 VM_MODIFY_PC(2); 4345 } 4346 VMBREAK; 4347 4348 VMCASE(JIT_INTERP_OP_LDAA_2): 4349 { 4350 /* Load the address of an argument into the register 2 */ 4351 VM_R2_PTR = VM_ARG(void); 4352 VM_MODIFY_PC(2); 4353 } 4354 VMBREAK; 4355 4356 VMCASE(JIT_INTERP_OP_STA_0_BYTE): 4357 { 4358 /* Store an 8-bit integer into an argument */ 4359 *VM_ARG(jit_sbyte) = (jit_sbyte)VM_R0_INT; 4360 VM_MODIFY_PC(2); 4361 } 4362 VMBREAK; 4363 4364 VMCASE(JIT_INTERP_OP_STA_0_SHORT): 4365 { 4366 /* Store an 16-bit integer into an argument */ 4367 *VM_ARG(jit_short) = (jit_short)VM_R0_INT; 4368 VM_MODIFY_PC(2); 4369 } 4370 VMBREAK; 4371 4372 VMCASE(JIT_INTERP_OP_STA_0_INT): 4373 { 4374 /* Store an 32-bit integer into an argument */ 4375 *VM_ARG(jit_int) = (jit_int)VM_R0_INT; 4376 VM_MODIFY_PC(2); 4377 } 4378 VMBREAK; 4379 4380 VMCASE(JIT_INTERP_OP_STA_0_LONG): 4381 { 4382 /* Store an 64-bit integer into an argument */ 4383 *VM_ARG(jit_long) = (jit_long)VM_R0_LONG; 4384 VM_MODIFY_PC(2); 4385 } 4386 VMBREAK; 4387 4388 VMCASE(JIT_INTERP_OP_STA_0_FLOAT32): 4389 { 4390 /* Store a 32-bit float into an argument */ 4391 *VM_ARG(jit_float32) = VM_R0_FLOAT32; 4392 VM_MODIFY_PC(2); 4393 } 4394 VMBREAK; 4395 4396 VMCASE(JIT_INTERP_OP_STA_0_FLOAT64): 4397 { 4398 /* Store a 64-bit float into an argument */ 4399 *VM_ARG(jit_float64) = VM_R0_FLOAT64; 4400 VM_MODIFY_PC(2); 4401 } 4402 VMBREAK; 4403 4404 VMCASE(JIT_INTERP_OP_STA_0_NFLOAT): 4405 { 4406 /* Store a native float into an argument */ 4407 *VM_ARG(jit_nfloat) = VM_R0_NFLOAT; 4408 VM_MODIFY_PC(2); 4409 } 4410 VMBREAK; 4411 4412 /****************************************************************** 4413 * Local variable frame access opcodes. 4414 ******************************************************************/ 4415 4416 VMCASE(JIT_INTERP_OP_LDL_0_SBYTE): 4417 { 4418 /* Load a signed 8-bit integer local into the register 0 */ 4419 VM_R0_INT = *VM_LOC(jit_sbyte); 4420 VM_MODIFY_PC(2); 4421 } 4422 VMBREAK; 4423 4424 VMCASE(JIT_INTERP_OP_LDL_0_UBYTE): 4425 { 4426 /* Load an unsigned 8-bit integer local into the register 0 */ 4427 VM_R0_INT = *VM_LOC(jit_ubyte); 4428 VM_MODIFY_PC(2); 4429 } 4430 VMBREAK; 4431 4432 VMCASE(JIT_INTERP_OP_LDL_0_SHORT): 4433 { 4434 /* Load a signed 16-bit integer local into the register 0 */ 4435 VM_R0_INT = *VM_LOC(jit_short); 4436 VM_MODIFY_PC(2); 4437 } 4438 VMBREAK; 4439 4440 VMCASE(JIT_INTERP_OP_LDL_0_USHORT): 4441 { 4442 /* Load am unsigned 16-bit integer local into the register 0 */ 4443 VM_R0_INT = *VM_LOC(jit_ushort); 4444 VM_MODIFY_PC(2); 4445 } 4446 VMBREAK; 4447 4448 VMCASE(JIT_INTERP_OP_LDL_0_INT): 4449 { 4450 /* Load a 32-bit integer local into the register 0 */ 4451 VM_R0_INT = *VM_LOC(jit_int); 4452 VM_MODIFY_PC(2); 4453 } 4454 VMBREAK; 4455 4456 VMCASE(JIT_INTERP_OP_LDL_0_LONG): 4457 { 4458 /* Load a 64-bit integer local into the register 0 */ 4459 VM_R0_LONG = *VM_LOC(jit_long); 4460 VM_MODIFY_PC(2); 4461 } 4462 VMBREAK; 4463 4464 VMCASE(JIT_INTERP_OP_LDL_0_FLOAT32): 4465 { 4466 /* Load a 32-bit float local into the register 0 */ 4467 VM_R0_FLOAT32 = *VM_LOC(jit_float32); 4468 VM_MODIFY_PC(2); 4469 } 4470 VMBREAK; 4471 4472 VMCASE(JIT_INTERP_OP_LDL_0_FLOAT64): 4473 { 4474 /* Load a 64-bit float local into the register 0 */ 4475 VM_R0_FLOAT64 = *VM_LOC(jit_float64); 4476 VM_MODIFY_PC(2); 4477 } 4478 VMBREAK; 4479 4480 VMCASE(JIT_INTERP_OP_LDL_0_NFLOAT): 4481 { 4482 /* Load a native float local into the register 0 */ 4483 VM_R0_NFLOAT = *VM_LOC(jit_nfloat); 4484 VM_MODIFY_PC(2); 4485 } 4486 VMBREAK; 4487 4488 VMCASE(JIT_INTERP_OP_LDLA_0): 4489 { 4490 /* Load the address of a local into the register 0 */ 4491 VM_R0_PTR = VM_LOC(void); 4492 VM_MODIFY_PC(2); 4493 } 4494 VMBREAK; 4495 4496 VMCASE(JIT_INTERP_OP_LDL_1_SBYTE): 4497 { 4498 /* Load a signed 8-bit integer local into the register 1 */ 4499 VM_R1_INT = *VM_LOC(jit_sbyte); 4500 VM_MODIFY_PC(2); 4501 } 4502 VMBREAK; 4503 4504 VMCASE(JIT_INTERP_OP_LDL_1_UBYTE): 4505 { 4506 /* Load an unsigned 8-bit integer local into the register 1 */ 4507 VM_R1_INT = *VM_LOC(jit_ubyte); 4508 VM_MODIFY_PC(2); 4509 } 4510 VMBREAK; 4511 4512 VMCASE(JIT_INTERP_OP_LDL_1_SHORT): 4513 { 4514 /* Load a signed 16-bit integer local into the register 1 */ 4515 VM_R1_INT = *VM_LOC(jit_short); 4516 VM_MODIFY_PC(2); 4517 } 4518 VMBREAK; 4519 4520 VMCASE(JIT_INTERP_OP_LDL_1_USHORT): 4521 { 4522 /* Load am unsigned 16-bit integer local into the register 1 */ 4523 VM_R1_INT = *VM_LOC(jit_ushort); 4524 VM_MODIFY_PC(2); 4525 } 4526 VMBREAK; 4527 4528 VMCASE(JIT_INTERP_OP_LDL_1_INT): 4529 { 4530 /* Load a 32-bit integer local into the register 1 */ 4531 VM_R1_INT = *VM_LOC(jit_int); 4532 VM_MODIFY_PC(2); 4533 } 4534 VMBREAK; 4535 4536 VMCASE(JIT_INTERP_OP_LDL_1_LONG): 4537 { 4538 /* Load a 64-bit integer local into the register 1 */ 4539 VM_R1_LONG = *VM_LOC(jit_long); 4540 VM_MODIFY_PC(2); 4541 } 4542 VMBREAK; 4543 4544 VMCASE(JIT_INTERP_OP_LDL_1_FLOAT32): 4545 { 4546 /* Load a 32-bit float local into the register 1 */ 4547 VM_R1_FLOAT32 = *VM_LOC(jit_float32); 4548 VM_MODIFY_PC(2); 4549 } 4550 VMBREAK; 4551 4552 VMCASE(JIT_INTERP_OP_LDL_1_FLOAT64): 4553 { 4554 /* Load a 64-bit float local into the register 1 */ 4555 VM_R1_FLOAT64 = *VM_LOC(jit_float64); 4556 VM_MODIFY_PC(2); 4557 } 4558 VMBREAK; 4559 4560 VMCASE(JIT_INTERP_OP_LDL_1_NFLOAT): 4561 { 4562 /* Load a native float local into the register 1 */ 4563 VM_R1_NFLOAT = *VM_LOC(jit_nfloat); 4564 VM_MODIFY_PC(2); 4565 } 4566 VMBREAK; 4567 4568 VMCASE(JIT_INTERP_OP_LDLA_1): 4569 { 4570 /* Load the address of a local into the register 1 */ 4571 VM_R1_PTR = VM_LOC(void); 4572 VM_MODIFY_PC(2); 4573 } 4574 VMBREAK; 4575 4576 VMCASE(JIT_INTERP_OP_LDL_2_SBYTE): 4577 { 4578 /* Load a signed 8-bit integer local into the register 2 */ 4579 VM_R2_INT = *VM_LOC(jit_sbyte); 4580 VM_MODIFY_PC(2); 4581 } 4582 VMBREAK; 4583 4584 VMCASE(JIT_INTERP_OP_LDL_2_UBYTE): 4585 { 4586 /* Load an unsigned 8-bit integer local into the register 2 */ 4587 VM_R2_INT = *VM_LOC(jit_ubyte); 4588 VM_MODIFY_PC(2); 4589 } 4590 VMBREAK; 4591 4592 VMCASE(JIT_INTERP_OP_LDL_2_SHORT): 4593 { 4594 /* Load a signed 16-bit integer local into the register 2 */ 4595 VM_R2_INT = *VM_LOC(jit_short); 4596 VM_MODIFY_PC(2); 4597 } 4598 VMBREAK; 4599 4600 VMCASE(JIT_INTERP_OP_LDL_2_USHORT): 4601 { 4602 /* Load am unsigned 16-bit integer local into the register 2 */ 4603 VM_R2_INT = *VM_LOC(jit_ushort); 4604 VM_MODIFY_PC(2); 4605 } 4606 VMBREAK; 4607 4608 VMCASE(JIT_INTERP_OP_LDL_2_INT): 4609 { 4610 /* Load a 32-bit integer local into the register 2 */ 4611 VM_R2_INT = *VM_LOC(jit_int); 4612 VM_MODIFY_PC(2); 4613 } 4614 VMBREAK; 4615 4616 VMCASE(JIT_INTERP_OP_LDL_2_LONG): 4617 { 4618 /* Load a 64-bit integer local into the register 2 */ 4619 VM_R2_LONG = *VM_LOC(jit_long); 4620 VM_MODIFY_PC(2); 4621 } 4622 VMBREAK; 4623 4624 VMCASE(JIT_INTERP_OP_LDL_2_FLOAT32): 4625 { 4626 /* Load a 32-bit float local into the register 2 */ 4627 VM_R2_FLOAT32 = *VM_LOC(jit_float32); 4628 VM_MODIFY_PC(2); 4629 } 4630 VMBREAK; 4631 4632 VMCASE(JIT_INTERP_OP_LDL_2_FLOAT64): 4633 { 4634 /* Load a 64-bit float local into the register 2 */ 4635 VM_R2_FLOAT64 = *VM_LOC(jit_float64); 4636 VM_MODIFY_PC(2); 4637 } 4638 VMBREAK; 4639 4640 VMCASE(JIT_INTERP_OP_LDL_2_NFLOAT): 4641 { 4642 /* Load a native float local into the register 2 */ 4643 VM_R2_NFLOAT = *VM_LOC(jit_nfloat); 4644 VM_MODIFY_PC(2); 4645 } 4646 VMBREAK; 4647 4648 VMCASE(JIT_INTERP_OP_LDLA_2): 4649 { 4650 /* Load the address of a local into the register 2 */ 4651 VM_R2_PTR = VM_LOC(void); 4652 VM_MODIFY_PC(2); 4653 } 4654 VMBREAK; 4655 4656 VMCASE(JIT_INTERP_OP_STL_0_BYTE): 4657 { 4658 /* Store an 8-bit integer into a local */ 4659 *VM_LOC(jit_sbyte) = (jit_sbyte)VM_R0_INT; 4660 VM_MODIFY_PC(2); 4661 } 4662 VMBREAK; 4663 4664 VMCASE(JIT_INTERP_OP_STL_0_SHORT): 4665 { 4666 /* Store an 16-bit integer into a local */ 4667 *VM_LOC(jit_short) = (jit_short)VM_R0_INT; 4668 VM_MODIFY_PC(2); 4669 } 4670 VMBREAK; 4671 4672 VMCASE(JIT_INTERP_OP_STL_0_INT): 4673 { 4674 /* Store an 32-bit integer into a local */ 4675 *VM_LOC(jit_int) = (jit_int)VM_R0_INT; 4676 VM_MODIFY_PC(2); 4677 } 4678 VMBREAK; 4679 4680 VMCASE(JIT_INTERP_OP_STL_0_LONG): 4681 { 4682 /* Store an 64-bit integer into a local */ 4683 *VM_LOC(jit_long) = (jit_long)VM_R0_LONG; 4684 VM_MODIFY_PC(2); 4685 } 4686 VMBREAK; 4687 4688 VMCASE(JIT_INTERP_OP_STL_0_FLOAT32): 4689 { 4690 /* Store a 32-bit float into a local */ 4691 *VM_LOC(jit_float32) = VM_R0_FLOAT32; 4692 VM_MODIFY_PC(2); 4693 } 4694 VMBREAK; 4695 4696 VMCASE(JIT_INTERP_OP_STL_0_FLOAT64): 4697 { 4698 /* Store a 64-bit float into a local */ 4699 *VM_LOC(jit_float64) = VM_R0_FLOAT64; 4700 VM_MODIFY_PC(2); 4701 } 4702 VMBREAK; 4703 4704 VMCASE(JIT_INTERP_OP_STL_0_NFLOAT): 4705 { 4706 /* Store a native float into a local */ 4707 *VM_LOC(jit_nfloat) = VM_R0_NFLOAT; 4708 VM_MODIFY_PC(2); 4709 } 4710 VMBREAK; 4711 4712 /****************************************************************** 4713 * Load constant values. 4714 ******************************************************************/ 4715 4716 #define JIT_WORDS_PER_TYPE(type) \ 4717 ((sizeof(type) + sizeof(void *) - 1) / sizeof(void *)) 4718 4719 VMCASE(JIT_INTERP_OP_LDC_0_INT): 4720 { 4721 /* Load an integer constant into the register 0 */ 4722 VM_R0_INT = (jit_int)VM_NINT_ARG; 4723 VM_MODIFY_PC(2); 4724 } 4725 VMBREAK; 4726 4727 VMCASE(JIT_INTERP_OP_LDC_0_LONG): 4728 { 4729 /* Load a long constant into the register 0 */ 4730 #ifdef JIT_NATIVE_INT64 4731 VM_R0_LONG = (jit_long)VM_NINT_ARG; 4732 VM_MODIFY_PC(2); 4733 #else 4734 jit_memcpy(&r0.long_value, pc + 1, sizeof(jit_long)); 4735 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_long)); 4736 #endif 4737 } 4738 VMBREAK; 4739 4740 VMCASE(JIT_INTERP_OP_LDC_0_FLOAT32): 4741 { 4742 /* Load a 32-bit float constant into the register 0 */ 4743 jit_memcpy(&r0.float32_value, pc + 1, sizeof(jit_float32)); 4744 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_float32)); 4745 } 4746 VMBREAK; 4747 4748 VMCASE(JIT_INTERP_OP_LDC_0_FLOAT64): 4749 { 4750 /* Load a 64-bit float constant into the register 0 */ 4751 jit_memcpy(&r0.float64_value, pc + 1, sizeof(jit_float64)); 4752 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_float64)); 4753 } 4754 VMBREAK; 4755 4756 VMCASE(JIT_INTERP_OP_LDC_0_NFLOAT): 4757 { 4758 /* Load a native float constant into the registre 0 */ 4759 jit_memcpy(&r0.nfloat_value, pc + 1, sizeof(jit_nfloat)); 4760 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_nfloat)); 4761 } 4762 VMBREAK; 4763 4764 VMCASE(JIT_INTERP_OP_LDC_1_INT): 4765 { 4766 /* Load an integer constant into the register 1 */ 4767 VM_R1_INT = (jit_int)VM_NINT_ARG; 4768 VM_MODIFY_PC(2); 4769 } 4770 VMBREAK; 4771 4772 VMCASE(JIT_INTERP_OP_LDC_1_LONG): 4773 { 4774 /* Load a long constant into the register 1 */ 4775 #ifdef JIT_NATIVE_INT64 4776 VM_R1_LONG = (jit_long)VM_NINT_ARG; 4777 VM_MODIFY_PC(2); 4778 #else 4779 jit_memcpy(&r1.long_value, pc + 1, sizeof(jit_long)); 4780 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_long)); 4781 #endif 4782 } 4783 VMBREAK; 4784 4785 VMCASE(JIT_INTERP_OP_LDC_1_FLOAT32): 4786 { 4787 /* Load a 32-bit float constant into the register 1 */ 4788 jit_memcpy(&r1.float32_value, pc + 1, sizeof(jit_float32)); 4789 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_float32)); 4790 } 4791 VMBREAK; 4792 4793 VMCASE(JIT_INTERP_OP_LDC_1_FLOAT64): 4794 { 4795 /* Load a 64-bit float constant into the register 1 */ 4796 jit_memcpy(&r1.float64_value, pc + 1, sizeof(jit_float64)); 4797 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_float64)); 4798 } 4799 VMBREAK; 4800 4801 VMCASE(JIT_INTERP_OP_LDC_1_NFLOAT): 4802 { 4803 /* Load a native float constant into the registre 1 */ 4804 jit_memcpy(&r1.nfloat_value, pc + 1, sizeof(jit_nfloat)); 4805 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_nfloat)); 4806 } 4807 VMBREAK; 4808 4809 VMCASE(JIT_INTERP_OP_LDC_2_INT): 4810 { 4811 /* Load an integer constant into the register 2 */ 4812 VM_R2_INT = (jit_int)VM_NINT_ARG; 4813 VM_MODIFY_PC(2); 4814 } 4815 VMBREAK; 4816 4817 VMCASE(JIT_INTERP_OP_LDC_2_LONG): 4818 { 4819 /* Load a long constant into the register 2 */ 4820 #ifdef JIT_NATIVE_INT64 4821 VM_R2_LONG = (jit_long)VM_NINT_ARG; 4822 VM_MODIFY_PC(2); 4823 #else 4824 jit_memcpy(&r2.long_value, pc + 1, sizeof(jit_long)); 4825 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_long)); 4826 #endif 4827 } 4828 VMBREAK; 4829 4830 VMCASE(JIT_INTERP_OP_LDC_2_FLOAT32): 4831 { 4832 /* Load a 32-bit float constant into the register 2 */ 4833 jit_memcpy(&r2.float32_value, pc + 1, sizeof(jit_float32)); 4834 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_float32)); 4835 } 4836 VMBREAK; 4837 4838 VMCASE(JIT_INTERP_OP_LDC_2_FLOAT64): 4839 { 4840 /* Load a 64-bit float constant into the register 2 */ 4841 jit_memcpy(&r2.float64_value, pc + 1, sizeof(jit_float64)); 4842 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_float64)); 4843 } 4844 VMBREAK; 4845 4846 VMCASE(JIT_INTERP_OP_LDC_2_NFLOAT): 4847 { 4848 /* Load a native float constant into the registre 2 */ 4849 jit_memcpy(&r2.nfloat_value, pc + 1, sizeof(jit_nfloat)); 4850 VM_MODIFY_PC(1 + JIT_WORDS_PER_TYPE(jit_nfloat)); 4851 } 4852 VMBREAK; 4853 4854 /****************************************************************** 4855 * Load return value. 4856 ******************************************************************/ 4857 4858 VMCASE(JIT_INTERP_OP_LDR_0_INT): 4859 { 4860 /* Load an integer return value into the register 0 */ 4861 VM_R0_INT = return_area->int_value; 4862 VM_MODIFY_PC(1); 4863 } 4864 VMBREAK; 4865 4866 VMCASE(JIT_INTERP_OP_LDR_0_LONG): 4867 { 4868 /* Load a long integer return value into the register 0 */ 4869 VM_R0_LONG = return_area->long_value; 4870 VM_MODIFY_PC(1); 4871 } 4872 VMBREAK; 4873 4874 VMCASE(JIT_INTERP_OP_LDR_0_FLOAT32): 4875 { 4876 /* Load a 32-bit float return value into the register 0 */ 4877 VM_R0_FLOAT32 = return_area->float32_value; 4878 VM_MODIFY_PC(1); 4879 } 4880 VMBREAK; 4881 4882 VMCASE(JIT_INTERP_OP_LDR_0_FLOAT64): 4883 { 4884 /* Load a 64-bit float return value into the register 0 */ 4885 VM_R0_FLOAT64 = return_area->float64_value; 4886 VM_MODIFY_PC(1); 4887 } 4888 VMBREAK; 4889 4890 VMCASE(JIT_INTERP_OP_LDR_0_NFLOAT): 4891 { 4892 /* Load a native float return value into the register 0 */ 4893 VM_R0_NFLOAT = return_area->nfloat_value; 4894 VM_MODIFY_PC(1); 4895 } 4896 VMBREAK; 4897 4898 /****************************************************************** 4899 * Stack management. 4900 ******************************************************************/ 4901 4902 VMCASE(JIT_OP_RETRIEVE_FRAME_POINTER): 4903 { 4904 /* Move the frame pointer into the register 0 */ 4905 VM_R0_PTR = frame; 4906 VM_MODIFY_PC(1); 4907 } 4908 VMBREAK; 4909 4910 VMCASE(JIT_OP_POP_STACK): 4911 { 4912 /* Pop a specific number of items from the stack */ 4913 temparg = VM_NINT_ARG; 4914 VM_MODIFY_PC_AND_STACK(2, temparg); 4915 } 4916 VMBREAK; 4917 4918 VMCASE(JIT_INTERP_OP_POP): 4919 { 4920 /* Pop a single item from the stack */ 4921 VM_MODIFY_PC_AND_STACK(1, 1); 4922 } 4923 VMBREAK; 4924 4925 VMCASE(JIT_INTERP_OP_POP_2): 4926 { 4927 /* Pop two items from the stack */ 4928 VM_MODIFY_PC_AND_STACK(1, 2); 4929 } 4930 VMBREAK; 4931 4932 VMCASE(JIT_INTERP_OP_POP_3): 4933 { 4934 /* Pop three items from the stack */ 4935 VM_MODIFY_PC_AND_STACK(1, 3); 4936 } 4937 VMBREAK; 4938 4939 VMCASE(JIT_OP_PUSH_RETURN_AREA_PTR): 4940 { 4941 /* Push the address of "return_area" for an external call */ 4942 VM_STK_PTRP = return_area; 4943 VM_MODIFY_PC_AND_STACK(1, -1); 4944 } 4945 VMBREAK; 4946 4947 /****************************************************************** 4948 * Debugging support. 4949 ******************************************************************/ 4950 4951 VMCASE(JIT_OP_MARK_BREAKPOINT): 4952 { 4953 /* Process a marked breakpoint within the current function */ 4954 tempptr = (void *)VM_NINT_ARG; 4955 tempptr2 = (void *)VM_NINT_ARG2; 4956 VM_MODIFY_PC(3); 4957 _jit_backtrace_push(&call_trace, pc); 4958 _jit_debugger_hook 4959 (func->func, (jit_nint)tempptr, (jit_nint)tempptr2); 4960 _jit_backtrace_pop(); 4961 } 4962 VMBREAK; 4963 4964 /****************************************************************** 4965 * Opcodes that aren't used by the interpreter. These are replaced 4966 * by more specific instructions during function compilation. 4967 ******************************************************************/ 4968 4969 VMCASE(JIT_OP_IMPORT): 4970 VMCASE(JIT_OP_COPY_LOAD_SBYTE): 4971 VMCASE(JIT_OP_COPY_LOAD_UBYTE): 4972 VMCASE(JIT_OP_COPY_LOAD_SHORT): 4973 VMCASE(JIT_OP_COPY_LOAD_USHORT): 4974 VMCASE(JIT_OP_COPY_INT): 4975 VMCASE(JIT_OP_COPY_LONG): 4976 VMCASE(JIT_OP_COPY_FLOAT32): 4977 VMCASE(JIT_OP_COPY_FLOAT64): 4978 VMCASE(JIT_OP_COPY_NFLOAT): 4979 VMCASE(JIT_OP_COPY_STORE_BYTE): 4980 VMCASE(JIT_OP_COPY_STORE_SHORT): 4981 VMCASE(JIT_OP_ADDRESS_OF): 4982 VMCASE(JIT_OP_INCOMING_REG): 4983 VMCASE(JIT_OP_INCOMING_FRAME_POSN): 4984 VMCASE(JIT_OP_OUTGOING_REG): 4985 VMCASE(JIT_OP_OUTGOING_FRAME_POSN): 4986 VMCASE(JIT_OP_RETURN_REG): 4987 VMCASE(JIT_OP_SET_PARAM_INT): 4988 VMCASE(JIT_OP_SET_PARAM_LONG): 4989 VMCASE(JIT_OP_SET_PARAM_FLOAT32): 4990 VMCASE(JIT_OP_SET_PARAM_FLOAT64): 4991 VMCASE(JIT_OP_SET_PARAM_NFLOAT): 4992 VMCASE(JIT_OP_SET_PARAM_STRUCT): 4993 VMCASE(JIT_OP_ENTER_FINALLY): 4994 VMCASE(JIT_OP_ENTER_FILTER): 4995 VMCASE(JIT_OP_CALL_FILTER_RETURN): 4996 VMCASE(JIT_OP_MARK_OFFSET): 4997 { 4998 /* Shouldn't happen, but skip the instruction anyway */ 4999 VM_MODIFY_PC_AND_STACK(1, 0); 5000 } 5001 VMBREAK; 5002 5003 } 5004 VMSWITCHEND 5005 5006 handle_builtin: ; 5007 jit_exception_builtin(builtin_exception); 5008 } 5009 5010 int jit_function_apply 5011 (jit_function_t func, void **args, void *return_area) 5012 { 5013 if(func) 5014 { 5015 return jit_function_apply_vararg 5016 (func, func->signature, args, return_area); 5017 } 5018 else 5019 { 5020 return jit_function_apply_vararg(func, 0, args, return_area); 5021 } 5022 } 5023 5024 /* Imported from "jit-rules-interp.c" */ 5025 unsigned int _jit_interp_calculate_arg_size 5026 (jit_function_t func, jit_type_t signature); 5027 5028 int jit_function_apply_vararg 5029 (jit_function_t func, jit_type_t signature, void **args, void *return_area) 5030 { 5031 struct jit_backtrace call_trace; 5032 jit_function_interp_t entry; 5033 jit_item interp_return_area; 5034 jit_item *arg_buffer; 5035 jit_item *temp_arg; 5036 jit_type_t type; 5037 unsigned int num_params; 5038 unsigned int param; 5039 jit_jmp_buf jbuf; 5040 5041 /* Push a "setjmp" context onto the stack, so that we can catch 5042 any exceptions that are thrown up to this level and prevent 5043 them from propagating further */ 5044 _jit_unwind_push_setjmp(&jbuf); 5045 if(setjmp(jbuf.buf)) 5046 { 5047 _jit_unwind_pop_setjmp(); 5048 return 0; 5049 } 5050 5051 /* Initialize the backtrace information */ 5052 _jit_backtrace_push(&call_trace, 0); 5053 5054 /* Clear the exception context */ 5055 jit_exception_clear_last(); 5056 5057 /* Bail out if the function is NULL */ 5058 if(!func) 5059 { 5060 jit_exception_builtin(JIT_RESULT_NULL_FUNCTION); 5061 } 5062 5063 /* Make sure that the function is compiled */ 5064 if(func->is_compiled) 5065 { 5066 entry = (jit_function_interp_t)(func->entry_point); 5067 } 5068 else 5069 { 5070 entry = (jit_function_interp_t)(*func->context->on_demand_driver)(func); 5071 } 5072 5073 /* Populate the low-level argument buffer */ 5074 if(!signature) 5075 { 5076 signature = func->signature; 5077 arg_buffer = (jit_item *)alloca(entry->args_size); 5078 } 5079 else if(signature == func->signature) 5080 { 5081 arg_buffer = (jit_item *)alloca(entry->args_size); 5082 } 5083 else 5084 { 5085 arg_buffer = (jit_item *)alloca 5086 (_jit_interp_calculate_arg_size(func, signature)); 5087 } 5088 temp_arg = arg_buffer; 5089 if(func->nested_parent) 5090 { 5091 jit_exception_builtin(JIT_RESULT_CALLED_NESTED); 5092 } 5093 type = jit_type_get_return(signature); 5094 if(jit_type_return_via_pointer(type)) 5095 { 5096 if(!return_area) 5097 { 5098 return_area = alloca(jit_type_get_size(type)); 5099 } 5100 temp_arg->ptr_value = return_area; 5101 ++temp_arg; 5102 } 5103 num_params = jit_type_num_params(signature); 5104 for(param = 0; param < num_params; ++param) 5105 { 5106 type = jit_type_normalize 5107 (jit_type_get_param(signature, param)); 5108 if(!(args[param])) 5109 { 5110 jit_exception_builtin(JIT_RESULT_NULL_REFERENCE); 5111 } 5112 switch(type->kind) 5113 { 5114 case JIT_TYPE_SBYTE: 5115 { 5116 temp_arg->int_value = *((jit_sbyte *)(args[param])); 5117 ++temp_arg; 5118 } 5119 break; 5120 5121 case JIT_TYPE_UBYTE: 5122 { 5123 temp_arg->int_value = *((jit_ubyte *)(args[param])); 5124 ++temp_arg; 5125 } 5126 break; 5127 5128 case JIT_TYPE_SHORT: 5129 { 5130 temp_arg->int_value = *((jit_short *)(args[param])); 5131 ++temp_arg; 5132 } 5133 break; 5134 5135 case JIT_TYPE_USHORT: 5136 { 5137 temp_arg->int_value = *((jit_ushort *)(args[param])); 5138 ++temp_arg; 5139 } 5140 break; 5141 5142 case JIT_TYPE_INT: 5143 case JIT_TYPE_UINT: 5144 { 5145 temp_arg->int_value = *((jit_int *)(args[param])); 5146 ++temp_arg; 5147 } 5148 break; 5149 5150 case JIT_TYPE_LONG: 5151 case JIT_TYPE_ULONG: 5152 { 5153 temp_arg->long_value = *((jit_long *)(args[param])); 5154 ++temp_arg; 5155 } 5156 break; 5157 5158 case JIT_TYPE_FLOAT32: 5159 { 5160 temp_arg->float32_value = 5161 *((jit_float32 *)(args[param])); 5162 ++temp_arg; 5163 } 5164 break; 5165 5166 case JIT_TYPE_FLOAT64: 5167 { 5168 temp_arg->float64_value = 5169 *((jit_float64 *)(args[param])); 5170 ++temp_arg; 5171 } 5172 break; 5173 5174 case JIT_TYPE_NFLOAT: 5175 { 5176 temp_arg->nfloat_value = 5177 *((jit_nfloat *)(args[param])); 5178 ++temp_arg; 5179 } 5180 break; 5181 5182 case JIT_TYPE_STRUCT: 5183 case JIT_TYPE_UNION: 5184 { 5185 jit_memcpy(temp_arg, args[param], 5186 jit_type_get_size(type)); 5187 temp_arg += JIT_NUM_ITEMS_IN_STRUCT 5188 (jit_type_get_size(type)); 5189 } 5190 break; 5191 } 5192 } 5193 5194 /* Run the function */ 5195 _jit_run_function(entry, arg_buffer, &interp_return_area); 5196 5197 /* Copy the return value into place, if it isn't already there */ 5198 if(return_area) 5199 { 5200 type = jit_type_normalize(jit_type_get_return(signature)); 5201 if(type && type != jit_type_void) 5202 { 5203 switch(type->kind) 5204 { 5205 case JIT_TYPE_SBYTE: 5206 case JIT_TYPE_UBYTE: 5207 { 5208 *((jit_sbyte *)return_area) = 5209 (jit_sbyte)(interp_return_area.int_value); 5210 } 5211 break; 5212 5213 case JIT_TYPE_SHORT: 5214 case JIT_TYPE_USHORT: 5215 { 5216 *((jit_short *)return_area) = 5217 (jit_short)(interp_return_area.int_value); 5218 } 5219 break; 5220 5221 case JIT_TYPE_INT: 5222 case JIT_TYPE_UINT: 5223 { 5224 *((jit_int *)return_area) = 5225 interp_return_area.int_value; 5226 } 5227 break; 5228 5229 case JIT_TYPE_LONG: 5230 case JIT_TYPE_ULONG: 5231 { 5232 *((jit_long *)return_area) = 5233 interp_return_area.long_value; 5234 } 5235 break; 5236 5237 case JIT_TYPE_FLOAT32: 5238 { 5239 *((jit_float32 *)return_area) = 5240 interp_return_area.float32_value; 5241 } 5242 break; 5243 5244 case JIT_TYPE_FLOAT64: 5245 { 5246 *((jit_float64 *)return_area) = 5247 interp_return_area.float64_value; 5248 } 5249 break; 5250 5251 case JIT_TYPE_NFLOAT: 5252 { 5253 *((jit_nfloat *)return_area) = 5254 interp_return_area.nfloat_value; 5255 } 5256 break; 5257 5258 case JIT_TYPE_STRUCT: 5259 case JIT_TYPE_UNION: 5260 { 5261 if(!jit_type_return_via_pointer(type)) 5262 { 5263 jit_memcpy(return_area, &interp_return_area, 5264 jit_type_get_size(type)); 5265 } 5266 } 5267 break; 5268 } 5269 } 5270 } 5271 5272 /* Pop the "setjmp" context and exit */ 5273 _jit_unwind_pop_setjmp(); 5274 return 1; 5275 } 5276 5277 #endif /* JIT_BACKEND_INTERP */