Skip to content

Conversation

@zherczeg
Copy link
Member

@zherczeg zherczeg commented Dec 4, 2020

  • Type for realm objects is introduced (ecma_global_object_t)
  • Realm reference is added to built-in objects and ECMAScript functions
  • Resolving built-ins, global environments, and scopes require realm object
  • Unnecessary global object accesses are removed from the code

Missing: external functions and static snapshot functions have no realm reference

@zherczeg
Copy link
Member Author

zherczeg commented Dec 4, 2020

Depends on #4352

@zherczeg zherczeg force-pushed the implement_realms branch 11 times, most recently from 0fd5939 to faa948f Compare December 7, 2020 07:20
@zherczeg
Copy link
Member Author

zherczeg commented Dec 7, 2020

Benchmark Heap (bytes) Stack (bytes) Perf (sec)
3d-cube.js 10680 -> 11200 : -4.869% 13672 -> 14056 : -2.809% 1.145 -> 1.149 : -0.307%
3d-morph.js 289008 -> 289224 : -0.075% 1712 -> 1704 : +0.467% 1.194 -> 1.187 : +0.572%
3d-raytrace.js 119384 -> 117648 : +1.454% 2548 -> 2596 : -1.884% 1.329 -> 1.359 : -2.298%
access-binary-trees.js 27120 -> 28656 : -5.664% 3376 -> 3448 : -2.133% 0.769 -> 0.774 : -0.661%
access-fannkuch.js 1584 -> 1784 : -12.626% 1784 -> 1776 : +0.448% 2.559 -> 2.552 : +0.273%
access-nbody.js 4088 -> 4600 : -12.524% 1872 -> 1864 : +0.427% 1.577 -> 1.570 : +0.483%
bitops-3bit-bits-in-byte.js 808 -> 1016 : -25.743% 1728 -> 1720 : +0.463% 0.696 -> 0.698 : -0.371%
bitops-bits-in-byte.js 768 -> 976 : -27.083% 1728 -> 1720 : +0.463% 1.019 -> 1.015 : +0.398%
bitops-bitwise-and.js 544 -> 744 : -36.765% 1480 -> 1472 : +0.541% 1.227 -> 1.214 : +1.041%
bitops-nsieve-bits.js 60952 -> 61176 : -0.368% 1728 -> 1720 : +0.463% 1.475 -> 1.481 : -0.387%
controlflow-recursive.js 1048 -> 1280 : -22.137% 61592 -> 63624 : -3.299% 0.517 -> 0.517 : +0.067%
crypto-aes.js 27904 -> 27888 : +0.057% 2288 -> 2312 : -1.049% 0.880 -> 0.882 : -0.169%
crypto-md5.js 70640 -> 70960 : -0.453% 1796 -> 1788 : +0.445% 0.733 -> 0.735 : -0.335%
crypto-sha1.js 45984 -> 46320 : -0.731% 1856 -> 1848 : +0.431% 0.756 -> 0.754 : +0.241%
crypto.js 50664 -> 51696 : -2.037% 3164 -> 3228 : -2.023% 8.676 -> 8.654 : +0.250%
date-format-tofte.js 8688 -> 9168 : -5.525% 2128 -> 2120 : +0.376% 1.008 -> 1.008 : +0.028%
date-format-xparb.js 14912 -> 15256 : -2.307% 2688 -> 2704 : -0.595% 0.819 -> 0.818 : +0.175%
deltablue.js 453256 -> 456496 : -0.715% 3540 -> 3636 : -2.712% 5.446 -> 5.475 : -0.527%
math-cordic.js 1824 -> 2040 : -11.842% 1728 -> 1720 : +0.463% 1.706 -> 1.698 : +0.442%
math-partial-sums.js 1280 -> 1504 : -17.500% 1704 -> 1696 : +0.469% 1.042 -> 1.045 : -0.294%
math-spectral-norm.js 2992 -> 3256 : -8.824% 1728 -> 1720 : +0.463% 0.744 -> 0.743 : +0.113%
raytrace.js 21840 -> 22472 : -2.894% 4952 -> 4844 : +2.181% 2.775 -> 2.835 : -2.130%
richards.js 8216 -> 8560 : -4.187% 2148 -> 2244 : -4.469% 0.309 -> 0.308 : +0.250%
string-base64.js 89856 -> 90096 : -0.267% 1776 -> 1768 : +0.450% 1.413 -> 1.399 : +0.932%
string-fasta.js 4056 -> 4392 : -8.284% 1712 -> 1704 : +0.467% 3.386 -> 3.377 : +0.267%
Geometric mean: -8.051% -0.466% -0.075%
Binary (bytes) master(de37e1e) patch(faa948f) Diff
size 239156 239156 0 bytes
.rodata 20695 20695 0 bytes
.dynstr 285 285 0 bytes
.rel.plt 240 240 0 bytes
.interp 25 25 0 bytes
.dynsym 576 576 0 bytes
.gnu.hash 252 252 0 bytes
.text 211152 211072 -80 bytes
.comment 85 85 0 bytes
.shstrtab 226 226 0 bytes
.data 8 8 0 bytes
.ARM.exidx 8 8 0 bytes
.rel.dyn 16 16 0 bytes
.init 12 12 0 bytes
.got 136 136 0 bytes
.plt 384 384 0 bytes
.note.ABI-tag 32 32 0 bytes
.gnu.version_r 32 32 0 bytes
.bss 1575248 1575064 -184 bytes
.fini 8 8 0 bytes
.hash 220 220 0 bytes
.gnu.version 72 72 0 bytes
.fini_array 4 4 0 bytes
.init_array 4 4 0 bytes
.dynamic 240 240 0 bytes
.eh_frame 4 4 0 bytes
.ARM.attributes 53 53 0 bytes

@zherczeg
Copy link
Member Author

zherczeg commented Dec 7, 2020

There is a 184 byte bss decrease and a 200 byte heap memory increase because the global object is stored on the heap now. Furthermore byte codes needs an extra 4 byte for realms.

@zherczeg
Copy link
Member Author

zherczeg commented Dec 7, 2020

There was an 1.5K increase on access-binary-trees.js, so I run this test with --mem-stress-test option. The change was from 27056 to 27344, so the reason of increase is the delayed gc runs. The usual 200 byte increase is also visible.

@zherczeg zherczeg changed the title Implement global realm and support realms for built-in objects Implement global realm object and support realms for built-ins and JS functions Dec 7, 2020
- Type for realm objects is introduced (ecma_global_object_t)
- Realm reference is added to built-in objects and ECMAScript functions
- Resolving built-ins, global environments, and scopes require realm object
- Unnecessary global object accesses are removed from the code

Missing: external functions and static snapshot functions have no realm reference

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
@zherczeg zherczeg changed the title Implement global realm object and support realms for built-ins and JS functions Implement realm object and support realms for built-ins and JS functions Dec 7, 2020
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rerobika
Copy link
Member

rerobika commented Dec 7, 2020

Could you please add $test262.createRealm support after #4329?

@rerobika rerobika added the ES.next Related to ES2015+ features label Dec 7, 2020
@zherczeg
Copy link
Member Author

zherczeg commented Dec 7, 2020

Of course. Next patch will also do several things.

Copy link
Member

@dbatyai dbatyai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbatyai dbatyai merged commit df92c86 into jerryscript-project:master Dec 8, 2020
@zherczeg zherczeg deleted the implement_realms branch December 8, 2020 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ES.next Related to ES2015+ features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants