71 bool is_first_frame() const { return _anchor.last_Java_sp() == NULL; } 72 73 }; 74 75 76 // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args) 77 class JavaCallArguments : public StackObj { 78 private: 79 enum Constants { 80 _default_size = 8 // Must be at least # of arguments in JavaCalls methods 81 }; 82 83 intptr_t _value_buffer [_default_size + 1]; 84 u_char _value_state_buffer[_default_size + 1]; 85 86 intptr_t* _value; 87 u_char* _value_state; 88 int _size; 89 int _max_size; 90 bool _start_at_zero; // Support late setting of receiver 91 JVMCI_ONLY(nmethod* _alternative_target;) // Nmethod that should be called instead of normal target 92 93 void initialize() { 94 // Starts at first element to support set_receiver. 95 _value = &_value_buffer[1]; 96 _value_state = &_value_state_buffer[1]; 97 98 _max_size = _default_size; 99 _size = 0; 100 _start_at_zero = false; 101 JVMCI_ONLY(_alternative_target = NULL;) 102 } 103 104 // Helper for push_oop and the like. The value argument is a 105 // "handle" that refers to an oop. We record the address of the 106 // handle rather than the designated oop. The handle is later 107 // resolved to the oop by parameters(). This delays the exposure of 108 // naked oops until it is GC-safe. 109 template<typename T> 110 inline int push_oop_impl(T handle, int size) { 111 // JNITypes::put_obj expects an oop value, so we play fast and 112 // loose with the type system. The cast from handle type to oop 113 // *must* use a C-style cast. In a product build it performs a 114 // reinterpret_cast. In a debug build (more accurately, in a 115 // CHECK_UNHANDLED_OOPS build) it performs a static_cast, invoking 116 // the debug-only oop class's conversion from void* constructor. 117 JNITypes::put_obj((oop)handle, _value, size); // Updates size. 118 return size; // Return the updated size. 119 } 120 121 public: 122 JavaCallArguments() { initialize(); } 123 124 JavaCallArguments(Handle receiver) { 125 initialize(); 126 push_oop(receiver); 127 } 128 129 JavaCallArguments(int max_size) { 130 if (max_size > _default_size) { 131 _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1); 132 _value_state = NEW_RESOURCE_ARRAY(u_char, max_size + 1); 133 134 // Reserve room for potential receiver in value and state 135 _value++; 136 _value_state++; 137 138 _max_size = max_size; 139 _size = 0; 140 _start_at_zero = false; 141 JVMCI_ONLY(_alternative_target = NULL;) 142 } else { 143 initialize(); 144 } 145 } 146 147 #if INCLUDE_JVMCI 148 void set_alternative_target(nmethod* target) { 149 _alternative_target = target; 150 } 151 152 nmethod* alternative_target() { 153 return _alternative_target; 154 } 155 #endif 156 157 // The possible values for _value_state elements. 158 enum { 159 value_state_primitive, 160 value_state_oop, 161 value_state_handle, 162 value_state_jobject, 163 value_state_limit 164 }; 165 166 inline void push_oop(Handle h) { 167 _value_state[_size] = value_state_handle; 168 _size = push_oop_impl(h.raw_value(), _size); 169 } 170 171 inline void push_jobject(jobject h) { 172 _value_state[_size] = value_state_jobject; | 71 bool is_first_frame() const { return _anchor.last_Java_sp() == NULL; } 72 73 }; 74 75 76 // Encapsulates arguments to a JavaCall (faster, safer, and more convenient than using var-args) 77 class JavaCallArguments : public StackObj { 78 private: 79 enum Constants { 80 _default_size = 8 // Must be at least # of arguments in JavaCalls methods 81 }; 82 83 intptr_t _value_buffer [_default_size + 1]; 84 u_char _value_state_buffer[_default_size + 1]; 85 86 intptr_t* _value; 87 u_char* _value_state; 88 int _size; 89 int _max_size; 90 bool _start_at_zero; // Support late setting of receiver 91 #if INCLUDE_JVMCI 92 Handle _alternative_target; // HotSpotNmethod wrapping an nmethod whose verified entry point 93 // should be called instead of the normal target 94 #endif 95 96 void initialize() { 97 // Starts at first element to support set_receiver. 98 _value = &_value_buffer[1]; 99 _value_state = &_value_state_buffer[1]; 100 101 _max_size = _default_size; 102 _size = 0; 103 _start_at_zero = false; 104 } 105 106 // Helper for push_oop and the like. The value argument is a 107 // "handle" that refers to an oop. We record the address of the 108 // handle rather than the designated oop. The handle is later 109 // resolved to the oop by parameters(). This delays the exposure of 110 // naked oops until it is GC-safe. 111 template<typename T> 112 inline int push_oop_impl(T handle, int size) { 113 // JNITypes::put_obj expects an oop value, so we play fast and 114 // loose with the type system. The cast from handle type to oop 115 // *must* use a C-style cast. In a product build it performs a 116 // reinterpret_cast. In a debug build (more accurately, in a 117 // CHECK_UNHANDLED_OOPS build) it performs a static_cast, invoking 118 // the debug-only oop class's conversion from void* constructor. 119 JNITypes::put_obj((oop)handle, _value, size); // Updates size. 120 return size; // Return the updated size. 121 } 122 123 public: 124 JavaCallArguments() { initialize(); } 125 126 JavaCallArguments(Handle receiver) { 127 initialize(); 128 push_oop(receiver); 129 } 130 131 JavaCallArguments(int max_size) { 132 if (max_size > _default_size) { 133 _value = NEW_RESOURCE_ARRAY(intptr_t, max_size + 1); 134 _value_state = NEW_RESOURCE_ARRAY(u_char, max_size + 1); 135 136 // Reserve room for potential receiver in value and state 137 _value++; 138 _value_state++; 139 140 _max_size = max_size; 141 _size = 0; 142 _start_at_zero = false; 143 } else { 144 initialize(); 145 } 146 } 147 148 #if INCLUDE_JVMCI 149 void set_alternative_target(Handle target) { 150 _alternative_target = target; 151 } 152 153 Handle alternative_target() { 154 return _alternative_target; 155 } 156 #endif 157 158 // The possible values for _value_state elements. 159 enum { 160 value_state_primitive, 161 value_state_oop, 162 value_state_handle, 163 value_state_jobject, 164 value_state_limit 165 }; 166 167 inline void push_oop(Handle h) { 168 _value_state[_size] = value_state_handle; 169 _size = push_oop_impl(h.raw_value(), _size); 170 } 171 172 inline void push_jobject(jobject h) { 173 _value_state[_size] = value_state_jobject; |