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.
520 _Jv_NewMultiArray (jclass type, jint dimensions, jint *sizes)
522 JvAssert (type->isArray());
523 jclass element_type = type->getComponentType();
525 if (element_type->isPrimitive())
526 result = _Jv_NewPrimArray (element_type, sizes[0]);
528 result = _Jv_NewObjectArray (sizes[0], element_type, NULL);
532 JvAssert (! element_type->isPrimitive());
533 JvAssert (element_type->isArray());
534 jobject *contents = elements ((jobjectArray) result);
535 for (int i = 0; i < sizes[0]; ++i)
536 contents[i] = _Jv_NewMultiArray (element_type, dimensions - 1,
544 _Jv_NewMultiArray (jclass array_type, jint dimensions, ...)
547 jint sizes[dimensions];
548 va_start (args, dimensions);
549 for (int i = 0; i < dimensions; ++i)
551 jint size = va_arg (args, jint);
556 return _Jv_NewMultiArray (array_type, dimensions, sizes);
561 #define DECLARE_PRIM_TYPE(NAME, SIG, LEN) \
562 _Jv_ArrayVTable _Jv_##NAME##VTable; \
563 java::lang::Class _Jv_##NAME##Class ((jobject) #NAME, \
564 (jbyte) SIG, (jint) LEN, \
565 (jobject) &_Jv_##NAME##VTable);
567 DECLARE_PRIM_TYPE(byte, 'B', 1);
568 DECLARE_PRIM_TYPE(short, 'S', 2);
569 DECLARE_PRIM_TYPE(int, 'I', 4);
570 DECLARE_PRIM_TYPE(long, 'J', 8);
571 DECLARE_PRIM_TYPE(boolean, 'Z', 1);
572 DECLARE_PRIM_TYPE(char, 'C', 2);
573 DECLARE_PRIM_TYPE(float, 'F', 4);
574 DECLARE_PRIM_TYPE(double, 'D', 8);
575 DECLARE_PRIM_TYPE(void, 'V', 0);
578 _Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader)
583 return JvPrimClass (byte);
585 return JvPrimClass (short);
587 return JvPrimClass (int);
589 return JvPrimClass (long);
591 return JvPrimClass (boolean);
593 return JvPrimClass (char);
595 return JvPrimClass (float);
597 return JvPrimClass (double);
599 return JvPrimClass (void);
603 for (i = 1; sig[i] && sig[i] != ';'; ++i)
605 _Jv_Utf8Const *name = _Jv_makeUtf8Const (&sig[1], i - 1);
606 return _Jv_FindClass (name, loader);
611 jclass klass = _Jv_FindClassFromSignature (&sig[1], loader);
614 return _Jv_GetArrayClass (klass, loader);
618 return NULL; // Placate compiler.
624 JvConvertArgv (int argc, const char **argv)
628 jobjectArray ar = JvNewObjectArray(argc, &StringClass, NULL);
629 jobject* ptr = elements(ar);
630 for (int i = 0; i < argc; i++)
632 const char *arg = argv[i];
633 // FIXME - should probably use JvNewStringUTF.
634 *ptr++ = JvNewStringLatin1(arg, strlen(arg));
636 return (JArray<jstring>*) ar;
639 // FIXME: These variables are static so that they will be
640 // automatically scanned by the Boehm collector. This is needed
641 // because with qthreads the collector won't scan the initial stack --
642 // it will only scan the qthreads stacks.
644 // Command line arguments.
645 static JArray<jstring> *arg_vec;
647 // The primary thread.
648 static java::lang::Thread *main_thread;
651 _Jv_ThisExecutable (void)
657 _Jv_ThisExecutable (const char *name)
661 _Jv_execName = (char *) _Jv_Malloc (strlen (name) + 1);
662 strcpy (_Jv_execName, name);
666 #ifdef USE_WIN32_SIGNALLING
668 extern "C" int* win32_get_restart_frame (void *);
671 win32_exception_handler (LPEXCEPTION_POINTERS e)
674 if (e->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
675 setjmp_buf = win32_get_restart_frame (nullp);
676 else if (e->ExceptionRecord->ExceptionCode == EXCEPTION_INT_DIVIDE_BY_ZERO)
677 setjmp_buf = win32_get_restart_frame (arithexception);
679 return EXCEPTION_CONTINUE_SEARCH;
681 e->ContextRecord->Ebp = setjmp_buf[0];
682 // FIXME: Why does i386-signal.h increment the PC here, do we need to do it?
683 e->ContextRecord->Eip = setjmp_buf[1];
684 // FIXME: Is this the stack pointer? Do we need it?
685 e->ContextRecord->Esp = setjmp_buf[2];
687 return EXCEPTION_CONTINUE_EXECUTION;
692 #ifndef DISABLE_GETENV_PROPERTIES
695 next_property_key (char *s, size_t *length)
701 // Skip over whitespace
705 // If we've reached the end, return NULL. Also return NULL if for
706 // some reason we've come across a malformed property string.
712 // Determine the length of the property key.
730 next_property_value (char *s, size_t *length)
746 // If we've reached the end, return NULL.
750 // Determine the length of the property value.
769 process_gcj_properties ()
771 char *props = getenv("GCJ_PROPERTIES");
774 size_t property_count = 0;
779 // Whip through props quickly in order to count the number of
781 while (p && (p = next_property_key (p, &length)))
783 // Skip to the end of the key
786 p = next_property_value (p, &length);
793 // Allocate an array of property value/key pairs.
794 _Jv_Environment_Properties =
795 (property_pair *) malloc (sizeof(property_pair)
796 * (property_count + 1));
798 // Go through the properties again, initializing _Jv_Properties
802 while (p && (p = next_property_key (p, &length)))
804 _Jv_Environment_Properties[property_count].key = p;
805 _Jv_Environment_Properties[property_count].key_length = length;
807 // Skip to the end of the key
810 p = next_property_value (p, &length);
812 _Jv_Environment_Properties[property_count].value = p;
813 _Jv_Environment_Properties[property_count].value_length = length;
820 memset ((void *) &_Jv_Environment_Properties[property_count],
821 0, sizeof (property_pair));
825 // Null terminate the strings.
826 while (_Jv_Environment_Properties[i].key)
828 _Jv_Environment_Properties[i].key[_Jv_Environment_Properties[i].key_length] = 0;
829 _Jv_Environment_Properties[i++].value[_Jv_Environment_Properties[i].value_length] = 0;
833 #endif // DISABLE_GETENV_PROPERTIES
836 _Jv_CreateJavaVM (void* /*vm_args*/)
838 PROCESS_GCJ_PROPERTIES;
840 // Turn stack trace generation off while creating exception objects.
841 _Jv_InitClass (&java::lang::Throwable::class$);
842 java::lang::Throwable::trace_enabled = 0;
848 arithexception = new java::lang::ArithmeticException
849 (JvNewStringLatin1 ("/ by zero"));
852 no_memory = new java::lang::OutOfMemoryError;
854 java::lang::Throwable::trace_enabled = 1;
857 LTDL_SET_PRELOADED_SYMBOLS ();
861 // Initialise winsock for networking
863 if (WSAStartup (MAKEWORD (1, 1), &data))
864 MessageBox (NULL, "Error initialising winsock library.", "Error", MB_OK | MB_ICONEXCLAMATION);
865 #endif /* USE_WINSOCK */
867 #ifdef USE_WIN32_SIGNALLING
868 // Install exception handler
869 SetUnhandledExceptionFilter (win32_exception_handler);
870 #elif defined(HAVE_SIGACTION)
871 // We only want this on POSIX systems.
872 struct sigaction act;
873 act.sa_handler = SIG_IGN;
874 sigemptyset (&act.sa_mask);
876 sigaction (SIGPIPE, &act, NULL);
878 signal (SIGPIPE, SIG_IGN);
887 _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
893 java::lang::Runtime *runtime = NULL;
895 #ifdef HAVE_PROC_SELF_EXE
897 sprintf (exec_name, "/proc/%d/exe", getpid ());
898 _Jv_ThisExecutable (exec_name);
900 _Jv_ThisExecutable (argv[0]);
905 _Jv_CreateJavaVM (NULL);
907 // Get the Runtime here. We want to initialize it before searching
908 // for `main'; that way it will be set up if `main' is a JNI method.
909 runtime = java::lang::Runtime::getRuntime ();
911 arg_vec = JvConvertArgv (argc - 1, argv + 1);
914 main_thread = new gnu::gcj::runtime::FirstThread (klass, arg_vec);
916 main_thread = new gnu::gcj::runtime::FirstThread
917 (JvNewStringLatin1 (name), arg_vec, is_jar);
921 // We need a new ClassLoader because the classpath must be the
922 // jar file only. The easiest way to do this is to lose our
923 // reference to the previous classloader.
924 _Jv_Jar_Class_Path = strdup (name);
925 gnu::gcj::runtime::VMClassLoader::instance = NULL;
928 catch (java::lang::Throwable *t)
930 java::lang::System::err->println (JvNewStringLatin1
931 ("Exception during runtime initialization"));
932 t->printStackTrace();
936 _Jv_AttachCurrentThread (main_thread);
937 _Jv_ThreadRun (main_thread);
940 int status = (int) java::lang::ThreadGroup::had_uncaught_exception;
941 runtime->exit (status);
945 JvRunMain (jclass klass, int argc, const char **argv)
947 _Jv_RunMain (klass, NULL, argc, argv, false);
952 // Parse a string and return a heap size.
954 parse_heap_size (const char *spec)
957 unsigned long val = strtoul (spec, &end, 10);
958 if (*end == 'k' || *end == 'K')
960 else if (*end == 'm' || *end == 'M')
965 // Set the initial heap size. This might be ignored by the GC layer.
966 // This must be called before _Jv_RunMain.
968 _Jv_SetInitialHeapSize (const char *arg)
970 size_t size = parse_heap_size (arg);
971 _Jv_GCSetInitialHeapSize (size);
974 // Set the maximum heap size. This might be ignored by the GC layer.
975 // This must be called before _Jv_RunMain.
977 _Jv_SetMaximumHeapSize (const char *arg)
979 size_t size = parse_heap_size (arg);
980 _Jv_GCSetMaximumHeapSize (size);
986 _Jv_Malloc (jsize size)
988 if (__builtin_expect (size == 0, false))
990 void *ptr = malloc ((size_t) size);
991 if (__builtin_expect (ptr == NULL, false))
997 _Jv_Realloc (void *ptr, jsize size)
999 if (__builtin_expect (size == 0, false))
1001 ptr = realloc (ptr, (size_t) size);
1002 if (__builtin_expect (ptr == NULL, false))
1008 _Jv_MallocUnchecked (jsize size)
1010 if (__builtin_expect (size == 0, false))
1012 return malloc ((size_t) size);
1016 _Jv_Free (void* ptr)
1023 // In theory, these routines can be #ifdef'd away on machines which
1024 // support divide overflow signals. However, we never know if some
1025 // code might have been compiled with "-fuse-divide-subroutine", so we
1026 // always include them in libgcj.
1029 _Jv_divI (jint dividend, jint divisor)
1031 if (__builtin_expect (divisor == 0, false))
1032 _Jv_ThrowSignal (arithexception);
1034 if (dividend == (jint) 0x80000000L && divisor == -1)
1037 return dividend / divisor;
1041 _Jv_remI (jint dividend, jint divisor)
1043 if (__builtin_expect (divisor == 0, false))
1044 _Jv_ThrowSignal (arithexception);
1046 if (dividend == (jint) 0x80000000L && divisor == -1)
1049 return dividend % divisor;
1053 _Jv_divJ (jlong dividend, jlong divisor)
1055 if (__builtin_expect (divisor == 0, false))
1056 _Jv_ThrowSignal (arithexception);
1058 if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)
1061 return dividend / divisor;
1065 _Jv_remJ (jlong dividend, jlong divisor)
1067 if (__builtin_expect (divisor == 0, false))
1068 _Jv_ThrowSignal (arithexception);
1070 if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)
1073 return dividend % divisor;