1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24  
  25 #ifndef SHARE_VM_RUNTIME_CONTINUATION_HPP
  26 #define SHARE_VM_RUNTIME_CONTINUATION_HPP
  27 
  28 #include "runtime/globals.hpp"
  29 
  30 #define CONT_FULL_STACK (!UseNewCode)
  31 
  32 // The order of this struct matters as it's directly manipulated by assembly code (push/pop)
  33 struct FrameInfo {
  34   address pc;
  35   intptr_t* fp;
  36   intptr_t* sp;
  37 };
  38 
  39 class Continuation : AllStatic {
  40 private:
  41   static Method* _entry_method;
  42   static Method* entry_method(Thread*);
  43 
  44 public:
  45   static void freeze(JavaThread* thread, FrameInfo* fi, int scopes);
  46   static int prepare_thaw(FrameInfo* fi, bool return_barrier);
  47   static void thaw(FrameInfo* fi, bool return_barrier);
  48 
  49   static bool is_continuation_entry_frame(const frame& f);
  50   static bool is_cont_bottom_frame(const frame& f);
  51   static bool is_return_barrier_entry(const address pc);
  52   static address sender_pc_past_barrier(JavaThread* thread, const frame& f);
  53   static address get_entry_pc_past_barrier(JavaThread* thread, const frame& f);
  54   static frame fix_continuation_bottom_sender(const frame& callee, frame f, RegisterMap* map);
  55 };
  56 
  57 void CONT_RegisterNativeMethods(JNIEnv *env, jclass cls);
  58 
  59 #endif // SHARE_VM_RUNTIME_CONTINUATION_HPP