-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce builtin function govm and makechan #330
base: master
Are you sure you want to change the base?
Commits on Mar 27, 2021
-
Introduce builtin function go and makechan
Builtin go(fn, arg1, arg2, ...) starts a goroutine which run fn(arg1, arg2, ...) in a new VM cloned from the current running VM, and returns a job object that has wait, result, abort methods. Builtin makechan(size) accepts an optional size parameter, makes a channel to send/receive object, and returns a chan object that has send, recv, close methods. To be able to access *VM instance that it is running in for go() and makechan(), now VM will always pass VMObj to and only to BuiltinFunction as arg[0].
Configuration menu - View commit details
-
Copy full SHA for 0f02c83 - Browse repository at this point
Copy the full SHA 0f02c83View commit details -
Rename job to goroutineVM for better understanding
A goroutineVM is a VM cloned from the current VM in a shared way that the cloned VM(the child) can access globals and constants of the parent VM, but with its own stack and frames. The cloned VM will be running with a specified compiled function as the entrypoint in a new goroutine created by the parent VM.
Configuration menu - View commit details
-
Copy full SHA for 67ce595 - Browse repository at this point
Copy the full SHA 67ce595View commit details
Commits on Mar 29, 2021
-
In golang spec, "go" statement has no return value, which is not the semantic here: we want "govm" returns a goroutineVM object which can be used to wait, abort, or get result of the goroutineVM.
Configuration menu - View commit details
-
Copy full SHA for d67644e - Browse repository at this point
Copy the full SHA d67644eView commit details -
Configuration menu - View commit details
-
Copy full SHA for e4ca97e - Browse repository at this point
Copy the full SHA e4ca97eView commit details -
Configuration menu - View commit details
-
Copy full SHA for ee08782 - Browse repository at this point
Copy the full SHA ee08782View commit details
Commits on Mar 30, 2021
-
Use needvmObj flag in BuiltinFunction
VM will only pass its vmObj to builtin function that has needvmObj equals true, so that normal builtin functions do not need to notice the change.
Configuration menu - View commit details
-
Copy full SHA for 9e5fbbc - Browse repository at this point
Copy the full SHA 9e5fbbcView commit details
Commits on Apr 1, 2021
-
goroutineVM: block parent VM untill all descendant VMs exit
The goroutineVM will not exit unless: 1. All its descendant VMs exit 2. It calls abort() 3. Its goroutineVM object abort() is called on behalf of its parent VM The latter 2 cases will trigger aborting procedure of all the descendant VMs, which will further result in d5#1 above.
Configuration menu - View commit details
-
Copy full SHA for cc984e8 - Browse repository at this point
Copy the full SHA cc984e8View commit details
Commits on Apr 14, 2021
-
correct source position for closure function in call stack
Take below snipet as an example: $ cat cmd/tengo/test.tengo test1 := func() { v := 1 test2 := func() { len(1,1,1,1) v++ } test2() } test1() ---- before the fix: $ ./tengo test.tengo Runtime Error: wrong number of arguments in call to 'builtin-function:len' at - at test.tengo:7:2 at test.tengo:10:1 ---- after the fix: $ ./tengo test.tengo Runtime Error: wrong number of arguments in call to 'builtin-function:len' at test.tengo:4:3 at test.tengo:7:2 at test.tengo:10:1
Configuration menu - View commit details
-
Copy full SHA for 5047ab7 - Browse repository at this point
Copy the full SHA 5047ab7View commit details -
govm now supports calling both script functions and native functions
with this commit: 1. builtinGovm() now accepts native golang function, but unlike compiled functions which run in a cloned VM, native golang functions do not need VM, they just run in a goroutine. 2. Parent VMs now have records of errors of all its descendent VMs. A VM's error is a combination of the error of itself and all errors of the descendent VMs, in another word, parent VM's error includes all errors of the child VMs. 3. ErrVMAborted is no longer treated as runtime error.
Configuration menu - View commit details
-
Copy full SHA for c4aa6ae - Browse repository at this point
Copy the full SHA c4aa6aeView commit details -
rename builtin govm back to go
now that "govm" does not always run function in VM, so "go" is better. update docs to reflect the usage changes.
Configuration menu - View commit details
-
Copy full SHA for c81780b - Browse repository at this point
Copy the full SHA c81780bView commit details
Commits on Apr 15, 2021
-
Wrap main VM's error to make TestVMErrorUnwrap test pass
And now abort() on the same VM twice will not panic.
Configuration menu - View commit details
-
Copy full SHA for cf3fef9 - Browse repository at this point
Copy the full SHA cf3fef9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4462ad9 - Browse repository at this point
Copy the full SHA 4462ad9View commit details
Commits on Apr 17, 2021
-
On a panic happens in a VM: * the panic value along with both its script level and native level callstack are recorded as run time error, its parent VM should examine this error. * the panic will not cause whole program exits, but it does trigger the abort chain, so that the VM in which the panic happens and all its descendent VMs will terminate. So panic only causes the descendent group of VMs to exit. Other VM groups are not affected.
Configuration menu - View commit details
-
Copy full SHA for a6205f4 - Browse repository at this point
Copy the full SHA a6205f4View commit details
Commits on May 3, 2021
-
Make VM's input/output redirectable
Export VMObj to std.fmt, so that fmtPrintln can get vm.Out to output to a io.Writer per VM.
Configuration menu - View commit details
-
Copy full SHA for 496574d - Browse repository at this point
Copy the full SHA 496574dView commit details
Commits on May 6, 2021
-
Configuration menu - View commit details
-
Copy full SHA for b6d2aba - Browse repository at this point
Copy the full SHA b6d2abaView commit details
Commits on May 20, 2021
-
Configuration menu - View commit details
-
Copy full SHA for a14d22e - Browse repository at this point
Copy the full SHA a14d22eView commit details
Commits on May 27, 2021
-
Configuration menu - View commit details
-
Copy full SHA for 367afb1 - Browse repository at this point
Copy the full SHA 367afb1View commit details
Commits on May 29, 2021
-
Configuration menu - View commit details
-
Copy full SHA for b979ae1 - Browse repository at this point
Copy the full SHA b979ae1View commit details
Commits on May 31, 2021
-
check aborting status before starting child VM
and nil child VM to gc after it is done
Configuration menu - View commit details
-
Copy full SHA for 3a929e2 - Browse repository at this point
Copy the full SHA 3a929e2View commit details -
Start from small stack and frame space and grow on demand
This reduce memory foot print significantly when there are large number of small VMs running.
Configuration menu - View commit details
-
Copy full SHA for 4cfaeeb - Browse repository at this point
Copy the full SHA 4cfaeebView commit details