< prev index next >

src/share/vm/runtime/javaCalls.hpp

Print this page




  86   bool             is_first_frame() const   { return _anchor.last_Java_sp() == NULL; }
  87 
  88 };
  89 
  90 
  91 // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args)
  92 class JavaCallArguments : public StackObj {
  93  private:
  94   enum Constants {
  95    _default_size = 8    // Must be at least # of arguments in JavaCalls methods
  96   };
  97 
  98   intptr_t    _value_buffer [_default_size + 1];
  99   bool        _is_oop_buffer[_default_size + 1];
 100 
 101   intptr_t*   _value;
 102   bool*       _is_oop;
 103   int         _size;
 104   int         _max_size;
 105   bool        _start_at_zero;      // Support late setting of receiver

 106 
 107   void initialize() {
 108     // Starts at first element to support set_receiver.
 109     _value    = &_value_buffer[1];
 110     _is_oop   = &_is_oop_buffer[1];
 111 
 112     _max_size = _default_size;
 113     _size = 0;
 114     _start_at_zero = false;

 115   }
 116 
 117  public:
 118   JavaCallArguments() { initialize(); }
 119 
 120   JavaCallArguments(Handle receiver) {
 121     initialize();
 122     push_oop(receiver);
 123   }
 124 
 125   JavaCallArguments(int max_size) {
 126     if (max_size > _default_size) {
 127       _value  = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
 128       _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1);
 129 
 130       // Reserve room for potential receiver in value and is_oop
 131       _value++; _is_oop++;
 132 
 133       _max_size = max_size;
 134       _size = 0;
 135       _start_at_zero = false;

 136     } else {
 137       initialize();
 138     }
 139   }
 140 










 141   inline void push_oop(Handle h)    { _is_oop[_size] = true;
 142                                JNITypes::put_obj((oop)h.raw_value(), _value, _size); }
 143 
 144   inline void push_int(int i)       { _is_oop[_size] = false;
 145                                JNITypes::put_int(i, _value, _size); }
 146 
 147   inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false;
 148                                JNITypes::put_double(d, _value, _size); }
 149 
 150   inline void push_long(jlong l)    { _is_oop[_size] = false; _is_oop[_size + 1] = false;
 151                                JNITypes::put_long(l, _value, _size); }
 152 
 153   inline void push_float(float f)   { _is_oop[_size] = false;
 154                                JNITypes::put_float(f, _value, _size); }
 155 
 156   // receiver
 157   Handle receiver() {
 158     assert(_size > 0, "must at least be one argument");
 159     assert(_is_oop[0], "first argument must be an oop");
 160     assert(_value[0] != 0, "receiver must be not-null");




  86   bool             is_first_frame() const   { return _anchor.last_Java_sp() == NULL; }
  87 
  88 };
  89 
  90 
  91 // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args)
  92 class JavaCallArguments : public StackObj {
  93  private:
  94   enum Constants {
  95    _default_size = 8    // Must be at least # of arguments in JavaCalls methods
  96   };
  97 
  98   intptr_t    _value_buffer [_default_size + 1];
  99   bool        _is_oop_buffer[_default_size + 1];
 100 
 101   intptr_t*   _value;
 102   bool*       _is_oop;
 103   int         _size;
 104   int         _max_size;
 105   bool        _start_at_zero;      // Support late setting of receiver
 106   JVMCI_ONLY(nmethod*    _alternative_target;) // Nmethod that should be called instead of normal target
 107 
 108   void initialize() {
 109     // Starts at first element to support set_receiver.
 110     _value    = &_value_buffer[1];
 111     _is_oop   = &_is_oop_buffer[1];
 112 
 113     _max_size = _default_size;
 114     _size = 0;
 115     _start_at_zero = false;
 116     JVMCI_ONLY(_alternative_target = NULL;)
 117   }
 118 
 119  public:
 120   JavaCallArguments() { initialize(); }
 121 
 122   JavaCallArguments(Handle receiver) {
 123     initialize();
 124     push_oop(receiver);
 125   }
 126 
 127   JavaCallArguments(int max_size) {
 128     if (max_size > _default_size) {
 129       _value  = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1);
 130       _is_oop = NEW_RESOURCE_ARRAY(bool, max_size + 1);
 131 
 132       // Reserve room for potential receiver in value and is_oop
 133       _value++; _is_oop++;
 134 
 135       _max_size = max_size;
 136       _size = 0;
 137       _start_at_zero = false;
 138       JVMCI_ONLY(_alternative_target = NULL;)
 139     } else {
 140       initialize();
 141     }
 142   }
 143 
 144 #if INCLUDE_JVMCI
 145   void set_alternative_target(nmethod* target) {
 146     _alternative_target = target;
 147   }
 148 
 149   nmethod* alternative_target() {
 150     return _alternative_target;
 151   }
 152 #endif
 153 
 154   inline void push_oop(Handle h)    { _is_oop[_size] = true;
 155                                JNITypes::put_obj((oop)h.raw_value(), _value, _size); }
 156 
 157   inline void push_int(int i)       { _is_oop[_size] = false;
 158                                JNITypes::put_int(i, _value, _size); }
 159 
 160   inline void push_double(double d) { _is_oop[_size] = false; _is_oop[_size + 1] = false;
 161                                JNITypes::put_double(d, _value, _size); }
 162 
 163   inline void push_long(jlong l)    { _is_oop[_size] = false; _is_oop[_size + 1] = false;
 164                                JNITypes::put_long(l, _value, _size); }
 165 
 166   inline void push_float(float f)   { _is_oop[_size] = false;
 167                                JNITypes::put_float(f, _value, _size); }
 168 
 169   // receiver
 170   Handle receiver() {
 171     assert(_size > 0, "must at least be one argument");
 172     assert(_is_oop[0], "first argument must be an oop");
 173     assert(_value[0] != 0, "receiver must be not-null");


< prev index next >