jsc project | ScriptCoreLib framework

CIL in javascript environment

A .net assembly contains metadata tokens and byte streams. Why not have a CIL interpreter in javascript? It can be done but it may be 100x times slower research shows. Too see the example you must enable firefox console mode.

View example

Sample method presented in CIL stream format
0x06000002: [/* return */ 0x00, /* params */ 0x2, /* locals, stack*/ [
/* 0x00 */ 0x00, // nop
/* 0x01 */ 0x16, // ldc.i4.0
/* 0x02 */ 0x0a, // stloc.0
/* 0x03 */ 0x2b, 0x0d, // br.s
/* 0x05 */ 0x00, // nop
/* 0x06 */ 0x02, // ldarg.0
/* 0x07 */ 0x28, 0x01, 0x00, 0x00, 0x06, // call
/* 0x0c */ 0x00, // nop
/* 0x0d */ 0x00, // nop
/* 0x0e */ 0x06, // ldloc.0
/* 0x0f */ 0x17, // ldc.i4.1
/* 0x10 */ 0x58, // add
/* 0x11 */ 0x0a, // stloc.0
/* 0x12 */ 0x06, // ldloc.0
/* 0x13 */ 0x03, // ldarg.1
/* 0x14 */ 0xfe, 0x04, // clt
/* 0x16 */ 0x0b, // stloc.1
/* 0x17 */ 0x07, // ldloc.1
/* 0x18 */ 0x2d, 0xeb, // brtrue.s
/* 0x1a */ 0x2a, // ret
]]	
	
Output of the test

CIL in javascript
elapsed: 671
elapsed: 32