1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
343
344 #ifdef IA64
345 // IA64 has two stacks sharing the same area of memory, a normal
346 // stack growing downwards and a register stack growing upwards.
347 // Guard pages, if present, are in the centre. This code splits
348 // the stack in two even without guard pages, though in theory
349 // there's nothing to stop us allocating more to the normal stack
350 // or more to the register stack if one or the other were found
351 // to grow faster.
352 int total_pages = align_size_down(stack_bytes, page_bytes) / page_bytes;
353 stack_bottom += (total_pages - guard_pages) / 2 * page_bytes;
354 #endif // IA64
355
356 stack_bottom += guard_bytes;
357
358 pthread_attr_destroy(&attr);
359
360 // The initial thread has a growable stack, and the size reported
361 // by pthread_attr_getstack is the maximum size it could possibly
362 // be given what currently mapped. This can be huge, so we cap it.
363 if (os::Linux::is_initial_thread()) {
364 stack_bytes = stack_top - stack_bottom;
365
366 if (stack_bytes > JavaThread::stack_size_at_create())
367 stack_bytes = JavaThread::stack_size_at_create();
368
369 stack_bottom = stack_top - stack_bytes;
370 }
371
372 assert(os::current_stack_pointer() >= stack_bottom, "should do");
373 assert(os::current_stack_pointer() < stack_top, "should do");
374
375 *bottom = stack_bottom;
376 *size = stack_top - stack_bottom;
377 }
378
379 address os::current_stack_base() {
380 address bottom;
381 size_t size;
382 current_stack_region(&bottom, &size);
383 return bottom + size;
|
1 /*
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
343
344 #ifdef IA64
345 // IA64 has two stacks sharing the same area of memory, a normal
346 // stack growing downwards and a register stack growing upwards.
347 // Guard pages, if present, are in the centre. This code splits
348 // the stack in two even without guard pages, though in theory
349 // there's nothing to stop us allocating more to the normal stack
350 // or more to the register stack if one or the other were found
351 // to grow faster.
352 int total_pages = align_size_down(stack_bytes, page_bytes) / page_bytes;
353 stack_bottom += (total_pages - guard_pages) / 2 * page_bytes;
354 #endif // IA64
355
356 stack_bottom += guard_bytes;
357
358 pthread_attr_destroy(&attr);
359
360 // The initial thread has a growable stack, and the size reported
361 // by pthread_attr_getstack is the maximum size it could possibly
362 // be given what currently mapped. This can be huge, so we cap it.
363 if (os::is_primordial_thread()) {
364 stack_bytes = stack_top - stack_bottom;
365
366 if (stack_bytes > JavaThread::stack_size_at_create())
367 stack_bytes = JavaThread::stack_size_at_create();
368
369 stack_bottom = stack_top - stack_bytes;
370 }
371
372 assert(os::current_stack_pointer() >= stack_bottom, "should do");
373 assert(os::current_stack_pointer() < stack_top, "should do");
374
375 *bottom = stack_bottom;
376 *size = stack_top - stack_bottom;
377 }
378
379 address os::current_stack_base() {
380 address bottom;
381 size_t size;
382 current_stack_region(&bottom, &size);
383 return bottom + size;
|