Commit 11922361 by Bryce McKinlay Committed by Bryce McKinlay

Implement -Xss.

        * include/jvm.h (gcj::stack_size): Declare.
        (_Jv_StackSize): Declare.
        * posix-threads.cc (_Jv_InitThreads): Validate gcj::stack_size.
        (_Jv_ThreadStart): Set stack size if specified.
        * prims.cc (gcj::stack_size): Define.
        (parse_memory_size): Renamed from parse_heap_size.
        (_Jv_SetStackSize): Parse stack size argument and set
        gcj::stack_size.

From-SVN: r107132
parent f9314d01
2005-11-17 Bryce McKinlay <mckinlay@redhat.com>
Implement -Xss.
* include/jvm.h (gcj::stack_size): Declare.
(_Jv_StackSize): Declare.
* posix-threads.cc (_Jv_InitThreads): Validate gcj::stack_size.
(_Jv_ThreadStart): Set stack size if specified.
* prims.cc (gcj::stack_size): Define.
(parse_memory_size): Renamed from parse_heap_size.
(_Jv_SetStackSize): Parse stack size argument and set
gcj::stack_size.
2005-11-17 Mark Wielaard <mark@klomp.org> 2005-11-17 Mark Wielaard <mark@klomp.org>
* java/text/SimpleDateFormat.java: Removed, fully merged now. * java/text/SimpleDateFormat.java: Removed, fully merged now.
......
...@@ -233,6 +233,9 @@ namespace gcj ...@@ -233,6 +233,9 @@ namespace gcj
/* When true, enable the bytecode verifier and BC-ABI verification. */ /* When true, enable the bytecode verifier and BC-ABI verification. */
extern bool verifyClasses; extern bool verifyClasses;
/* Thread stack size specified by the -Xss runtime argument. */
extern size_t stack_size;
} }
// This class handles all aspects of class preparation and linking. // This class handles all aspects of class preparation and linking.
...@@ -363,6 +366,10 @@ void _Jv_SetMaximumHeapSize (const char *arg); ...@@ -363,6 +366,10 @@ void _Jv_SetMaximumHeapSize (const char *arg);
during thread deregistration. */ during thread deregistration. */
void _Jv_FreeMethodCache (); void _Jv_FreeMethodCache ();
/* Set the stack size for threads. Parses ARG, a number which can
optionally have "k" or "m" appended. */
void _Jv_SetStackSize (const char *arg);
extern "C" void JvRunMain (jclass klass, int argc, const char **argv); extern "C" void JvRunMain (jclass klass, int argc, const char **argv);
void _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv, void _Jv_RunMain (jclass klass, const char *name, int argc, const char **argv,
bool is_jar); bool is_jar);
......
...@@ -311,6 +311,19 @@ _Jv_InitThreads (void) ...@@ -311,6 +311,19 @@ _Jv_InitThreads (void)
// Block SIGCHLD here to ensure that any non-Java threads inherit the new // Block SIGCHLD here to ensure that any non-Java threads inherit the new
// signal mask. // signal mask.
block_sigchld(); block_sigchld();
// Check/set the thread stack size.
size_t min_ss = 32 * 1024;
if (sizeof (void *) == 8)
// Bigger default on 64-bit systems.
min_ss *= 2;
if (min_ss < PTHREAD_STACK_MIN)
min_ss = PTHREAD_STACK_MIN;
if (gcj::stack_size > 0 && gcj::stack_size < min_ss)
gcj::stack_size = min_ss;
} }
_Jv_Thread_t * _Jv_Thread_t *
...@@ -430,6 +443,14 @@ _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data, ...@@ -430,6 +443,14 @@ _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
pthread_attr_init (&attr); pthread_attr_init (&attr);
pthread_attr_setschedparam (&attr, &param); pthread_attr_setschedparam (&attr, &param);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
// Set stack size if -Xss option was given.
if (gcj::stack_size > 0)
{
int e = pthread_attr_setstacksize (&attr, gcj::stack_size);
if (e != 0)
JvFail (strerror (e));
}
info = (struct starter *) _Jv_AllocBytes (sizeof (struct starter)); info = (struct starter *) _Jv_AllocBytes (sizeof (struct starter));
info->method = meth; info->method = meth;
......
...@@ -959,6 +959,9 @@ namespace gcj ...@@ -959,6 +959,9 @@ namespace gcj
// When true, enable the bytecode verifier and BC-ABI type verification. // When true, enable the bytecode verifier and BC-ABI type verification.
bool verifyClasses = true; bool verifyClasses = true;
// Thread stack size specified by the -Xss runtime argument.
size_t stack_size = 0;
} }
// We accept all non-standard options accepted by Sun's java command, // We accept all non-standard options accepted by Sun's java command,
...@@ -1045,7 +1048,7 @@ parse_x_arg (char* option_string) ...@@ -1045,7 +1048,7 @@ parse_x_arg (char* option_string)
} }
else if (! strncmp (option_string, "ss", 2)) else if (! strncmp (option_string, "ss", 2))
{ {
// FIXME: set thread stack size _Jv_SetStackSize (option_string + 2);
} }
else if (! strcmp (option_string, "X:+UseAltSigs")) else if (! strcmp (option_string, "X:+UseAltSigs"))
{ {
...@@ -1407,7 +1410,7 @@ JvRunMain (jclass klass, int argc, const char **argv) ...@@ -1407,7 +1410,7 @@ JvRunMain (jclass klass, int argc, const char **argv)
// Parse a string and return a heap size. // Parse a string and return a heap size.
static size_t static size_t
parse_heap_size (const char *spec) parse_memory_size (const char *spec)
{ {
char *end; char *end;
unsigned long val = strtoul (spec, &end, 10); unsigned long val = strtoul (spec, &end, 10);
...@@ -1423,7 +1426,7 @@ parse_heap_size (const char *spec) ...@@ -1423,7 +1426,7 @@ parse_heap_size (const char *spec)
void void
_Jv_SetInitialHeapSize (const char *arg) _Jv_SetInitialHeapSize (const char *arg)
{ {
size_t size = parse_heap_size (arg); size_t size = parse_memory_size (arg);
_Jv_GCSetInitialHeapSize (size); _Jv_GCSetInitialHeapSize (size);
} }
...@@ -1432,11 +1435,16 @@ _Jv_SetInitialHeapSize (const char *arg) ...@@ -1432,11 +1435,16 @@ _Jv_SetInitialHeapSize (const char *arg)
void void
_Jv_SetMaximumHeapSize (const char *arg) _Jv_SetMaximumHeapSize (const char *arg)
{ {
size_t size = parse_heap_size (arg); size_t size = parse_memory_size (arg);
_Jv_GCSetMaximumHeapSize (size); _Jv_GCSetMaximumHeapSize (size);
} }
void
_Jv_SetStackSize (const char *arg)
{
size_t size = parse_memory_size (arg);
gcj::stack_size = size;
}
void * void *
_Jv_Malloc (jsize size) _Jv_Malloc (jsize size)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment