this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: hoist dependency code

It is important that the dependency handling code
is called after all allocations of closeContext have
been called. We are not aware that the allocCC
called in initCloneCC actually allocates new ones,
but just to be sure.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I29873c2f21df1e5d7b143433440be08b7e4f75ed
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207454
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>

+39 -31
+39 -31
internal/core/adt/overlay.go
··· 97 97 ctx.initCloneCC(cc) 98 98 } 99 99 100 + for _, cc := range ctx.closeContexts { 101 + ctx.finishDependencies(cc) 102 + } 103 + 100 104 // TODO: walk overlay vertices and decrement counters of non-disjunction 101 105 // running tasks? 102 106 // TODO: find a faster way to do this. Walking over vertices would ··· 380 384 // panic("unexpected overlay in next") 381 385 } 382 386 383 - for _, d := range x.dependencies { 384 - if d.decremented { 385 - continue 386 - } 387 - 388 - if d.dependency.overlay == nil { 389 - // This dependency is irrelevant for the current overlay. We can 390 - // eliminate it as long as we decrement the accompanying counter. 391 - if o.conjunctCount < 2 { 392 - // This node can only be relevant if it has at least one other 393 - // dependency. Check that we are not decrementing the counter 394 - // to 0. 395 - // TODO: this currently panics for some tests. Disabling does 396 - // not seem to harm, though. Reconsider whether this is an issue. 397 - // panic("unexpected conjunctCount: must be at least 2") 398 - } 399 - o.conjunctCount-- 400 - continue 401 - } 402 - 403 - dep := d.dependency 404 - if dep.overlay != nil { 405 - dep = dep.overlay 406 - } 407 - o.dependencies = append(o.dependencies, &ccDep{ 408 - dependency: dep, 409 - kind: d.kind, 410 - decremented: false, 411 - }) 412 - } 413 - 414 387 switch p := x.parentConjuncts.(type) { 415 388 case *closeContext: 416 389 if p.overlay == nil { ··· 460 433 461 434 // NOTE: copying externalDeps is hard and seems unnecessary, as it needs to 462 435 // be resolved in the base anyway. 436 + } 437 + 438 + func (ctx *overlayContext) finishDependencies(x *closeContext) { 439 + o := x.overlay 440 + 441 + for _, d := range x.dependencies { 442 + if d.decremented { 443 + continue 444 + } 445 + 446 + if d.dependency.overlay == nil { 447 + // This dependency is irrelevant for the current overlay. We can 448 + // eliminate it as long as we decrement the accompanying counter. 449 + if o.conjunctCount < 2 { 450 + // This node can only be relevant if it has at least one other 451 + // dependency. Check that we are not decrementing the counter 452 + // to 0. 453 + // TODO: this currently panics for some tests. Disabling does 454 + // not seem to harm, though. Reconsider whether this is an issue. 455 + // panic("unexpected conjunctCount: must be at least 2") 456 + } 457 + o.conjunctCount-- 458 + continue 459 + } 460 + 461 + dep := d.dependency 462 + if dep.overlay != nil { 463 + dep = dep.overlay 464 + } 465 + o.dependencies = append(o.dependencies, &ccDep{ 466 + dependency: dep, 467 + kind: d.kind, 468 + decremented: false, 469 + }) 470 + } 463 471 } 464 472 465 473 func (ctx *overlayContext) cloneScheduler(dst, src *nodeContext) {