Mercurial > hg > graal-jvmci-8
comparison src/cpu/zero/vm/stubGenerator_zero.cpp @ 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 | 348346af6676 |
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 2007, 2008 Red Hat, Inc. | 3 * Copyright 2007, 2008, 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. |
58 stack->setup(alloca(zero_stack_size), zero_stack_size); | 58 stack->setup(alloca(zero_stack_size), zero_stack_size); |
59 stack_needs_teardown = true; | 59 stack_needs_teardown = true; |
60 } | 60 } |
61 | 61 |
62 // Allocate and initialize our frame | 62 // Allocate and initialize our frame |
63 thread->push_zero_frame( | 63 EntryFrame *frame = |
64 EntryFrame::build(stack, parameters, parameter_words, call_wrapper)); | 64 EntryFrame::build(parameters, parameter_words, call_wrapper, THREAD); |
65 | 65 |
66 // Make the call | |
67 Interpreter::invoke_method(method, entry_point, THREAD); | |
68 | |
69 // Store result depending on type | |
70 if (!HAS_PENDING_EXCEPTION) { | 66 if (!HAS_PENDING_EXCEPTION) { |
71 switch (result_type) { | 67 // Push the frame |
72 case T_INT: | 68 thread->push_zero_frame(frame); |
73 *(jint *) result = *(jint *) stack->sp(); | 69 |
74 break; | 70 // Make the call |
75 case T_LONG: | 71 Interpreter::invoke_method(method, entry_point, THREAD); |
76 *(jlong *) result = *(jlong *) stack->sp(); | 72 |
77 break; | 73 // Store the result |
78 case T_FLOAT: | 74 if (!HAS_PENDING_EXCEPTION) { |
79 *(jfloat *) result = *(jfloat *) stack->sp(); | 75 switch (result_type) { |
80 break; | 76 case T_INT: |
81 case T_DOUBLE: | 77 *(jint *) result = *(jint *) stack->sp(); |
82 *(jdouble *) result = *(jdouble *) stack->sp(); | 78 break; |
83 break; | 79 case T_LONG: |
84 case T_OBJECT: | 80 *(jlong *) result = *(jlong *) stack->sp(); |
85 *(oop *) result = *(oop *) stack->sp(); | 81 break; |
86 break; | 82 case T_FLOAT: |
87 default: | 83 *(jfloat *) result = *(jfloat *) stack->sp(); |
88 ShouldNotReachHere(); | 84 break; |
85 case T_DOUBLE: | |
86 *(jdouble *) result = *(jdouble *) stack->sp(); | |
87 break; | |
88 case T_OBJECT: | |
89 *(oop *) result = *(oop *) stack->sp(); | |
90 break; | |
91 default: | |
92 ShouldNotReachHere(); | |
93 } | |
89 } | 94 } |
95 | |
96 // Unwind the frame | |
97 thread->pop_zero_frame(); | |
90 } | 98 } |
91 | |
92 // Unwind our frame | |
93 thread->pop_zero_frame(); | |
94 | 99 |
95 // Tear down the stack if necessary | 100 // Tear down the stack if necessary |
96 if (stack_needs_teardown) | 101 if (stack_needs_teardown) |
97 stack->teardown(); | 102 stack->teardown(); |
98 } | 103 } |
224 | 229 |
225 void StubGenerator_generate(CodeBuffer* code, bool all) { | 230 void StubGenerator_generate(CodeBuffer* code, bool all) { |
226 StubGenerator g(code, all); | 231 StubGenerator g(code, all); |
227 } | 232 } |
228 | 233 |
229 EntryFrame *EntryFrame::build(ZeroStack* stack, | 234 EntryFrame *EntryFrame::build(const intptr_t* parameters, |
230 const intptr_t* parameters, | |
231 int parameter_words, | 235 int parameter_words, |
232 JavaCallWrapper* call_wrapper) { | 236 JavaCallWrapper* call_wrapper, |
233 if (header_words + parameter_words > stack->available_words()) { | 237 TRAPS) { |
234 Unimplemented(); | 238 |
235 } | 239 ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack(); |
240 stack->overflow_check(header_words + parameter_words, CHECK_NULL); | |
236 | 241 |
237 stack->push(0); // next_frame, filled in later | 242 stack->push(0); // next_frame, filled in later |
238 intptr_t *fp = stack->sp(); | 243 intptr_t *fp = stack->sp(); |
239 assert(fp - stack->sp() == next_frame_off, "should be"); | 244 assert(fp - stack->sp() == next_frame_off, "should be"); |
240 | 245 |