File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,12 @@ function WasmSourceMap(sourceMap) {
5555}
5656
5757WasmSourceMap . prototype . lookup = function ( offset ) {
58- var info = this . mapping [ this . normalizeOffset ( offset ) ] ;
58+ var normalized = this . normalizeOffset ( offset ) ;
59+ #if 'emscripten_generate_pc' in addedLibraryItems
60+ if ( ! wasmOffsetConverter . isSameFunc ( offset , normalized ) )
61+ return null ;
62+ #endif
63+ var info = this . mapping [ normalized ] ;
5964 if ( ! info )
6065 return null ;
6166 return {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ function WasmOffsetConverter(wasmBytes) {
1313 var idx = 0 ;
1414
1515 this . map = { } ;
16+ this . func_starts = [ ] ;
1617
1718 function unsignedLEB128 ( ) {
1819 var result = 0 ;
@@ -69,6 +70,7 @@ function WasmOffsetConverter(wasmBytes) {
6970 while ( count -- > 0 ) {
7071 var size = unsignedLEB128 ( ) ;
7172 this . map [ idx ++ ] = offset ;
73+ this . func_starts . push ( offset ) ;
7274 offset += size ;
7375 }
7476 return ;
@@ -80,3 +82,23 @@ function WasmOffsetConverter(wasmBytes) {
8082WasmOffsetConverter . prototype . convert = function ( funcidx , offset ) {
8183 return this . map [ funcidx ] + offset ;
8284}
85+
86+ WasmOffsetConverter . prototype . isSameFunc = function ( offset1 , offset2 ) {
87+ var array = this . func_starts ;
88+ function bisect ( offset ) {
89+ var lo = 0 ;
90+ var hi = array . length ;
91+ var mid ;
92+
93+ while ( lo < hi ) {
94+ mid = Math . floor ( ( lo + hi ) / 2 ) ;
95+ if ( array [ mid ] > offset ) {
96+ hi = mid ;
97+ } else {
98+ lo = mid + 1 ;
99+ }
100+ }
101+ return lo ;
102+ }
103+ return bisect ( offset1 ) == bisect ( offset2 ) ;
104+ }
You can’t perform that action at this time.
0 commit comments