sharkBlock.cpp revision 1879
/*
* Copyright 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 "interpreter/bytecodes.hpp"
#include "shark/llvmHeaders.hpp"
#include "shark/llvmValue.hpp"
#include "shark/sharkBlock.hpp"
#include "shark/sharkBuilder.hpp"
#include "shark/sharkConstant.hpp"
#include "shark/sharkState.hpp"
#include "shark/sharkValue.hpp"
#include "shark/shark_globals.hpp"
using namespace llvm;
SharkValue *a, *b, *c, *d;
int i;
// Ensure the current state is initialized before we emit any code,
// so that any setup code for the state is at the start of the block
// Parse the bytecodes
NOT_PRODUCT(a = b = c = d = NULL);
if (SharkTraceBytecodes)
do_trap(trap_request());
return;
}
if (UseLoopSafepoints) {
// XXX if a lcmp is followed by an if_?? then C2 maybe-inserts
// the safepoint before the lcmp rather than before the if.
// Maybe we should do this too. See parse2.cpp for details.
switch (bc()) {
case Bytecodes::_ifnonnull:
case Bytecodes::_if_acmpeq:
case Bytecodes::_if_acmpne:
case Bytecodes::_if_icmpeq:
case Bytecodes::_if_icmpne:
case Bytecodes::_if_icmplt:
case Bytecodes::_if_icmple:
case Bytecodes::_if_icmpgt:
case Bytecodes::_if_icmpge:
break;
break;
case Bytecodes::_tableswitch:
case Bytecodes::_lookupswitch:
if (switch_default_dest() <= bci()) {
break;
}
int len = switch_table_length();
for (int i = 0; i < len; i++) {
if (switch_dest(i) <= bci()) {
break;
}
}
break;
}
}
switch (bc()) {
break;
case Bytecodes::_aconst_null:
break;
case Bytecodes::_iconst_m1:
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
xpop();
break;
xpop();
xpop();
break;
a = xpop();
b = xpop();
xpush(a);
xpush(b);
break;
a = xpop();
xpush(a);
xpush(a);
break;
a = xpop();
b = xpop();
xpush(a);
xpush(b);
xpush(a);
break;
a = xpop();
b = xpop();
c = xpop();
xpush(a);
xpush(c);
xpush(b);
xpush(a);
break;
a = xpop();
b = xpop();
xpush(b);
xpush(a);
xpush(b);
xpush(a);
break;
a = xpop();
b = xpop();
c = xpop();
xpush(b);
xpush(a);
xpush(c);
xpush(b);
xpush(a);
break;
a = xpop();
b = xpop();
c = xpop();
d = xpop();
xpush(b);
xpush(a);
xpush(d);
xpush(c);
xpush(b);
xpush(a);
break;
case Bytecodes::_arraylength:
break;
do_getfield();
break;
case Bytecodes::_getstatic:
do_getstatic();
break;
do_putfield();
break;
case Bytecodes::_putstatic:
do_putstatic();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
do_idiv();
break;
do_irem();
break;
a = pop();
break;
b = pop();
a = pop();
a->jint_value(),
break;
b = pop();
a = pop();
builder()->CreateAShr(
a->jint_value(),
break;
b = pop();
a = pop();
builder()->CreateLShr(
a->jint_value(),
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
a->zero_checked() && b->zero_checked()));
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
do_ldiv();
break;
do_lrem();
break;
a = pop();
break;
b = pop();
a = pop();
a->jlong_value(),
builder()->CreateIntCast(
SharkType::jlong_type(), true)), false));
break;
b = pop();
a = pop();
builder()->CreateAShr(
a->jlong_value(),
builder()->CreateIntCast(
SharkType::jlong_type(), true)), false));
break;
b = pop();
a = pop();
builder()->CreateLShr(
a->jlong_value(),
builder()->CreateIntCast(
SharkType::jlong_type(), true)), false));
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
a->zero_checked() && b->zero_checked()));
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
b = pop();
a = pop();
break;
a = pop();
break;
i,
local(i)->jint_value()), false));
break;
do_lcmp();
break;
do_fcmp(false, false);
break;
do_fcmp(false, true);
break;
do_fcmp(true, false);
break;
do_fcmp(true, true);
break;
a = pop();
builder()->CreateIntCast(
break;
builder()->CreateSIToFP(
break;
builder()->CreateSIToFP(
break;
builder()->CreateIntCast(
break;
builder()->CreateSIToFP(
break;
builder()->CreateSIToFP(
break;
builder()->CreateCall(
break;
builder()->CreateCall(
break;
builder()->CreateFPExt(
break;
builder()->CreateCall(
break;
builder()->CreateCall(
break;
builder()->CreateFPTrunc(
break;
builder()->CreateAShr(
pop()->jint_value(),
break;
pop()->jint_value(),
break;
builder()->CreateAShr(
pop()->jint_value(),
break;
break;
break;
break;
break;
break;
break;
do_athrow();
break;
do_goto();
break;
do_jsr();
break;
do_ret();
break;
break;
case Bytecodes::_ifnonnull:
break;
case Bytecodes::_if_acmpeq:
b = pop();
a = pop();
break;
case Bytecodes::_if_acmpne:
b = pop();
a = pop();
break;
break;
break;
break;
break;
break;
break;
case Bytecodes::_if_icmpeq:
b = pop();
a = pop();
break;
case Bytecodes::_if_icmpne:
b = pop();
a = pop();
break;
case Bytecodes::_if_icmplt:
b = pop();
a = pop();
break;
case Bytecodes::_if_icmple:
b = pop();
a = pop();
break;
case Bytecodes::_if_icmpgt:
b = pop();
a = pop();
break;
case Bytecodes::_if_icmpge:
b = pop();
a = pop();
break;
case Bytecodes::_tableswitch:
case Bytecodes::_lookupswitch:
do_switch();
break;
case Bytecodes::_invokestatic:
case Bytecodes::_invokespecial:
case Bytecodes::_invokevirtual:
case Bytecodes::_invokeinterface:
do_call();
break;
case Bytecodes::_instanceof:
// This is a very common construct:
//
// if (object instanceof Klass) {
// something = (Klass) object;
// ...
// }
//
// which gets compiled to something like this:
//
// 28: aload 9
// 30: instanceof <Class Klass>
// 33: ifeq 52
// 36: aload 9
// 38: checkcast <Class Klass>
//
// Handling both bytecodes at once allows us
// to eliminate the checkcast.
(!UseLoopSafepoints ||
if (maybe_do_instanceof_if()) {
if (SharkTraceBytecodes)
break;
}
}
// fall through
case Bytecodes::_checkcast:
break;
do_new();
break;
do_newarray();
break;
case Bytecodes::_anewarray:
do_anewarray();
break;
case Bytecodes::_multianewarray:
break;
case Bytecodes::_monitorenter:
break;
case Bytecodes::_monitorexit:
break;
default:
}
}
}
return entry_state()->copy();
}
int SharkBlock::switch_default_dest() {
return iter()->get_dest_table(0);
}
int SharkBlock::switch_table_length() {
switch(bc()) {
case Bytecodes::_tableswitch:
case Bytecodes::_lookupswitch:
default:
}
}
int SharkBlock::switch_key(int i) {
switch(bc()) {
case Bytecodes::_tableswitch:
case Bytecodes::_lookupswitch:
default:
}
}
int SharkBlock::switch_dest(int i) {
switch(bc()) {
case Bytecodes::_tableswitch:
case Bytecodes::_lookupswitch:
default:
}
}
Value *a, *b, *p, *q;
if (is_long) {
a = sa->jlong_value();
b = sb->jlong_value();
}
else {
a = sa->jint_value();
b = sb->jint_value();
}
builder()->CreateCondBr(
builder()->CreateICmpEQ(a, p),
builder()->CreateICmpEQ(b, q)),
if (is_rem) {
if (is_long)
else
}
else {
special_result = a;
}
if (is_rem)
else
if (is_long)
else
if (is_long)
else
}
bool will_link;
// Pop the value off the stack where necessary
if (!is_get)
// Find the object we're accessing, if necessary
if (is_field) {
}
}
if (!is_field)
"addr");
// Do the access
if (is_get) {
if (field_type != stack_type) {
}
}
else {
if (field_type != stack_type) {
}
if (field->is_volatile())
}
}
// Push the value onto the stack where necessary
if (is_get)
}
void SharkBlock::do_lcmp() {
}
Value *a, *b;
if (is_double) {
b = pop()->jdouble_value();
a = pop()->jdouble_value();
}
else {
b = pop()->jfloat_value();
a = pop()->jfloat_value();
}
builder()->CreateCondBr(
builder()->CreateFCmpUNO(a, b),
}
void SharkBlock::emit_IR() {
}
}
}
void SharkBlock::maybe_add_backedge_safepoint() {
}
bool SharkBlock::has_trap() {
return false;
}
int SharkBlock::trap_request() {
}
int SharkBlock::trap_bci() {
}
}
void SharkBlock::do_arraylength() {
}
}
}
}
void SharkBlock::do_athrow() {
}
void SharkBlock::do_goto() {
}
void SharkBlock::do_jsr() {
}
void SharkBlock::do_ret() {
}
}
void SharkBlock::do_switch() {
}
void SharkBlock::do_call() {
}
void SharkBlock::do_instance_check() {
}
bool SharkBlock::maybe_do_instanceof_if() {
}
void SharkBlock::do_new() {
}
void SharkBlock::do_newarray() {
}
void SharkBlock::do_anewarray() {
}
void SharkBlock::do_multianewarray() {
}
void SharkBlock::do_monitorenter() {
}
void SharkBlock::do_monitorexit() {
}