0

I'm using the v8 library to run js code in my project. And I want to implement controlled execution of the compiled js code. I would like to be able to control the execution of bytecode step by step. From one instruction to another. Is it possible at all?

rsey
  • 3
  • 1
  • 4
  • What did you meant by debugging byte code, Did you mean debugging the source code or actual machine code? – Janith Sep 13 '18 at 09:11
  • Thanks for the answer. Yes, perhaps the question is not clearly formulated. I need to debug ignition bytecode. And I do not know if it's possible. – Alexey Novikov Sep 13 '18 at 09:28
  • As of my knowledge, javascript code is converted to c++ on runtime (inside the v8 engine). And there is a inspector protocol that you can debug your code while talking with the engine. So by ignition bytecode did you meant debugging the v8 engine? – Janith Sep 13 '18 at 09:44
  • No. Example from this article https://medium.com/dailyjs/understanding-v8s-bytecode-317d46c94775 . js string "let result = 1 + obj.x" converted to 19 S> 0x2ddf8802cf6f @ LdaSmi [1] 0x2ddf8802cf71 @ Star r0 34 E> 0x2ddf8802cf73 @ LdaNamedProperty a0, [0], [4] 28 E> 0x2ddf8802cf77 @ Add r0, [6] – Alexey Novikov Sep 13 '18 at 09:55
  • It's about the possibility of tracing bytecode, given in the example and described in the article. – Alexey Novikov Sep 13 '18 at 09:56

1 Answers1

0

Javascript is an interpreted language, not a compiled language. V8 is the javascript engine of google and present in chrome browser. Web page is generally constructed using HTML, Javascript and CSS and web browser is enough to do HTML rendering and Javascript interpretation. You don't need to even installed JVM to render the page which contains Javascript.

V8 is written in C++ and you can debug it, even you can extend your javascript by exposig javascript object and extend existing JS object(like document etc) implementing the C++ binding in V8. Hope it is making clear to you.

If you are doing server site scripting using JSP then the compilation will come in place and you will get the .java files containing the byte code and the JVM and other tools like Javac will come in picture.

Sanjeev
  • 348
  • 2
  • 9