diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-15 11:23:35 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-15 11:23:35 -0300 |
commit | ba710603811c68fe3a69b3bb98e9038d37489a79 (patch) | |
tree | c960f80517482d4baa33f92dd7f9b9002b24f365 /lgc.c | |
parent | 3823fc6c814d20f2b2a0a1e3be8782084440040f (diff) | |
download | lua-ba710603811c68fe3a69b3bb98e9038d37489a79.tar.gz lua-ba710603811c68fe3a69b3bb98e9038d37489a79.tar.bz2 lua-ba710603811c68fe3a69b3bb98e9038d37489a79.zip |
Removed "bulk operations"
Negligible performance gains don't justify extra complexity.
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 36 |
1 files changed, 7 insertions, 29 deletions
@@ -465,46 +465,24 @@ static void traverseweakvalue (global_State *g, Table *h) { | |||
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | #define BK2(x) cast(lua_Unsigned, ((x) << 8) | BIT_ISCOLLECTABLE) | ||
469 | /* | ||
470 | ** Check whether some value in the cell starting at index 'i' | ||
471 | ** is collectable | ||
472 | */ | ||
473 | static int checkBulkCollectable (Table *h, unsigned i) { | ||
474 | const lua_Unsigned bitscoll = BK2(BK2(BK2(BK2(BK2(BK2(BK2(BK2(~0u)))))))); | ||
475 | int j; | ||
476 | i /= NM; | ||
477 | for (j = 0; j < BKSZ; j++) { | ||
478 | if (h->array[i].u.bulk[j] & bitscoll) | ||
479 | return 1; | ||
480 | } | ||
481 | return 0; | ||
482 | } | ||
483 | |||
484 | |||
485 | /* | 468 | /* |
486 | ** Traverse the array part of a table. The traversal is made by cells, | 469 | ** Traverse the array part of a table. |
487 | ** only traversing a cell if it has some collectable tag among its tags. | ||
488 | */ | 470 | */ |
489 | static int traversearray (global_State *g, Table *h) { | 471 | static int traversearray (global_State *g, Table *h) { |
490 | unsigned asize = luaH_realasize(h); | 472 | unsigned asize = luaH_realasize(h); |
491 | int marked = 0; /* true if some object is marked in this traversal */ | 473 | int marked = 0; /* true if some object is marked in this traversal */ |
492 | unsigned i; | 474 | unsigned i; |
493 | for (i = 0; i < asize; i += NM) { /* traverse array in cells */ | 475 | for (i = 0; i < asize; i++) { |
494 | if (checkBulkCollectable(h, i)) { /* something to mark in this cell? */ | 476 | GCObject *o = gcvalarr(h, i); |
495 | unsigned j; | 477 | if (o != NULL && iswhite(o)) { |
496 | for (j = 0; j < NM && i + j < asize; j++) { | 478 | marked = 1; |
497 | GCObject *o = gcvalarr(h, i + j); | 479 | reallymarkobject(g, o); |
498 | if (o != NULL && iswhite(o)) { | ||
499 | marked = 1; | ||
500 | reallymarkobject(g, o); | ||
501 | } | ||
502 | } | ||
503 | } | 480 | } |
504 | } | 481 | } |
505 | return marked; | 482 | return marked; |
506 | } | 483 | } |
507 | 484 | ||
485 | |||
508 | /* | 486 | /* |
509 | ** Traverse an ephemeron table and link it to proper list. Returns true | 487 | ** Traverse an ephemeron table and link it to proper list. Returns true |
510 | ** iff any object was marked during this traversal (which implies that | 488 | ** iff any object was marked during this traversal (which implies that |