9

Is there any way by which I can explore native code in Javascript? I want to see what Function() class has in it.

machineghost
  • 33,529
  • 30
  • 159
  • 234
alter
  • 4,320
  • 7
  • 31
  • 36
  • Ehh? There's a specification, if you'd like that? JavaScript is determined by it, and as so, for a non-browser-specific way to look at it, that's the way you want to go. – Sune Rasmussen May 20 '10 at 10:37
  • not exactly byte code...but the native classes and functions. For example if you write alert(Function) then you see Function(){[native code]}. So I want to explore this native code. – alter May 20 '10 at 19:24

2 Answers2

3

You could have a look at the source code of an open source browser such as Firefox.

Jesper
  • 202,709
  • 46
  • 318
  • 350
  • any other way to do it in runtime? – marcio Oct 28 '11 at 11:13
  • 1
    @marcioAlmada: At runtime, no. The code for `Function` (and most other built-ins) isn't Javascript; it's native code. In order to do it at runtime, the script engine would have to have an embedded native-code disassembler or something. Which none that i know of do. – cHao Jun 29 '12 at 18:09
2

I've always wanted to do this myself. On a side note, here's how to view assembly language code generated by the V8 JS engine for Chromium (I haven't tried it yet): How can I see the machine code generated by v8?

Community
  • 1
  • 1