|
Java example source code file (vframe_hp.cpp)
The vframe_hp.cpp Java example source code
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "code/codeCache.hpp"
#include "code/debugInfoRec.hpp"
#include "code/nmethod.hpp"
#include "code/pcDesc.hpp"
#include "code/scopeDesc.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/oopMapCache.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/basicLock.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/monitorChunk.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/vframeArray.hpp"
#include "runtime/vframe_hp.hpp"
#ifdef COMPILER2
#include "opto/matcher.hpp"
#endif
// ------------- compiledVFrame --------------
StackValueCollection* compiledVFrame::locals() const {
// Natives has no scope
if (scope() == NULL) return new StackValueCollection(0);
GrowableArray<ScopeValue*>* scv_list = scope()->locals();
if (scv_list == NULL) return new StackValueCollection(0);
// scv_list is the list of ScopeValues describing the JVM stack state.
// There is one scv_list entry for every JVM stack state in use.
int length = scv_list->length();
StackValueCollection* result = new StackValueCollection(length);
// In rare instances set_locals may have occurred in which case
// there are local values that are not described by the ScopeValue anymore
GrowableArray<jvmtiDeferredLocalVariable*>* deferred = NULL;
GrowableArray<jvmtiDeferredLocalVariableSet*>* list = thread()->deferred_locals();
if (list != NULL ) {
// In real life this never happens or is typically a single element search
for (int i = 0; i < list->length(); i++) {
if (list->at(i)->matches((vframe*)this)) {
deferred = list->at(i)->locals();
break;
}
}
}
for( int i = 0; i < length; i++ ) {
result->add( create_stack_value(scv_list->at(i)) );
}
// Replace specified locals with any deferred writes that are present
if (deferred != NULL) {
for ( int l = 0; l < deferred->length() ; l ++) {
jvmtiDeferredLocalVariable* val = deferred->at(l);
switch (val->type()) {
case T_BOOLEAN:
result->set_int_at(val->index(), val->value().z);
break;
case T_CHAR:
result->set_int_at(val->index(), val->value().c);
break;
case T_FLOAT:
result->set_float_at(val->index(), val->value().f);
break;
case T_DOUBLE:
result->set_double_at(val->index(), val->value().d);
break;
case T_BYTE:
result->set_int_at(val->index(), val->value().b);
break;
case T_SHORT:
result->set_int_at(val->index(), val->value().s);
break;
case T_INT:
result->set_int_at(val->index(), val->value().i);
break;
case T_LONG:
result->set_long_at(val->index(), val->value().j);
break;
case T_OBJECT:
{
Handle obj((oop)val->value().l);
result->set_obj_at(val->index(), obj);
}
break;
default:
ShouldNotReachHere();
}
}
}
return result;
}
void compiledVFrame::set_locals(StackValueCollection* values) const {
fatal("Should use update_local for each local update");
}
void compiledVFrame::update_local(BasicType type, int index, jvalue value) {
#ifdef ASSERT
assert(fr().is_deoptimized_frame(), "frame must be scheduled for deoptimization");
#endif /* ASSERT */
GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals();
if (deferred != NULL ) {
// See if this vframe has already had locals with deferred writes
int f;
for ( f = 0 ; f < deferred->length() ; f++ ) {
if (deferred->at(f)->matches(this)) {
// Matching, vframe now see if the local already had deferred write
GrowableArray<jvmtiDeferredLocalVariable*>* locals = deferred->at(f)->locals();
int l;
for (l = 0 ; l < locals->length() ; l++ ) {
if (locals->at(l)->index() == index) {
locals->at(l)->set_value(value);
return;
}
}
// No matching local already present. Push a new value onto the deferred collection
locals->push(new jvmtiDeferredLocalVariable(index, type, value));
return;
}
}
// No matching vframe must push a new vframe
} else {
// No deferred updates pending for this thread.
// allocate in C heap
deferred = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariableSet*> (1, true);
thread()->set_deferred_locals(deferred);
}
deferred->push(new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id()));
assert(deferred->top()->id() == fr().id(), "Huh? Must match");
deferred->top()->set_local_at(index, type, value);
}
StackValueCollection* compiledVFrame::expressions() const {
// Natives has no scope
if (scope() == NULL) return new StackValueCollection(0);
GrowableArray<ScopeValue*>* scv_list = scope()->expressions();
if (scv_list == NULL) return new StackValueCollection(0);
// scv_list is the list of ScopeValues describing the JVM stack state.
// There is one scv_list entry for every JVM stack state in use.
int length = scv_list->length();
StackValueCollection* result = new StackValueCollection(length);
for( int i = 0; i < length; i++ )
result->add( create_stack_value(scv_list->at(i)) );
return result;
}
// The implementation of the following two methods was factorized into the
// class StackValue because it is also used from within deoptimization.cpp for
// rematerialization and relocking of non-escaping objects.
StackValue *compiledVFrame::create_stack_value(ScopeValue *sv) const {
return StackValue::create_stack_value(&_fr, register_map(), sv);
}
BasicLock* compiledVFrame::resolve_monitor_lock(Location location) const {
return StackValue::resolve_monitor_lock(&_fr, location);
}
GrowableArray<MonitorInfo*>* compiledVFrame::monitors() const {
// Natives has no scope
if (scope() == NULL) {
nmethod* nm = code();
Method* method = nm->method();
assert(method->is_native(), "");
if (!method->is_synchronized()) {
return new GrowableArray<MonitorInfo*>(0);
}
// This monitor is really only needed for UseBiasedLocking, but
// return it in all cases for now as it might be useful for stack
// traces and tools as well
GrowableArray<MonitorInfo*> *monitors = new GrowableArray
Other Java examples (source code examples)Here is a short list of links related to this Java vframe_hp.cpp source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.