Mark Spencer Mark Spencer - 1 month ago 12
Javascript Question

Function documentation and syntax - ECMA262

Help me where I can find documentation for the

TO_NUMBER
function and what does the
%
(percentage sign) mean when placed before
MathExpRT
(which also can't find any docs about it)

https://github.com/v8/v8/blob/b0e4dce6091a8777bda80d962df76525dc6c5ea9/src/js/math.js#L62-L64

Answer

TO_NUMBER is a V8-internal macro defined here:

https://github.com/v8/v8/blob/ac886b0c1c173d6ceff762952e1d6cf78e8bd172/src/js/macros.py#L96

Not that this will help you much: it simply calls into an intrinsic, which is implemented as generated code, and has many different implementations depending on compiler (V8 has four), hardware platform (V8 supports about 10), and available type information. One generic code generator can be seen here:

https://github.com/v8/v8/blob/5acc31d86329794407f2764a369c2f638305b376/src/code-stub-assembler.cc#L3259

If you just want to know the semantics, you better look at the ECMAScript 262 standard.