Mercurial > hg > graal-jvmci-8
comparison src/cpu/zero/vm/stack_zero.hpp @ 1379:f9271ff9d324
6941224: Improved stack overflow handling for Zero
Summary: Adding stack overflow checking to Shark brought to light a bunch of deficiencies in Zero's stack overflow code.
Reviewed-by: twisti
Contributed-by: Gary Benson <gbenson@redhat.com>
author | twisti |
---|---|
date | Thu, 15 Apr 2010 02:40:12 -0700 |
parents | 354d3184f6b2 |
children | 0c5b3cf3c1f5 |
comparison
equal
deleted
inserted
replaced
1377:ef74d6d1ac1e | 1379:f9271ff9d324 |
---|---|
1 /* | 1 /* |
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. |
3 * Copyright 2008, 2009 Red Hat, Inc. | 3 * Copyright 2008, 2009, 2010 Red Hat, Inc. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * | 5 * |
6 * This code is free software; you can redistribute it and/or modify it | 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 | 7 * under the terms of the GNU General Public License version 2 only, as |
8 * published by the Free Software Foundation. | 8 * published by the Free Software Foundation. |
27 private: | 27 private: |
28 intptr_t *_base; // the last available word | 28 intptr_t *_base; // the last available word |
29 intptr_t *_top; // the word past the end of the stack | 29 intptr_t *_top; // the word past the end of the stack |
30 intptr_t *_sp; // the top word on the stack | 30 intptr_t *_sp; // the top word on the stack |
31 | 31 |
32 private: | |
33 int _shadow_pages_size; // how much ABI stack must we keep free? | |
34 | |
32 public: | 35 public: |
33 ZeroStack() | 36 ZeroStack() |
34 : _base(NULL), _top(NULL), _sp(NULL) {} | 37 : _base(NULL), _top(NULL), _sp(NULL) { |
38 _shadow_pages_size = StackShadowPages * os::vm_page_size(); | |
39 } | |
35 | 40 |
36 bool needs_setup() const { | 41 bool needs_setup() const { |
37 return _base == NULL; | 42 return _base == NULL; |
38 } | 43 } |
39 | 44 |
78 void *alloc(size_t size) { | 83 void *alloc(size_t size) { |
79 int count = align_size_up(size, wordSize) >> LogBytesPerWord; | 84 int count = align_size_up(size, wordSize) >> LogBytesPerWord; |
80 assert(count <= available_words(), "stack overflow"); | 85 assert(count <= available_words(), "stack overflow"); |
81 return _sp -= count; | 86 return _sp -= count; |
82 } | 87 } |
88 | |
89 int shadow_pages_size() const { | |
90 return _shadow_pages_size; | |
91 } | |
92 | |
93 public: | |
94 void overflow_check(int required_words, TRAPS); | |
95 static void handle_overflow(TRAPS); | |
83 | 96 |
84 public: | 97 public: |
85 static ByteSize base_offset() { | 98 static ByteSize base_offset() { |
86 return byte_offset_of(ZeroStack, _base); | 99 return byte_offset_of(ZeroStack, _base); |
87 } | 100 } |