r/ProgrammingLanguages • u/sleepydevxd • Jun 17 '26
V8 Engine Feedback Vector
Hello everyone,
Recently, I'm looking into v8 JavaScript Engine and found out about FeedBack Vector, which I want to investigate more about it in order to understand how the Engine assigns type at runtime after being interpreted by Ignition.
Although I tried to compile the v8 source code and it was able to run a simple script on my machine, I can't seem to be able to get the information regarding Feedback Vector and the data inside it.
So far, I have tried to use some promising flags that are available:
+ --log-feedback-vector
+ --maglev-print-feedback
+ --invocation-count-for-feedback-allocation=1
+ --no-lazy-feedback-allocation
None of them are working - no output to the terminal after I ran it.
I followed this (old and maybe outdated) article:
- An Introduction to Speculative Optimization in V8
With the same code, I can not retrieve the same BinaryOp which I believe have changed after many updates. I want to avoid any "natives syntax", in general, but even when I included it (e.g. %DebugPrint(add);), it does not seem to give me the information that I wanted like in the article.
My goal is to analyse JavaScript's V8 bytecode and output the correct possible types of variables (similar to what Mytype do). So if I can have another way to work around this, it would be very appreciated!
I don't know if this is the right place to ask these kind of question. Therefore, I'm sorry in advanced if this caused any confusion.
Thank you everyone for your time.
View all comments
Show parent comment
2
u/sleepydevxd Jun 18 '26
Yes, that's actually what I'm trying to achieve right now: reading the bytecode and "precisely" output the types of variables, arguments, return types, etc.
Right now, I know that base on the lexical scope of a JS script, it's fairly straightforward to map it to the bytecode:
```
LdaConstant [1:0x3ec40101e599 <HeapNumber 100.1>]
LdaConstant [3:"My name is Blahblah"]
```
My concern lies on functions/prototypes. How can I guarantee the return type of them? I read the V8 source code and there is a piece of information:
```
The FeedbackVector holds the runtime feedback (Inline Caches) used by the optimizing compilers.
```
and in the attached article:
```Due to the dynamic nature of JavaScript we usually don't know the precise types of values until runtime, i.e. just by looking at the source code it's often impossible to tell the possible values of inputs to operations. That's why we need to speculate, based on previously collected feedback about the values we've seen so far, and then assume that we're going to always see similar values in the future.```
So I wonder if there is any useful information in the Feedback Vector that I can make use of.
I'm quite new to V8 Engine so that's my initial explorations about how to reach the goal of analysing bytecode.
Could you help to point out how they are different problems? Am I choosing a more complicated route that can be achieved through other methods?
Thank you very much!