diff -u -r ./hotspot/src_/share/vm/prims/jvmtiEnv.cpp ./hotspot/src/share/vm/pri - Pastebin.com (original) (raw)

  1. diff -u -r ./hotspot/src_/share/vm/prims/jvmtiEnv.cpp ./hotspot/src/share/vm/prims/jvmtiEnv.cpp
  2. --- ./hotspot/src_/share/vm/prims/jvmtiEnv.cpp 2013-12-19 01:10:36.297992000 +0100
  3. +++ ./hotspot/src/share/vm/prims/jvmtiEnv.cpp 2014-02-10 14:52:14.734339000 +0100
  4. @@ -1982,6 +1982,106 @@
  5. //
  6. + // Operand Stack functions
  7. + //
  8. +// Threads_lock NOT held, java_thread not protected by lock
  9. +// java_thread - pre-checked
  10. +// java_thread - unchecked
  11. +// depth - pre-checked as non-negative
  12. +// value_ptr - pre-checked for NULL
  13. +jvmtiError
  14. +JvmtiEnv::GetOperandObject(JavaThread* java_thread, jint depth, jint slot, jobject* value_ptr) {
  15. + JavaThread* current_thread = JavaThread::current();
  16. + // rm object is created to clean up the javaVFrame created in
  17. + // doit_prologue(), but after doit() is finished with it.
  18. + ResourceMark rm(current_thread);
  19. + VM_GetOperand op(java_thread, current_thread, depth, slot);
  20. + VMThread::execute(&op);
  21. + jvmtiError err = op.result();
  22. + if (err != JVMTI_ERROR_NONE) {
  23. + return err;
  24. + } else {
  25. + *value_ptr = op.value().l;
  26. + return JVMTI_ERROR_NONE;
  27. + }
  28. +} /* end GetOperandObject */
  29. +// Threads_lock NOT held, java_thread not protected by lock
  30. +// java_thread - pre-checked
  31. +// java_thread - unchecked
  32. +// depth - pre-checked as non-negative
  33. +// value_ptr - pre-checked for NULL
  34. +jvmtiError
  35. +JvmtiEnv::GetOperandInt(JavaThread* java_thread, jint depth, jint slot, jint* value_ptr) {
  36. + // rm object is created to clean up the javaVFrame created in
  37. + // doit_prologue(), but after doit() is finished with it.
  38. + ResourceMark rm;
  39. + VM_GetOperand op(java_thread, depth, slot, T_INT);
  40. + VMThread::execute(&op);
  41. + *value_ptr = op.value().i;
  42. + return op.result();
  43. +} /* end GetOperandInt */
  44. +// Threads_lock NOT held, java_thread not protected by lock
  45. +// java_thread - pre-checked
  46. +// java_thread - unchecked
  47. +// depth - pre-checked as non-negative
  48. +// value_ptr - pre-checked for NULL
  49. +jvmtiError
  50. +JvmtiEnv::GetOperandLong(JavaThread* java_thread, jint depth, jint slot, jlong* value_ptr) {
  51. + // rm object is created to clean up the javaVFrame created in
  52. + // doit_prologue(), but after doit() is finished with it.
  53. + ResourceMark rm;
  54. + VM_GetOperand op(java_thread, depth, slot, T_LONG);
  55. + VMThread::execute(&op);
  56. + *value_ptr = op.value().j;
  57. + return op.result();
  58. +} /* end GetOperandLong */
  59. +// Threads_lock NOT held, java_thread not protected by lock
  60. +// java_thread - pre-checked
  61. +// java_thread - unchecked
  62. +// depth - pre-checked as non-negative
  63. +// value_ptr - pre-checked for NULL
  64. +jvmtiError
  65. +JvmtiEnv::GetOperandFloat(JavaThread* java_thread, jint depth, jint slot, jfloat* value_ptr) {
  66. + // rm object is created to clean up the javaVFrame created in
  67. + // doit_prologue(), but after doit() is finished with it.
  68. + ResourceMark rm;
  69. + VM_GetOperand op(java_thread, depth, slot, T_FLOAT);
  70. + VMThread::execute(&op);
  71. + *value_ptr = op.value().f;
  72. + return op.result();
  73. +} /* end GetOperandFloat */
  74. +// Threads_lock NOT held, java_thread not protected by lock
  75. +// java_thread - pre-checked
  76. +// java_thread - unchecked
  77. +// depth - pre-checked as non-negative
  78. +// value_ptr - pre-checked for NULL
  79. +jvmtiError
  80. +JvmtiEnv::GetOperandDouble(JavaThread* java_thread, jint depth, jint slot, jdouble* value_ptr) {
  81. + // rm object is created to clean up the javaVFrame created in
  82. + // doit_prologue(), but after doit() is finished with it.
  83. + ResourceMark rm;
  84. + VM_GetOperand op(java_thread, depth, slot, T_DOUBLE);
  85. + VMThread::execute(&op);
  86. + *value_ptr = op.value().d;
  87. + return op.result();
  88. +} /* end GetOperandDouble */
  89. + //
  90. // Breakpoint functions
  91. //
  92. diff -u -r ./hotspot/src_/share/vm/prims/jvmtiImpl.cpp ./hotspot/src/share/vm/prims/jvmtiImpl.cpp
  93. --- ./hotspot/src_/share/vm/prims/jvmtiImpl.cpp 2013-12-19 01:10:36.309992000 +0100
  94. +++ ./hotspot/src/share/vm/prims/jvmtiImpl.cpp 2014-02-10 14:57:14.350344000 +0100
  95. @@ -827,6 +827,147 @@
  96. JavaThread* thread, JavaThread* caller_thread, jint depth)
  97. : VM_GetOrSetLocal(thread, caller_thread, depth, 0) {}
  98. +///////////////////////////////////////////////////////////////
  99. +//
  100. +// class VM_GetOperand
  101. +//
  102. +// Constructor for non-object getter
  103. +VM_GetOperand::VM_GetOperand(JavaThread* thread, jint depth, int index, BasicType type)
  104. + : _thread(thread)
  105. + , _calling_thread(NULL)
  106. + , _depth(depth)
  107. + , _index(index)
  108. + , _type(type)
  109. + , _jvf(NULL)
  110. + , _result(JVMTI_ERROR_NONE)
  111. +{
  112. +}
  113. +// Constructor for object getter
  114. +VM_GetOperand::VM_GetOperand(JavaThread* thread, JavaThread* calling_thread, jint depth, int index)
  115. + : _thread(thread)
  116. + , _calling_thread(calling_thread)
  117. + , _depth(depth)
  118. + , _index(index)
  119. + , _type(T_OBJECT)
  120. + , _jvf(NULL)
  121. + , _result(JVMTI_ERROR_NONE)
  122. +{
  123. +}
  124. +vframe *VM_GetOperand::get_vframe() {
  125. + if (!_thread->has_last_Java_frame()) {
  126. + return NULL;
  127. + }
  128. + RegisterMap reg_map(_thread);
  129. + vframe *vf = _thread->last_java_vframe(&reg_map);
  130. + int d = 0;
  131. + while ((vf != NULL) && (d < _depth)) {
  132. + vf = vf->java_sender();
  133. + d++;
  134. + }
  135. + return vf;
  136. +}
  137. +javaVFrame *VM_GetOperand::get_java_vframe() {
  138. + vframe* vf = get_vframe();
  139. + if (vf == NULL) {
  140. + _result = JVMTI_ERROR_NO_MORE_FRAMES;
  141. + return NULL;
  142. + }
  143. + javaVFrame *jvf = (javaVFrame*)vf;
  144. + if (!vf->is_java_frame()) {
  145. + _result = JVMTI_ERROR_OPAQUE_FRAME;
  146. + return NULL;
  147. + }
  148. + return jvf;
  149. +}
  150. +// Checks error conditions:
  151. +// JVMTI_ERROR_INVALID_SLOT
  152. +// Returns: 'true' - everything is Ok, 'false' - error code
  153. +bool VM_GetOperand::check_slot_type(javaVFrame* jvf) {
  154. + // index checking
  155. + StackValueCollection *expressions = _jvf->expressions();
  156. + jint size = expressions->size();
  157. + size -= (_type == T_LONG || _type == T_DOUBLE) ? 1 : 0;
  158. +
  159. + if (_index < 0 || _index >= size) {
  160. + _result = JVMTI_ERROR_INVALID_SLOT;
  161. + return false;
  162. + }
  163. +
  164. + // FIXME insert proper type-checking code here
  165. +
  166. + return true;
  167. +}
  168. +bool VM_GetOperand::doit_prologue() {
  169. + _jvf = get_java_vframe();
  170. + NULL_CHECK(_jvf, false);
  171. + if (_jvf->method()->is_native()) {
  172. + if (getting_receiver() && !_jvf->method()->is_static()) {
  173. + return true;
  174. + } else {
  175. + _result = JVMTI_ERROR_OPAQUE_FRAME;
  176. + return false;
  177. + }
  178. + }
  179. + if (!check_slot_type(_jvf)) {
  180. + return false;
  181. + }
  182. + return true;
  183. +}
  184. +void VM_GetOperand::doit() {
  185. + // get
  186. + if (_jvf->method()->is_native() && _jvf->is_compiled_frame()) {
  187. + assert(getting_receiver(), "Can only get here when getting receiver");
  188. + oop receiver = _jvf->fr().get_native_receiver();
  189. + _value.l = JNIHandles::make_local(_calling_thread, receiver);
  190. + } else {
  191. + StackValueCollection *expressions = _jvf->expressions();
  192. + if (expressions->at(_index)->type() == T_CONFLICT) {
  193. + memset(&_value, 0, sizeof(_value));
  194. + _value.l = NULL;
  195. + return;
  196. + }
  197. + switch (_type) {
  198. + case T_INT: _value.i = expressions->int_at (_index); break;
  199. + case T_LONG: _value.j = expressions->long_at (_index); break;
  200. + case T_FLOAT: _value.f = expressions->float_at (_index); break;
  201. + case T_DOUBLE: _value.d = expressions->double_at(_index); break;
  202. + case T_OBJECT: {
  203. + // Wrap the oop to be returned in a local JNI handle since
  204. + // oops_do() no longer applies after doit() is finished.
  205. + intptr_t temp = expressions->at(_index)->get_int();
  206. + intptr_t *addr = &temp;
  207. + _value.l = JNIHandles::make_local(_calling_thread, *(oop *)addr);
  208. + break;
  209. + }
  210. + default: ShouldNotReachHere();
  211. + }
  212. + }
  213. +}
  214. +bool VM_GetOperand::allow_nested_vm_operations() const {
  215. + return true; // May need to deoptimize
  216. +}
  217. +VM_GetOperandReceiver::VM_GetOperandReceiver(
  218. + JavaThread* thread, JavaThread* caller_thread, jint depth)
  219. + : VM_GetOperand(thread, caller_thread, depth, 0) {}
  220. /////////////////////////////////////////////////////////////////////////////////////////
  221. //
  222. diff -u -r ./hotspot/src_/share/vm/prims/jvmtiImpl.hpp ./hotspot/src/share/vm/prims/jvmtiImpl.hpp
  223. --- ./hotspot/src_/share/vm/prims/jvmtiImpl.hpp 2013-12-19 01:10:36.309992000 +0100
  224. +++ ./hotspot/src/share/vm/prims/jvmtiImpl.hpp 2014-02-10 14:54:03.762341000 +0100
  225. @@ -400,6 +400,58 @@
  226. ///////////////////////////////////////////////////////////////
  227. +// This is a copy of VM_GetOrSetLocal modified to access operands
  228. +// instead of local variables.
  229. +//
  230. +class VM_GetOperand : public VM_Operation {
  231. + protected:
  232. + JavaThread* _thread;
  233. + JavaThread* _calling_thread;
  234. + jint _depth;
  235. + jint _index;
  236. + BasicType _type;
  237. + jvalue _value;
  238. + javaVFrame* _jvf;
  239. + // It is possible to get the receiver out of a non-static native wrapper
  240. + // frame. Use VM_GetReceiver to do this.
  241. + virtual bool getting_receiver() const { return false; }
  242. + jvmtiError _result;
  243. + vframe* get_vframe();
  244. + javaVFrame* get_java_vframe();
  245. + bool check_slot_type(javaVFrame* vf);
  246. +public:
  247. + // Constructor for non-object getter
  248. + VM_GetOperand(JavaThread* thread, jint depth, jint index, BasicType type);
  249. + // Constructor for object getter
  250. + VM_GetOperand(JavaThread* thread, JavaThread* calling_thread, jint depth,
  251. + int index);
  252. + VMOp_Type type() const { return VMOp_GetOperand; }
  253. + jvalue value() { return _value; }
  254. + jvmtiError result() { return _result; }
  255. + bool doit_prologue();
  256. + void doit();
  257. + bool allow_nested_vm_operations() const;
  258. + const char* name() const { return "get operands"; }
  259. +};
  260. +class VM_GetOperandReceiver : public VM_GetOperand {
  261. + protected:
  262. + virtual bool getting_receiver() const { return true; }
  263. + public:
  264. + VM_GetOperandReceiver(JavaThread* thread, JavaThread* calling_thread, jint depth);
  265. + const char* name() const { return "get operand receiver"; }
  266. +};
  267. +///////////////////////////////////////////////////////////////
  268. //
  269. // class JvmtiSuspendControl
  270. //
  271. diff -u -r ./hotspot/src_/share/vm/prims/jvmti.xml ./hotspot/src/share/vm/prims/jvmti.xml
  272. --- ./hotspot/src_/share/vm/prims/jvmti.xml 2013-12-19 01:10:36.293992000 +0100
  273. +++ ./hotspot/src/share/vm/prims/jvmti.xml 2014-02-10 14:50:31.750337000 +0100
  274. @@ -6137,6 +6137,266 @@
  275. +
  276. +
  277. +
  278. + These functions are used to retrieve or set the value of an operand stack slot.
  279. + The slot is identified by the depth of the frame containing its
  280. + value and the slot's number within that frame.
  281. +
  282. +
  283. +
  284. + Get Operand Stack Value - Object
  285. +
  286. + This function can be used to retrieve the value of an operand
  287. + stack slot whose type is Object or a subclass of Object.
  288. +
  289. + jvmdi
  290. +
  291. +
  292. +
  293. +
  294. +
  295. +
  296. +
  297. + The thread of the frame containing the slot's value.
  298. +
  299. +
  300. +
  301. +
  302. +
  303. + The depth of the frame containing the slot's value.
  304. +
  305. +
  306. +
  307. +
  308. +
  309. + The slot's number.
  310. +
  311. +
  312. +
  313. +
  314. +
  315. + On return, points to the slot's value.
  316. +
  317. +
  318. +
  319. +
  320. +
  321. + Invalid slot.
  322. +
  323. +
  324. + The slot's type is not
  325. + Object or a subclass of Object.
  326. +
  327. +
  328. + Not a visible frame
  329. +
  330. +
  331. +
  332. +
  333. +
  334. + Get Operand Stack Value - Int
  335. +
  336. + This function can be used to retrieve the value of an operand
  337. + stack slot whose type is int,
  338. + short, char, byte, or
  339. + boolean.
  340. +
  341. + jvmdi
  342. +
  343. +
  344. +
  345. +
  346. +
  347. +
  348. +
  349. + The thread of the frame containing the slot's value.
  350. +
  351. +
  352. +
  353. +
  354. +
  355. + The depth of the frame containing the slot's value.
  356. +
  357. +
  358. +
  359. +
  360. +
  361. + The slot's number.
  362. +
  363. +
  364. +
  365. +
  366. +
  367. + On return, points to the slot's value.
  368. +
  369. +
  370. +
  371. +
  372. +
  373. + Invalid slot.
  374. +
  375. +
  376. + The slot's type is not
  377. + int, short,
  378. + char, byte, or
  379. + boolean.
  380. +
  381. +
  382. + Not a visible frame
  383. +
  384. +
  385. +
  386. +
  387. +
  388. + Get Operand Stack Value - Long
  389. +
  390. + This function can be used to retrieve the value of an operand
  391. + stack slot whose type is long.
  392. +
  393. + jvmdi
  394. +
  395. +
  396. +
  397. +
  398. +
  399. +
  400. +
  401. + The thread of the frame containing the slot's value.
  402. +
  403. +
  404. +
  405. +
  406. +
  407. + The depth of the frame containing the slot's value.
  408. +
  409. +
  410. +
  411. +
  412. +
  413. + The slot's number.
  414. +
  415. +
  416. +
  417. +
  418. +
  419. + On return, points to the slot's value.
  420. +
  421. +
  422. +
  423. +
  424. +
  425. + Invalid slot.
  426. +
  427. +
  428. + The variable type is not long.
  429. +
  430. +
  431. + Not a visible frame
  432. +
  433. +
  434. +
  435. +
  436. +
  437. + Get Operand Stack Value - Float
  438. +
  439. + This function can be used to retrieve the value of an operand
  440. + stack slot whose type is float.
  441. +
  442. + jvmdi
  443. +
  444. +
  445. +
  446. +
  447. +
  448. +
  449. +
  450. + The thread of the frame containing the slot's value.
  451. +
  452. +
  453. +
  454. +
  455. +
  456. + The depth of the frame containing the slot's value.
  457. +
  458. +
  459. +
  460. +
  461. +
  462. + The slot's number.
  463. +
  464. +
  465. +
  466. +
  467. +
  468. + On return, points to the slot's value.
  469. +
  470. +
  471. +
  472. +
  473. +
  474. + Invalid slot.
  475. +
  476. +
  477. + The variable type is not float.
  478. +
  479. +
  480. + Not a visible frame
  481. +
  482. +
  483. +
  484. +
  485. +
  486. + Get Operand Stack Value - Double
  487. +
  488. + This function can be used to retrieve the value of an operand
  489. + stack slot whose type is double.
  490. +
  491. + jvmdi
  492. +
  493. +
  494. +
  495. +
  496. +
  497. +
  498. +
  499. + The thread of the frame containing the slot's value.
  500. +
  501. +
  502. +
  503. +
  504. +
  505. + The depth of the frame containing the slot's value.
  506. +
  507. +
  508. +
  509. +
  510. +
  511. + The slot's number.
  512. +
  513. +
  514. +
  515. +
  516. +
  517. + On return, points to the slot's value.
  518. +
  519. +
  520. +
  521. +
  522. +
  523. + Invalid slot.
  524. +
  525. +
  526. + The variable type is not double.
  527. +
  528. +
  529. + Not a visible frame
  530. +
  531. +
  532. +
  533. +
  534. diff -u -r ./hotspot/src_/share/vm/runtime/vm_operations.hpp ./hotspot/src/share/vm/runtime/vm_operations.hpp
  535. --- ./hotspot/src_/share/vm/runtime/vm_operations.hpp 2013-12-19 01:10:36.377992000 +0100
  536. +++ ./hotspot/src/share/vm/runtime/vm_operations.hpp 2014-02-10 14:48:02.346335000 +0100
  537. @@ -87,6 +87,7 @@
  538. template(GetFrameLocation) \
  539. template(ChangeBreakpoints) \
  540. template(GetOrSetLocal) \
  541. + template(GetOperand) \
  542. template(GetCurrentLocation) \
  543. template(EnterInterpOnlyMode) \
  544. template(ChangeSingleStep) \