1 // |
1 // |
2 // Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. |
2 // Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
3 // Copyright 2012, 2013 SAP AG. All rights reserved. |
3 // Copyright 2012, 2014 SAP AG. All rights reserved. |
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. |
1361 |
1361 |
1362 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { |
1362 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { |
1363 Compile* C = ra_->C; |
1363 Compile* C = ra_->C; |
1364 MacroAssembler _masm(&cbuf); |
1364 MacroAssembler _masm(&cbuf); |
1365 |
1365 |
1366 const long framesize = ((long)C->frame_slots()) << LogBytesPerInt; |
1366 const long framesize = C->frame_size_in_bytes(); |
1367 assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment"); |
1367 assert(framesize % (2 * wordSize) == 0, "must preserve 2*wordSize alignment"); |
1368 |
1368 |
1369 const bool method_is_frameless = false /* TODO: PPC port C->is_frameless_method()*/; |
1369 const bool method_is_frameless = false /* TODO: PPC port C->is_frameless_method()*/; |
1370 |
1370 |
1371 const Register return_pc = R20; // Must match return_addr() in frame section. |
1371 const Register return_pc = R20; // Must match return_addr() in frame section. |
1372 const Register callers_sp = R21; |
1372 const Register callers_sp = R21; |
1387 // Calls to C2R adapters often do not accept exceptional returns. |
1387 // Calls to C2R adapters often do not accept exceptional returns. |
1388 // We require that their callers must bang for them. But be |
1388 // We require that their callers must bang for them. But be |
1389 // careful, because some VM calls (such as call site linkage) can |
1389 // careful, because some VM calls (such as call site linkage) can |
1390 // use several kilobytes of stack. But the stack safety zone should |
1390 // use several kilobytes of stack. But the stack safety zone should |
1391 // account for that. See bugs 4446381, 4468289, 4497237. |
1391 // account for that. See bugs 4446381, 4468289, 4497237. |
1392 if (C->need_stack_bang(framesize) && UseStackBanging) { |
1392 |
|
1393 int bangsize = C->bang_size_in_bytes(); |
|
1394 assert(bangsize >= framesize || bangsize <= 0, "stack bang size incorrect"); |
|
1395 if (C->need_stack_bang(bangsize) && UseStackBanging) { |
1393 // Unfortunately we cannot use the function provided in |
1396 // Unfortunately we cannot use the function provided in |
1394 // assembler.cpp as we have to emulate the pipes. So I had to |
1397 // assembler.cpp as we have to emulate the pipes. So I had to |
1395 // insert the code of generate_stack_overflow_check(), see |
1398 // insert the code of generate_stack_overflow_check(), see |
1396 // assembler.cpp for some illuminative comments. |
1399 // assembler.cpp for some illuminative comments. |
1397 const int page_size = os::vm_page_size(); |
1400 const int page_size = os::vm_page_size(); |
1398 int bang_end = StackShadowPages*page_size; |
1401 int bang_end = StackShadowPages * page_size; |
1399 |
1402 |
1400 // This is how far the previous frame's stack banging extended. |
1403 // This is how far the previous frame's stack banging extended. |
1401 const int bang_end_safe = bang_end; |
1404 const int bang_end_safe = bang_end; |
1402 |
1405 |
1403 if (framesize > page_size) { |
1406 if (bangsize > page_size) { |
1404 bang_end += framesize; |
1407 bang_end += bangsize; |
1405 } |
1408 } |
1406 |
1409 |
1407 int bang_offset = bang_end_safe; |
1410 int bang_offset = bang_end_safe; |
1408 |
1411 |
1409 while (bang_offset <= bang_end) { |
1412 while (bang_offset <= bang_end) { |
1445 // R11 trashed |
1448 // R11 trashed |
1446 } // C->need_stack_bang(framesize) && UseStackBanging |
1449 } // C->need_stack_bang(framesize) && UseStackBanging |
1447 |
1450 |
1448 unsigned int bytes = (unsigned int)framesize; |
1451 unsigned int bytes = (unsigned int)framesize; |
1449 long offset = Assembler::align_addr(bytes, frame::alignment_in_bytes); |
1452 long offset = Assembler::align_addr(bytes, frame::alignment_in_bytes); |
1450 ciMethod *currMethod = C -> method(); |
1453 ciMethod *currMethod = C->method(); |
1451 |
1454 |
1452 // Optimized version for most common case. |
1455 // Optimized version for most common case. |
1453 if (UsePower6SchedulerPPC64 && |
1456 if (UsePower6SchedulerPPC64 && |
1454 !method_is_frameless && Assembler::is_simm((int)(-offset), 16) && |
1457 !method_is_frameless && Assembler::is_simm((int)(-offset), 16) && |
1455 !(false /* ConstantsALot TODO: PPC port*/)) { |
1458 !(false /* ConstantsALot TODO: PPC port*/)) { |