1/*
2 * Copyright (c) 1997, 2016, 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#include "precompiled.hpp"
26#include "interpreter/bytecodeInterpreter.hpp"
27#include "interpreter/cppInterpreterGenerator.hpp"
28#include "interpreter/interpreter.hpp"
29#include "interpreter/interpreterRuntime.hpp"
30#include "memory/resourceArea.hpp"
31#include "runtime/timerTrace.hpp"
32
33#ifdef CC_INTERP
34
35#ifdef ZERO
36# include "entry_zero.hpp"
37#else
38#error "Only Zero CppInterpreter is supported"
39#endif
40
41void CppInterpreter::initialize() {
42 if (_code != NULL) return;
43 AbstractInterpreter::initialize();
44
45 // generate interpreter
46 { ResourceMark rm;
47 TraceTime timer("Interpreter generation", TRACETIME_LOG(Info, startuptime));
48 int code_size = InterpreterCodeSize;
49 NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
50 _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
51 "Interpreter");
52 CppInterpreterGenerator g(_code);
53 if (PrintInterpreter) print();
54 }
55
56 // Allow c++ interpreter to do one initialization now that switches are set, etc.
57 BytecodeInterpreter start_msg(BytecodeInterpreter::initialize);
58 if (JvmtiExport::can_post_interpreter_events())
59 BytecodeInterpreter::runWithChecks(&start_msg);
60 else
61 BytecodeInterpreter::run(&start_msg);
62}
63
64
65void CppInterpreter::invoke_method(Method* method, address entry_point, TRAPS) {
66 ((ZeroEntry *) entry_point)->invoke(method, THREAD);
67}
68
69void CppInterpreter::invoke_osr(Method* method,
70 address entry_point,
71 address osr_buf,
72 TRAPS) {
73 ((ZeroEntry *) entry_point)->invoke_osr(method, osr_buf, THREAD);
74}
75
76
77
78InterpreterCodelet* CppInterpreter::codelet_containing(address pc) {
79 // FIXME: I'm pretty sure _code is null and this is never called, which is why it's copied.
80 return (InterpreterCodelet*)_code->stub_containing(pc);
81}
82
83#endif // CC_INTERP
84