** Mark an object. Userdata with no user values, strings, and closed ** upvalues are visited and turned black here. Open upvalues are ** already indirectly linked through their respective threads in the ** 'twups' list, so they don't go to the gray list; nevertheless, they ** are kept gray to avoid barriers, as their values will be revisited ** by the thread or by 'remarkupvals'. Other objects
| 337 | ** (only closures can), and a userdata's metatable must be a table. |
| 338 | */ |
| 339 | static void reallymarkobject (global_State *g, GCObject *o) { |
| 340 | g->GCmarked += objsize(o); |
| 341 | switch (o->tt) { |
| 342 | case LUA_VSHRSTR: |
| 343 | case LUA_VLNGSTR: { |
| 344 | set2black(o); /* nothing to visit */ |
| 345 | break; |
| 346 | } |
| 347 | case LUA_VUPVAL: { |
| 348 | UpVal *uv = gco2upv(o); |
| 349 | if (upisopen(uv)) |
| 350 | set2gray(uv); /* open upvalues are kept gray */ |
| 351 | else |
| 352 | set2black(uv); /* closed upvalues are visited here */ |
| 353 | markvalue(g, uv->v.p); /* mark its content */ |
| 354 | break; |
| 355 | } |
| 356 | case LUA_VUSERDATA: { |
| 357 | Udata *u = gco2u(o); |
| 358 | if (u->nuvalue == 0) { /* no user values? */ |
| 359 | markobjectN(g, u->metatable); /* mark its metatable */ |
| 360 | set2black(u); /* nothing else to mark */ |
| 361 | break; |
| 362 | } |
| 363 | /* else... */ |
| 364 | } /* FALLTHROUGH */ |
| 365 | case LUA_VLCL: case LUA_VCCL: case LUA_VTABLE: |
| 366 | case LUA_VTHREAD: case LUA_VPROTO: { |
| 367 | linkobjgclist(o, g->gray); /* to be visited later */ |
| 368 | break; |
| 369 | } |
| 370 | default: lua_assert(0); break; |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | |
| 375 | /* |
no test coverage detected