1 // prims.cc - Code for core of runtime environment.
3 /* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
13 #ifdef USE_WIN32_SIGNALLING
15 #endif /* USE_WIN32_SIGNALLING */
18 #undef __INSIDE_CYGWIN__
20 #endif /* USE_WINSOCK */
34 #include <java-signal.h>
35 #include <java-threads.h>
39 #include <java/lang/ThreadGroup.h>
42 #ifndef DISABLE_GETENV_PROPERTIES
44 #include <java-props.h>
45 #define PROCESS_GCJ_PROPERTIES process_gcj_properties()
47 #define PROCESS_GCJ_PROPERTIES
48 #endif // DISABLE_GETENV_PROPERTIES
50 #include <java/lang/Class.h>
51 #include <java/lang/ClassLoader.h>
52 #include <java/lang/Runtime.h>
53 #include <java/lang/String.h>
54 #include <java/lang/Thread.h>
55 #include <java/lang/ThreadGroup.h>
56 #include <gnu/gcj/runtime/FirstThread.h>
57 #include <java/lang/ArrayIndexOutOfBoundsException.h>
58 #include <java/lang/ArithmeticException.h>
59 #include <java/lang/ClassFormatError.h>
60 #include <java/lang/NegativeArraySizeException.h>
61 #include <java/lang/NullPointerException.h>
62 #include <java/lang/OutOfMemoryError.h>
63 #include <java/lang/System.h>
64 #include <java/lang/reflect/Modifier.h>
65 #include <java/io/PrintStream.h>
66 #include <java/lang/UnsatisfiedLinkError.h>
67 #include <gnu/gcj/runtime/VMClassLoader.h>
73 // We allocate a single OutOfMemoryError exception which we keep
74 // around for use if we run out of memory.
75 static java::lang::OutOfMemoryError *no_memory;
77 // Largest representable size_t.
78 #define SIZE_T_MAX ((size_t) (~ (size_t) 0))
80 static const char *no_properties[] = { NULL };
82 // Properties set at compile time.
83 const char **_Jv_Compiler_Properties = no_properties;
85 // The JAR file to add to the beginning of java.class.path.
86 const char *_Jv_Jar_Class_Path;
88 #ifndef DISABLE_GETENV_PROPERTIES
89 // Property key/value pairs.
90 property_pair *_Jv_Environment_Properties;
93 // The name of this executable.
94 static char *_Jv_execName;
96 // Stash the argv pointer to benefit native libraries that need it.
97 const char **_Jv_argv;
101 // Pointer to JVMPI notification functions.
102 void (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (JVMPI_Event *event);
103 void (*_Jv_JVMPI_Notify_THREAD_START) (JVMPI_Event *event);
104 void (*_Jv_JVMPI_Notify_THREAD_END) (JVMPI_Event *event);
108 extern "C" void _Jv_ThrowSignal (jthrowable) __attribute ((noreturn));
110 // Just like _Jv_Throw, but fill in the stack trace first. Although
111 // this is declared extern in order that its name not be mangled, it
112 // is not intended to be used outside this file.
114 _Jv_ThrowSignal (jthrowable throwable)
116 throwable->fillInStackTrace ();
121 static java::lang::NullPointerException *nullp;
123 SIGNAL_HANDLER (catch_segv)
125 MAKE_THROW_FRAME (nullp);
126 _Jv_ThrowSignal (nullp);
130 static java::lang::ArithmeticException *arithexception;
133 SIGNAL_HANDLER (catch_fpe)
135 #ifdef HANDLE_DIVIDE_OVERFLOW
136 HANDLE_DIVIDE_OVERFLOW;
138 MAKE_THROW_FRAME (arithexception);
140 _Jv_ThrowSignal (arithexception);
147 _Jv_equalUtf8Consts (Utf8Const* a, Utf8Const *b)
150 _Jv_ushort *aptr, *bptr;
153 if (a->hash != b->hash)
156 if (b->length != len)
158 aptr = (_Jv_ushort *)a->data;
159 bptr = (_Jv_ushort *)b->data;
160 len = (len + 1) >> 1;
162 if (*aptr++ != *bptr++)
167 /* True iff A is equal to STR.
168 HASH is STR->hashCode().
172 _Jv_equal (Utf8Const* a, jstring str, jint hash)
174 if (a->hash != (_Jv_ushort) hash)
176 jint len = str->length();
178 jchar *sptr = _Jv_GetStringChars (str);
179 unsigned char* ptr = (unsigned char*) a->data;
180 unsigned char* limit = ptr + a->length;
183 int ch = UTF8_GET (ptr, limit);
192 /* Like _Jv_equal, but stop after N characters. */
194 _Jv_equaln (Utf8Const *a, jstring str, jint n)
196 jint len = str->length();
198 jchar *sptr = _Jv_GetStringChars (str);
199 unsigned char* ptr = (unsigned char*) a->data;
200 unsigned char* limit = ptr + a->length;
201 for (; n-- > 0; i++, sptr++)
203 int ch = UTF8_GET (ptr, limit);
212 /* Count the number of Unicode chars encoded in a given Ut8 string. */
214 _Jv_strLengthUtf8(char* str, int len)
217 unsigned char* limit;
220 ptr = (unsigned char*) str;
223 for (; ptr < limit; str_length++)
225 if (UTF8_GET (ptr, limit) < 0)
231 /* Calculate a hash value for a string encoded in Utf8 format.
232 * This returns the same hash value as specified or java.lang.String.hashCode.
235 hashUtf8String (char* str, int len)
237 unsigned char* ptr = (unsigned char*) str;
238 unsigned char* limit = ptr + len;
243 int ch = UTF8_GET (ptr, limit);
244 /* Updated specification from
245 http://www.javasoft.com/docs/books/jls/clarify.html. */
246 hash = (31 * hash) + ch;
252 _Jv_makeUtf8Const (char* s, int len)
256 Utf8Const* m = (Utf8Const*) _Jv_AllocBytes (sizeof(Utf8Const) + len + 1);
259 memcpy (m->data, s, len);
262 m->hash = hashUtf8String (s, len) & 0xFFFF;
267 _Jv_makeUtf8Const (jstring string)
269 jint hash = string->hashCode ();
270 jint len = _Jv_GetStringUTFLength (string);
272 Utf8Const* m = (Utf8Const*)
273 _Jv_AllocBytes (sizeof(Utf8Const) + len + 1);
278 _Jv_GetStringUTFRegion (string, 0, string->length (), m->data);
288 _Jv_Abort (const char *function, const char *file, int line,
292 _Jv_Abort (const char *, const char *, int, const char *message)
297 "libgcj failure: %s\n in function %s, file %s, line %d\n",
298 message, function, file, line);
300 java::io::PrintStream *err = java::lang::System::err;
301 err->print(JvNewStringLatin1 ("libgcj failure: "));
302 err->println(JvNewStringLatin1 (message));
309 fail_on_finalization (jobject)
311 JvFail ("object was finalized");
315 _Jv_GCWatch (jobject obj)
317 _Jv_RegisterFinalizer (obj, fail_on_finalization);
321 _Jv_ThrowBadArrayIndex(jint bad_index)
323 throw new java::lang::ArrayIndexOutOfBoundsException
324 (java::lang::String::valueOf (bad_index));
328 _Jv_ThrowNullPointerException ()
330 throw new java::lang::NullPointerException;
333 // Explicitly throw a no memory exception.
334 // The collector calls this when it encounters an out-of-memory condition.
335 void _Jv_ThrowNoMemory()
337 _Jv_Throw (no_memory);
340 // Allocate a new object of class KLASS. SIZE is the size of the object
341 // to allocate. You might think this is redundant, but it isn't; some
342 // classes, such as String, aren't of fixed size.
344 _Jv_AllocObject (jclass klass, jint size)
346 _Jv_InitClass (klass);
348 jobject obj = (jobject) _Jv_AllocObj (size, klass);
350 // If this class has inherited finalize from Object, then don't
351 // bother registering a finalizer. We know that finalize() is the
352 // very first method after the dummy entry. If this turns out to be
353 // unreliable, a more robust implementation can be written. Such an
354 // implementation would look for Object.finalize in Object's method
355 // table at startup, and then use that information to find the
356 // appropriate index in the method vector.
357 if (klass->vtable->get_finalizer()
358 != java::lang::Object::class$.vtable->get_finalizer())
359 _Jv_RegisterFinalizer (obj, _Jv_FinalizeObject);
362 // Service JVMPI request.
364 if (__builtin_expect (_Jv_JVMPI_Notify_OBJECT_ALLOC != 0, false))
368 event.event_type = JVMPI_EVENT_OBJECT_ALLOC;
370 event.u.obj_alloc.arena_id = 0;
371 event.u.obj_alloc.class_id = (jobjectID) klass;
372 event.u.obj_alloc.is_array = 0;
373 event.u.obj_alloc.size = size;
374 event.u.obj_alloc.obj_id = (jobjectID) obj;
376 // FIXME: This doesn't look right for the Boehm GC. A GC may
377 // already be in progress. _Jv_DisableGC () doesn't wait for it.
378 // More importantly, I don't see the need for disabling GC, since we
379 // blatantly have a pointer to obj on our stack, ensuring that the
380 // object can't be collected. Even for a nonconservative collector,
381 // it appears to me that this must be true, since we are about to
382 // return obj. Isn't this whole approach way too intrusive for
383 // a useful profiling interface? - HB
385 (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (&event);
393 // A version of the above that assumes the object contains no pointers,
394 // and requires no finalization. This can't happen if we need pointers
396 #ifdef JV_HASH_SYNCHRONIZATION
398 _Jv_AllocPtrFreeObject (jclass klass, jint size)
400 _Jv_InitClass (klass);
402 jobject obj = (jobject) _Jv_AllocPtrFreeObj (size, klass);
405 // Service JVMPI request.
407 if (__builtin_expect (_Jv_JVMPI_Notify_OBJECT_ALLOC != 0, false))
411 event.event_type = JVMPI_EVENT_OBJECT_ALLOC;
413 event.u.obj_alloc.arena_id = 0;
414 event.u.obj_alloc.class_id = (jobjectID) klass;
415 event.u.obj_alloc.is_array = 0;
416 event.u.obj_alloc.size = size;
417 event.u.obj_alloc.obj_id = (jobjectID) obj;
420 (*_Jv_JVMPI_Notify_OBJECT_ALLOC) (&event);
427 #endif /* JV_HASH_SYNCHRONIZATION */
430 // Allocate a new array of Java objects. Each object is of type
431 // `elementClass'. `init' is used to initialize each slot in the
434 _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
436 if (__builtin_expect (count < 0, false))
437 throw new java::lang::NegativeArraySizeException;
439 JvAssert (! elementClass->isPrimitive ());
441 // Ensure that elements pointer is properly aligned.
442 jobjectArray obj = NULL;
443 size_t size = (size_t) elements (obj);
444 size += count * sizeof (jobject);
446 // FIXME: second argument should be "current loader"
447 jclass klass = _Jv_GetArrayClass (elementClass, 0);
449 obj = (jobjectArray) _Jv_AllocArray (size, klass);
451 jsize *lp = const_cast<jsize *> (&obj->length);
453 // We know the allocator returns zeroed memory. So don't bother
457 jobject *ptr = elements(obj);
464 // Allocate a new array of primitives. ELTYPE is the type of the
465 // element, COUNT is the size of the array.
467 _Jv_NewPrimArray (jclass eltype, jint count)
469 int elsize = eltype->size();
470 if (__builtin_expect (count < 0, false))
471 throw new java::lang::NegativeArraySizeException;
473 JvAssert (eltype->isPrimitive ());
474 jobject dummy = NULL;
475 size_t size = (size_t) _Jv_GetArrayElementFromElementType (dummy, eltype);
477 // Check for overflow.
478 if (__builtin_expect ((size_t) count >
479 (SIZE_T_MAX - size) / elsize, false))
482 jclass klass = _Jv_GetArrayClass (eltype, 0);
484 # ifdef JV_HASH_SYNCHRONIZATION
485 // Since the vtable is always statically allocated,
486 // these are completely pointerfree! Make sure the GC doesn't touch them.
488 (__JArray*) _Jv_AllocPtrFreeObj (size + elsize * count, klass);
489 memset((char *)arr + size, 0, elsize * count);
491 __JArray *arr = (__JArray*) _Jv_AllocObj (size + elsize * count, klass);
492 // Note that we assume we are given zeroed memory by the allocator.
495 jsize *lp = const_cast<jsize *> (&arr->length);
502 _Jv_NewArray (jint type, jint size)
506 case 4: return JvNewBooleanArray (size);
507 case 5: return JvNewCharArray (size);
508 case 6: return JvNewFloatArray (size);
509 case 7: return JvNewDoubleArray (size);
510 case 8: return JvNewByteArray (size);
511 case 9: return JvNewShortArray (size);
512 case 10: return JvNewIntArray (size);
513 case 11: return JvNewLongArray (size);
515 JvFail ("newarray - bad type code");
516 return NULL; // Placate compiler.
519 // Allocate a possibly multi-dimensional array but don't check that
520 // any array length is <0.
522 _Jv_NewMultiArrayUnchecked (jclass type, jint dimensions, jint *sizes)
524 JvAssert (type->isArray());
525 jclass element_type = type->getComponentType();
527 if (element_type->isPrimitive())
528 result = _Jv_NewPrimArray (element_type, sizes[0]);
530 result = _Jv_NewObjectArray (sizes[0], element_type, NULL);
534 JvAssert (! element_type->isPrimitive());
535 JvAssert (element_type->isArray());
536 jobject *contents = elements ((jobjectArray) result);
537 for (int i = 0; i < sizes[0]; ++i)
538 contents[i] = _Jv_NewMultiArrayUnchecked (element_type, dimensions - 1,
546 _Jv_NewMultiArray (jclass type, jint dimensions, jint *sizes)
548 for (int i = 0; i < dimensions; ++i)
550 throw new java::lang::NegativeArraySizeException;
552 return _Jv_NewMultiArrayUnchecked (type, dimensions, sizes);
556 _Jv_NewMultiArray (jclass array_type, jint dimensions, ...)
559 jint sizes[dimensions];
560 va_start (args, dimensions);
561 for (int i = 0; i < dimensions; ++i)
563 jint size = va_arg (args, jint);
565 throw new java::lang::NegativeArraySizeException;
570 return _Jv_NewMultiArrayUnchecked (array_type, dimensions, sizes);
575 #define DECLARE_PRIM_TYPE(NAME, SIG, LEN) \
576 _Jv_ArrayVTable _Jv_##NAME##VTable; \
577 java::lang::Class _Jv_##NAME##Class ((jobject) #NAME, \
578 (jbyte) SIG, (jint) LEN, \
579 (jobject) &_Jv_##NAME##VTable);
581 DECLARE_PRIM_TYPE(byte, 'B', 1);
582 DECLARE_PRIM_TYPE(short, 'S', 2);
583 DECLARE_PRIM_TYPE(int, 'I', 4);
584 DECLARE_PRIM_TYPE(long, 'J', 8);
585 DECLARE_PRIM_TYPE(boolean, 'Z', 1);
586 DECLARE_PRIM_TYPE(char, 'C', 2);
587 DECLARE_PRIM_TYPE(float, 'F', 4);
588 DECLARE_PRIM_TYPE(double, 'D', 8);
589 DECLARE_PRIM_TYPE(void, 'V', 0);
592 _Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader)
597 return JvPrimClass (byte);
599 return JvPrimClass (short);
601 return JvPrimClass (int);
603 return JvPrimClass (long);
605 return JvPrimClass (boolean);
607 return JvPrimClass (char);
609 return JvPrimClass (float);
611 return JvPrimClass (double);
613 return JvPrimClass (void);
617 for (i = 1; sig[i] && sig[i] != ';'; ++i)
619 _Jv_Utf8Const *name = _Jv_makeUtf8Const (&sig[1], i - 1);
620 return _Jv_FindClass (name, loader);
625 jclass klass = _Jv_FindClassFromSignature (&sig[1], loader);
628 return _Jv_GetArrayClass (klass, loader);
632 return NULL; // Placate compiler.
638 JvConvertArgv (int argc, const char **argv)
642 jobjectArray ar = JvNewObjectArray(argc, &StringClass, NULL);
643 jobject* ptr = elements(ar);
644 for (int i = 0; i < argc; i++)
646 const char *arg = argv[i];
647 // FIXME - should probably use JvNewStringUTF.
648 *ptr++ = JvNewStringLatin1(arg, strlen(arg));
650 return (JArray<jstring>*) ar;
653 // FIXME: These variables are static so that they will be
654 // automatically scanned by the Boehm collector. This is needed
655 // because with qthreads the collector won't scan the initial stack --
656 // it will only scan the qthreads stacks.
658 // Command line arguments.
659 static JArray<jstring> *arg_vec;
661 // The primary thread.
662 static java::lang::Thread *main_thread;
665 _Jv_ThisExecutable (void)
671 _Jv_ThisExecutable (const char *name)
675 _Jv_execName = (char *) _Jv_Malloc (strlen (name) + 1);
676 strcpy (_Jv_execName, name);
680 #ifdef USE_WIN32_SIGNALLING
682 extern "C" int* win32_get_restart_frame (void *);
685 win32_exception_handler (LPEXCEPTION_POINTERS e)
688 if (e->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
689 setjmp_buf = win32_get_restart_frame (nullp);
690 else if (e->ExceptionRecord->ExceptionCode == EXCEPTION_INT_DIVIDE_BY_ZERO)
691 setjmp_buf = win32_get_restart_frame (arithexception);
693 return EXCEPTION_CONTINUE_SEARCH;
695 e->ContextRecord->Ebp = setjmp_buf[0];
696 // FIXME: Why does i386-signal.h increment the PC here, do we need to do it?
697 e->ContextRecord->Eip = setjmp_buf[1];
698 // FIXME: Is this the stack pointer? Do we need it?
699 e->ContextRecord->Esp = setjmp_buf[2];
701 return EXCEPTION_CONTINUE_EXECUTION;
706 #ifndef DISABLE_GETENV_PROPERTIES
709 next_property_key (char *s, size_t *length)
715 // Skip over whitespace
719 // If we've reached the end, return NULL. Also return NULL if for
720 // some reason we've come across a malformed property string.
726 // Determine the length of the property key.
744 next_property_value (char *s, size_t *length)
760 // If we've reached the end, return NULL.
764 // Determine the length of the property value.
783 process_gcj_properties ()
785 char *props = getenv("GCJ_PROPERTIES");
788 size_t property_count = 0;
793 // Whip through props quickly in order to count the number of
795 while (p && (p = next_property_key (p, &length)))
797 // Skip to the end of the key
800 p = next_property_value (p, &length);
807 // Allocate an array of property value/key pairs.
808 _Jv_Environment_Properties =
809 (property_pair *) malloc (sizeof(property_pair)
810 * (property_count + 1));
812 // Go through the properties again, initializing _Jv_Properties
816 while (p && (p = next_property_key (p, &length)))
818 _Jv_Environment_Properties[property_count].key = p;
819 _Jv_Environment_Properties[property_count].key_length = length;
821 // Skip to the end of the key
824 p = next_property_value (p, &length);
826 _Jv_Environment_Properties[property_count].value = p;
827 _Jv_Environment_Properties[property_count].value_length = length;
834 memset ((void *) &_Jv_Environment_Properties[property_count],
835 0, sizeof (property_pair));
839 // Null terminate the strings.
840 while (_Jv_Environment_Properties[i].key)
842 _Jv_Environment_Properties[i].key[_Jv_Environment_Properties[i].key_length] = 0;
843 _Jv_Environment_Properties[i++].value[_Jv_Environment_Properties[i].value_length] = 0;
847 #endif // DISABLE_GETENV_PROPERTIES
850 _Jv_CreateJavaVM (void* /*vm_args*/)
852 PROCESS_GCJ_PROPERTIES;
854 // Turn stack trace generation off while creating exception objects.
855 _Jv_InitClass (&java::lang::Throwable::class$);
856 java::lang::Throwable::trace_enabled = 0;
862 arithexception = new java::lang::ArithmeticException
863 (JvNewStringLatin1 ("/ by zero"));
866 no_memory = new java::lang::OutOfMemoryError;
868 java::lang::Throwable::trace_enabled = 1;
871 LTDL_SET_PRELOADED_SYMBOLS ();
875 // Initialise winsock for networking
877 if (WSAStartup (MAKEWORD (1, 1), &data))
878 MessageBox (NULL, "Error initialising winsock library.", "Error", MB_OK | MB_ICONEXCLAMATION);
879 #endif /* USE_WINSOCK */
881 #ifdef USE_WIN32_SIGNALLING
882 // Install exception handler
883 SetUnhandledExceptionFilter (win32_exception_handler);
884 #elif defined(HAVE_SIGACTION)
885 // We only want this on POSIX systems.
886 struct sigaction act;
887 act.sa_handler = SIG_IGN;
888 sigemptyset (&act.sa_mask);
890 sigaction (SIGPIPE, &act, NULL);
892 signal (SIGPIPE, SIG_IGN);
901 _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
907 java::lang::Runtime *runtime = NULL;
909 #ifdef HAVE_PROC_SELF_EXE
911 sprintf (exec_name, "/proc/%d/exe", getpid ());
912 _Jv_ThisExecutable (exec_name);
914 _Jv_ThisExecutable (argv[0]);
919 _Jv_CreateJavaVM (NULL);
921 // Get the Runtime here. We want to initialize it before searching
922 // for `main'; that way it will be set up if `main' is a JNI method.
923 runtime = java::lang::Runtime::getRuntime ();
925 arg_vec = JvConvertArgv (argc - 1, argv + 1);
928 main_thread = new gnu::gcj::runtime::FirstThread (klass, arg_vec);
930 main_thread = new gnu::gcj::runtime::FirstThread
931 (JvNewStringLatin1 (name), arg_vec, is_jar);
935 // We need a new ClassLoader because the classpath must be the
936 // jar file only. The easiest way to do this is to lose our
937 // reference to the previous classloader.
938 _Jv_Jar_Class_Path = strdup (name);
939 gnu::gcj::runtime::VMClassLoader::instance = NULL;
942 catch (java::lang::Throwable *t)
944 java::lang::System::err->println (JvNewStringLatin1
945 ("Exception during runtime initialization"));
946 t->printStackTrace();
950 _Jv_AttachCurrentThread (main_thread);
951 _Jv_ThreadRun (main_thread);
954 int status = (int) java::lang::ThreadGroup::had_uncaught_exception;
955 runtime->exit (status);
959 JvRunMain (jclass klass, int argc, const char **argv)
961 _Jv_RunMain (klass, NULL, argc, argv, false);
966 // Parse a string and return a heap size.
968 parse_heap_size (const char *spec)
971 unsigned long val = strtoul (spec, &end, 10);
972 if (*end == 'k' || *end == 'K')
974 else if (*end == 'm' || *end == 'M')
979 // Set the initial heap size. This might be ignored by the GC layer.
980 // This must be called before _Jv_RunMain.
982 _Jv_SetInitialHeapSize (const char *arg)
984 size_t size = parse_heap_size (arg);
985 _Jv_GCSetInitialHeapSize (size);
988 // Set the maximum heap size. This might be ignored by the GC layer.
989 // This must be called before _Jv_RunMain.
991 _Jv_SetMaximumHeapSize (const char *arg)
993 size_t size = parse_heap_size (arg);
994 _Jv_GCSetMaximumHeapSize (size);
1000 _Jv_Malloc (jsize size)
1002 if (__builtin_expect (size == 0, false))
1004 void *ptr = malloc ((size_t) size);
1005 if (__builtin_expect (ptr == NULL, false))
1011 _Jv_Realloc (void *ptr, jsize size)
1013 if (__builtin_expect (size == 0, false))
1015 ptr = realloc (ptr, (size_t) size);
1016 if (__builtin_expect (ptr == NULL, false))
1022 _Jv_MallocUnchecked (jsize size)
1024 if (__builtin_expect (size == 0, false))
1026 return malloc ((size_t) size);
1030 _Jv_Free (void* ptr)
1037 // In theory, these routines can be #ifdef'd away on machines which
1038 // support divide overflow signals. However, we never know if some
1039 // code might have been compiled with "-fuse-divide-subroutine", so we
1040 // always include them in libgcj.
1043 _Jv_divI (jint dividend, jint divisor)
1045 if (__builtin_expect (divisor == 0, false))
1046 _Jv_ThrowSignal (arithexception);
1048 if (dividend == (jint) 0x80000000L && divisor == -1)
1051 return dividend / divisor;
1055 _Jv_remI (jint dividend, jint divisor)
1057 if (__builtin_expect (divisor == 0, false))
1058 _Jv_ThrowSignal (arithexception);
1060 if (dividend == (jint) 0x80000000L && divisor == -1)
1063 return dividend % divisor;
1067 _Jv_divJ (jlong dividend, jlong divisor)
1069 if (__builtin_expect (divisor == 0, false))
1070 _Jv_ThrowSignal (arithexception);
1072 if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)
1075 return dividend / divisor;
1079 _Jv_remJ (jlong dividend, jlong divisor)
1081 if (__builtin_expect (divisor == 0, false))
1082 _Jv_ThrowSignal (arithexception);
1084 if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)
1087 return dividend % divisor;