src/share/vm/shark/sharkTopLevelBlock.cpp

changeset 4314
2cd5e15048e6
parent 4037
da91efe96a93
child 4442
c566b81b3323
     1.1 --- a/src/share/vm/shark/sharkTopLevelBlock.cpp	Mon Nov 26 17:25:11 2012 -0800
     1.2 +++ b/src/share/vm/shark/sharkTopLevelBlock.cpp	Tue Nov 27 12:48:52 2012 -0800
     1.3 @@ -65,6 +65,7 @@
     1.4      switch (bc()) {
     1.5      case Bytecodes::_ldc:
     1.6      case Bytecodes::_ldc_w:
     1.7 +    case Bytecodes::_ldc2_w:
     1.8        if (!SharkConstant::for_ldc(iter())->is_loaded()) {
     1.9          set_trap(
    1.10            Deoptimization::make_trap_request(
    1.11 @@ -109,7 +110,8 @@
    1.12      case Bytecodes::_invokespecial:
    1.13      case Bytecodes::_invokevirtual:
    1.14      case Bytecodes::_invokeinterface:
    1.15 -      method = iter()->get_method(will_link);
    1.16 +      ciSignature* sig;
    1.17 +      method = iter()->get_method(will_link, &sig);
    1.18        assert(will_link, "typeflow responsibility");
    1.19  
    1.20        if (!method->holder()->is_linked()) {
    1.21 @@ -562,12 +564,12 @@
    1.22    Value *exception_klass = builder()->CreateValueOfStructEntry(
    1.23      xstack(0)->jobject_value(),
    1.24      in_ByteSize(oopDesc::klass_offset_in_bytes()),
    1.25 -    SharkType::oop_type(),
    1.26 +    SharkType::klass_type(),
    1.27      "exception_klass");
    1.28  
    1.29    for (int i = 0; i < num_options; i++) {
    1.30      Value *check_klass =
    1.31 -      builder()->CreateInlineOop(exc_handler(i)->catch_klass());
    1.32 +      builder()->CreateInlineMetadata(exc_handler(i)->catch_klass(), SharkType::klass_type());
    1.33  
    1.34      BasicBlock *not_exact   = function()->CreateBlock("not_exact");
    1.35      BasicBlock *not_subtype = function()->CreateBlock("not_subtype");
    1.36 @@ -823,7 +825,7 @@
    1.37      builder()->CreateArrayAddress(
    1.38        array->jarray_value(), basic_type, index->jint_value()));
    1.39  
    1.40 -  const Type *stack_type = SharkType::to_stackType(basic_type);
    1.41 +  Type *stack_type = SharkType::to_stackType(basic_type);
    1.42    if (value->getType() != stack_type)
    1.43      value = builder()->CreateIntCast(value, stack_type, basic_type != T_CHAR);
    1.44  
    1.45 @@ -910,7 +912,7 @@
    1.46      ShouldNotReachHere();
    1.47    }
    1.48  
    1.49 -  const Type *array_type = SharkType::to_arrayType(basic_type);
    1.50 +  Type *array_type = SharkType::to_arrayType(basic_type);
    1.51    if (value->getType() != array_type)
    1.52      value = builder()->CreateIntCast(value, array_type, basic_type != T_CHAR);
    1.53  
    1.54 @@ -1102,9 +1104,9 @@
    1.55  
    1.56  Value *SharkTopLevelBlock::get_direct_callee(ciMethod* method) {
    1.57    return builder()->CreateBitCast(
    1.58 -    builder()->CreateInlineOop(method),
    1.59 -    SharkType::Method*_type(),
    1.60 -    "callee");
    1.61 +    builder()->CreateInlineMetadata(method, SharkType::Method_type()),
    1.62 +                                    SharkType::Method_type(),
    1.63 +                                    "callee");
    1.64  }
    1.65  
    1.66  Value *SharkTopLevelBlock::get_virtual_callee(SharkValue* receiver,
    1.67 @@ -1118,7 +1120,7 @@
    1.68    return builder()->CreateLoad(
    1.69      builder()->CreateArrayAddress(
    1.70        klass,
    1.71 -      SharkType::Method*_type(),
    1.72 +      SharkType::Method_type(),
    1.73        vtableEntry::size() * wordSize,
    1.74        in_ByteSize(InstanceKlass::vtable_start_offset() * wordSize),
    1.75        LLVMValue::intptr_constant(vtable_index)),
    1.76 @@ -1136,7 +1138,7 @@
    1.77    // Locate the receiver's itable
    1.78    Value *object_klass = builder()->CreateValueOfStructEntry(
    1.79      receiver->jobject_value(), in_ByteSize(oopDesc::klass_offset_in_bytes()),
    1.80 -    SharkType::oop_type(),
    1.81 +    SharkType::klass_type(),
    1.82      "object_klass");
    1.83  
    1.84    Value *vtable_start = builder()->CreateAdd(
    1.85 @@ -1169,12 +1171,12 @@
    1.86    }
    1.87  
    1.88    // Locate this interface's entry in the table
    1.89 -  Value *iklass = builder()->CreateInlineOop(method->holder());
    1.90 +  Value *iklass = builder()->CreateInlineMetadata(method->holder(), SharkType::klass_type());
    1.91    BasicBlock *loop_entry = builder()->GetInsertBlock();
    1.92    builder()->CreateBr(loop);
    1.93    builder()->SetInsertPoint(loop);
    1.94    PHINode *itable_entry_addr = builder()->CreatePHI(
    1.95 -    SharkType::intptr_type(), "itable_entry_addr");
    1.96 +    SharkType::intptr_type(), 0, "itable_entry_addr");
    1.97    itable_entry_addr->addIncoming(itable_start, loop_entry);
    1.98  
    1.99    Value *itable_entry = builder()->CreateIntToPtr(
   1.100 @@ -1183,11 +1185,11 @@
   1.101    Value *itable_iklass = builder()->CreateValueOfStructEntry(
   1.102      itable_entry,
   1.103      in_ByteSize(itableOffsetEntry::interface_offset_in_bytes()),
   1.104 -    SharkType::oop_type(),
   1.105 +    SharkType::klass_type(),
   1.106      "itable_iklass");
   1.107  
   1.108    builder()->CreateCondBr(
   1.109 -    builder()->CreateICmpEQ(itable_iklass, LLVMValue::null()),
   1.110 +    builder()->CreateICmpEQ(itable_iklass, LLVMValue::nullKlass()),
   1.111      got_null, not_null);
   1.112  
   1.113    // A null entry means that the class doesn't implement the
   1.114 @@ -1231,7 +1233,7 @@
   1.115              method->itable_index() * itableMethodEntry::size() * wordSize)),
   1.116          LLVMValue::intptr_constant(
   1.117            itableMethodEntry::method_offset_in_bytes())),
   1.118 -      PointerType::getUnqual(SharkType::Method*_type())),
   1.119 +      PointerType::getUnqual(SharkType::Method_type())),
   1.120      "callee");
   1.121  }
   1.122  
   1.123 @@ -1243,7 +1245,9 @@
   1.124  
   1.125    // Find the method being called
   1.126    bool will_link;
   1.127 -  ciMethod *dest_method = iter()->get_method(will_link);
   1.128 +  ciSignature* sig;
   1.129 +  ciMethod *dest_method = iter()->get_method(will_link, &sig);
   1.130 +
   1.131    assert(will_link, "typeflow responsibility");
   1.132    assert(dest_method->is_static() == is_static, "must match bc");
   1.133  
   1.134 @@ -1259,10 +1263,17 @@
   1.135    assert(holder_klass->is_interface() ||
   1.136           holder_klass->super() == NULL ||
   1.137           !is_interface, "must match bc");
   1.138 +
   1.139 +  bool is_forced_virtual = is_interface && holder_klass == java_lang_Object_klass();
   1.140 +
   1.141    ciKlass *holder = iter()->get_declared_method_holder();
   1.142    ciInstanceKlass *klass =
   1.143      ciEnv::get_instance_klass_for_declared_method_holder(holder);
   1.144  
   1.145 +  if (is_forced_virtual) {
   1.146 +    klass = java_lang_Object_klass();
   1.147 +  }
   1.148 +
   1.149    // Find the receiver in the stack.  We do this before
   1.150    // trying to inline because the inliner can only use
   1.151    // zero-checked values, not being able to perform the
   1.152 @@ -1294,7 +1305,7 @@
   1.153    // Find the method we are calling
   1.154    Value *callee;
   1.155    if (call_is_virtual) {
   1.156 -    if (is_virtual) {
   1.157 +    if (is_virtual || is_forced_virtual) {
   1.158        assert(klass->is_linked(), "scan_for_traps responsibility");
   1.159        int vtable_index = call_method->resolve_vtable_index(
   1.160          target()->holder(), klass);
   1.161 @@ -1490,12 +1501,12 @@
   1.162  
   1.163    // Get the class we're checking against
   1.164    builder()->SetInsertPoint(not_null);
   1.165 -  Value *check_klass = builder()->CreateInlineOop(klass);
   1.166 +  Value *check_klass = builder()->CreateInlineMetadata(klass, SharkType::klass_type());
   1.167  
   1.168    // Get the class of the object being tested
   1.169    Value *object_klass = builder()->CreateValueOfStructEntry(
   1.170      object, in_ByteSize(oopDesc::klass_offset_in_bytes()),
   1.171 -    SharkType::oop_type(),
   1.172 +    SharkType::klass_type(),
   1.173      "object_klass");
   1.174  
   1.175    // Perform the check
   1.176 @@ -1520,7 +1531,7 @@
   1.177    // First merge
   1.178    builder()->SetInsertPoint(merge1);
   1.179    PHINode *nonnull_result = builder()->CreatePHI(
   1.180 -    SharkType::jint_type(), "nonnull_result");
   1.181 +    SharkType::jint_type(), 0, "nonnull_result");
   1.182    nonnull_result->addIncoming(
   1.183      LLVMValue::jint_constant(IC_IS_INSTANCE), is_instance);
   1.184    nonnull_result->addIncoming(
   1.185 @@ -1531,7 +1542,7 @@
   1.186    // Second merge
   1.187    builder()->SetInsertPoint(merge2);
   1.188    PHINode *result = builder()->CreatePHI(
   1.189 -    SharkType::jint_type(), "result");
   1.190 +    SharkType::jint_type(), 0, "result");
   1.191    result->addIncoming(LLVMValue::jint_constant(IC_IS_NULL), null_block);
   1.192    result->addIncoming(nonnull_result, nonnull_block);
   1.193  
   1.194 @@ -1698,7 +1709,7 @@
   1.195      heap_object = builder()->CreateIntToPtr(
   1.196        old_top, SharkType::oop_type(), "heap_object");
   1.197  
   1.198 -    Value *check = builder()->CreateCmpxchgPtr(new_top, top_addr, old_top);
   1.199 +    Value *check = builder()->CreateAtomicCmpXchg(top_addr, old_top, new_top, llvm::SequentiallyConsistent);
   1.200      builder()->CreateCondBr(
   1.201        builder()->CreateICmpEQ(old_top, check),
   1.202        initialize, retry);
   1.203 @@ -1707,7 +1718,7 @@
   1.204      builder()->SetInsertPoint(initialize);
   1.205      if (tlab_object) {
   1.206        PHINode *phi = builder()->CreatePHI(
   1.207 -        SharkType::oop_type(), "fast_object");
   1.208 +        SharkType::oop_type(), 0, "fast_object");
   1.209        phi->addIncoming(tlab_object, got_tlab);
   1.210        phi->addIncoming(heap_object, got_heap);
   1.211        fast_object = phi;
   1.212 @@ -1730,7 +1741,7 @@
   1.213  
   1.214      Value *klass_addr = builder()->CreateAddressOfStructEntry(
   1.215        fast_object, in_ByteSize(oopDesc::klass_offset_in_bytes()),
   1.216 -      PointerType::getUnqual(SharkType::oop_type()),
   1.217 +      PointerType::getUnqual(SharkType::klass_type()),
   1.218        "klass_addr");
   1.219  
   1.220      // Set the mark
   1.221 @@ -1744,7 +1755,7 @@
   1.222      builder()->CreateStore(LLVMValue::intptr_constant(mark), mark_addr);
   1.223  
   1.224      // Set the class
   1.225 -    Value *rtklass = builder()->CreateInlineOop(klass);
   1.226 +    Value *rtklass = builder()->CreateInlineMetadata(klass, SharkType::klass_type());
   1.227      builder()->CreateStore(rtklass, klass_addr);
   1.228      got_fast = builder()->GetInsertBlock();
   1.229  
   1.230 @@ -1767,7 +1778,7 @@
   1.231      builder()->SetInsertPoint(push_object);
   1.232    }
   1.233    if (fast_object) {
   1.234 -    PHINode *phi = builder()->CreatePHI(SharkType::oop_type(), "object");
   1.235 +    PHINode *phi = builder()->CreatePHI(SharkType::oop_type(), 0, "object");
   1.236      phi->addIncoming(fast_object, got_fast);
   1.237      phi->addIncoming(slow_object, got_slow);
   1.238      object = phi;
   1.239 @@ -1849,8 +1860,9 @@
   1.240  
   1.241  void SharkTopLevelBlock::acquire_method_lock() {
   1.242    Value *lockee;
   1.243 -  if (target()->is_static())
   1.244 +  if (target()->is_static()) {
   1.245      lockee = builder()->CreateInlineOop(target()->holder()->java_mirror());
   1.246 +  }
   1.247    else
   1.248      lockee = local(0)->jobject_value();
   1.249  
   1.250 @@ -1898,7 +1910,7 @@
   1.251  
   1.252    Value *lock = builder()->CreatePtrToInt(
   1.253      monitor_header_addr, SharkType::intptr_type());
   1.254 -  Value *check = builder()->CreateCmpxchgPtr(lock, mark_addr, disp);
   1.255 +  Value *check = builder()->CreateAtomicCmpXchg(mark_addr, disp, lock, llvm::Acquire);
   1.256    builder()->CreateCondBr(
   1.257      builder()->CreateICmpEQ(disp, check),
   1.258      acquired_fast, try_recursive);
   1.259 @@ -1983,7 +1995,7 @@
   1.260      PointerType::getUnqual(SharkType::intptr_type()),
   1.261      "mark_addr");
   1.262  
   1.263 -  Value *check = builder()->CreateCmpxchgPtr(disp, mark_addr, lock);
   1.264 +  Value *check = builder()->CreateAtomicCmpXchg(mark_addr, lock, disp, llvm::Release);
   1.265    builder()->CreateCondBr(
   1.266      builder()->CreateICmpEQ(lock, check),
   1.267      released_fast, slow_path);

mercurial