diff --git a/remix-lib/src/sourceLocationTracker.js b/remix-lib/src/sourceLocationTracker.js index d4a83fdad8..f3bf72f88f 100644 --- a/remix-lib/src/sourceLocationTracker.js +++ b/remix-lib/src/sourceLocationTracker.js @@ -11,6 +11,8 @@ function SourceLocationTracker (_codeManager) { this.codeManager = _codeManager this.event = new EventManager() this.sourceMappingDecoder = new SourceMappingDecoder() + this.sourceMapCacheOfInstructionIndex = {} + this.sourceMapCacheOfVMTraceIndex = {} } /** @@ -23,10 +25,14 @@ function SourceLocationTracker (_codeManager) { */ SourceLocationTracker.prototype.getSourceLocationFromInstructionIndex = function (address, index, contracts, cb) { var self = this + if (self.sourceMapCacheOfInstructionIndex[address]) { + return cb(null, self.sourceMappingDecoder.atIndex(index, self.sourceMapCacheOfInstructionIndex[address])) + } extractSourceMap(this.codeManager, address, contracts, function (error, sourceMap) { if (error) { cb(error) } else { + if (!helper.isContractCreation(address)) self.sourceMapCacheOfInstructionIndex[address] = sourceMap cb(null, self.sourceMappingDecoder.atIndex(index, sourceMap)) } }) @@ -42,12 +48,16 @@ SourceLocationTracker.prototype.getSourceLocationFromInstructionIndex = function */ SourceLocationTracker.prototype.getSourceLocationFromVMTraceIndex = function (address, vmtraceStepIndex, contracts, cb) { var self = this + if (self.sourceMapCacheOfVMTraceIndex[address]) { + return cb(null, self.sourceMappingDecoder.atIndex(vmtraceStepIndex, self.sourceMapCacheOfVMTraceIndex[address])) + } extractSourceMap(this.codeManager, address, contracts, function (error, sourceMap) { if (!error) { self.codeManager.getInstructionIndex(address, vmtraceStepIndex, function (error, index) { if (error) { cb(error) } else { + if (!helper.isContractCreation(address)) self.sourceMapCacheOfVMTraceIndex[address] = sourceMap cb(null, self.sourceMappingDecoder.atIndex(index, sourceMap)) } }) diff --git a/remix-solidity/src/decoder/internalCallTree.js b/remix-solidity/src/decoder/internalCallTree.js index 2e5218f1ac..254affce07 100644 --- a/remix-solidity/src/decoder/internalCallTree.js +++ b/remix-solidity/src/decoder/internalCallTree.js @@ -200,7 +200,7 @@ function includeVariableDeclaration (tree, step, sourceLocation, scopeId, newLoc }) } var functionDefinition = resolveFunctionDefinition(tree, step, previousSourceLocation) - if (functionDefinition && ((newLocation && traceHelper.isJumpDestInstruction(tree.traceManager.trace[step - 1])) || functionDefinition.attributes.isConstructor)) { + if (functionDefinition && newLocation && traceHelper.isJumpDestInstruction(tree.traceManager.trace[step - 1])) { tree.functionCallStack.push(step) // means: the previous location was a function definition && JUMPDEST // => we are at the beginning of the function and input/output are setup