aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp
AgeCommit message (Collapse)Author
2024-11-21interp: align created globalsAyke van Laethem
Use the alignment from the align attribute of the runtime.alloc call. This is going to be a more accurate alignment, and is typically smaller than the default.
2024-09-05interp: support big-endian targetsAyke van Laethem
The interp package was assuming that all targets were little-endian. But that's not true: we now have a big-endian target (GOARCH=mips). This fixes the interp package to use the appropriate byte order for a given target.
2024-08-14make spell: add a few missing misspellings, fix format of .csv file, also ↵Dan Kegel
fix *.md
2024-08-12GNUmakefile: add spellfix target, use it. (#4387)dkegel-fastly
TODO: Remove the go.mod/go.sum in internal/tools once doing so doesn't break CI (e.g. once we drop support for go 1.19) * builder/cc1as.h: fix typo found by 'make spell' * GNUmakefile: remove exception for inbetween, fix instance now found by 'make spell' * GNUmakefile: remove exception for programmmer, fix instance now found by 'make spell' * go.mod: use updated misspell. GNUmakefile: add spellfix target, use it. * ignore directories properly when invoking spellchecker. * make spell: give internal/tools its own go.mod, as misspell requires newer go * make lint: depend on tools and run the installed revive (which was perhaps implied by the change that added revive to internal/tools, but not required in GNUmakefile until we gave internal/tools its own temporary go.mod) * .github: now that 'make spell' works well, run it from CI * GNUmakefile: make spell now aborts if it finds misspelt words, so what it finds doesn't get lost in CI logs * GNUmakefile: tools: avoid -C option on go generate to make test-llvm15-go119 circleci job happy, see https://cs.opensource.google/go/go/+/2af48cbb7d85e5fdc635e75b99f949010c607786 * internal/tools/go.mod: fix format of go version to leave out patchlevel, else go complains.
2024-07-20main: add interp testsAyke van Laethem
This one needed more advanced checking of the error messages, because we don't want to hardcode things like `!dbg !10` in the output.
2024-05-13Adding a commentMarco Manino
2024-05-13Checking for methodset existanceMarco Manino
2024-02-27interp: make getelementptr offsets signedAyke van Laethem
getelementptr offsets are signed, not unsigned. Yet they were used as unsigned integers in interp. Somehow this worked most of the time, until finally there was some code that did a getelementptr with a negative index.
2024-02-27interp: return a proper error message when indexing out of rangeAyke van Laethem
This helps debug issues inside interp.
2024-02-19interp: do not register runtime timers during interpAyke van Laethem
The runtime hasn't been initialized yet so this leads to problems. This fixes https://github.com/tinygo-org/tinygo/issues/4123.
2023-10-04all: use the new LLVM pass managerAyke van Laethem
The old LLVM pass manager is deprecated and should not be used anymore. Moreover, the pass manager builder (which we used to set up a pass pipeline) is actually removed from LLVM entirely in LLVM 17: https://reviews.llvm.org/D145387 https://reviews.llvm.org/D145835 The new pass manager does change the binary size in many cases: both growing and shrinking it. However, on average the binary size remains more or less the same. This is needed as a preparation for LLVM 17.
2023-10-01all: remove LLVM 14 supportAyke van Laethem
This is a big change: apart from removing LLVM 14 it also removes typed pointer support (which was only fully supported in LLVM up to version 14). This removes about 200 lines of code, but more importantly removes a ton of special cases for LLVM 14.
2023-09-22interp: print LLVM instruction in tracebackAyke van Laethem
The old traceback would look like this: # internal/godebug /usr/local/go/src/internal/godebug/godebug.go:101:11: interp: test call <2> 0 <3> 0 traceback: /usr/local/go/src/internal/godebug/godebug.go:101:11: call <2> 0 <3> 0 /usr/local/go/src/internal/godebug: call <1> 0 With this patch, it looks like this: # io/fs /usr/local/go/src/io/fs/fs.go:144:45: interp: test %0 = load %runtime._interface, ptr @"internal/oserror.ErrInvalid", align 8, !dbg !316 traceback: /usr/local/go/src/io/fs/fs.go:144:45: %0 = load %runtime._interface, ptr @"internal/oserror.ErrInvalid", align 8, !dbg !316 /usr/local/go/src/io/fs/fs.go:137:28: %0 = call %runtime._interface @"io/fs.errInvalid"(ptr undef), !dbg !317 For developers (like me) who are familiar with LLVM, this is probably easier to read. For users, I'm not sure: the instructions have quite a lot of distracting fluff in them. But at least it contains the function names that are called (which are not currently present in the old traceback). ...that said, having the LLVM instructions in a bug report is probably going to be easier for people who are familar with LLVM.
2023-09-21interp: improve unknown opcode handlingKenneth Bell
2023-09-21build: #3893 do not return LLVM structs from BuildKenneth Bell
2023-09-10interp: don't copy unknown values in runtime.sliceCopyAyke van Laethem
This was bug https://github.com/tinygo-org/tinygo/issues/3890. See the diff for details. Essentially, it means that `copy` in the interpreter was copying data that wasn't known yet, or copying data into a slice that could be read externally after the interp pass.
2023-05-20interp: add support for reading a pointer tagAyke van Laethem
This is necessary to get https://github.com/tinygo-org/tinygo/pull/3691 working.
2023-05-20interp: fix subtle bug in pointer xorAyke van Laethem
If a pointer value was xor'ed with a value other than 0, it would not have been run at runtime but instead would fall through to the generic integer operations. This would likely result in a "cannot convert pointer to integer" panic. This commit fixes this subtle case.
2023-05-20interp: move some often-repeated code into a functionAyke van Laethem
2023-04-16Switch interp tests to opaque pointersElliott Sales de Andrade
2023-03-24feat: fix typosshivay
2023-02-17all: refactor reflect packageAyke van Laethem
This is a big commit that changes the way runtime type information is stored in the binary. Instead of compressing it and storing it in a number of sidetables, it is stored similar to how the Go compiler toolchain stores it (but still more compactly). This has a number of advantages: * It is much easier to add new features to reflect support. They can simply be added to these structs without requiring massive changes (especially in the reflect lowering pass). * It removes the reflect lowering pass, which was a large amount of hard to understand and debug code. * The reflect lowering pass also required merging all LLVM IR into one module, which is terrible for performance especially when compiling large amounts of code. See issue 2870 for details. * It is (probably!) easier to reason about for the compiler. The downside is that it increases code size a bit, especially when reflect is involved. I hope to fix some of that in later patches.
2023-01-17runtime: implement precise GCAyke van Laethem
This implements the block-based GC as a partially precise GC. This means that for most heap allocations it is known which words contain a pointer and which don't. This should in theory make the GC faster (because it can skip non-pointer object) and have fewer false positives in a GC cycle. It does however use a bit more RAM to store the layout of each object. Right now this GC seems to be slower than the conservative GC, but should be less likely to run out of memory as a result of false positives.
2023-01-17all: store data layout as little endian valueAyke van Laethem
This makes it much easier to read the value at runtime, as pointer indices are naturally little endian. It should not affect anything else in the program.
2022-10-19ci: add support for LLVM 15Ayke van Laethem
This commit switches to LLVM 15 everywhere by default, while still keeping LLVM 14 support.
2022-10-19interp: add support for constant icmp instructionsAyke van Laethem
These instructions sometimes pop up in LLVM 15, but they never occured in LLVM 14. Implementing them is relatively straightforward: simply generalize the code that already exists for llvm.ICmp interpreting.
2022-10-19all: remove pointer ElementType callsAyke van Laethem
This is needed for opaque pointers, which are enabled by default in LLVM 15.
2022-10-19interp: change object.llvmType to the initializer typeAyke van Laethem
Previously it was a pointer type, which won't work with opaque pointers. Instead, use the global initializer type instead.
2022-10-19all: replace llvm.Const* calls with builder.Create* callsAyke van Laethem
A number of llvm.Const* functions (in particular extractvalue and insertvalue) were removed in LLVM 15, so we have to use a builder instead. This builder will create the same constant values, it simply uses a different API.
2022-10-19all: add type parameter to *GEP callsAyke van Laethem
This is necessary for LLVM 15.
2022-10-19all: add type parameter to CreateLoadAyke van Laethem
This is needed for LLVM 15.
2022-10-19all: add type parameter to CreateCallAyke van Laethem
This uses LLVMBuildCall2 in the background, which is the replacement for the deprecated LLVMBuildCall function.
2022-09-15interp: fix reading from external globalAyke van Laethem
This fixes https://github.com/tinygo-org/tinygo/issues/3020.
2022-08-20make interp timeout configurable from command lineDamian Gryski
2022-08-07all: update _test.go files for ioutil changesDamian Gryski
2022-06-02interp: do not unroll loopsNia Waldvogel
This change triggers a revert whenever a basic block runs instructions at runtime twice. As a result, a loop body with runtime-only instructions will no longer be unrolled. This should help some extreme cases where loops can be expanded into hundreds or thousands of instructions.
2022-05-30builder: free LLVM objects after useAyke van Laethem
This reduces the TinyGo memory consumption when running make tinygo-test from 5.8GB to around 2GB on my laptop.
2022-05-25interp: implement binary operators in markExternal* functionsAyke van Laethem
This is necessary for the next commit. The next commit would otherwise cause an issue with the following constant operation: i64 add (i64 ptrtoint (%runtime.machHeader* @_mh_execute_header to i64), i64 32)
2022-05-25interp: improve error handling of markExternal* functionsAyke van Laethem
2022-05-22interp: fix some buggy localValue handlingAyke van Laethem
Bug: 1. fn.locals[v.value] returns 0 (the default value) if v.value is not part of the fn.locals map. 2. locals[fn.locals[v.value]] then returns the first local value, which is usually non-nil 3. This incorrect value is then used as the operand value. The manifestation of this convoluted bug was https://github.com/tinygo-org/tinygo/issues/2842. It didn't occur more often probably because it only seems to happen in practice with inline assembly. Fixes https://github.com/tinygo-org/tinygo/issues/2842
2022-05-22interp: do not try to interpret past task.Pause()Ayke van Laethem
For context, see: https://github.com/tinygo-org/tinygo/pull/2863#issuecomment-1133875237 Basically, testdata/goroutine.go was doing `time.Sleep()` inside an init function which broke because doing that from a non-goroutine is not allowed. However, we never hit this bug because of https://github.com/tinygo-org/tinygo/issues/2842 (I didn't investigate exactly why).
2022-05-08Skip slice-copy test for LLVM < 14Elliott Sales de Andrade
Fixes #2836
2022-04-23all: update to LLVM 14Ayke van Laethem
Switch over to LLVM 14 for static builds. Keep using LLVM 13 for regular builds for now. This uses a branch of the upstream Espressif branch to fix an issue, see: https://github.com/espressif/llvm-project/pull/59
2022-03-17interp: prevent an off-by-one during interp debugDamian Gryski
2022-01-24interp: don't log from the interp packageAyke van Laethem
We shouldn't be logging anything when not explicitly requested via a flag or some other way.
2022-01-21interp: handle type assertions on nil interfacesNia Waldvogel
Previously, a type assertion on a nil interface would result in an out-of-bounds operand access, as we assumed it was a ptrtoint. This would usually result in an undefined value which happens not to have the same name as the asserted type (and therefore the assertion fails as expected). However, with an LLVM build with asserts, LLVM throws an assertion error: ``` interp.test: /home/niaow/go/src/github.com/tinygo-org/tinygo/llvm-project/llvm/include/llvm/IR/User.h:170: llvm::Value* llvm::User::getOperand(unsigned int) const: Assertion `i < NumUserOperands && "getOperand() out of range!"' failed. ``` This change handles a type code of 0 specially.
2022-01-20interpreter.go: double timeout to let a real world project build. Waiting ↵Dan Kegel
is a bit less frustrating with breadcrumbs.
2022-01-19compiler: remove parentHandle from calling conventionNia Waldvogel
This removes the parentHandle argument from the internal calling convention. It was formerly used to implment coroutines. Now that coroutines have been removed, it is no longer necessary.
2022-01-15interp: always run atomic and volatile loads/stores at runtimeNia Waldvogel
2022-01-11interp: show breadcrumbs to help developer find slow init functions; raise ↵Dan Kegel
timeout.