1

I have a following JavaScript code:

class Contract {

// constructor
constructor() {

    // dynamic data
    this.str = '';
    this.count = 0; 
}

// update function
update(_value){
    this.str = _value;
    this.count++; 
   }
}

How can I get bytecode and state of virtual machine using V8 engine?

1 Answer 1

1

Bytecode is not exposed on V8's C++ API.

For human inspection, you can dump it to stdout by using the --print-bytecode flag.

If you're willing to modify V8 for your purposes, you can e.g. look for occurrences of FLAG_print_bytecode in the source to see how the bytecode can be accessed.

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you. I can parse javascript with V8's C++ to C++ object and get access to properties. So there should be a way for accessing property bytcode
Internally, there's SharedFunctionInfo::HasBytecodeArray() and SharedFunctionInfo::GetBytecodeArray(), but as I said, these are not exposed on the embedder API. What do you need the bytecode for?
Sorry as I understand this APIs is not public ?
I just need to get the byte code and the state of the virtual machine after each call. I mean to have some C++ object which contains byte code. Not just printing
Correct, there's no way to access bytecode via the public API. It's an internal implementation detail. Sorry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.