Where are the basic operators (+, >, <, etc.) defined in the source code? I think the Chrome Engine is called V8? But I don’t feel like downloading, compiling and debugging it to find out.
I looked in some the .h/.cc files, gave up and came here.
Where are the basic operators (+, >, <, etc.) defined in the source code? I think the Chrome Engine is called V8? But I don’t feel like downloading, compiling and debugging it to find out.
I looked in some the .h/.cc files, gave up and came here.
3
Answers
The definition of operators seems to be located here:
https://chromium.googlesource.com/v8/v8/+/1769f892cef0822e6a8b5334e2ad909a0c33e906/src/compiler/js-operator.h
Where did you check the source code of V8 engine?
I can see many operators defined and used in the source.
Please check the following link.
https://chromium.googlesource.com/v8/v8/+/refs/heads/main/src/builtins/builtins-number.cc
Regards
(V8 developer here.)
There isn’t just one "definition" of an operator.
There are token definitions in the tokenizer.
There are AST node definitions in the parser.
There are bytecode handler implementations in the interpreter, which are reusing code that’s also used to generate stand-alone builtin stubs, and there’s the corresponding code in the bytecode generator.
And then each of the compilers has its own handling of them with varying levels of optimization; especially in case of the optimizing compiler there’s also a bunch of further processing of the operators in its various stages.
If you’re trying to understand which operators are available, as one commenter is speculating, it’s probably easier to look at the JavaScript specification or MDN.