src/share/vm/shark/sharkBlock.cpp

changeset 2047
d2ede61b7a12
child 2314
f95d63e2154a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/shark/sharkBlock.cpp	Wed Aug 11 05:51:21 2010 -0700
     1.3 @@ -0,0 +1,1260 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright 2008, 2009, 2010 Red Hat, Inc.
     1.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8 + *
     1.9 + * This code is free software; you can redistribute it and/or modify it
    1.10 + * under the terms of the GNU General Public License version 2 only, as
    1.11 + * published by the Free Software Foundation.
    1.12 + *
    1.13 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.15 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.16 + * version 2 for more details (a copy is included in the LICENSE file that
    1.17 + * accompanied this code).
    1.18 + *
    1.19 + * You should have received a copy of the GNU General Public License version
    1.20 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.22 + *
    1.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.24 + * or visit www.oracle.com if you need additional information or have any
    1.25 + * questions.
    1.26 + *
    1.27 + */
    1.28 +
    1.29 +#include "incls/_precompiled.incl"
    1.30 +#include "incls/_sharkBlock.cpp.incl"
    1.31 +
    1.32 +using namespace llvm;
    1.33 +
    1.34 +void SharkBlock::parse_bytecode(int start, int limit) {
    1.35 +  SharkValue *a, *b, *c, *d;
    1.36 +  int i;
    1.37 +
    1.38 +  // Ensure the current state is initialized before we emit any code,
    1.39 +  // so that any setup code for the state is at the start of the block
    1.40 +  current_state();
    1.41 +
    1.42 +  // Parse the bytecodes
    1.43 +  iter()->reset_to_bci(start);
    1.44 +  while (iter()->next_bci() < limit) {
    1.45 +    NOT_PRODUCT(a = b = c = d = NULL);
    1.46 +    iter()->next();
    1.47 +
    1.48 +    if (SharkTraceBytecodes)
    1.49 +      tty->print_cr("%4d: %s", bci(), Bytecodes::name(bc()));
    1.50 +
    1.51 +    if (has_trap() && trap_bci() == bci()) {
    1.52 +      do_trap(trap_request());
    1.53 +      return;
    1.54 +    }
    1.55 +
    1.56 +    if (UseLoopSafepoints) {
    1.57 +      // XXX if a lcmp is followed by an if_?? then C2 maybe-inserts
    1.58 +      // the safepoint before the lcmp rather than before the if.
    1.59 +      // Maybe we should do this too.  See parse2.cpp for details.
    1.60 +      switch (bc()) {
    1.61 +      case Bytecodes::_goto:
    1.62 +      case Bytecodes::_ifnull:
    1.63 +      case Bytecodes::_ifnonnull:
    1.64 +      case Bytecodes::_if_acmpeq:
    1.65 +      case Bytecodes::_if_acmpne:
    1.66 +      case Bytecodes::_ifeq:
    1.67 +      case Bytecodes::_ifne:
    1.68 +      case Bytecodes::_iflt:
    1.69 +      case Bytecodes::_ifle:
    1.70 +      case Bytecodes::_ifgt:
    1.71 +      case Bytecodes::_ifge:
    1.72 +      case Bytecodes::_if_icmpeq:
    1.73 +      case Bytecodes::_if_icmpne:
    1.74 +      case Bytecodes::_if_icmplt:
    1.75 +      case Bytecodes::_if_icmple:
    1.76 +      case Bytecodes::_if_icmpgt:
    1.77 +      case Bytecodes::_if_icmpge:
    1.78 +        if (iter()->get_dest() <= bci())
    1.79 +          maybe_add_backedge_safepoint();
    1.80 +        break;
    1.81 +
    1.82 +      case Bytecodes::_goto_w:
    1.83 +        if (iter()->get_far_dest() <= bci())
    1.84 +          maybe_add_backedge_safepoint();
    1.85 +        break;
    1.86 +
    1.87 +      case Bytecodes::_tableswitch:
    1.88 +      case Bytecodes::_lookupswitch:
    1.89 +        if (switch_default_dest() <= bci()) {
    1.90 +          maybe_add_backedge_safepoint();
    1.91 +          break;
    1.92 +        }
    1.93 +        int len = switch_table_length();
    1.94 +        for (int i = 0; i < len; i++) {
    1.95 +          if (switch_dest(i) <= bci()) {
    1.96 +            maybe_add_backedge_safepoint();
    1.97 +            break;
    1.98 +          }
    1.99 +        }
   1.100 +        break;
   1.101 +      }
   1.102 +    }
   1.103 +
   1.104 +    switch (bc()) {
   1.105 +    case Bytecodes::_nop:
   1.106 +      break;
   1.107 +
   1.108 +    case Bytecodes::_aconst_null:
   1.109 +      push(SharkValue::null());
   1.110 +      break;
   1.111 +
   1.112 +    case Bytecodes::_iconst_m1:
   1.113 +      push(SharkValue::jint_constant(-1));
   1.114 +      break;
   1.115 +    case Bytecodes::_iconst_0:
   1.116 +      push(SharkValue::jint_constant(0));
   1.117 +      break;
   1.118 +    case Bytecodes::_iconst_1:
   1.119 +      push(SharkValue::jint_constant(1));
   1.120 +      break;
   1.121 +    case Bytecodes::_iconst_2:
   1.122 +      push(SharkValue::jint_constant(2));
   1.123 +      break;
   1.124 +    case Bytecodes::_iconst_3:
   1.125 +      push(SharkValue::jint_constant(3));
   1.126 +      break;
   1.127 +    case Bytecodes::_iconst_4:
   1.128 +      push(SharkValue::jint_constant(4));
   1.129 +      break;
   1.130 +    case Bytecodes::_iconst_5:
   1.131 +      push(SharkValue::jint_constant(5));
   1.132 +      break;
   1.133 +
   1.134 +    case Bytecodes::_lconst_0:
   1.135 +      push(SharkValue::jlong_constant(0));
   1.136 +      break;
   1.137 +    case Bytecodes::_lconst_1:
   1.138 +      push(SharkValue::jlong_constant(1));
   1.139 +      break;
   1.140 +
   1.141 +    case Bytecodes::_fconst_0:
   1.142 +      push(SharkValue::jfloat_constant(0));
   1.143 +      break;
   1.144 +    case Bytecodes::_fconst_1:
   1.145 +      push(SharkValue::jfloat_constant(1));
   1.146 +      break;
   1.147 +    case Bytecodes::_fconst_2:
   1.148 +      push(SharkValue::jfloat_constant(2));
   1.149 +      break;
   1.150 +
   1.151 +    case Bytecodes::_dconst_0:
   1.152 +      push(SharkValue::jdouble_constant(0));
   1.153 +      break;
   1.154 +    case Bytecodes::_dconst_1:
   1.155 +      push(SharkValue::jdouble_constant(1));
   1.156 +      break;
   1.157 +
   1.158 +    case Bytecodes::_bipush:
   1.159 +      push(SharkValue::jint_constant(iter()->get_constant_u1()));
   1.160 +      break;
   1.161 +    case Bytecodes::_sipush:
   1.162 +      push(SharkValue::jint_constant(iter()->get_constant_u2()));
   1.163 +      break;
   1.164 +
   1.165 +    case Bytecodes::_ldc:
   1.166 +    case Bytecodes::_ldc_w:
   1.167 +    case Bytecodes::_ldc2_w:
   1.168 +      push(SharkConstant::for_ldc(iter())->value(builder()));
   1.169 +      break;
   1.170 +
   1.171 +    case Bytecodes::_iload_0:
   1.172 +    case Bytecodes::_lload_0:
   1.173 +    case Bytecodes::_fload_0:
   1.174 +    case Bytecodes::_dload_0:
   1.175 +    case Bytecodes::_aload_0:
   1.176 +      push(local(0));
   1.177 +      break;
   1.178 +    case Bytecodes::_iload_1:
   1.179 +    case Bytecodes::_lload_1:
   1.180 +    case Bytecodes::_fload_1:
   1.181 +    case Bytecodes::_dload_1:
   1.182 +    case Bytecodes::_aload_1:
   1.183 +      push(local(1));
   1.184 +      break;
   1.185 +    case Bytecodes::_iload_2:
   1.186 +    case Bytecodes::_lload_2:
   1.187 +    case Bytecodes::_fload_2:
   1.188 +    case Bytecodes::_dload_2:
   1.189 +    case Bytecodes::_aload_2:
   1.190 +      push(local(2));
   1.191 +      break;
   1.192 +    case Bytecodes::_iload_3:
   1.193 +    case Bytecodes::_lload_3:
   1.194 +    case Bytecodes::_fload_3:
   1.195 +    case Bytecodes::_dload_3:
   1.196 +    case Bytecodes::_aload_3:
   1.197 +      push(local(3));
   1.198 +      break;
   1.199 +    case Bytecodes::_iload:
   1.200 +    case Bytecodes::_lload:
   1.201 +    case Bytecodes::_fload:
   1.202 +    case Bytecodes::_dload:
   1.203 +    case Bytecodes::_aload:
   1.204 +      push(local(iter()->get_index()));
   1.205 +      break;
   1.206 +
   1.207 +    case Bytecodes::_baload:
   1.208 +      do_aload(T_BYTE);
   1.209 +      break;
   1.210 +    case Bytecodes::_caload:
   1.211 +      do_aload(T_CHAR);
   1.212 +      break;
   1.213 +    case Bytecodes::_saload:
   1.214 +      do_aload(T_SHORT);
   1.215 +      break;
   1.216 +    case Bytecodes::_iaload:
   1.217 +      do_aload(T_INT);
   1.218 +      break;
   1.219 +    case Bytecodes::_laload:
   1.220 +      do_aload(T_LONG);
   1.221 +      break;
   1.222 +    case Bytecodes::_faload:
   1.223 +      do_aload(T_FLOAT);
   1.224 +      break;
   1.225 +    case Bytecodes::_daload:
   1.226 +      do_aload(T_DOUBLE);
   1.227 +      break;
   1.228 +    case Bytecodes::_aaload:
   1.229 +      do_aload(T_OBJECT);
   1.230 +      break;
   1.231 +
   1.232 +    case Bytecodes::_istore_0:
   1.233 +    case Bytecodes::_lstore_0:
   1.234 +    case Bytecodes::_fstore_0:
   1.235 +    case Bytecodes::_dstore_0:
   1.236 +    case Bytecodes::_astore_0:
   1.237 +      set_local(0, pop());
   1.238 +      break;
   1.239 +    case Bytecodes::_istore_1:
   1.240 +    case Bytecodes::_lstore_1:
   1.241 +    case Bytecodes::_fstore_1:
   1.242 +    case Bytecodes::_dstore_1:
   1.243 +    case Bytecodes::_astore_1:
   1.244 +      set_local(1, pop());
   1.245 +      break;
   1.246 +    case Bytecodes::_istore_2:
   1.247 +    case Bytecodes::_lstore_2:
   1.248 +    case Bytecodes::_fstore_2:
   1.249 +    case Bytecodes::_dstore_2:
   1.250 +    case Bytecodes::_astore_2:
   1.251 +      set_local(2, pop());
   1.252 +      break;
   1.253 +    case Bytecodes::_istore_3:
   1.254 +    case Bytecodes::_lstore_3:
   1.255 +    case Bytecodes::_fstore_3:
   1.256 +    case Bytecodes::_dstore_3:
   1.257 +    case Bytecodes::_astore_3:
   1.258 +      set_local(3, pop());
   1.259 +      break;
   1.260 +    case Bytecodes::_istore:
   1.261 +    case Bytecodes::_lstore:
   1.262 +    case Bytecodes::_fstore:
   1.263 +    case Bytecodes::_dstore:
   1.264 +    case Bytecodes::_astore:
   1.265 +      set_local(iter()->get_index(), pop());
   1.266 +      break;
   1.267 +
   1.268 +    case Bytecodes::_bastore:
   1.269 +      do_astore(T_BYTE);
   1.270 +      break;
   1.271 +    case Bytecodes::_castore:
   1.272 +      do_astore(T_CHAR);
   1.273 +      break;
   1.274 +    case Bytecodes::_sastore:
   1.275 +      do_astore(T_SHORT);
   1.276 +      break;
   1.277 +    case Bytecodes::_iastore:
   1.278 +      do_astore(T_INT);
   1.279 +      break;
   1.280 +    case Bytecodes::_lastore:
   1.281 +      do_astore(T_LONG);
   1.282 +      break;
   1.283 +    case Bytecodes::_fastore:
   1.284 +      do_astore(T_FLOAT);
   1.285 +      break;
   1.286 +    case Bytecodes::_dastore:
   1.287 +      do_astore(T_DOUBLE);
   1.288 +      break;
   1.289 +    case Bytecodes::_aastore:
   1.290 +      do_astore(T_OBJECT);
   1.291 +      break;
   1.292 +
   1.293 +    case Bytecodes::_pop:
   1.294 +      xpop();
   1.295 +      break;
   1.296 +    case Bytecodes::_pop2:
   1.297 +      xpop();
   1.298 +      xpop();
   1.299 +      break;
   1.300 +    case Bytecodes::_swap:
   1.301 +      a = xpop();
   1.302 +      b = xpop();
   1.303 +      xpush(a);
   1.304 +      xpush(b);
   1.305 +      break;
   1.306 +    case Bytecodes::_dup:
   1.307 +      a = xpop();
   1.308 +      xpush(a);
   1.309 +      xpush(a);
   1.310 +      break;
   1.311 +    case Bytecodes::_dup_x1:
   1.312 +      a = xpop();
   1.313 +      b = xpop();
   1.314 +      xpush(a);
   1.315 +      xpush(b);
   1.316 +      xpush(a);
   1.317 +      break;
   1.318 +    case Bytecodes::_dup_x2:
   1.319 +      a = xpop();
   1.320 +      b = xpop();
   1.321 +      c = xpop();
   1.322 +      xpush(a);
   1.323 +      xpush(c);
   1.324 +      xpush(b);
   1.325 +      xpush(a);
   1.326 +      break;
   1.327 +    case Bytecodes::_dup2:
   1.328 +      a = xpop();
   1.329 +      b = xpop();
   1.330 +      xpush(b);
   1.331 +      xpush(a);
   1.332 +      xpush(b);
   1.333 +      xpush(a);
   1.334 +      break;
   1.335 +    case Bytecodes::_dup2_x1:
   1.336 +      a = xpop();
   1.337 +      b = xpop();
   1.338 +      c = xpop();
   1.339 +      xpush(b);
   1.340 +      xpush(a);
   1.341 +      xpush(c);
   1.342 +      xpush(b);
   1.343 +      xpush(a);
   1.344 +      break;
   1.345 +    case Bytecodes::_dup2_x2:
   1.346 +      a = xpop();
   1.347 +      b = xpop();
   1.348 +      c = xpop();
   1.349 +      d = xpop();
   1.350 +      xpush(b);
   1.351 +      xpush(a);
   1.352 +      xpush(d);
   1.353 +      xpush(c);
   1.354 +      xpush(b);
   1.355 +      xpush(a);
   1.356 +      break;
   1.357 +
   1.358 +    case Bytecodes::_arraylength:
   1.359 +      do_arraylength();
   1.360 +      break;
   1.361 +
   1.362 +    case Bytecodes::_getfield:
   1.363 +      do_getfield();
   1.364 +      break;
   1.365 +    case Bytecodes::_getstatic:
   1.366 +      do_getstatic();
   1.367 +      break;
   1.368 +    case Bytecodes::_putfield:
   1.369 +      do_putfield();
   1.370 +      break;
   1.371 +    case Bytecodes::_putstatic:
   1.372 +      do_putstatic();
   1.373 +      break;
   1.374 +
   1.375 +    case Bytecodes::_iadd:
   1.376 +      b = pop();
   1.377 +      a = pop();
   1.378 +      push(SharkValue::create_jint(
   1.379 +        builder()->CreateAdd(a->jint_value(), b->jint_value()), false));
   1.380 +      break;
   1.381 +    case Bytecodes::_isub:
   1.382 +      b = pop();
   1.383 +      a = pop();
   1.384 +      push(SharkValue::create_jint(
   1.385 +        builder()->CreateSub(a->jint_value(), b->jint_value()), false));
   1.386 +      break;
   1.387 +    case Bytecodes::_imul:
   1.388 +      b = pop();
   1.389 +      a = pop();
   1.390 +      push(SharkValue::create_jint(
   1.391 +        builder()->CreateMul(a->jint_value(), b->jint_value()), false));
   1.392 +      break;
   1.393 +    case Bytecodes::_idiv:
   1.394 +      do_idiv();
   1.395 +      break;
   1.396 +    case Bytecodes::_irem:
   1.397 +      do_irem();
   1.398 +      break;
   1.399 +    case Bytecodes::_ineg:
   1.400 +      a = pop();
   1.401 +      push(SharkValue::create_jint(
   1.402 +        builder()->CreateNeg(a->jint_value()), a->zero_checked()));
   1.403 +      break;
   1.404 +    case Bytecodes::_ishl:
   1.405 +      b = pop();
   1.406 +      a = pop();
   1.407 +      push(SharkValue::create_jint(
   1.408 +        builder()->CreateShl(
   1.409 +          a->jint_value(),
   1.410 +          builder()->CreateAnd(
   1.411 +            b->jint_value(), LLVMValue::jint_constant(0x1f))), false));
   1.412 +      break;
   1.413 +    case Bytecodes::_ishr:
   1.414 +      b = pop();
   1.415 +      a = pop();
   1.416 +      push(SharkValue::create_jint(
   1.417 +        builder()->CreateAShr(
   1.418 +          a->jint_value(),
   1.419 +          builder()->CreateAnd(
   1.420 +            b->jint_value(), LLVMValue::jint_constant(0x1f))), false));
   1.421 +      break;
   1.422 +    case Bytecodes::_iushr:
   1.423 +      b = pop();
   1.424 +      a = pop();
   1.425 +      push(SharkValue::create_jint(
   1.426 +        builder()->CreateLShr(
   1.427 +          a->jint_value(),
   1.428 +          builder()->CreateAnd(
   1.429 +            b->jint_value(), LLVMValue::jint_constant(0x1f))), false));
   1.430 +      break;
   1.431 +    case Bytecodes::_iand:
   1.432 +      b = pop();
   1.433 +      a = pop();
   1.434 +      push(SharkValue::create_jint(
   1.435 +        builder()->CreateAnd(a->jint_value(), b->jint_value()), false));
   1.436 +      break;
   1.437 +    case Bytecodes::_ior:
   1.438 +      b = pop();
   1.439 +      a = pop();
   1.440 +      push(SharkValue::create_jint(
   1.441 +        builder()->CreateOr(a->jint_value(), b->jint_value()),
   1.442 +        a->zero_checked() && b->zero_checked()));
   1.443 +      break;
   1.444 +    case Bytecodes::_ixor:
   1.445 +      b = pop();
   1.446 +      a = pop();
   1.447 +      push(SharkValue::create_jint(
   1.448 +        builder()->CreateXor(a->jint_value(), b->jint_value()), false));
   1.449 +      break;
   1.450 +
   1.451 +    case Bytecodes::_ladd:
   1.452 +      b = pop();
   1.453 +      a = pop();
   1.454 +      push(SharkValue::create_jlong(
   1.455 +        builder()->CreateAdd(a->jlong_value(), b->jlong_value()), false));
   1.456 +      break;
   1.457 +    case Bytecodes::_lsub:
   1.458 +      b = pop();
   1.459 +      a = pop();
   1.460 +      push(SharkValue::create_jlong(
   1.461 +        builder()->CreateSub(a->jlong_value(), b->jlong_value()), false));
   1.462 +      break;
   1.463 +    case Bytecodes::_lmul:
   1.464 +      b = pop();
   1.465 +      a = pop();
   1.466 +      push(SharkValue::create_jlong(
   1.467 +        builder()->CreateMul(a->jlong_value(), b->jlong_value()), false));
   1.468 +      break;
   1.469 +    case Bytecodes::_ldiv:
   1.470 +      do_ldiv();
   1.471 +      break;
   1.472 +    case Bytecodes::_lrem:
   1.473 +      do_lrem();
   1.474 +      break;
   1.475 +    case Bytecodes::_lneg:
   1.476 +      a = pop();
   1.477 +      push(SharkValue::create_jlong(
   1.478 +        builder()->CreateNeg(a->jlong_value()), a->zero_checked()));
   1.479 +      break;
   1.480 +    case Bytecodes::_lshl:
   1.481 +      b = pop();
   1.482 +      a = pop();
   1.483 +      push(SharkValue::create_jlong(
   1.484 +        builder()->CreateShl(
   1.485 +          a->jlong_value(),
   1.486 +          builder()->CreateIntCast(
   1.487 +            builder()->CreateAnd(
   1.488 +              b->jint_value(), LLVMValue::jint_constant(0x3f)),
   1.489 +            SharkType::jlong_type(), true)), false));
   1.490 +      break;
   1.491 +    case Bytecodes::_lshr:
   1.492 +      b = pop();
   1.493 +      a = pop();
   1.494 +      push(SharkValue::create_jlong(
   1.495 +        builder()->CreateAShr(
   1.496 +          a->jlong_value(),
   1.497 +          builder()->CreateIntCast(
   1.498 +            builder()->CreateAnd(
   1.499 +              b->jint_value(), LLVMValue::jint_constant(0x3f)),
   1.500 +            SharkType::jlong_type(), true)), false));
   1.501 +      break;
   1.502 +    case Bytecodes::_lushr:
   1.503 +      b = pop();
   1.504 +      a = pop();
   1.505 +      push(SharkValue::create_jlong(
   1.506 +        builder()->CreateLShr(
   1.507 +          a->jlong_value(),
   1.508 +          builder()->CreateIntCast(
   1.509 +            builder()->CreateAnd(
   1.510 +              b->jint_value(), LLVMValue::jint_constant(0x3f)),
   1.511 +            SharkType::jlong_type(), true)), false));
   1.512 +      break;
   1.513 +    case Bytecodes::_land:
   1.514 +      b = pop();
   1.515 +      a = pop();
   1.516 +      push(SharkValue::create_jlong(
   1.517 +        builder()->CreateAnd(a->jlong_value(), b->jlong_value()), false));
   1.518 +      break;
   1.519 +    case Bytecodes::_lor:
   1.520 +      b = pop();
   1.521 +      a = pop();
   1.522 +      push(SharkValue::create_jlong(
   1.523 +        builder()->CreateOr(a->jlong_value(), b->jlong_value()),
   1.524 +        a->zero_checked() && b->zero_checked()));
   1.525 +      break;
   1.526 +    case Bytecodes::_lxor:
   1.527 +      b = pop();
   1.528 +      a = pop();
   1.529 +      push(SharkValue::create_jlong(
   1.530 +        builder()->CreateXor(a->jlong_value(), b->jlong_value()), false));
   1.531 +      break;
   1.532 +
   1.533 +    case Bytecodes::_fadd:
   1.534 +      b = pop();
   1.535 +      a = pop();
   1.536 +      push(SharkValue::create_jfloat(
   1.537 +        builder()->CreateFAdd(a->jfloat_value(), b->jfloat_value())));
   1.538 +      break;
   1.539 +    case Bytecodes::_fsub:
   1.540 +      b = pop();
   1.541 +      a = pop();
   1.542 +      push(SharkValue::create_jfloat(
   1.543 +        builder()->CreateFSub(a->jfloat_value(), b->jfloat_value())));
   1.544 +      break;
   1.545 +    case Bytecodes::_fmul:
   1.546 +      b = pop();
   1.547 +      a = pop();
   1.548 +      push(SharkValue::create_jfloat(
   1.549 +        builder()->CreateFMul(a->jfloat_value(), b->jfloat_value())));
   1.550 +      break;
   1.551 +    case Bytecodes::_fdiv:
   1.552 +      b = pop();
   1.553 +      a = pop();
   1.554 +      push(SharkValue::create_jfloat(
   1.555 +        builder()->CreateFDiv(a->jfloat_value(), b->jfloat_value())));
   1.556 +      break;
   1.557 +    case Bytecodes::_frem:
   1.558 +      b = pop();
   1.559 +      a = pop();
   1.560 +      push(SharkValue::create_jfloat(
   1.561 +        builder()->CreateFRem(a->jfloat_value(), b->jfloat_value())));
   1.562 +      break;
   1.563 +    case Bytecodes::_fneg:
   1.564 +      a = pop();
   1.565 +      push(SharkValue::create_jfloat(
   1.566 +        builder()->CreateFNeg(a->jfloat_value())));
   1.567 +      break;
   1.568 +
   1.569 +    case Bytecodes::_dadd:
   1.570 +      b = pop();
   1.571 +      a = pop();
   1.572 +      push(SharkValue::create_jdouble(
   1.573 +        builder()->CreateFAdd(a->jdouble_value(), b->jdouble_value())));
   1.574 +      break;
   1.575 +    case Bytecodes::_dsub:
   1.576 +      b = pop();
   1.577 +      a = pop();
   1.578 +      push(SharkValue::create_jdouble(
   1.579 +        builder()->CreateFSub(a->jdouble_value(), b->jdouble_value())));
   1.580 +      break;
   1.581 +    case Bytecodes::_dmul:
   1.582 +      b = pop();
   1.583 +      a = pop();
   1.584 +      push(SharkValue::create_jdouble(
   1.585 +        builder()->CreateFMul(a->jdouble_value(), b->jdouble_value())));
   1.586 +      break;
   1.587 +    case Bytecodes::_ddiv:
   1.588 +      b = pop();
   1.589 +      a = pop();
   1.590 +      push(SharkValue::create_jdouble(
   1.591 +        builder()->CreateFDiv(a->jdouble_value(), b->jdouble_value())));
   1.592 +      break;
   1.593 +    case Bytecodes::_drem:
   1.594 +      b = pop();
   1.595 +      a = pop();
   1.596 +      push(SharkValue::create_jdouble(
   1.597 +        builder()->CreateFRem(a->jdouble_value(), b->jdouble_value())));
   1.598 +      break;
   1.599 +    case Bytecodes::_dneg:
   1.600 +      a = pop();
   1.601 +      push(SharkValue::create_jdouble(
   1.602 +        builder()->CreateFNeg(a->jdouble_value())));
   1.603 +      break;
   1.604 +
   1.605 +    case Bytecodes::_iinc:
   1.606 +      i = iter()->get_index();
   1.607 +      set_local(
   1.608 +        i,
   1.609 +        SharkValue::create_jint(
   1.610 +          builder()->CreateAdd(
   1.611 +            LLVMValue::jint_constant(iter()->get_iinc_con()),
   1.612 +            local(i)->jint_value()), false));
   1.613 +      break;
   1.614 +
   1.615 +    case Bytecodes::_lcmp:
   1.616 +      do_lcmp();
   1.617 +      break;
   1.618 +
   1.619 +    case Bytecodes::_fcmpl:
   1.620 +      do_fcmp(false, false);
   1.621 +      break;
   1.622 +    case Bytecodes::_fcmpg:
   1.623 +      do_fcmp(false, true);
   1.624 +      break;
   1.625 +    case Bytecodes::_dcmpl:
   1.626 +      do_fcmp(true, false);
   1.627 +      break;
   1.628 +    case Bytecodes::_dcmpg:
   1.629 +      do_fcmp(true, true);
   1.630 +      break;
   1.631 +
   1.632 +    case Bytecodes::_i2l:
   1.633 +      a = pop();
   1.634 +      push(SharkValue::create_jlong(
   1.635 +        builder()->CreateIntCast(
   1.636 +          a->jint_value(), SharkType::jlong_type(), true), a->zero_checked()));
   1.637 +      break;
   1.638 +    case Bytecodes::_i2f:
   1.639 +      push(SharkValue::create_jfloat(
   1.640 +        builder()->CreateSIToFP(
   1.641 +          pop()->jint_value(), SharkType::jfloat_type())));
   1.642 +      break;
   1.643 +    case Bytecodes::_i2d:
   1.644 +      push(SharkValue::create_jdouble(
   1.645 +        builder()->CreateSIToFP(
   1.646 +          pop()->jint_value(), SharkType::jdouble_type())));
   1.647 +      break;
   1.648 +
   1.649 +    case Bytecodes::_l2i:
   1.650 +      push(SharkValue::create_jint(
   1.651 +        builder()->CreateIntCast(
   1.652 +          pop()->jlong_value(), SharkType::jint_type(), true), false));
   1.653 +      break;
   1.654 +    case Bytecodes::_l2f:
   1.655 +      push(SharkValue::create_jfloat(
   1.656 +        builder()->CreateSIToFP(
   1.657 +          pop()->jlong_value(), SharkType::jfloat_type())));
   1.658 +      break;
   1.659 +    case Bytecodes::_l2d:
   1.660 +      push(SharkValue::create_jdouble(
   1.661 +        builder()->CreateSIToFP(
   1.662 +          pop()->jlong_value(), SharkType::jdouble_type())));
   1.663 +      break;
   1.664 +
   1.665 +    case Bytecodes::_f2i:
   1.666 +      push(SharkValue::create_jint(
   1.667 +        builder()->CreateCall(
   1.668 +          builder()->f2i(), pop()->jfloat_value()), false));
   1.669 +      break;
   1.670 +    case Bytecodes::_f2l:
   1.671 +      push(SharkValue::create_jlong(
   1.672 +        builder()->CreateCall(
   1.673 +          builder()->f2l(), pop()->jfloat_value()), false));
   1.674 +      break;
   1.675 +    case Bytecodes::_f2d:
   1.676 +      push(SharkValue::create_jdouble(
   1.677 +        builder()->CreateFPExt(
   1.678 +          pop()->jfloat_value(), SharkType::jdouble_type())));
   1.679 +      break;
   1.680 +
   1.681 +    case Bytecodes::_d2i:
   1.682 +      push(SharkValue::create_jint(
   1.683 +        builder()->CreateCall(
   1.684 +          builder()->d2i(), pop()->jdouble_value()), false));
   1.685 +      break;
   1.686 +    case Bytecodes::_d2l:
   1.687 +      push(SharkValue::create_jlong(
   1.688 +        builder()->CreateCall(
   1.689 +          builder()->d2l(), pop()->jdouble_value()), false));
   1.690 +      break;
   1.691 +    case Bytecodes::_d2f:
   1.692 +      push(SharkValue::create_jfloat(
   1.693 +        builder()->CreateFPTrunc(
   1.694 +          pop()->jdouble_value(), SharkType::jfloat_type())));
   1.695 +      break;
   1.696 +
   1.697 +    case Bytecodes::_i2b:
   1.698 +      push(SharkValue::create_jint(
   1.699 +        builder()->CreateAShr(
   1.700 +          builder()->CreateShl(
   1.701 +            pop()->jint_value(),
   1.702 +            LLVMValue::jint_constant(24)),
   1.703 +          LLVMValue::jint_constant(24)), false));
   1.704 +      break;
   1.705 +    case Bytecodes::_i2c:
   1.706 +      push(SharkValue::create_jint(
   1.707 +        builder()->CreateAnd(
   1.708 +            pop()->jint_value(),
   1.709 +            LLVMValue::jint_constant(0xffff)), false));
   1.710 +      break;
   1.711 +    case Bytecodes::_i2s:
   1.712 +      push(SharkValue::create_jint(
   1.713 +        builder()->CreateAShr(
   1.714 +          builder()->CreateShl(
   1.715 +            pop()->jint_value(),
   1.716 +            LLVMValue::jint_constant(16)),
   1.717 +          LLVMValue::jint_constant(16)), false));
   1.718 +      break;
   1.719 +
   1.720 +    case Bytecodes::_return:
   1.721 +      do_return(T_VOID);
   1.722 +      break;
   1.723 +    case Bytecodes::_ireturn:
   1.724 +      do_return(T_INT);
   1.725 +      break;
   1.726 +    case Bytecodes::_lreturn:
   1.727 +      do_return(T_LONG);
   1.728 +      break;
   1.729 +    case Bytecodes::_freturn:
   1.730 +      do_return(T_FLOAT);
   1.731 +      break;
   1.732 +    case Bytecodes::_dreturn:
   1.733 +      do_return(T_DOUBLE);
   1.734 +      break;
   1.735 +    case Bytecodes::_areturn:
   1.736 +      do_return(T_OBJECT);
   1.737 +      break;
   1.738 +
   1.739 +    case Bytecodes::_athrow:
   1.740 +      do_athrow();
   1.741 +      break;
   1.742 +
   1.743 +    case Bytecodes::_goto:
   1.744 +    case Bytecodes::_goto_w:
   1.745 +      do_goto();
   1.746 +      break;
   1.747 +
   1.748 +    case Bytecodes::_jsr:
   1.749 +    case Bytecodes::_jsr_w:
   1.750 +      do_jsr();
   1.751 +      break;
   1.752 +
   1.753 +    case Bytecodes::_ret:
   1.754 +      do_ret();
   1.755 +      break;
   1.756 +
   1.757 +    case Bytecodes::_ifnull:
   1.758 +      do_if(ICmpInst::ICMP_EQ, SharkValue::null(), pop());
   1.759 +      break;
   1.760 +    case Bytecodes::_ifnonnull:
   1.761 +      do_if(ICmpInst::ICMP_NE, SharkValue::null(), pop());
   1.762 +      break;
   1.763 +    case Bytecodes::_if_acmpeq:
   1.764 +      b = pop();
   1.765 +      a = pop();
   1.766 +      do_if(ICmpInst::ICMP_EQ, b, a);
   1.767 +      break;
   1.768 +    case Bytecodes::_if_acmpne:
   1.769 +      b = pop();
   1.770 +      a = pop();
   1.771 +      do_if(ICmpInst::ICMP_NE, b, a);
   1.772 +      break;
   1.773 +    case Bytecodes::_ifeq:
   1.774 +      do_if(ICmpInst::ICMP_EQ, SharkValue::jint_constant(0), pop());
   1.775 +      break;
   1.776 +    case Bytecodes::_ifne:
   1.777 +      do_if(ICmpInst::ICMP_NE, SharkValue::jint_constant(0), pop());
   1.778 +      break;
   1.779 +    case Bytecodes::_iflt:
   1.780 +      do_if(ICmpInst::ICMP_SLT, SharkValue::jint_constant(0), pop());
   1.781 +      break;
   1.782 +    case Bytecodes::_ifle:
   1.783 +      do_if(ICmpInst::ICMP_SLE, SharkValue::jint_constant(0), pop());
   1.784 +      break;
   1.785 +    case Bytecodes::_ifgt:
   1.786 +      do_if(ICmpInst::ICMP_SGT, SharkValue::jint_constant(0), pop());
   1.787 +      break;
   1.788 +    case Bytecodes::_ifge:
   1.789 +      do_if(ICmpInst::ICMP_SGE, SharkValue::jint_constant(0), pop());
   1.790 +      break;
   1.791 +    case Bytecodes::_if_icmpeq:
   1.792 +      b = pop();
   1.793 +      a = pop();
   1.794 +      do_if(ICmpInst::ICMP_EQ, b, a);
   1.795 +      break;
   1.796 +    case Bytecodes::_if_icmpne:
   1.797 +      b = pop();
   1.798 +      a = pop();
   1.799 +      do_if(ICmpInst::ICMP_NE, b, a);
   1.800 +      break;
   1.801 +    case Bytecodes::_if_icmplt:
   1.802 +      b = pop();
   1.803 +      a = pop();
   1.804 +      do_if(ICmpInst::ICMP_SLT, b, a);
   1.805 +      break;
   1.806 +    case Bytecodes::_if_icmple:
   1.807 +      b = pop();
   1.808 +      a = pop();
   1.809 +      do_if(ICmpInst::ICMP_SLE, b, a);
   1.810 +      break;
   1.811 +    case Bytecodes::_if_icmpgt:
   1.812 +      b = pop();
   1.813 +      a = pop();
   1.814 +      do_if(ICmpInst::ICMP_SGT, b, a);
   1.815 +      break;
   1.816 +    case Bytecodes::_if_icmpge:
   1.817 +      b = pop();
   1.818 +      a = pop();
   1.819 +      do_if(ICmpInst::ICMP_SGE, b, a);
   1.820 +      break;
   1.821 +
   1.822 +    case Bytecodes::_tableswitch:
   1.823 +    case Bytecodes::_lookupswitch:
   1.824 +      do_switch();
   1.825 +      break;
   1.826 +
   1.827 +    case Bytecodes::_invokestatic:
   1.828 +    case Bytecodes::_invokespecial:
   1.829 +    case Bytecodes::_invokevirtual:
   1.830 +    case Bytecodes::_invokeinterface:
   1.831 +      do_call();
   1.832 +      break;
   1.833 +
   1.834 +    case Bytecodes::_instanceof:
   1.835 +      // This is a very common construct:
   1.836 +      //
   1.837 +      //  if (object instanceof Klass) {
   1.838 +      //    something = (Klass) object;
   1.839 +      //    ...
   1.840 +      //  }
   1.841 +      //
   1.842 +      // which gets compiled to something like this:
   1.843 +      //
   1.844 +      //  28: aload 9
   1.845 +      //  30: instanceof <Class Klass>
   1.846 +      //  33: ifeq 52
   1.847 +      //  36: aload 9
   1.848 +      //  38: checkcast <Class Klass>
   1.849 +      //
   1.850 +      // Handling both bytecodes at once allows us
   1.851 +      // to eliminate the checkcast.
   1.852 +      if (iter()->next_bci() < limit &&
   1.853 +          (iter()->next_bc() == Bytecodes::_ifeq ||
   1.854 +           iter()->next_bc() == Bytecodes::_ifne) &&
   1.855 +          (!UseLoopSafepoints ||
   1.856 +           iter()->next_get_dest() > iter()->next_bci())) {
   1.857 +        if (maybe_do_instanceof_if()) {
   1.858 +          iter()->next();
   1.859 +          if (SharkTraceBytecodes)
   1.860 +            tty->print_cr("%4d: %s", bci(), Bytecodes::name(bc()));
   1.861 +          break;
   1.862 +        }
   1.863 +      }
   1.864 +      // fall through
   1.865 +    case Bytecodes::_checkcast:
   1.866 +      do_instance_check();
   1.867 +      break;
   1.868 +
   1.869 +    case Bytecodes::_new:
   1.870 +      do_new();
   1.871 +      break;
   1.872 +    case Bytecodes::_newarray:
   1.873 +      do_newarray();
   1.874 +      break;
   1.875 +    case Bytecodes::_anewarray:
   1.876 +      do_anewarray();
   1.877 +      break;
   1.878 +    case Bytecodes::_multianewarray:
   1.879 +      do_multianewarray();
   1.880 +      break;
   1.881 +
   1.882 +    case Bytecodes::_monitorenter:
   1.883 +      do_monitorenter();
   1.884 +      break;
   1.885 +    case Bytecodes::_monitorexit:
   1.886 +      do_monitorexit();
   1.887 +      break;
   1.888 +
   1.889 +    default:
   1.890 +      ShouldNotReachHere();
   1.891 +    }
   1.892 +  }
   1.893 +}
   1.894 +
   1.895 +SharkState* SharkBlock::initial_current_state() {
   1.896 +  return entry_state()->copy();
   1.897 +}
   1.898 +
   1.899 +int SharkBlock::switch_default_dest() {
   1.900 +  return iter()->get_dest_table(0);
   1.901 +}
   1.902 +
   1.903 +int SharkBlock::switch_table_length() {
   1.904 +  switch(bc()) {
   1.905 +  case Bytecodes::_tableswitch:
   1.906 +    return iter()->get_int_table(2) - iter()->get_int_table(1) + 1;
   1.907 +
   1.908 +  case Bytecodes::_lookupswitch:
   1.909 +    return iter()->get_int_table(1);
   1.910 +
   1.911 +  default:
   1.912 +    ShouldNotReachHere();
   1.913 +  }
   1.914 +}
   1.915 +
   1.916 +int SharkBlock::switch_key(int i) {
   1.917 +  switch(bc()) {
   1.918 +  case Bytecodes::_tableswitch:
   1.919 +    return iter()->get_int_table(1) + i;
   1.920 +
   1.921 +  case Bytecodes::_lookupswitch:
   1.922 +    return iter()->get_int_table(2 + 2 * i);
   1.923 +
   1.924 +  default:
   1.925 +    ShouldNotReachHere();
   1.926 +  }
   1.927 +}
   1.928 +
   1.929 +int SharkBlock::switch_dest(int i) {
   1.930 +  switch(bc()) {
   1.931 +  case Bytecodes::_tableswitch:
   1.932 +    return iter()->get_dest_table(i + 3);
   1.933 +
   1.934 +  case Bytecodes::_lookupswitch:
   1.935 +    return iter()->get_dest_table(2 + 2 * i + 1);
   1.936 +
   1.937 +  default:
   1.938 +    ShouldNotReachHere();
   1.939 +  }
   1.940 +}
   1.941 +
   1.942 +void SharkBlock::do_div_or_rem(bool is_long, bool is_rem) {
   1.943 +  SharkValue *sb = pop();
   1.944 +  SharkValue *sa = pop();
   1.945 +
   1.946 +  check_divide_by_zero(sb);
   1.947 +
   1.948 +  Value *a, *b, *p, *q;
   1.949 +  if (is_long) {
   1.950 +    a = sa->jlong_value();
   1.951 +    b = sb->jlong_value();
   1.952 +    p = LLVMValue::jlong_constant(0x8000000000000000LL);
   1.953 +    q = LLVMValue::jlong_constant(-1);
   1.954 +  }
   1.955 +  else {
   1.956 +    a = sa->jint_value();
   1.957 +    b = sb->jint_value();
   1.958 +    p = LLVMValue::jint_constant(0x80000000);
   1.959 +    q = LLVMValue::jint_constant(-1);
   1.960 +  }
   1.961 +
   1.962 +  BasicBlock *ip           = builder()->GetBlockInsertionPoint();
   1.963 +  BasicBlock *special_case = builder()->CreateBlock(ip, "special_case");
   1.964 +  BasicBlock *general_case = builder()->CreateBlock(ip, "general_case");
   1.965 +  BasicBlock *done         = builder()->CreateBlock(ip, "done");
   1.966 +
   1.967 +  builder()->CreateCondBr(
   1.968 +    builder()->CreateAnd(
   1.969 +      builder()->CreateICmpEQ(a, p),
   1.970 +      builder()->CreateICmpEQ(b, q)),
   1.971 +    special_case, general_case);
   1.972 +
   1.973 +  builder()->SetInsertPoint(special_case);
   1.974 +  Value *special_result;
   1.975 +  if (is_rem) {
   1.976 +    if (is_long)
   1.977 +      special_result = LLVMValue::jlong_constant(0);
   1.978 +    else
   1.979 +      special_result = LLVMValue::jint_constant(0);
   1.980 +  }
   1.981 +  else {
   1.982 +    special_result = a;
   1.983 +  }
   1.984 +  builder()->CreateBr(done);
   1.985 +
   1.986 +  builder()->SetInsertPoint(general_case);
   1.987 +  Value *general_result;
   1.988 +  if (is_rem)
   1.989 +    general_result = builder()->CreateSRem(a, b);
   1.990 +  else
   1.991 +    general_result = builder()->CreateSDiv(a, b);
   1.992 +  builder()->CreateBr(done);
   1.993 +
   1.994 +  builder()->SetInsertPoint(done);
   1.995 +  PHINode *result;
   1.996 +  if (is_long)
   1.997 +    result = builder()->CreatePHI(SharkType::jlong_type(), "result");
   1.998 +  else
   1.999 +    result = builder()->CreatePHI(SharkType::jint_type(), "result");
  1.1000 +  result->addIncoming(special_result, special_case);
  1.1001 +  result->addIncoming(general_result, general_case);
  1.1002 +
  1.1003 +  if (is_long)
  1.1004 +    push(SharkValue::create_jlong(result, false));
  1.1005 +  else
  1.1006 +    push(SharkValue::create_jint(result, false));
  1.1007 +}
  1.1008 +
  1.1009 +void SharkBlock::do_field_access(bool is_get, bool is_field) {
  1.1010 +  bool will_link;
  1.1011 +  ciField *field = iter()->get_field(will_link);
  1.1012 +  assert(will_link, "typeflow responsibility");
  1.1013 +  assert(is_field != field->is_static(), "mismatch");
  1.1014 +
  1.1015 +  // Pop the value off the stack where necessary
  1.1016 +  SharkValue *value = NULL;
  1.1017 +  if (!is_get)
  1.1018 +    value = pop();
  1.1019 +
  1.1020 +  // Find the object we're accessing, if necessary
  1.1021 +  Value *object = NULL;
  1.1022 +  if (is_field) {
  1.1023 +    SharkValue *value = pop();
  1.1024 +    check_null(value);
  1.1025 +    object = value->generic_value();
  1.1026 +  }
  1.1027 +  if (is_get && field->is_constant()) {
  1.1028 +    SharkConstant *constant = SharkConstant::for_field(iter());
  1.1029 +    if (constant->is_loaded())
  1.1030 +      value = constant->value(builder());
  1.1031 +  }
  1.1032 +  if (!is_get || value == NULL) {
  1.1033 +    if (!is_field)
  1.1034 +      object = builder()->CreateInlineOop(field->holder());
  1.1035 +
  1.1036 +    BasicType   basic_type = field->type()->basic_type();
  1.1037 +    const Type *stack_type = SharkType::to_stackType(basic_type);
  1.1038 +    const Type *field_type = SharkType::to_arrayType(basic_type);
  1.1039 +
  1.1040 +    Value *addr = builder()->CreateAddressOfStructEntry(
  1.1041 +      object, in_ByteSize(field->offset_in_bytes()),
  1.1042 +      PointerType::getUnqual(field_type),
  1.1043 +      "addr");
  1.1044 +
  1.1045 +    // Do the access
  1.1046 +    if (is_get) {
  1.1047 +      Value *field_value = builder()->CreateLoad(addr);
  1.1048 +
  1.1049 +      if (field_type != stack_type) {
  1.1050 +        field_value = builder()->CreateIntCast(
  1.1051 +          field_value, stack_type, basic_type != T_CHAR);
  1.1052 +      }
  1.1053 +
  1.1054 +      value = SharkValue::create_generic(field->type(), field_value, false);
  1.1055 +    }
  1.1056 +    else {
  1.1057 +      Value *field_value = value->generic_value();
  1.1058 +
  1.1059 +      if (field_type != stack_type) {
  1.1060 +        field_value = builder()->CreateIntCast(
  1.1061 +          field_value, field_type, basic_type != T_CHAR);
  1.1062 +      }
  1.1063 +
  1.1064 +      builder()->CreateStore(field_value, addr);
  1.1065 +
  1.1066 +      if (!field->type()->is_primitive_type())
  1.1067 +        builder()->CreateUpdateBarrierSet(oopDesc::bs(), addr);
  1.1068 +
  1.1069 +      if (field->is_volatile())
  1.1070 +        builder()->CreateMemoryBarrier(SharkBuilder::BARRIER_STORELOAD);
  1.1071 +    }
  1.1072 +  }
  1.1073 +
  1.1074 +  // Push the value onto the stack where necessary
  1.1075 +  if (is_get)
  1.1076 +    push(value);
  1.1077 +}
  1.1078 +
  1.1079 +void SharkBlock::do_lcmp() {
  1.1080 +  Value *b = pop()->jlong_value();
  1.1081 +  Value *a = pop()->jlong_value();
  1.1082 +
  1.1083 +  BasicBlock *ip   = builder()->GetBlockInsertionPoint();
  1.1084 +  BasicBlock *ne   = builder()->CreateBlock(ip, "lcmp_ne");
  1.1085 +  BasicBlock *lt   = builder()->CreateBlock(ip, "lcmp_lt");
  1.1086 +  BasicBlock *gt   = builder()->CreateBlock(ip, "lcmp_gt");
  1.1087 +  BasicBlock *done = builder()->CreateBlock(ip, "done");
  1.1088 +
  1.1089 +  BasicBlock *eq = builder()->GetInsertBlock();
  1.1090 +  builder()->CreateCondBr(builder()->CreateICmpEQ(a, b), done, ne);
  1.1091 +
  1.1092 +  builder()->SetInsertPoint(ne);
  1.1093 +  builder()->CreateCondBr(builder()->CreateICmpSLT(a, b), lt, gt);
  1.1094 +
  1.1095 +  builder()->SetInsertPoint(lt);
  1.1096 +  builder()->CreateBr(done);
  1.1097 +
  1.1098 +  builder()->SetInsertPoint(gt);
  1.1099 +  builder()->CreateBr(done);
  1.1100 +
  1.1101 +  builder()->SetInsertPoint(done);
  1.1102 +  PHINode *result = builder()->CreatePHI(SharkType::jint_type(), "result");
  1.1103 +  result->addIncoming(LLVMValue::jint_constant(-1), lt);
  1.1104 +  result->addIncoming(LLVMValue::jint_constant(0),  eq);
  1.1105 +  result->addIncoming(LLVMValue::jint_constant(1),  gt);
  1.1106 +
  1.1107 +  push(SharkValue::create_jint(result, false));
  1.1108 +}
  1.1109 +
  1.1110 +void SharkBlock::do_fcmp(bool is_double, bool unordered_is_greater) {
  1.1111 +  Value *a, *b;
  1.1112 +  if (is_double) {
  1.1113 +    b = pop()->jdouble_value();
  1.1114 +    a = pop()->jdouble_value();
  1.1115 +  }
  1.1116 +  else {
  1.1117 +    b = pop()->jfloat_value();
  1.1118 +    a = pop()->jfloat_value();
  1.1119 +  }
  1.1120 +
  1.1121 +  BasicBlock *ip      = builder()->GetBlockInsertionPoint();
  1.1122 +  BasicBlock *ordered = builder()->CreateBlock(ip, "ordered");
  1.1123 +  BasicBlock *ge      = builder()->CreateBlock(ip, "fcmp_ge");
  1.1124 +  BasicBlock *lt      = builder()->CreateBlock(ip, "fcmp_lt");
  1.1125 +  BasicBlock *eq      = builder()->CreateBlock(ip, "fcmp_eq");
  1.1126 +  BasicBlock *gt      = builder()->CreateBlock(ip, "fcmp_gt");
  1.1127 +  BasicBlock *done    = builder()->CreateBlock(ip, "done");
  1.1128 +
  1.1129 +  builder()->CreateCondBr(
  1.1130 +    builder()->CreateFCmpUNO(a, b),
  1.1131 +    unordered_is_greater ? gt : lt, ordered);
  1.1132 +
  1.1133 +  builder()->SetInsertPoint(ordered);
  1.1134 +  builder()->CreateCondBr(builder()->CreateFCmpULT(a, b), lt, ge);
  1.1135 +
  1.1136 +  builder()->SetInsertPoint(ge);
  1.1137 +  builder()->CreateCondBr(builder()->CreateFCmpUGT(a, b), gt, eq);
  1.1138 +
  1.1139 +  builder()->SetInsertPoint(lt);
  1.1140 +  builder()->CreateBr(done);
  1.1141 +
  1.1142 +  builder()->SetInsertPoint(gt);
  1.1143 +  builder()->CreateBr(done);
  1.1144 +
  1.1145 +  builder()->SetInsertPoint(eq);
  1.1146 +  builder()->CreateBr(done);
  1.1147 +
  1.1148 +  builder()->SetInsertPoint(done);
  1.1149 +  PHINode *result = builder()->CreatePHI(SharkType::jint_type(), "result");
  1.1150 +  result->addIncoming(LLVMValue::jint_constant(-1), lt);
  1.1151 +  result->addIncoming(LLVMValue::jint_constant(0),  eq);
  1.1152 +  result->addIncoming(LLVMValue::jint_constant(1),  gt);
  1.1153 +
  1.1154 +  push(SharkValue::create_jint(result, false));
  1.1155 +}
  1.1156 +
  1.1157 +void SharkBlock::emit_IR() {
  1.1158 +  ShouldNotCallThis();
  1.1159 +}
  1.1160 +
  1.1161 +SharkState* SharkBlock::entry_state() {
  1.1162 +  ShouldNotCallThis();
  1.1163 +}
  1.1164 +
  1.1165 +void SharkBlock::do_zero_check(SharkValue* value) {
  1.1166 +  ShouldNotCallThis();
  1.1167 +}
  1.1168 +
  1.1169 +void SharkBlock::maybe_add_backedge_safepoint() {
  1.1170 +  ShouldNotCallThis();
  1.1171 +}
  1.1172 +
  1.1173 +bool SharkBlock::has_trap() {
  1.1174 +  return false;
  1.1175 +}
  1.1176 +
  1.1177 +int SharkBlock::trap_request() {
  1.1178 +  ShouldNotCallThis();
  1.1179 +}
  1.1180 +
  1.1181 +int SharkBlock::trap_bci() {
  1.1182 +  ShouldNotCallThis();
  1.1183 +}
  1.1184 +
  1.1185 +void SharkBlock::do_trap(int trap_request) {
  1.1186 +  ShouldNotCallThis();
  1.1187 +}
  1.1188 +
  1.1189 +void SharkBlock::do_arraylength() {
  1.1190 +  ShouldNotCallThis();
  1.1191 +}
  1.1192 +
  1.1193 +void SharkBlock::do_aload(BasicType basic_type) {
  1.1194 +  ShouldNotCallThis();
  1.1195 +}
  1.1196 +
  1.1197 +void SharkBlock::do_astore(BasicType basic_type) {
  1.1198 +  ShouldNotCallThis();
  1.1199 +}
  1.1200 +
  1.1201 +void SharkBlock::do_return(BasicType type) {
  1.1202 +  ShouldNotCallThis();
  1.1203 +}
  1.1204 +
  1.1205 +void SharkBlock::do_athrow() {
  1.1206 +  ShouldNotCallThis();
  1.1207 +}
  1.1208 +
  1.1209 +void SharkBlock::do_goto() {
  1.1210 +  ShouldNotCallThis();
  1.1211 +}
  1.1212 +
  1.1213 +void SharkBlock::do_jsr() {
  1.1214 +  ShouldNotCallThis();
  1.1215 +}
  1.1216 +
  1.1217 +void SharkBlock::do_ret() {
  1.1218 +  ShouldNotCallThis();
  1.1219 +}
  1.1220 +
  1.1221 +void SharkBlock::do_if(ICmpInst::Predicate p, SharkValue* b, SharkValue* a) {
  1.1222 +  ShouldNotCallThis();
  1.1223 +}
  1.1224 +
  1.1225 +void SharkBlock::do_switch() {
  1.1226 +  ShouldNotCallThis();
  1.1227 +}
  1.1228 +
  1.1229 +void SharkBlock::do_call() {
  1.1230 +  ShouldNotCallThis();
  1.1231 +}
  1.1232 +
  1.1233 +void SharkBlock::do_instance_check() {
  1.1234 +  ShouldNotCallThis();
  1.1235 +}
  1.1236 +
  1.1237 +bool SharkBlock::maybe_do_instanceof_if() {
  1.1238 +  ShouldNotCallThis();
  1.1239 +}
  1.1240 +
  1.1241 +void SharkBlock::do_new() {
  1.1242 +  ShouldNotCallThis();
  1.1243 +}
  1.1244 +
  1.1245 +void SharkBlock::do_newarray() {
  1.1246 +  ShouldNotCallThis();
  1.1247 +}
  1.1248 +
  1.1249 +void SharkBlock::do_anewarray() {
  1.1250 +  ShouldNotCallThis();
  1.1251 +}
  1.1252 +
  1.1253 +void SharkBlock::do_multianewarray() {
  1.1254 +  ShouldNotCallThis();
  1.1255 +}
  1.1256 +
  1.1257 +void SharkBlock::do_monitorenter() {
  1.1258 +  ShouldNotCallThis();
  1.1259 +}
  1.1260 +
  1.1261 +void SharkBlock::do_monitorexit() {
  1.1262 +  ShouldNotCallThis();
  1.1263 +}

mercurial