core/vm: jit vm#1490
Conversation
26a8837 to
f7fcddf
Compare
baded05 to
3eda45c
Compare
7680af3 to
8b370f1
Compare
a4e0b5c to
347b726
Compare
There was a problem hiding this comment.
Because the GOROOT should determine the go version. Not PATH. Got a better suggestion?
There was a problem hiding this comment.
GOROOT is not always present in the environment.Using it here would require that people set it before building.
There was a problem hiding this comment.
I am guessing that you added this in order to be able to build/test with different Go versions.
If that's what you want, we can add a variable GO that allows you to specify the go binary.
You could then invoke make as follows:
make GO=/path/to/go/bin/go1.5
// or even
make GO=go1.5
There was a problem hiding this comment.
I don't think it's possible to use a single shared base because it is pushed to the stack.
There was a problem hiding this comment.
Sorry, that was a bit misguided. We also push common.BigFalse and friends to the stack in other places.
Bigints on the stack are not mutated. I think what @Gustav-Simonsson meant is that we could do something
like this to avoid allocating base when it is not required.
x, y := S256(stack.pop()), S256(stack.pop())
if y.Cmp(common.Big0) == 0 {
stack.Push(common.Big0)
return
}
...There was a problem hiding this comment.
We can, yes. I don't think it will make much difference but certainly agree that not requiring base in certain areas is cleaner
There was a problem hiding this comment.
Actually the reason why it is as it is right now is because the code has been copied from the origin VM to their respective functions. I wanted minimal changes to the opcodes before "moving on" to reduce the risk of bugs and errors. Again I certainly agree it can and should be refactored.
There was a problem hiding this comment.
btw x.Abs(x) mutates the stack value if x < (1<<255).
We might want to look into that. Can this happen?
There was a problem hiding this comment.
ahh, no, it shouldn't happen because the stack never contains negative values. S256 always creates a new int if the number is negative, so Abs is fine then. But this is really hard to see.
There was a problem hiding this comment.
btw this is a general potential danger with the current impl, if somewhere somehow one can push a negative int to the stack, it can be exploited by a number of other op codes.
There was a problem hiding this comment.
We need better big int objects (proper unsigned ints really). It shouldn't happen unless someone screws it up now
There was a problem hiding this comment.
I think one way to make this safer would be to move S256 to a method on stack, e.g. popS256 and document under which conditions the value refers to the live int on the stack.
There was a problem hiding this comment.
Hmm, interesting thought. Maybe we should remove push and add pushU256 and a pushS256. Remove all manual S/U256 before the push operation.
There was a problem hiding this comment.
Hmm, we could potentially avoid this hashing by reusing the contract address as id, but then it's not unique on code. Which could be fine if most contracts use CALLCODE on existing contracts for the heavy lifting. What do you think?
There was a problem hiding this comment.
I think the sha3 is fine for now. It's not that slow.
5f87691 to
94fd83e
Compare
* changed stack and removed stack ptr. Let go decide on slice reuse.
Reduced the amount of state copied that are required by N calls by doing a balance check prior to any state modifications.
Reduced big int allocation by making stack items modifiable. Instead of adding items such as `common.Big0` to the stack, `new(big.Int)` is added instead. One must expect that any item that is added to the stack might change.
…at's left in the block (ethereum#1490)
H(code)) is available and if so will use the compiled version instead. If no compiled version is available it will compile the byte code in a separate thread and continues using the byte-code VM.Status
stage 1 implemented
stage 2 implemented, but commented out
stage 3 TODO (future PTR)