Print this page
rev 1026 : imported patch indy.compiler.inline.patch

Split Close
Expand all
Collapse all
          --- old/src/share/vm/runtime/frame.cpp
          +++ new/src/share/vm/runtime/frame.cpp
   1    1  /*
   2      - * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
        2 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 749 lines elided ↑ open up ↑
 762  762      }
 763  763    }
 764  764  
 765  765    int max_locals()  { return _max_locals; }
 766  766    frame* fr()       { return _fr; }
 767  767  };
 768  768  
 769  769  
 770  770  class InterpretedArgumentOopFinder: public SignatureInfo {
 771  771   private:
 772      -  OopClosure* _f;      // Closure to invoke
 773      -  int    _offset;      // TOS-relative offset, decremented with each argument
 774      -  bool   _is_static;   // true if the callee is a static method
      772 +  OopClosure* _f;        // Closure to invoke
      773 +  int    _offset;        // TOS-relative offset, decremented with each argument
      774 +  bool   _has_receiver;  // true if the callee has a receiver
 775  775    frame* _fr;
 776  776  
 777  777    void set(int size, BasicType type) {
 778  778      _offset -= size;
 779  779      if (type == T_OBJECT || type == T_ARRAY) oop_offset_do();
 780  780    }
 781  781  
 782  782    void oop_offset_do() {
 783  783      oop* addr;
 784  784      addr = (oop*)_fr->interpreter_frame_tos_at(_offset);
 785  785      _f->do_oop(addr);
 786  786    }
 787  787  
 788  788   public:
 789      -  InterpretedArgumentOopFinder(symbolHandle signature, bool is_static, frame* fr, OopClosure* f) : SignatureInfo(signature) {
      789 +  InterpretedArgumentOopFinder(symbolHandle signature, bool has_receiver, frame* fr, OopClosure* f) : SignatureInfo(signature), _has_receiver(has_receiver) {
 790  790      // compute size of arguments
 791      -    int args_size = ArgumentSizeComputer(signature).size() + (is_static ? 0 : 1);
      791 +    int args_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
 792  792      assert(!fr->is_interpreted_frame() ||
 793  793             args_size <= fr->interpreter_frame_expression_stack_size(),
 794  794              "args cannot be on stack anymore");
 795  795      // initialize InterpretedArgumentOopFinder
 796  796      _f         = f;
 797  797      _fr        = fr;
 798  798      _offset    = args_size;
 799      -    _is_static = is_static;
 800  799    }
 801  800  
 802  801    void oops_do() {
 803      -    if (!_is_static) {
      802 +    if (_has_receiver) {
 804  803        --_offset;
 805  804        oop_offset_do();
 806  805      }
 807  806      iterate_parameters();
 808  807    }
 809  808  };
 810  809  
 811  810  
 812  811  // Entry frame has following form (n arguments)
 813  812  //         +-----------+
↓ open down ↓ 91 lines elided ↑ open up ↑
 905  904  #ifdef CC_INTERP
 906  905      f->do_oop((oop*)&istate->_oop_temp);
 907  906  #else
 908  907      f->do_oop((oop*)( fp() + interpreter_frame_oop_temp_offset ));
 909  908  #endif /* CC_INTERP */
 910  909    }
 911  910  
 912  911    int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals();
 913  912  
 914  913    symbolHandle signature;
 915      -  bool is_static = false;
      914 +  bool has_receiver = false;
 916  915  
 917  916    // Process a callee's arguments if we are at a call site
 918  917    // (i.e., if we are at an invoke bytecode)
 919  918    // This is used sometimes for calling into the VM, not for another
 920  919    // interpreted or compiled frame.
 921  920    if (!m->is_native()) {
 922  921      Bytecode_invoke *call = Bytecode_invoke_at_check(m, bci);
 923  922      if (call != NULL) {
 924  923        signature = symbolHandle(thread, call->signature());
 925      -      is_static = call->is_invokestatic();
      924 +      has_receiver = call->has_receiver();
 926  925        if (map->include_argument_oops() &&
 927  926            interpreter_frame_expression_stack_size() > 0) {
 928  927          ResourceMark rm(thread);  // is this right ???
 929  928          // we are at a call site & the expression stack is not empty
 930  929          // => process callee's arguments
 931  930          //
 932  931          // Note: The expression stack can be empty if an exception
 933  932          //       occurred during method resolution/execution. In all
 934  933          //       cases we empty the expression stack completely be-
 935  934          //       fore handling the exception (the exception handling
 936  935          //       code in the interpreter calls a blocking runtime
 937  936          //       routine which can cause this code to be executed).
 938  937          //       (was bug gri 7/27/98)
 939      -        oops_interpreted_arguments_do(signature, is_static, f);
      938 +        oops_interpreted_arguments_do(signature, has_receiver, f);
 940  939        }
 941  940      }
 942  941    }
 943  942  
 944  943    if (TaggedStackInterpreter) {
 945  944      // process locals & expression stack
 946  945      InterpreterOopMap *mask = NULL;
 947  946  #ifdef ASSERT
 948  947      InterpreterOopMap oopmap_mask;
 949  948      OopMapCache::compute_one_oop_map(m, bci, &oopmap_mask);
 950  949      mask = &oopmap_mask;
 951  950  #endif // ASSERT
 952  951      oops_interpreted_locals_do(f, max_locals, mask);
 953      -    oops_interpreted_expressions_do(f, signature, is_static,
      952 +    oops_interpreted_expressions_do(f, signature, has_receiver,
 954  953                                      m->max_stack(),
 955  954                                      max_locals, mask);
 956  955    } else {
 957  956      InterpreterFrameClosure blk(this, max_locals, m->max_stack(), f);
 958  957  
 959  958      // process locals & expression stack
 960  959      InterpreterOopMap mask;
 961  960      if (query_oop_map_cache) {
 962  961        m->mask_for(bci, &mask);
 963  962      } else {
↓ open down ↓ 21 lines elided ↑ open up ↑
 985  984        // Not always true - too bad.  May have dead oops without tags in locals.
 986  985        // assert(*p == NULL || !(*p)->is_oop(), "oop not tagged on interpreter locals");
 987  986        assert(*p == NULL || !mask->is_oop(i), "local oop map mismatch");
 988  987  #endif // ASSERT
 989  988      }
 990  989    }
 991  990  }
 992  991  
 993  992  void frame::oops_interpreted_expressions_do(OopClosure *f,
 994  993                                        symbolHandle signature,
 995      -                                      bool is_static,
      994 +                                      bool has_receiver,
 996  995                                        int max_stack,
 997  996                                        int max_locals,
 998  997                                        InterpreterOopMap *mask) {
 999  998    // There is no stack no matter what the esp is pointing to (native methods
1000  999    // might look like expression stack is nonempty).
1001 1000    if (max_stack == 0) return;
1002 1001  
1003 1002    // Point the top of the expression stack above arguments to a call so
1004 1003    // arguments aren't gc'ed as both stack values for callee and callee
1005 1004    // arguments in callee's locals.
1006 1005    int args_size = 0;
1007 1006    if (!signature.is_null()) {
1008      -    args_size = ArgumentSizeComputer(signature).size() + (is_static ? 0 : 1);
     1007 +    args_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
1009 1008    }
1010 1009  
1011 1010    intptr_t *tos_addr = interpreter_frame_tos_at(args_size);
1012 1011    assert(args_size != 0 || tos_addr == interpreter_frame_tos_address(), "these are same");
1013 1012    intptr_t *frst_expr = interpreter_frame_expression_stack_at(0);
1014 1013    // In case of exceptions, the expression stack is invalid and the esp
1015 1014    // will be reset to express this condition. Therefore, we call f only
1016 1015    // if addr is 'inside' the stack (i.e., addr >= esp for Intel).
1017 1016    bool in_stack;
1018 1017    if (interpreter_frame_expression_stack_direction() > 0) {
↓ open down ↓ 12 lines elided ↑ open up ↑
1031 1030  #ifdef ASSERT
1032 1031      } else {
1033 1032        assert(tag == TagValue, "bad tag value for stack element");
1034 1033        oop *p = (oop*) interpreter_frame_expression_stack_at((j));
1035 1034        assert(*p == NULL || !mask->is_oop(j+max_locals), "stack oop map mismatch");
1036 1035  #endif // ASSERT
1037 1036      }
1038 1037    }
1039 1038  }
1040 1039  
1041      -void frame::oops_interpreted_arguments_do(symbolHandle signature, bool is_static, OopClosure* f) {
1042      -  InterpretedArgumentOopFinder finder(signature, is_static, this, f);
     1040 +void frame::oops_interpreted_arguments_do(symbolHandle signature, bool has_receiver, OopClosure* f) {
     1041 +  InterpretedArgumentOopFinder finder(signature, has_receiver, this, f);
1043 1042    finder.oops_do();
1044 1043  }
1045 1044  
1046 1045  void frame::oops_code_blob_do(OopClosure* f, CodeBlobClosure* cf, const RegisterMap* reg_map) {
1047 1046    assert(_cb != NULL, "sanity check");
1048 1047    if (_cb->oop_maps() != NULL) {
1049 1048      OopMapSet::oops_do(this, reg_map, f);
1050 1049  
1051 1050      // Preserve potential arguments for a callee. We handle this by dispatching
1052 1051      // on the codeblob. For c2i, we do
↓ open down ↓ 6 lines elided ↑ open up ↑
1059 1058    // prevent them from being collected. However, this visit should be
1060 1059    // restricted to certain phases of the collection only. The
1061 1060    // closure decides how it wants nmethods to be traced.
1062 1061    if (cf != NULL)
1063 1062      cf->do_code_blob(_cb);
1064 1063  }
1065 1064  
1066 1065  class CompiledArgumentOopFinder: public SignatureInfo {
1067 1066   protected:
1068 1067    OopClosure*     _f;
1069      -  int             _offset;      // the current offset, incremented with each argument
1070      -  bool            _is_static;   // true if the callee is a static method
     1068 +  int             _offset;        // the current offset, incremented with each argument
     1069 +  bool            _has_receiver;  // true if the callee has a receiver
1071 1070    frame           _fr;
1072 1071    RegisterMap*    _reg_map;
1073 1072    int             _arg_size;
1074 1073    VMRegPair*      _regs;        // VMReg list of arguments
1075 1074  
1076 1075    void set(int size, BasicType type) {
1077 1076      if (type == T_OBJECT || type == T_ARRAY) handle_oop_offset();
1078 1077      _offset += size;
1079 1078    }
1080 1079  
1081 1080    virtual void handle_oop_offset() {
1082 1081      // Extract low order register number from register array.
1083 1082      // In LP64-land, the high-order bits are valid but unhelpful.
1084 1083      VMReg reg = _regs[_offset].first();
1085 1084      oop *loc = _fr.oopmapreg_to_location(reg, _reg_map);
1086 1085      _f->do_oop(loc);
1087 1086    }
1088 1087  
1089 1088   public:
1090      -  CompiledArgumentOopFinder(symbolHandle signature, bool is_static, OopClosure* f, frame fr,  const RegisterMap* reg_map)
     1089 +  CompiledArgumentOopFinder(symbolHandle signature, bool has_receiver, OopClosure* f, frame fr,  const RegisterMap* reg_map)
1091 1090      : SignatureInfo(signature) {
1092 1091  
1093 1092      // initialize CompiledArgumentOopFinder
1094 1093      _f         = f;
1095 1094      _offset    = 0;
1096      -    _is_static = is_static;
     1095 +    _has_receiver = has_receiver;
1097 1096      _fr        = fr;
1098 1097      _reg_map   = (RegisterMap*)reg_map;
1099      -    _arg_size  = ArgumentSizeComputer(signature).size() + (is_static ? 0 : 1);
     1098 +    _arg_size  = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
1100 1099  
1101 1100      int arg_size;
1102      -    _regs = SharedRuntime::find_callee_arguments(signature(), is_static, &arg_size);
     1101 +    _regs = SharedRuntime::find_callee_arguments(signature(), has_receiver, &arg_size);
1103 1102      assert(arg_size == _arg_size, "wrong arg size");
1104 1103    }
1105 1104  
1106 1105    void oops_do() {
1107      -    if (!_is_static) {
     1106 +    if (_has_receiver) {
1108 1107        handle_oop_offset();
1109 1108        _offset++;
1110 1109      }
1111 1110      iterate_parameters();
1112 1111    }
1113 1112  };
1114 1113  
1115      -void frame::oops_compiled_arguments_do(symbolHandle signature, bool is_static, const RegisterMap* reg_map, OopClosure* f) {
     1114 +void frame::oops_compiled_arguments_do(symbolHandle signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f) {
1116 1115    ResourceMark rm;
1117      -  CompiledArgumentOopFinder finder(signature, is_static, f, *this, reg_map);
     1116 +  CompiledArgumentOopFinder finder(signature, has_receiver, f, *this, reg_map);
1118 1117    finder.oops_do();
1119 1118  }
1120 1119  
1121 1120  
1122 1121  // Get receiver out of callers frame, i.e. find parameter 0 in callers
1123 1122  // frame.  Consult ADLC for where parameter 0 is to be found.  Then
1124 1123  // check local reg_map for it being a callee-save register or argument
1125 1124  // register, both of which are saved in the local frame.  If not found
1126 1125  // there, it must be an in-stack argument of the caller.
1127 1126  // Note: caller.sp() points to callee-arguments
↓ open down ↓ 267 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX