Starlight-JS / starlight

JS engine in Rust
https://teletype.in/@starlight-js
Mozilla Public License 2.0
509 stars 9 forks source link

Move native reference builtin #131

Closed jameslahm closed 3 years ago

playXE commented 3 years ago

Moving native references to separate structs does not look good. It should always be in one large array. External references can be passed at VM instance creation time and there should be no other way to add them at runtime: only when VM instance is created or in VM_NATIVE_REFERENCES global array.

github-actions[bot] commented 3 years ago

Test262 conformance changes:

Test result Dev count PR count Difference
Total 79,437 79,437 0
Passed 18,192 18,196 +4
Ignored 24,388 24,388 0
Failed 36,813 36,809 -4
Panics 44 44 0
Conformance 22.90 22.91 +0.01%
Base Failed But New Passed ``` 1. [non-strict] test262/test/built-ins/Object/keys/15.2.3.14-2-8.js 2. [strict] test262/test/built-ins/Object/create/15.2.3.5-4-39.js 3. [strict] test262/test/built-ins/Object/keys/15.2.3.14-3-1.js 4. [strict] test262/test/built-ins/Object/keys/15.2.3.14-4-1.js 5. [non-strict] test262/test/built-ins/Object/defineProperties/15.2.3.7-6-a-93-3.js 6. [non-strict] test262/test/built-ins/Object/keys/15.2.3.14-4-1.js ```
New Failed But Base Passed ``` 1. [non-strict] test262/test/built-ins/Object/keys/15.2.3.14-3-1.js 2. [strict] test262/test/built-ins/Object/defineProperties/15.2.3.7-6-a-93-3.js ```
jameslahm commented 3 years ago

yeah, that makes sense. I have changed VM_NATIVE_REFERENCES to be immutable. And now there is no other way to add native references in runtime. Native references only in VM_NATIVE_REFERENCES or in external references. I move native references in separate structs mainly to make maintaining native references easier, avoiding the need to copy functions in VM_NATIVE_REFERENCES each time we implement a new function. And VM_NATIVE_REFERENCES only be initialized in the lazy static function, and will not be changed in runtime.