Commit a2600e1d authored by yann300's avatar yann300

keep a cache of source location

parent f9b824dd
......@@ -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))
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment