Advertisement
Guest User

Untitled

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