Skip to content

Commit b4d7295

Browse files
committed
Revert "improve closure thread handling"
This reverts commit 6191293. There was
1 parent 80e5499 commit b4d7295

File tree

3 files changed

+43
-45
lines changed

3 files changed

+43
-45
lines changed

bug_test.go

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,47 @@
11
package main
22

3-
import (
4-
"testing"
3+
// import (
4+
// "testing"
55

6-
"github.com/apmckinlay/gsuneido/compile"
7-
. "github.com/apmckinlay/gsuneido/core"
8-
)
6+
// "github.com/apmckinlay/gsuneido/builtin"
7+
// . "github.com/apmckinlay/gsuneido/core"
8+
// "github.com/apmckinlay/gsuneido/util/exit"
9+
// )
910

10-
func TestBug(t *testing.T) {
11-
Libload = libload // dependency injection
12-
MainThread = &mainThread
11+
// func TestBug(t *testing.T) {
12+
// if testing.Short() {
13+
// t.Skip("skipping test in short mode")
14+
// }
15+
// Libload = libload // dependency injection
16+
// mainThread = &Thread{}
17+
// mainThread.Name = "main"
18+
// mainThread.UIThread = true
19+
// MainThread = mainThread
20+
// builtin.UIThread = mainThread
21+
// exit.Add(func() { mainThread.Close() })
1322

14-
openDbms()
15-
defer db.CloseKeepMapped()
23+
// openDbms()
24+
// defer db.CloseKeepMapped()
1625

17-
src := `
18-
Init.Repl()
19-
retryException = 'some exception'
20-
count = 0
21-
block = {
22-
try
23-
{
24-
Print(count, "++")
25-
if count++ < 2
26-
throw 'case failed: testing'
27-
Print('Should see me!!')
28-
}
29-
catch (err, 'case failed:')
30-
{
31-
Suneido.X = err
32-
throw retryException
33-
}
34-
}
35-
Retry(block, maxRetries: 3, minDelayMs: 100, :retryException)
36-
`
37-
compile.EvalString(&mainThread, src)
38-
}
26+
// run(`
27+
// Init.Repl()
28+
// //Use("axonlib")
29+
// //Use("Accountinglib")
30+
// //Use("etalib")
31+
// //Use("pcmiler")
32+
// //Use("ticketlib")
33+
// //Use("prlib")
34+
// //Use("prcadlib")
35+
// //Use("etaprlib")
36+
// //Use("invenlib")
37+
// //Use("wolib")
38+
// //Use("polib")
39+
// //Use("configlib")
40+
// //Use("demobookoptions")
41+
// //Use("Test_lib")
42+
// Print("running...")
43+
// Timer(secs: 60) {
44+
// Qfuzz.MakeQuery()
45+
// }
46+
// `)
47+
// }

core/interp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ loop:
614614
parent = fr.blockParent
615615
}
616616
block := &SuClosure{SuFunc: fn, locals: fr.locals.v, this: fr.this,
617-
parent: parent, thread: th}
617+
parent: parent}
618618
th.Push(block)
619619
case op.BlockBreak:
620620
panic(BlockBreak)

core/suclosure.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ type SuClosure struct {
1919
locals []Value // if concurrent, then read-only
2020
*SuFunc
2121
concurrent bool
22-
thread *Thread
2322
}
2423

2524
// Value interface
@@ -38,7 +37,7 @@ func (b *SuClosure) Call(th *Thread, this Value, as *ArgSpec) Value {
3837
bf := b.SuFunc
3938

4039
v := b.locals
41-
if th != b.thread {
40+
if b.concurrent {
4241
// make a mutable copy of the locals for the frame
4342
v = slc.Clone(b.locals)
4443
}
@@ -62,16 +61,6 @@ func (b *SuClosure) Call(th *Thread, this Value, as *ArgSpec) Value {
6261
fr.this = this
6362
fr.blockParent = b.parent
6463
fr.locals = locals{v: v, onHeap: true}
65-
if th != b.thread {
66-
defer func() {
67-
for i := range v {
68-
if (i < int(b.Offset) || i > int(b.Offset+b.Nparams)) &&
69-
v[i] != b.locals[i] {
70-
panic("closure changes from other thread")
71-
}
72-
}
73-
}()
74-
}
7564
return th.run()
7665
}
7766

0 commit comments

Comments
 (0)