0N/A/*
1499N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_INTERPRETER_REWRITER_HPP
1879N/A#define SHARE_VM_INTERPRETER_REWRITER_HPP
1879N/A
1879N/A#include "memory/allocation.hpp"
1879N/A#include "runtime/handles.inline.hpp"
1879N/A#include "utilities/growableArray.hpp"
1879N/A
0N/A// The Rewriter adds caches to the constant pool and rewrites bytecode indices
0N/A// pointing into the constant pool for better interpreter performance.
0N/A
726N/Aclass Rewriter: public StackObj {
0N/A private:
726N/A instanceKlassHandle _klass;
726N/A constantPoolHandle _pool;
726N/A objArrayHandle _methods;
726N/A intArray _cp_map;
726N/A intStack _cp_cache_map;
3932N/A intArray _method_handle_invokers;
726N/A
726N/A void init_cp_map(int length) {
726N/A _cp_map.initialize(length, -1);
726N/A // Choose an initial value large enough that we don't get frequent
726N/A // calls to grow().
726N/A _cp_cache_map.initialize(length / 2);
726N/A }
726N/A int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; }
726N/A bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; }
726N/A int maybe_add_cp_cache_entry(int i) { return has_cp_cache(i) ? _cp_map[i] : add_cp_cache_entry(i); }
726N/A int add_cp_cache_entry(int cp_index) {
1059N/A assert((cp_index & _secondary_entry_tag) == 0, "bad tag");
726N/A assert(_cp_map[cp_index] == -1, "not twice on same cp_index");
726N/A int cache_index = _cp_cache_map.append(cp_index);
726N/A _cp_map.at_put(cp_index, cache_index);
726N/A assert(cp_entry_to_cp_cache(cp_index) == cache_index, "");
726N/A return cache_index;
726N/A }
1059N/A int add_secondary_cp_cache_entry(int main_cpc_entry) {
1059N/A assert(main_cpc_entry < _cp_cache_map.length(), "must be earlier CP cache entry");
1059N/A int cache_index = _cp_cache_map.append(main_cpc_entry | _secondary_entry_tag);
1059N/A return cache_index;
1059N/A }
726N/A
1580N/A // Access the contents of _cp_cache_map to determine CP cache layout.
1580N/A int cp_cache_entry_pool_index(int cache_index) {
1580N/A int cp_index = _cp_cache_map[cache_index];
1580N/A if ((cp_index & _secondary_entry_tag) != 0)
1580N/A return -1;
1580N/A else
1580N/A return cp_index;
1580N/A }
1580N/A int cp_cache_secondary_entry_main_index(int cache_index) {
1580N/A int cp_index = _cp_cache_map[cache_index];
1580N/A if ((cp_index & _secondary_entry_tag) == 0)
1580N/A return -1;
1580N/A else
1580N/A return (cp_index - _secondary_entry_tag);
1580N/A }
1580N/A
726N/A // All the work goes in here:
1138N/A Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS);
726N/A
Error!

 

There was an error!

null

java.lang.NullPointerException