-
Notifications
You must be signed in to change notification settings - Fork 951
WIP: redesign interp #2655
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
base: dev
Are you sure you want to change the base?
WIP: redesign interp #2655
Conversation
This is still a bit more complex than I want (especially with |
There is one known problem right now: the memory management assumes that a store of a non-byte-multiple integer (mainly |
Why would that not be correct? All modern general-purpose ISAs are byte addressable, not bit addressable. LLVM backends lower |
From the LLVM docs for store:
If I understand what this is saying, this is unspecified behavior. However, yes I expect that this is at least generally correct. |
Now most of the base tests pass. The main exceptions are:
|
The |
Well I found the problem: it was a stack overflow in |
This is probably because those rely on |
The remaining issue with |
a0df4b9
to
ac5f18f
Compare
With the latest commit, the |
Use the existing compilerContext.createObjectLayout on the channel's underlying element to create a layout value that can be passed to the channel buffer's allocation.
Split compilerContext.createObjectLayout into two parts in preparation for calling the second part by the map creation layout function.
A Bits type for manipulating a size and a bitmap as one. Probably overkill for the needs coming up of building the layout for a hashmap but it can be shrunk down or replaced. For now, it makes the building of a bucket layout straightfoward in the next commit. Also the unit tests are a bit much given the limited use of the type.
Modify build.createMapUpdate to take the element type. Define the compilerContext.createMapLayout for creating a hashmap bucket layout. Pass the hashmap layout to the hashmapMake and hashmapSet functions. Define a hashmapBucketLayout function that takes sizes and bitmaps for the key and element types of a map and returns the size and bitmap for the bucket type. This is the function that needs to be kept in sync with the bucket layout implemented by src/runtime/hashmap.go. In src/runtime/hashmap.go, modifies arguments to hashmapMake and the hashmapSet family of functions to take the layout parameter in order to get the layout value passed to the alloc call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given my confusion regarding pointerAlign vs pointerSize, the first parameter name to createObjectLayout1 is then a misnomer. Maybe both should be passed to createObjectLayout1 or maybe createObjectLayout1 should should compute those two values again on its own.
compiler/llvm.go
Outdated
@@ -102,6 +101,70 @@ func (c *compilerContext) createObjectLayout(t llvm.Type, pos token.Pos) llvm.Va | |||
layout := (uint64(1) << 1) | 1 | |||
return llvm.ConstIntToPtr(llvm.ConstInt(c.uintptrType, layout, false), c.i8ptrType) | |||
} | |||
return c.createObjectLayout1(pointerSize, objectSizeBytes, bitmap, pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My version passed a pointerSize. But with the change to line 163, this should also be the alignment. Maybe better to pass both or pass neither and just recompute them in createObjectLayout1.
compiler/llvm.go
Outdated
// We know there are pointers, we added one ourself for the bucket overhead | ||
// so no check for that. | ||
|
||
return c.createObjectLayout1(pointerAlign, mSizeBytes, mbitmap, pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't pass the alignment unless the earlier call does too.
compiler/llvm.go
Outdated
} | ||
|
||
func (c *compilerContext) createObjectLayout1(pointerSize, objectSizeBytes uint64, bitmap *big.Int, pos token.Pos) llvm.Value { | ||
pointerAlignment := c.targetData.PrefTypeAlignment(c.i8ptrType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the causes of confusion. I got the alignment here, without passing it from the caller.
Fix the bucket size for the case of a key or value or both being smaller than a pointer. Fix the layout construction when the pointer alignment is smaller than the pointer width.
I am not really sure how I feel about this. I have gotten a lot working so far, but this is just way too big and complicated right now. |
Some things that went right with this attempt:
Some things that went wrong with this attempt:
|
This is an attempt to redesign interp. It is still relatively early on, but the main goals are to track side-effects more accurately and keep time complexity down.