annotate src/cpu/zero/vm/stack_zero.inline.hpp @ 1511:348346af6676

6950178: Zero stack improvements Summary: Moves the logic for determining the size of the Zero stack into the ZeroStack class. Reviewed-by: twisti Contributed-by: Gary Benson <gbenson@redhat.com>
author twisti
date Thu, 06 May 2010 02:09:18 -0700
parents aa9c266de52a
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1383
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
1 /*
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved.
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
3 * Copyright 2010 Red Hat, Inc.
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
5 *
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
6 * This code is free software; you can redistribute it and/or modify it
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
7 * under the terms of the GNU General Public License version 2 only, as
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
8 * published by the Free Software Foundation.
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
9 *
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
10 * This code is distributed in the hope that it will be useful, but WITHOUT
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
13 * version 2 for more details (a copy is included in the LICENSE file that
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
14 * accompanied this code).
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
15 *
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License version
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
17 * 2 along with this work; if not, write to the Free Software Foundation,
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
19 *
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
21 * CA 95054 USA or visit www.sun.com if you need additional information or
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
22 * have any questions.
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
23 *
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
24 */
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
25
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
26 // This function should match SharkStack::CreateStackOverflowCheck
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
27 inline void ZeroStack::overflow_check(int required_words, TRAPS) {
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
28 // Check the Zero stack
1511
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
29 if (available_words() < required_words) {
1383
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
30 handle_overflow(THREAD);
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
31 return;
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
32 }
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
33
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
34 // Check the ABI stack
1511
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
35 if (abi_stack_available(THREAD) < 0) {
1383
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
36 handle_overflow(THREAD);
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
37 return;
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
38 }
aa9c266de52a 6944473: 6941224 misses new files
twisti
parents:
diff changeset
39 }
1511
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
40
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
41 // This method returns the amount of ABI stack available for us
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
42 // to use under normal circumstances. Note that the returned
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
43 // value can be negative.
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
44 inline int ZeroStack::abi_stack_available(Thread *thread) const {
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
45 int stack_used = thread->stack_base() - (address) &stack_used;
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
46 int stack_free = thread->stack_size() - stack_used;
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
47 return stack_free - shadow_pages_size();
348346af6676 6950178: Zero stack improvements
twisti
parents: 1383
diff changeset
48 }