src/share/vm/opto/library_call.cpp

changeset 2602
41d4973cf100
parent 2314
f95d63e2154a
child 2606
0ac769a57c64
     1.1 --- a/src/share/vm/opto/library_call.cpp	Thu Feb 24 14:49:34 2011 -0800
     1.2 +++ b/src/share/vm/opto/library_call.cpp	Sat Feb 26 12:10:54 2011 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     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 @@ -1193,7 +1193,7 @@
    1.11    Node* result;
    1.12    // Disable the use of pcmpestri until it can be guaranteed that
    1.13    // the load doesn't cross into the uncommited space.
    1.14 -  if (false && Matcher::has_match_rule(Op_StrIndexOf) &&
    1.15 +  if (Matcher::has_match_rule(Op_StrIndexOf) &&
    1.16        UseSSE42Intrinsics) {
    1.17      // Generate SSE4.2 version of indexOf
    1.18      // We currently only have match rules that use SSE4.2
    1.19 @@ -1211,14 +1211,14 @@
    1.20        return true;
    1.21      }
    1.22  
    1.23 +    ciInstanceKlass* str_klass = env()->String_klass();
    1.24 +    const TypeOopPtr* string_type = TypeOopPtr::make_from_klass(str_klass);
    1.25 +
    1.26      // Make the merge point
    1.27 -    RegionNode* result_rgn = new (C, 3) RegionNode(3);
    1.28 -    Node*       result_phi = new (C, 3) PhiNode(result_rgn, TypeInt::INT);
    1.29 +    RegionNode* result_rgn = new (C, 4) RegionNode(4);
    1.30 +    Node*       result_phi = new (C, 4) PhiNode(result_rgn, TypeInt::INT);
    1.31      Node* no_ctrl  = NULL;
    1.32  
    1.33 -    ciInstanceKlass* klass = env()->String_klass();
    1.34 -    const TypeOopPtr* string_type = TypeOopPtr::make_from_klass(klass);
    1.35 -
    1.36      // Get counts for string and substr
    1.37      Node* source_cnta = basic_plus_adr(receiver, receiver, count_offset);
    1.38      Node* source_cnt  = make_load(no_ctrl, source_cnta, TypeInt::INT, T_INT, string_type->add_offset(count_offset));
    1.39 @@ -1236,6 +1236,17 @@
    1.40      }
    1.41  
    1.42      if (!stopped()) {
    1.43 +      // Check for substr count == 0
    1.44 +      cmp = _gvn.transform( new(C, 3) CmpINode(substr_cnt, intcon(0)) );
    1.45 +      bol = _gvn.transform( new(C, 2) BoolNode(cmp, BoolTest::eq) );
    1.46 +      Node* if_zero = generate_slow_guard(bol, NULL);
    1.47 +      if (if_zero != NULL) {
    1.48 +        result_phi->init_req(3, intcon(0));
    1.49 +        result_rgn->init_req(3, if_zero);
    1.50 +      }
    1.51 +    }
    1.52 +
    1.53 +    if (!stopped()) {
    1.54        result = make_string_method_node(Op_StrIndexOf, receiver, source_cnt, argument, substr_cnt);
    1.55        result_phi->init_req(1, result);
    1.56        result_rgn->init_req(1, control());
    1.57 @@ -1244,8 +1255,8 @@
    1.58      record_for_igvn(result_rgn);
    1.59      result = _gvn.transform(result_phi);
    1.60  
    1.61 -  } else { //Use LibraryCallKit::string_indexOf
    1.62 -    // don't intrinsify is argument isn't a constant string.
    1.63 +  } else { // Use LibraryCallKit::string_indexOf
    1.64 +    // don't intrinsify if argument isn't a constant string.
    1.65      if (!argument->is_Con()) {
    1.66       return false;
    1.67      }
    1.68 @@ -1281,7 +1292,7 @@
    1.69      // No null check on the argument is needed since it's a constant String oop.
    1.70      _sp -= 2;
    1.71      if (stopped()) {
    1.72 -     return true;
    1.73 +      return true;
    1.74      }
    1.75  
    1.76      // The null string as a pattern always returns 0 (match at beginning of string)

mercurial