cppInterpreter_zero.cpp revision 6010:abec000618bf
131567Ssef/*
2204977Simp * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
331899Ssef * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
431899Ssef * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
531899Ssef *
631899Ssef * This code is free software; you can redistribute it and/or modify it
731899Ssef * under the terms of the GNU General Public License version 2 only, as
831899Ssef * published by the Free Software Foundation.
931899Ssef *
1031899Ssef * This code is distributed in the hope that it will be useful, but WITHOUT
1131899Ssef * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1231899Ssef * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1331899Ssef * version 2 for more details (a copy is included in the LICENSE file that
1431899Ssef * accompanied this code).
1531899Ssef *
1631899Ssef * You should have received a copy of the GNU General Public License version
1731899Ssef * 2 along with this work; if not, write to the Free Software Foundation,
1831899Ssef * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1931899Ssef *
2031899Ssef * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2131899Ssef * or visit www.oracle.com if you need additional information or have any
2231899Ssef * questions.
2331899Ssef *
2431899Ssef */
2531899Ssef
2631899Ssef#include "precompiled.hpp"
2731899Ssef#include "asm/assembler.hpp"
2831899Ssef#include "interpreter/bytecodeHistogram.hpp"
2931899Ssef#include "interpreter/cppInterpreter.hpp"
3031899Ssef#include "interpreter/interpreter.hpp"
3131899Ssef#include "interpreter/interpreterGenerator.hpp"
3232275Scharnier#include "interpreter/interpreterRuntime.hpp"
3332275Scharnier#include "oops/arrayOop.hpp"
3450477Speter#include "oops/methodData.hpp"
3532275Scharnier#include "oops/method.hpp"
3632275Scharnier#include "oops/oop.inline.hpp"
3731899Ssef#include "prims/jvmtiExport.hpp"
3831567Ssef#include "prims/jvmtiThreadState.hpp"
3931567Ssef#include "runtime/arguments.hpp"
4031567Ssef#include "runtime/deoptimization.hpp"
4131567Ssef#include "runtime/frame.inline.hpp"
42127328Salfred#include "runtime/interfaceSupport.hpp"
4385292Sdes#include "runtime/sharedRuntime.hpp"
44168569Sdelphij#include "runtime/stubRoutines.hpp"
4585292Sdes#include "runtime/synchronizer.hpp"
46104581Smike#include "runtime/timer.hpp"
4785292Sdes#include "runtime/vframeArray.hpp"
4885292Sdes#include "stack_zero.inline.hpp"
4985292Sdes#include "utilities/debug.hpp"
50158630Spav#include "utilities/macros.hpp"
51158630Spav#ifdef SHARK
52158630Spav#include "shark/shark_globals.hpp"
53158630Spav#endif
54158630Spav
55158630Spav#ifdef CC_INTERP
56158630Spav
5785292Sdes#define fixup_after_potential_safepoint()       \
5886138Sgreen  method = istate->method()
5932275Scharnier
60127328Salfred#define CALL_VM_NOCHECK_NOFIX(func)             \
61127332Sdwmalone  thread->set_last_Java_frame();                \
6285292Sdes  func;                                         \
63127332Sdwmalone  thread->reset_last_Java_frame();
6431567Ssef
6531567Ssef#define CALL_VM_NOCHECK(func)                   \
6631567Ssef  CALL_VM_NOCHECK_NOFIX(func)                   \
67101423Smdodd  fixup_after_potential_safepoint()
6831567Ssef
69158630Spavint CppInterpreter::normal_entry(Method* method, intptr_t UNUSED, TRAPS) {
7085292Sdes  JavaThread *thread = (JavaThread *) THREAD;
71101282Smdodd
7287703Smarkm  // Allocate and initialize our frame.
7331567Ssef  InterpreterFrame *frame = InterpreterFrame::build(method, CHECK_0);
7431567Ssef  thread->push_zero_frame(frame);
75171646Smarcel
76171646Smarcel  // Execute those bytecodes!
77171646Smarcel  main_loop(0, THREAD);
78171646Smarcel
79171646Smarcel  // No deoptimized frames on the stack
80171646Smarcel  return 0;
81171646Smarcel}
82171646Smarcel
83171646Smarcelvoid CppInterpreter::main_loop(int recurse, TRAPS) {
84171646Smarcel  JavaThread *thread = (JavaThread *) THREAD;
85171646Smarcel  ZeroStack *stack = thread->zero_stack();
86171646Smarcel
87171646Smarcel  // If we are entering from a deopt we may need to call
88171646Smarcel  // ourself a few times in order to get to our frame.
8931567Ssef  if (recurse)
90158630Spav    main_loop(recurse - 1, THREAD);
9131567Ssef
92228396Sed  InterpreterFrame *frame = thread->top_zero_frame()->as_interpreter_frame();
93192025Sdds  interpreterState istate = frame->interpreter_state();
94192025Sdds  Method* method = istate->method();
95200751Sjh
96200751Sjh  intptr_t *result = NULL;
97200751Sjh  int result_slots = 0;
98200751Sjh
99200751Sjh  while (true) {
100200751Sjh    // We can set up the frame anchor with everything we want at
101200751Sjh    // this point as we are thread_in_Java and no safepoints can
102200751Sjh    // occur until we go to vm mode.  We do have to clear flags
103200751Sjh    // on return from vm but that is it.
104200751Sjh    thread->set_last_Java_frame();
105200751Sjh
106200751Sjh    // Call the interpreter
107192025Sdds    if (JvmtiExport::can_post_interpreter_events())
108192025Sdds      BytecodeInterpreter::runWithChecks(istate);
109192025Sdds    else
110192025Sdds      BytecodeInterpreter::run(istate);
111192025Sdds    fixup_after_potential_safepoint();
112192025Sdds
113192025Sdds    // Clear the frame anchor
114192025Sdds    thread->reset_last_Java_frame();
115192025Sdds
116192025Sdds    // Examine the message from the interpreter to decide what to do
117192025Sdds    if (istate->msg() == BytecodeInterpreter::call_method) {
118192025Sdds      Method* callee = istate->callee();
119192025Sdds
120192025Sdds      // Trim back the stack to put the parameters at the top
121192025Sdds      stack->set_sp(istate->stack() + 1);
122192025Sdds
123192025Sdds      // Make the call
124192025Sdds      Interpreter::invoke_method(callee, istate->callee_entry_point(), THREAD);
125192025Sdds      fixup_after_potential_safepoint();
126192025Sdds
127192025Sdds      // Convert the result
128192025Sdds      istate->set_stack(stack->sp() - 1);
129192025Sdds
130192025Sdds      // Restore the stack
131192025Sdds      stack->set_sp(istate->stack_limit() + 1);
132192025Sdds
133192025Sdds      // Resume the interpreter
134192025Sdds      istate->set_msg(BytecodeInterpreter::method_resume);
135192025Sdds    }
136192025Sdds    else if (istate->msg() == BytecodeInterpreter::more_monitors) {
137192025Sdds      int monitor_words = frame::interpreter_frame_monitor_size();
138192025Sdds
139192025Sdds      // Allocate the space
140192025Sdds      stack->overflow_check(monitor_words, THREAD);
141192025Sdds      if (HAS_PENDING_EXCEPTION)
142192025Sdds        break;
143192025Sdds      stack->alloc(monitor_words * wordSize);
144192025Sdds
145192025Sdds      // Move the expression stack contents
146192025Sdds      for (intptr_t *p = istate->stack() + 1; p < istate->stack_base(); p++)
147192025Sdds        *(p - monitor_words) = *p;
148192025Sdds
149192025Sdds      // Move the expression stack pointers
150192025Sdds      istate->set_stack_limit(istate->stack_limit() - monitor_words);
151192025Sdds      istate->set_stack(istate->stack() - monitor_words);
152192025Sdds      istate->set_stack_base(istate->stack_base() - monitor_words);
153192025Sdds
154192025Sdds      // Zero the new monitor so the interpreter can find it.
155192025Sdds      ((BasicObjectLock *) istate->stack_base())->set_obj(NULL);
156192025Sdds
157192025Sdds      // Resume the interpreter
158192025Sdds      istate->set_msg(BytecodeInterpreter::got_monitors);
159192025Sdds    }
160192025Sdds    else if (istate->msg() == BytecodeInterpreter::return_from_method) {
161192025Sdds      // Copy the result into the caller's frame
162192025Sdds      result_slots = type2size[result_type_of(method)];
163192025Sdds      assert(result_slots >= 0 && result_slots <= 2, "what?");
164192025Sdds      result = istate->stack() + result_slots;
165192025Sdds      break;
166192025Sdds    }
167192025Sdds    else if (istate->msg() == BytecodeInterpreter::throwing_exception) {
168192025Sdds      assert(HAS_PENDING_EXCEPTION, "should do");
169192025Sdds      break;
170192025Sdds    }
171192025Sdds    else if (istate->msg() == BytecodeInterpreter::do_osr) {
172192025Sdds      // Unwind the current frame
173192025Sdds      thread->pop_zero_frame();
174192025Sdds
175192025Sdds      // Remove any extension of the previous frame
176192025Sdds      int extra_locals = method->max_locals() - method->size_of_parameters();
177192025Sdds      stack->set_sp(stack->sp() + extra_locals);
178192025Sdds
179192025Sdds      // Jump into the OSR method
180192025Sdds      Interpreter::invoke_osr(
181192025Sdds        method, istate->osr_entry(), istate->osr_buf(), THREAD);
182192025Sdds      return;
183192025Sdds    }
184192025Sdds    else {
185192025Sdds      ShouldNotReachHere();
186192025Sdds    }
187192025Sdds  }
188192025Sdds
189192025Sdds  // Unwind the current frame
190192025Sdds  thread->pop_zero_frame();
191192025Sdds
192192025Sdds  // Pop our local variables
193192025Sdds  stack->set_sp(stack->sp() + method->max_locals());
194192025Sdds
195192025Sdds  // Push our result
196192025Sdds  for (int i = 0; i < result_slots; i++)
197192025Sdds    stack->push(result[-i]);
198192025Sdds}
199192025Sdds
200192025Sddsint CppInterpreter::native_entry(Method* method, intptr_t UNUSED, TRAPS) {
201192025Sdds  // Make sure method is native and not abstract
202192025Sdds  assert(method->is_native() && !method->is_abstract(), "should be");
203192025Sdds
204192025Sdds  JavaThread *thread = (JavaThread *) THREAD;
205192025Sdds  ZeroStack *stack = thread->zero_stack();
206192025Sdds
207192025Sdds  // Allocate and initialize our frame
208192025Sdds  InterpreterFrame *frame = InterpreterFrame::build(method, CHECK_0);
209192025Sdds  thread->push_zero_frame(frame);
210192025Sdds  interpreterState istate = frame->interpreter_state();
211192025Sdds  intptr_t *locals = istate->locals();
212192025Sdds
213192025Sdds  // Update the invocation counter
214192025Sdds  if ((UseCompiler || CountCompiledCalls) && !method->is_synchronized()) {
215192025Sdds    MethodCounters* mcs = method->method_counters();
216192025Sdds    if (mcs == NULL) {
217192025Sdds      CALL_VM_NOCHECK(mcs = InterpreterRuntime::build_method_counters(thread, method));
218192025Sdds      if (HAS_PENDING_EXCEPTION)
219192025Sdds        goto unwind_and_return;
220192025Sdds    }
221192025Sdds    InvocationCounter *counter = mcs->invocation_counter();
222192025Sdds    counter->increment();
223192025Sdds    if (counter->reached_InvocationLimit(mcs->backedge_counter())) {
224192025Sdds      CALL_VM_NOCHECK(
225192025Sdds        InterpreterRuntime::frequency_counter_overflow(thread, NULL));
226192025Sdds      if (HAS_PENDING_EXCEPTION)
227192025Sdds        goto unwind_and_return;
228192025Sdds    }
229192025Sdds  }
230192025Sdds
231192025Sdds  // Lock if necessary
232192025Sdds  BasicObjectLock *monitor;
233192025Sdds  monitor = NULL;
234192025Sdds  if (method->is_synchronized()) {
235192025Sdds    monitor = (BasicObjectLock*) istate->stack_base();
236192025Sdds    oop lockee = monitor->obj();
237192025Sdds    markOop disp = lockee->mark()->set_unlocked();
238192025Sdds
239192025Sdds    monitor->lock()->set_displaced_header(disp);
240192025Sdds    if (Atomic::cmpxchg_ptr(monitor, lockee->mark_addr(), disp) != disp) {
241192025Sdds      if (thread->is_lock_owned((address) disp->clear_lock_bits())) {
242192025Sdds        monitor->lock()->set_displaced_header(NULL);
243192025Sdds      }
244192025Sdds      else {
245200780Sjh        CALL_VM_NOCHECK(InterpreterRuntime::monitorenter(thread, monitor));
246200780Sjh        if (HAS_PENDING_EXCEPTION)
247192025Sdds          goto unwind_and_return;
248192025Sdds      }
249192025Sdds    }
250192025Sdds  }
251192025Sdds
252192025Sdds  // Get the signature handler
253192025Sdds  InterpreterRuntime::SignatureHandler *handler; {
254192025Sdds    address handlerAddr = method->signature_handler();
255192025Sdds    if (handlerAddr == NULL) {
256192025Sdds      CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method));
257192025Sdds      if (HAS_PENDING_EXCEPTION)
258192025Sdds        goto unlock_unwind_and_return;
259192025Sdds
260192025Sdds      handlerAddr = method->signature_handler();
261200902Sed      assert(handlerAddr != NULL, "eh?");
262200902Sed    }
263192025Sdds    if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) {
26431567Ssef      CALL_VM_NOCHECK(handlerAddr =
26531567Ssef        InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL));
266158630Spav      if (HAS_PENDING_EXCEPTION)
267158630Spav        goto unlock_unwind_and_return;
268158630Spav    }
269168569Sdelphij    handler = \
270158630Spav      InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);
271158630Spav  }
272240005Szont
273240005Szont  // Get the native function entry point
274158630Spav  address function;
275158630Spav  function = method->native_function();
276158630Spav  assert(function != NULL, "should be set if signature handler is");
277158630Spav
278201350Sbrooks  // Build the argument list
279158630Spav  stack->overflow_check(handler->argument_count() * 2, THREAD);
280158630Spav  if (HAS_PENDING_EXCEPTION)
281158630Spav    goto unlock_unwind_and_return;
282158630Spav
283158630Spav  void **arguments;
284158630Spav  void *mirror; {
285158630Spav    arguments =
286228396Sed      (void **) stack->alloc(handler->argument_count() * sizeof(void **));
287158630Spav    void **dst = arguments;
288158630Spav
289158630Spav    void *env = thread->jni_environment();
290158630Spav    *(dst++) = &env;
291158630Spav
292158630Spav    if (method->is_static()) {
293158630Spav      istate->set_oop_temp(
294158630Spav        method->constants()->pool_holder()->java_mirror());
295158630Spav      mirror = istate->oop_temp_addr();
296158630Spav      *(dst++) = &mirror;
297158630Spav    }
298158630Spav
299158630Spav    intptr_t *src = locals;
300158630Spav    for (int i = dst - arguments; i < handler->argument_count(); i++) {
301158630Spav      ffi_type *type = handler->argument_type(i);
302158630Spav      if (type == &ffi_type_pointer) {
303158630Spav        if (*src) {
304158630Spav          stack->push((intptr_t) src);
305158630Spav          *(dst++) = stack->sp();
306158630Spav        }
307158630Spav        else {
308158630Spav          *(dst++) = src;
309158630Spav        }
310158630Spav        src--;
311158630Spav      }
312158630Spav      else if (type->size == 4) {
313158630Spav        *(dst++) = src--;
314158630Spav      }
315158630Spav      else if (type->size == 8) {
316158630Spav        src--;
317158630Spav        *(dst++) = src--;
318158630Spav      }
319158630Spav      else {
320158630Spav        ShouldNotReachHere();
321158630Spav      }
322158630Spav    }
323158630Spav  }
324158630Spav
325158630Spav  // Set up the Java frame anchor
326158630Spav  thread->set_last_Java_frame();
327158630Spav
328158630Spav  // Change the thread state to _thread_in_native
329158630Spav  ThreadStateTransition::transition_from_java(thread, _thread_in_native);
330158630Spav
331158630Spav  // Make the call
332158630Spav  intptr_t result[4 - LogBytesPerWord];
333158630Spav  ffi_call(handler->cif(), (void (*)()) function, result, arguments);
334158630Spav
335158630Spav  // Change the thread state back to _thread_in_Java.
336158630Spav  // ThreadStateTransition::transition_from_native() cannot be used
337158630Spav  // here because it does not check for asynchronous exceptions.
338158630Spav  // We have to manage the transition ourself.
339158630Spav  thread->set_thread_state(_thread_in_native_trans);
340158630Spav
341158630Spav  // Make sure new state is visible in the GC thread
342158630Spav  if (os::is_MP()) {
343158630Spav    if (UseMembar) {
344158630Spav      OrderAccess::fence();
345158630Spav    }
346158630Spav    else {
347158630Spav      InterfaceSupport::serialize_memory(thread);
348158630Spav    }
349158630Spav  }
350158630Spav
351158630Spav  // Handle safepoint operations, pending suspend requests,
352158630Spav  // and pending asynchronous exceptions.
353158630Spav  if (SafepointSynchronize::do_call_back() ||
354158630Spav      thread->has_special_condition_for_native_trans()) {
355158630Spav    JavaThread::check_special_condition_for_native_trans(thread);
356158630Spav    CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops());
357158630Spav  }
358158630Spav
359158630Spav  // Finally we can change the thread state to _thread_in_Java.
360158630Spav  thread->set_thread_state(_thread_in_Java);
361158630Spav  fixup_after_potential_safepoint();
362158630Spav
363158630Spav  // Clear the frame anchor
364158630Spav  thread->reset_last_Java_frame();
365158630Spav
366158630Spav  // If the result was an oop then unbox it and store it in
367158630Spav  // oop_temp where the garbage collector can see it before
368158630Spav  // we release the handle it might be protected by.
369158630Spav  if (handler->result_type() == &ffi_type_pointer) {
370158630Spav    if (result[0])
371158630Spav      istate->set_oop_temp(*(oop *) result[0]);
372158630Spav    else
373158630Spav      istate->set_oop_temp(NULL);
374158630Spav  }
375181061Sdes
376181061Sdes  // Reset handle block
377181061Sdes  thread->active_handles()->clear();
378181061Sdes
379181061Sdes unlock_unwind_and_return:
380181061Sdes
381158630Spav  // Unlock if necessary
382158630Spav  if (monitor) {
383181061Sdes    BasicLock *lock = monitor->lock();
384158630Spav    markOop header = lock->displaced_header();
385158630Spav    oop rcvr = monitor->obj();
386181061Sdes    monitor->set_obj(NULL);
387158630Spav
388158630Spav    if (header != NULL) {
389158630Spav      if (Atomic::cmpxchg_ptr(header, rcvr->mark_addr(), lock) != lock) {
390158630Spav        monitor->set_obj(rcvr); {
391158630Spav          HandleMark hm(thread);
392158630Spav          CALL_VM_NOCHECK(InterpreterRuntime::monitorexit(thread, monitor));
393158630Spav        }
394158630Spav      }
395158630Spav    }
396158630Spav  }
397158630Spav
398158630Spav unwind_and_return:
399158630Spav
400158630Spav  // Unwind the current activation
401181061Sdes  thread->pop_zero_frame();
402158630Spav
403158630Spav  // Pop our parameters
404168569Sdelphij  stack->set_sp(stack->sp() + method->size_of_parameters());
405168569Sdelphij
406158630Spav  // Push our result
407181061Sdes  if (!HAS_PENDING_EXCEPTION) {
408181061Sdes    BasicType type = result_type_of(method);
409158630Spav    stack->set_sp(stack->sp() - type2size[type]);
410158630Spav
411158630Spav    switch (type) {
412158630Spav    case T_VOID:
413158630Spav      break;
414181061Sdes
415181061Sdes    case T_BOOLEAN:
416158630Spav#ifndef VM_LITTLE_ENDIAN
417240005Szont      result[0] <<= (BitsPerWord - BitsPerByte);
418158630Spav#endif
419158630Spav      SET_LOCALS_INT(*(jboolean *) result != 0, 0);
420240005Szont      break;
421240005Szont
422181061Sdes    case T_CHAR:
423181061Sdes#ifndef VM_LITTLE_ENDIAN
424158630Spav      result[0] <<= (BitsPerWord - BitsPerShort);
425158630Spav#endif
426158630Spav      SET_LOCALS_INT(*(jchar *) result, 0);
427158630Spav      break;
428158630Spav
429158630Spav    case T_BYTE:
430158630Spav#ifndef VM_LITTLE_ENDIAN
431158630Spav      result[0] <<= (BitsPerWord - BitsPerByte);
432158630Spav#endif
433158630Spav      SET_LOCALS_INT(*(jbyte *) result, 0);
434158630Spav      break;
435158630Spav
436158630Spav    case T_SHORT:
437158630Spav#ifndef VM_LITTLE_ENDIAN
438181061Sdes      result[0] <<= (BitsPerWord - BitsPerShort);
439158630Spav#endif
440158630Spav      SET_LOCALS_INT(*(jshort *) result, 0);
44131567Ssef      break;
44231567Ssef
44331567Ssef    case T_INT:
44431567Ssef#ifndef VM_LITTLE_ENDIAN
44531567Ssef      result[0] <<= (BitsPerWord - BitsPerInt);
44631567Ssef#endif
447181061Sdes      SET_LOCALS_INT(*(jint *) result, 0);
448181061Sdes      break;
449240005Szont
45031567Ssef    case T_LONG:
451240005Szont      SET_LOCALS_LONG(*(jlong *) result, 0);
452133349Salfred      break;
453133349Salfred
45431567Ssef    case T_FLOAT:
455240005Szont      SET_LOCALS_FLOAT(*(jfloat *) result, 0);
456181061Sdes      break;
45731567Ssef
45831567Ssef    case T_DOUBLE:
459181061Sdes      SET_LOCALS_DOUBLE(*(jdouble *) result, 0);
46031567Ssef      break;
46131567Ssef
46231567Ssef    case T_OBJECT:
46385292Sdes    case T_ARRAY:
46485292Sdes      SET_LOCALS_OBJECT(istate->oop_temp(), 0);
46585292Sdes      break;
46685292Sdes
46785292Sdes    default:
46887703Smarkm      ShouldNotReachHere();
469239501Szont    }
470181061Sdes  }
471168569Sdelphij
472181061Sdes  // No deoptimized frames on the stack
473168569Sdelphij  return 0;
474168569Sdelphij}
475168569Sdelphij
476168569Sdelphijint CppInterpreter::accessor_entry(Method* method, intptr_t UNUSED, TRAPS) {
477168569Sdelphij  JavaThread *thread = (JavaThread *) THREAD;
478181061Sdes  ZeroStack *stack = thread->zero_stack();
479181061Sdes  intptr_t *locals = stack->sp();
48085292Sdes
48185292Sdes  // Drop into the slow path if we need a safepoint check
482240005Szont  if (SafepointSynchronize::do_call_back()) {
483240005Szont    return normal_entry(method, 0, THREAD);
48485292Sdes  }
48531567Ssef
48631567Ssef  // Load the object pointer and drop into the slow path
48731567Ssef  // if we have a NullPointerException
48831567Ssef  oop object = LOCALS_OBJECT(0);
48931567Ssef  if (object == NULL) {
49031567Ssef    return normal_entry(method, 0, THREAD);
491168569Sdelphij  }
492181061Sdes
493181061Sdes  // Read the field index from the bytecode, which looks like this:
494240005Szont  //  0:  aload_0
49532275Scharnier  //  1:  getfield
496240005Szont  //  2:    index
497181061Sdes  //  3:    index
498240005Szont  //  4:  ireturn/areturn
499181061Sdes  // NB this is not raw bytecode: index is in machine order
500168569Sdelphij  u1 *code = method->code_base();
501168569Sdelphij  assert(code[0] == Bytecodes::_aload_0 &&
502181061Sdes         code[1] == Bytecodes::_getfield &&
503181061Sdes         (code[4] == Bytecodes::_ireturn ||
504168569Sdelphij          code[4] == Bytecodes::_areturn), "should do");
505168569Sdelphij  u2 index = Bytes::get_native_u2(&code[2]);
506168569Sdelphij
507168569Sdelphij  // Get the entry from the constant pool cache, and drop into
508168569Sdelphij  // the slow path if it has not been resolved
509168569Sdelphij  ConstantPoolCache* cache = method->constants()->cache();
510168569Sdelphij  ConstantPoolCacheEntry* entry = cache->entry_at(index);
511181061Sdes  if (!entry->is_resolved(Bytecodes::_getfield)) {
51231567Ssef    return normal_entry(method, 0, THREAD);
513168569Sdelphij  }
514168569Sdelphij
515168569Sdelphij  // Get the result and push it onto the stack
516168569Sdelphij  switch (entry->flag_state()) {
517168569Sdelphij  case ltos:
518168569Sdelphij  case dtos:
519168569Sdelphij    stack->overflow_check(1, CHECK_0);
520168569Sdelphij    stack->alloc(wordSize);
521181061Sdes    break;
522216224Sjh  }
523181061Sdes  if (entry->is_volatile()) {
524168569Sdelphij    switch (entry->flag_state()) {
52531567Ssef    case ctos:
52631567Ssef      SET_LOCALS_INT(object->char_field_acquire(entry->f2_as_index()), 0);
52731567Ssef      break;
52831567Ssef
52931567Ssef    case btos:
53031567Ssef      SET_LOCALS_INT(object->byte_field_acquire(entry->f2_as_index()), 0);
53131567Ssef      break;
53231567Ssef
53331567Ssef    case stos:
53431567Ssef      SET_LOCALS_INT(object->short_field_acquire(entry->f2_as_index()), 0);
53531567Ssef      break;
53631567Ssef
53731567Ssef    case itos:
53831567Ssef      SET_LOCALS_INT(object->int_field_acquire(entry->f2_as_index()), 0);
53931567Ssef      break;
540240005Szont
541240005Szont    case ltos:
542181061Sdes      SET_LOCALS_LONG(object->long_field_acquire(entry->f2_as_index()), 0);
543240005Szont      break;
544240005Szont
545158630Spav    case ftos:
546240005Szont      SET_LOCALS_FLOAT(object->float_field_acquire(entry->f2_as_index()), 0);
547240005Szont      break;
548181061Sdes
549181061Sdes    case dtos:
550181061Sdes      SET_LOCALS_DOUBLE(object->double_field_acquire(entry->f2_as_index()), 0);
551181061Sdes      break;
552181061Sdes
553181061Sdes    case atos:
554181061Sdes      SET_LOCALS_OBJECT(object->obj_field_acquire(entry->f2_as_index()), 0);
555181061Sdes      break;
556181061Sdes
557181061Sdes    default:
558181061Sdes      ShouldNotReachHere();
559181061Sdes    }
560181061Sdes  }
561181061Sdes  else {
562181061Sdes    switch (entry->flag_state()) {
563181061Sdes    case ctos:
564181061Sdes      SET_LOCALS_INT(object->char_field(entry->f2_as_index()), 0);
565181061Sdes      break;
566181061Sdes
567181061Sdes    case btos:
568181061Sdes      SET_LOCALS_INT(object->byte_field(entry->f2_as_index()), 0);
569181061Sdes      break;
570181061Sdes
571181061Sdes    case stos:
572181061Sdes      SET_LOCALS_INT(object->short_field(entry->f2_as_index()), 0);
573181061Sdes      break;
574181061Sdes
575158630Spav    case itos:
576181061Sdes      SET_LOCALS_INT(object->int_field(entry->f2_as_index()), 0);
577181061Sdes      break;
578181061Sdes
579181061Sdes    case ltos:
580101289Smdodd      SET_LOCALS_LONG(object->long_field(entry->f2_as_index()), 0);
581181061Sdes      break;
582181061Sdes
583181061Sdes    case ftos:
584181061Sdes      SET_LOCALS_FLOAT(object->float_field(entry->f2_as_index()), 0);
585181061Sdes      break;
586181061Sdes
587181061Sdes    case dtos:
588240005Szont      SET_LOCALS_DOUBLE(object->double_field(entry->f2_as_index()), 0);
589240005Szont      break;
590181061Sdes
591181061Sdes    case atos:
592240005Szont      SET_LOCALS_OBJECT(object->obj_field(entry->f2_as_index()), 0);
593240005Szont      break;
594181061Sdes
595181061Sdes    default:
596181061Sdes      ShouldNotReachHere();
597181061Sdes    }
598240005Szont  }
599240005Szont
600181061Sdes  // No deoptimized frames on the stack
601181061Sdes  return 0;
602181061Sdes}
603181061Sdes
604181061Sdesint CppInterpreter::empty_entry(Method* method, intptr_t UNUSED, TRAPS) {
605181061Sdes  JavaThread *thread = (JavaThread *) THREAD;
606181061Sdes  ZeroStack *stack = thread->zero_stack();
607181061Sdes
608181061Sdes  // Drop into the slow path if we need a safepoint check
609181061Sdes  if (SafepointSynchronize::do_call_back()) {
610181061Sdes    return normal_entry(method, 0, THREAD);
611101289Smdodd  }
612240005Szont
613240005Szont  // Pop our parameters
614181061Sdes  stack->set_sp(stack->sp() + method->size_of_parameters());
615181061Sdes
616181061Sdes  // No deoptimized frames on the stack
617101289Smdodd  return 0;
618181061Sdes}
619181061Sdes
620181061Sdes// The new slots will be inserted before slot insert_before.
621181061Sdes// Slots < insert_before will have the same slot number after the insert.
622181061Sdes// Slots >= insert_before will become old_slot + num_slots.
623181061Sdesvoid CppInterpreter::insert_vmslots(int insert_before, int num_slots, TRAPS) {
624181061Sdes  JavaThread *thread = (JavaThread *) THREAD;
625181061Sdes  ZeroStack *stack = thread->zero_stack();
626181061Sdes
627181061Sdes  // Allocate the space
628181061Sdes  stack->overflow_check(num_slots, CHECK);
629181061Sdes  stack->alloc(num_slots * wordSize);
630181061Sdes  intptr_t *vmslots = stack->sp();
631181061Sdes
632240005Szont  // Shuffle everything up
633240005Szont  for (int i = 0; i < insert_before; i++)
634181061Sdes    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i + num_slots), i);
635181061Sdes}
636181061Sdes
637181061Sdesvoid CppInterpreter::remove_vmslots(int first_slot, int num_slots, TRAPS) {
638181061Sdes  JavaThread *thread = (JavaThread *) THREAD;
639134799Smarcel  ZeroStack *stack = thread->zero_stack();
640181061Sdes  intptr_t *vmslots = stack->sp();
641181061Sdes
642181061Sdes  // Move everything down
643134799Smarcel  for (int i = first_slot - 1; i >= 0; i--)
644181061Sdes    SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i), i + num_slots);
645181061Sdes
646181061Sdes  // Deallocate the space
647181061Sdes  stack->set_sp(stack->sp() + num_slots);
648181061Sdes}
649181061Sdes
650134799SmarcelBasicType CppInterpreter::result_type_of_handle(oop method_handle) {
651181061Sdes  oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
652181061Sdes  oop return_type = java_lang_invoke_MethodType::rtype(method_type);
653181061Sdes  return java_lang_Class::as_BasicType(return_type, (Klass* *) NULL);
654181061Sdes}
655181061Sdes
656181061Sdesintptr_t* CppInterpreter::calculate_unwind_sp(ZeroStack* stack,
657181061Sdes                                              oop method_handle) {
658181061Sdes  oop method_type = java_lang_invoke_MethodHandle::type(method_handle);
659181061Sdes  int argument_slots = java_lang_invoke_MethodType::ptype_slot_count(method_type);
660181061Sdes
661181061Sdes  return stack->sp() + argument_slots;
662181061Sdes}
663181061Sdes
664181061SdesIRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
665181061Sdes                                                Symbol*     name,
666181061Sdes                                                char*       message))
667240005Szont  THROW_MSG(name, message);
668181061SdesIRT_END
669240005Szont
670181061SdesInterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) {
671240005Szont  JavaThread *thread = (JavaThread *) THREAD;
672240005Szont  ZeroStack *stack = thread->zero_stack();
673240005Szont
674240005Szont  // Calculate the size of the frame we'll build, including
675181061Sdes  // any adjustments to the caller's frame that we'll make.
676181061Sdes  int extra_locals  = 0;
677181061Sdes  int monitor_words = 0;
678181061Sdes  int stack_words   = 0;
679181061Sdes
680181061Sdes  if (!method->is_native()) {
681240005Szont    extra_locals = method->max_locals() - method->size_of_parameters();
682240005Szont    stack_words  = method->max_stack();
683181061Sdes  }
684181061Sdes  if (method->is_synchronized()) {
685181061Sdes    monitor_words = frame::interpreter_frame_monitor_size();
686181061Sdes  }
687181061Sdes  stack->overflow_check(
688181061Sdes    extra_locals + header_words + monitor_words + stack_words, CHECK_NULL);
689181061Sdes
690240005Szont  // Adjust the caller's stack frame to accomodate any additional
691240005Szont  // local variables we have contiguously with our parameters.
692240005Szont  for (int i = 0; i < extra_locals; i++)
693240005Szont    stack->push(0);
694181061Sdes
695181061Sdes  intptr_t *locals;
696181061Sdes  if (method->is_native())
697181061Sdes    locals = stack->sp() + (method->size_of_parameters() - 1);
698181061Sdes  else
699181061Sdes    locals = stack->sp() + (method->max_locals() - 1);
700240005Szont
701240005Szont  stack->push(0); // next_frame, filled in later
702240005Szont  intptr_t *fp = stack->sp();
703240005Szont  assert(fp - stack->sp() == next_frame_off, "should be");
704181061Sdes
705181061Sdes  stack->push(INTERPRETER_FRAME);
706181061Sdes  assert(fp - stack->sp() == frame_type_off, "should be");
707181061Sdes
708181061Sdes  interpreterState istate =
709181061Sdes    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
710240005Szont  assert(fp - stack->sp() == istate_off, "should be");
711240005Szont
712181061Sdes  istate->set_locals(locals);
713181061Sdes  istate->set_method(method);
714181061Sdes  istate->set_self_link(istate);
715181061Sdes  istate->set_prev_link(NULL);
716181061Sdes  istate->set_thread(thread);
717181061Sdes  istate->set_bcp(method->is_native() ? NULL : method->code_base());
718181061Sdes  istate->set_constants(method->constants()->cache());
719181061Sdes  istate->set_msg(BytecodeInterpreter::method_entry);
720181061Sdes  istate->set_oop_temp(NULL);
721240005Szont  istate->set_mdx(NULL);
722240005Szont  istate->set_callee(NULL);
723181061Sdes
724181061Sdes  istate->set_monitor_base((BasicObjectLock *) stack->sp());
725181061Sdes  if (method->is_synchronized()) {
726181061Sdes    BasicObjectLock *monitor =
727181061Sdes      (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
728181061Sdes    oop object;
729181061Sdes    if (method->is_static())
730181061Sdes      object = method->constants()->pool_holder()->java_mirror();
731181061Sdes    else
732181061Sdes      object = (oop) locals[0];
733181061Sdes    monitor->set_obj(object);
734240005Szont  }
735240005Szont
736240005Szont  istate->set_stack_base(stack->sp());
737181061Sdes  istate->set_stack(stack->sp() - 1);
738181061Sdes  if (stack_words)
739181061Sdes    stack->alloc(stack_words * wordSize);
740181061Sdes  istate->set_stack_limit(stack->sp() - 1);
741181061Sdes
742181061Sdes  return (InterpreterFrame *) fp;
743127332Sdwmalone}
744181061Sdes
745240005Szontint AbstractInterpreter::BasicType_as_index(BasicType type) {
746240005Szont  int i = 0;
747240005Szont  switch (type) {
748240005Szont    case T_BOOLEAN: i = 0; break;
749181061Sdes    case T_CHAR   : i = 1; break;
750181061Sdes    case T_BYTE   : i = 2; break;
751181061Sdes    case T_SHORT  : i = 3; break;
752240005Szont    case T_INT    : i = 4; break;
753240005Szont    case T_LONG   : i = 5; break;
754127332Sdwmalone    case T_VOID   : i = 6; break;
755181061Sdes    case T_FLOAT  : i = 7; break;
756181061Sdes    case T_DOUBLE : i = 8; break;
757127332Sdwmalone    case T_OBJECT : i = 9; break;
758240005Szont    case T_ARRAY  : i = 9; break;
759240005Szont    default       : ShouldNotReachHere();
760240005Szont  }
761181061Sdes  assert(0 <= i && i < AbstractInterpreter::number_of_result_handlers,
762181061Sdes         "index out of bounds");
763181061Sdes  return i;
764181061Sdes}
765181061Sdes
766181061SdesBasicType CppInterpreter::result_type_of(Method* method) {
767181061Sdes  BasicType t;
768181061Sdes  switch (method->result_index()) {
769181061Sdes    case 0 : t = T_BOOLEAN; break;
770181061Sdes    case 1 : t = T_CHAR;    break;
771127332Sdwmalone    case 2 : t = T_BYTE;    break;
772181061Sdes    case 3 : t = T_SHORT;   break;
773181061Sdes    case 4 : t = T_INT;     break;
774240005Szont    case 5 : t = T_LONG;    break;
775240005Szont    case 6 : t = T_VOID;    break;
776240005Szont    case 7 : t = T_FLOAT;   break;
777181061Sdes    case 8 : t = T_DOUBLE;  break;
778181061Sdes    case 9 : t = T_OBJECT;  break;
779181061Sdes    default: ShouldNotReachHere();
780181061Sdes  }
781181061Sdes  assert(AbstractInterpreter::BasicType_as_index(t) == method->result_index(),
782181061Sdes         "out of step with AbstractInterpreter::BasicType_as_index");
783127332Sdwmalone  return t;
784181061Sdes}
785240005Szont
786240005Szontaddress InterpreterGenerator::generate_empty_entry() {
787240005Szont  if (!UseFastEmptyMethods)
788240005Szont    return NULL;
789181061Sdes
790181061Sdes  return generate_entry((address) CppInterpreter::empty_entry);
791181061Sdes}
792240005Szont
793240005Szontaddress InterpreterGenerator::generate_accessor_entry() {
794127332Sdwmalone  if (!UseFastAccessorMethods)
795181061Sdes    return NULL;
796181061Sdes
797181061Sdes  return generate_entry((address) CppInterpreter::accessor_entry);
798240005Szont}
799240005Szont
800181061Sdesaddress InterpreterGenerator::generate_Reference_get_entry(void) {
801181061Sdes#if INCLUDE_ALL_GCS
802181061Sdes  if (UseG1GC) {
803181061Sdes    // We need to generate have a routine that generates code to:
804181061Sdes    //   * load the value in the referent field
805181061Sdes    //   * passes that value to the pre-barrier.
806181061Sdes    //
807181061Sdes    // In the case of G1 this will record the value of the
808240005Szont    // referent in an SATB buffer if marking is active.
809181061Sdes    // This will cause concurrent marking to mark the referent
810181061Sdes    // field as live.
811181061Sdes    Unimplemented();
812127332Sdwmalone  }
813181061Sdes#endif // INCLUDE_ALL_GCS
814181061Sdes
81549609Sdes  // If G1 is not enabled then attempt to go through the accessor entry point
816181061Sdes  // Reference.get is an accessor
817181061Sdes  return generate_accessor_entry();
818181061Sdes}
819181061Sdes
820181061Sdesaddress InterpreterGenerator::generate_native_entry(bool synchronized) {
821181061Sdes  assert(synchronized == false, "should be");
822181061Sdes
823181061Sdes  return generate_entry((address) CppInterpreter::native_entry);
824181061Sdes}
825181061Sdes
826158630Spavaddress InterpreterGenerator::generate_normal_entry(bool synchronized) {
827181061Sdes  assert(synchronized == false, "should be");
828240005Szont
829240005Szont  return generate_entry((address) CppInterpreter::normal_entry);
830181061Sdes}
831181061Sdes
832181061Sdesaddress AbstractInterpreterGenerator::generate_method_entry(
833181061Sdes    AbstractInterpreter::MethodKind kind) {
834181061Sdes  address entry_point = NULL;
835181061Sdes
836240005Szont  switch (kind) {
837181061Sdes  case Interpreter::zerolocals:
838181061Sdes  case Interpreter::zerolocals_synchronized:
839181061Sdes    break;
840181061Sdes
841181061Sdes  case Interpreter::native:
842181061Sdes    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
843181061Sdes    break;
844181061Sdes
845181061Sdes  case Interpreter::native_synchronized:
846181061Sdes    entry_point = ((InterpreterGenerator*) this)->generate_native_entry(false);
847240005Szont    break;
848181061Sdes
849181061Sdes  case Interpreter::empty:
850181061Sdes    entry_point = ((InterpreterGenerator*) this)->generate_empty_entry();
851127328Salfred    break;
852181061Sdes
853181061Sdes  case Interpreter::accessor:
854181061Sdes    entry_point = ((InterpreterGenerator*) this)->generate_accessor_entry();
855181061Sdes    break;
856127328Salfred
857181061Sdes  case Interpreter::abstract:
858181061Sdes    entry_point = ((InterpreterGenerator*) this)->generate_abstract_entry();
859181061Sdes    break;
860181061Sdes
861240005Szont  case Interpreter::java_lang_math_sin:
862240005Szont  case Interpreter::java_lang_math_cos:
863181061Sdes  case Interpreter::java_lang_math_tan:
864181061Sdes  case Interpreter::java_lang_math_abs:
865240005Szont  case Interpreter::java_lang_math_log:
866240005Szont  case Interpreter::java_lang_math_log10:
867181061Sdes  case Interpreter::java_lang_math_sqrt:
868181061Sdes  case Interpreter::java_lang_math_pow:
869181061Sdes  case Interpreter::java_lang_math_exp:
870181061Sdes    entry_point = ((InterpreterGenerator*) this)->generate_math_entry(kind);
871181061Sdes    break;
872181061Sdes
873181061Sdes  case Interpreter::java_lang_ref_reference_get:
874181061Sdes    entry_point = ((InterpreterGenerator*)this)->generate_Reference_get_entry();
875181061Sdes    break;
876181061Sdes
877181061Sdes  default:
878181061Sdes    ShouldNotReachHere();
879181061Sdes  }
880181061Sdes
881181061Sdes  if (entry_point == NULL)
882181061Sdes    entry_point = ((InterpreterGenerator*) this)->generate_normal_entry(false);
883181061Sdes
884181061Sdes  return entry_point;
885181061Sdes}
886181061Sdes
887181061SdesInterpreterGenerator::InterpreterGenerator(StubQueue* code)
888181061Sdes : CppInterpreterGenerator(code) {
889181061Sdes   generate_all();
890181061Sdes}
891181061Sdes
892181061Sdes// Deoptimization helpers
893181061Sdes
894181061SdesInterpreterFrame *InterpreterFrame::build(int size, TRAPS) {
895181061Sdes  ZeroStack *stack = ((JavaThread *) THREAD)->zero_stack();
896181061Sdes
897181061Sdes  int size_in_words = size >> LogBytesPerWord;
898181061Sdes  assert(size_in_words * wordSize == size, "unaligned");
899181061Sdes  assert(size_in_words >= header_words, "too small");
900181061Sdes  stack->overflow_check(size_in_words, CHECK_NULL);
901181061Sdes
902181061Sdes  stack->push(0); // next_frame, filled in later
903181061Sdes  intptr_t *fp = stack->sp();
904181061Sdes  assert(fp - stack->sp() == next_frame_off, "should be");
905181061Sdes
906181061Sdes  stack->push(INTERPRETER_FRAME);
907181061Sdes  assert(fp - stack->sp() == frame_type_off, "should be");
908181061Sdes
909181061Sdes  interpreterState istate =
910181061Sdes    (interpreterState) stack->alloc(sizeof(BytecodeInterpreter));
911181061Sdes  assert(fp - stack->sp() == istate_off, "should be");
912181061Sdes  istate->set_self_link(NULL); // mark invalid
913181061Sdes
914181061Sdes  stack->alloc((size_in_words - header_words) * wordSize);
915181061Sdes
916181061Sdes  return (InterpreterFrame *) fp;
917181061Sdes}
918181061Sdes
91985292Sdesint AbstractInterpreter::layout_activation(Method* method,
920181061Sdes                                           int       tempcount,
921181061Sdes                                           int       popframe_extra_args,
922181061Sdes                                           int       moncount,
923181061Sdes                                           int       caller_actual_parameters,
924121606Smarcel                                           int       callee_param_count,
925181061Sdes                                           int       callee_locals,
926181061Sdes                                           frame*    caller,
927240005Szont                                           frame*    interpreter_frame,
928181061Sdes                                           bool      is_top_frame,
929181061Sdes                                           bool      is_bottom_frame) {
930181061Sdes  assert(popframe_extra_args == 0, "what to do?");
931181061Sdes  assert(!is_top_frame || (!callee_locals && !callee_param_count),
932181061Sdes         "top frame should have no caller");
933181061Sdes
934181061Sdes  // This code must exactly match what InterpreterFrame::build
935181061Sdes  // does (the full InterpreterFrame::build, that is, not the
936181061Sdes  // one that creates empty frames for the deoptimizer).
937181061Sdes  //
938181061Sdes  // If interpreter_frame is not NULL then it will be filled in.
939181061Sdes  // It's size is determined by a previous call to this method,
940181061Sdes  // so it should be correct.
941181061Sdes  //
942181061Sdes  // Note that tempcount is the current size of the expression
943181061Sdes  // stack.  For top most frames we will allocate a full sized
944181061Sdes  // expression stack and not the trimmed version that non-top
945181061Sdes  // frames have.
946181061Sdes
947240005Szont  int header_words        = InterpreterFrame::header_words;
948240005Szont  int monitor_words       = moncount * frame::interpreter_frame_monitor_size();
949181061Sdes  int stack_words         = is_top_frame ? method->max_stack() : tempcount;
950181061Sdes  int callee_extra_locals = callee_locals - callee_param_count;
95185292Sdes
952181061Sdes  if (interpreter_frame) {
953181061Sdes    intptr_t *locals        = interpreter_frame->fp() + method->max_locals();
954181061Sdes    interpreterState istate = interpreter_frame->get_interpreterState();
955181061Sdes    intptr_t *monitor_base  = (intptr_t*) istate;
956240005Szont    intptr_t *stack_base    = monitor_base - monitor_words;
957240005Szont    intptr_t *stack         = stack_base - tempcount - 1;
958181061Sdes
959181061Sdes    BytecodeInterpreter::layout_interpreterState(istate,
960181061Sdes                                                 caller,
961240005Szont                                                 NULL,
962240005Szont                                                 method,
963240005Szont                                                 locals,
964240005Szont                                                 stack,
965181061Sdes                                                 stack_base,
966181061Sdes                                                 monitor_base,
967181061Sdes                                                 NULL,
968181061Sdes                                                 is_top_frame);
969181061Sdes  }
970181061Sdes  return header_words + monitor_words + stack_words + callee_extra_locals;
971181061Sdes}
972240005Szont
973240005Szontvoid BytecodeInterpreter::layout_interpreterState(interpreterState istate,
974240005Szont                                                  frame*    caller,
975240005Szont                                                  frame*    current,
976181061Sdes                                                  Method* method,
977181061Sdes                                                  intptr_t* locals,
978240005Szont                                                  intptr_t* stack,
979240005Szont                                                  intptr_t* stack_base,
980181061Sdes                                                  intptr_t* monitor_base,
981181061Sdes                                                  intptr_t* frame_bottom,
982181061Sdes                                                  bool      is_top_frame) {
983181061Sdes  istate->set_locals(locals);
98486138Sgreen  istate->set_method(method);
985181061Sdes  istate->set_self_link(istate);
986181061Sdes  istate->set_prev_link(NULL);
987181061Sdes  // thread will be set by a hacky repurposing of frame::patch_pc()
988181061Sdes  // bcp will be set by vframeArrayElement::unpack_on_stack()
989127332Sdwmalone  istate->set_constants(method->constants()->cache());
990240005Szont  istate->set_msg(BytecodeInterpreter::method_resume);
991240005Szont  istate->set_bcp_advance(0);
992181061Sdes  istate->set_oop_temp(NULL);
993181061Sdes  istate->set_mdx(NULL);
994181061Sdes  if (caller->is_interpreted_frame()) {
995181061Sdes    interpreterState prev = caller->get_interpreterState();
996181061Sdes    prev->set_callee(method);
997181061Sdes    if (*prev->bcp() == Bytecodes::_invokeinterface)
998181061Sdes      prev->set_bcp_advance(5);
999158630Spav    else
1000240005Szont      prev->set_bcp_advance(3);
1001181061Sdes  }
1002181061Sdes  istate->set_callee(NULL);
1003240005Szont  istate->set_monitor_base((BasicObjectLock *) monitor_base);
1004181061Sdes  istate->set_stack_base(stack_base);
1005181061Sdes  istate->set_stack(stack);
1006181061Sdes  istate->set_stack_limit(stack_base - method->max_stack() - 1);
1007181061Sdes}
1008181061Sdes
1009181061Sdesaddress CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
1010181061Sdes  ShouldNotCallThis();
1011181061Sdes  return NULL;
1012181061Sdes}
1013181061Sdes
1014181061Sdesaddress CppInterpreter::deopt_entry(TosState state, int length) {
1015181061Sdes  return NULL;
1016181061Sdes}
1017181061Sdes
1018181061Sdes// Helper for (runtime) stack overflow checks
1019181061Sdes
1020158630Spavint AbstractInterpreter::size_top_interpreter_activation(Method* method) {
1021181061Sdes  return 0;
1022181061Sdes}
1023181061Sdes
1024181061Sdes// Helper for figuring out if frames are interpreter frames
1025158630Spav
1026181061Sdesbool CppInterpreter::contains(address pc) {
1027181061Sdes  return false; // make frame::print_value_on work
1028181061Sdes}
1029240005Szont
1030240005Szont// Result handlers and convertors
1031240005Szont
1032240005Szontaddress CppInterpreterGenerator::generate_result_handler_for(
1033181061Sdes    BasicType type) {
1034181061Sdes  assembler()->advance(1);
1035181061Sdes  return ShouldNotCallThisStub();
1036240005Szont}
1037240005Szont
1038158630Spavaddress CppInterpreterGenerator::generate_tosca_to_stack_converter(
1039181061Sdes    BasicType type) {
1040181061Sdes  assembler()->advance(1);
1041181061Sdes  return ShouldNotCallThisStub();
1042181061Sdes}
1043181061Sdes
1044181061Sdesaddress CppInterpreterGenerator::generate_stack_to_stack_converter(
1045181061Sdes    BasicType type) {
1046181061Sdes  assembler()->advance(1);
1047181061Sdes  return ShouldNotCallThisStub();
1048181061Sdes}
1049181061Sdes
1050181061Sdesaddress CppInterpreterGenerator::generate_stack_to_native_abi_converter(
1051181061Sdes    BasicType type) {
1052181061Sdes  assembler()->advance(1);
1053181061Sdes  return ShouldNotCallThisStub();
1054181061Sdes}
1055181061Sdes
1056181061Sdes#endif // CC_INTERP
1057181061Sdes