Skip to content

Commit d1cbff2

Browse files
author
Jesse Chen
committed
fix according to review
1 parent 4e5863d commit d1cbff2

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

src/compiler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9830,8 +9830,7 @@ export class Compiler extends DiagnosticEmitter {
98309830
let targetFunction = this.currentFlow.targetFunction;
98319831
let source = range.source;
98329832
if (source.debugInfoIndex < 0) source.debugInfoIndex = this.module.addDebugInfoFile(source.normalizedPath);
9833-
range.debugInfo.set(targetFunction.internalName, expr);
9834-
targetFunction.debugLocations.push(range);
9833+
targetFunction.debugLocations.set(expr, range);
98359834
}
98369835

98379836
/** Checks whether a particular function signature is supported. */

src/diagnostics.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
DiagnosticCode,
1212
diagnosticCodeToString
1313
} from "./diagnosticMessages.generated";
14-
import { ExpressionRef } from "./module";
1514

1615
import {
1716
isLineBreak,
@@ -46,7 +45,6 @@ export const enum DiagnosticCategory {
4645
export class Range {
4746

4847
source!: Source;
49-
debugInfo: Map<string, ExpressionRef> = new Map<string, ExpressionRef>();
5048

5149
constructor(public start: i32, public end: i32) {}
5250

src/program.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3746,7 +3746,7 @@ export class Function extends TypedElement {
37463746
/** Default control flow. */
37473747
flow!: Flow;
37483748
/** Remembered debug locations. */
3749-
debugLocations: Range[] = [];
3749+
debugLocations: Map<ExpressionRef, Range> = new Map<ExpressionRef, Range>();
37503750
/** Function reference, if compiled. */
37513751
ref: FunctionRef = 0;
37523752
/** Varargs stub for calling with omitted arguments. */
@@ -3913,15 +3913,11 @@ export class Function extends TypedElement {
39133913

39143914
addDebugInfo(module: Module, ref: FunctionRef): void {
39153915
if (this.program.options.sourceMap) {
3916-
let debugLocations = this.debugLocations;
3917-
for (let i = 0, k = debugLocations.length; i < k; ++i) {
3918-
let range = debugLocations[i];
3916+
for (const [expressRef, range] of this.debugLocations) {
39193917
let source = range.source;
3920-
const debugInfo = range.debugInfo.get(this.internalName);
3921-
assert(debugInfo);
39223918
module.setDebugLocation(
39233919
ref,
3924-
debugInfo as ExpressionRef,
3920+
expressRef,
39253921
source.debugInfoIndex,
39263922
source.lineAt(range.start),
39273923
source.columnAt() - 1 // source maps are 0-based

tests/compiler/template-debuginfo.debug.sourcemap.wat

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,17 +1277,24 @@
12771277
(local.set $block|3
12781278
(local.get $block)
12791279
)
1280+
;;@ ~lib/rt/tlsf.ts:97:2
12801281
(br $label$3
1282+
;;@ ~lib/rt/tlsf.ts:97:9
12811283
(i32.add
1284+
;;@ ~lib/rt/tlsf.ts:97:27
12821285
(i32.add
12831286
(local.get $block|3)
1287+
;;@ ~lib/rt/tlsf.ts:97:54
12841288
(i32.const 4)
12851289
)
1290+
;;@ ~lib/rt/tlsf.ts:97:72
12861291
(i32.and
12871292
(call $~lib/rt/common/BLOCK#get:mmInfo
12881293
(local.get $block|3)
12891294
)
1295+
;;@ ~lib/rt/tlsf.ts:97:87
12901296
(i32.xor
1297+
;;@ ~lib/rt/tlsf.ts:97:88
12911298
(i32.const 3)
12921299
(i32.const -1)
12931300
)
@@ -3480,12 +3487,17 @@
34803487
(local.set $fl|6
34813488
(local.get $fl)
34823489
)
3490+
;;@ ~lib/rt/tlsf.ts:145:2
34833491
(br $label$8
3492+
;;@ ~lib/rt/tlsf.ts:145:9
34843493
(i32.load offset=4
3494+
;;@ ~lib/rt/tlsf.ts:146:4
34853495
(i32.add
34863496
(local.get $root|5)
3497+
;;@ ~lib/rt/tlsf.ts:146:31
34873498
(i32.shl
34883499
(local.get $fl|6)
3500+
;;@ ~lib/rt/tlsf.ts:146:37
34893501
(i32.const 2)
34903502
)
34913503
)
@@ -3631,19 +3643,27 @@
36313643
(local.get $slMap)
36323644
)
36333645
)
3634-
;;@ ~lib/rt/tlsf.ts:344:31
3646+
;;@ ~lib/rt/tlsf.ts:164:2
36353647
(br $label$14
3648+
;;@ ~lib/rt/tlsf.ts:164:9
36363649
(i32.load offset=96
3650+
;;@ ~lib/rt/tlsf.ts:165:4
36373651
(i32.add
36383652
(local.get $root|12)
3653+
;;@ ~lib/rt/tlsf.ts:165:31
36393654
(i32.shl
3655+
;;@ ~lib/rt/tlsf.ts:165:32
36403656
(i32.add
3657+
;;@ ~lib/rt/tlsf.ts:165:33
36413658
(i32.shl
36423659
(local.get $fl|13)
3660+
;;@ ~lib/rt/tlsf.ts:165:39
36433661
(i32.const 4)
36443662
)
3663+
;;@ ~lib/rt/tlsf.ts:165:50
36453664
(local.get $sl|14)
36463665
)
3666+
;;@ ~lib/rt/tlsf.ts:165:64
36473667
(i32.const 2)
36483668
)
36493669
)
@@ -4076,22 +4096,29 @@
40764096
(i32.and
40774097
;;@ ~lib/rt/tlsf.ts:371:4
40784098
(call $~lib/rt/common/BLOCK#get:mmInfo
4079-
;;@ ~lib/rt/tlsf.ts:97:2
40804099
(block $label$5 (result i32)
4100+
;;@ ~lib/rt/tlsf.ts:371:13
40814101
(local.set $block|6
40824102
(local.get $block)
40834103
)
4104+
;;@ ~lib/rt/tlsf.ts:97:2
40844105
(br $label$5
4106+
;;@ ~lib/rt/tlsf.ts:97:9
40854107
(i32.add
4108+
;;@ ~lib/rt/tlsf.ts:97:27
40864109
(i32.add
40874110
(local.get $block|6)
4111+
;;@ ~lib/rt/tlsf.ts:97:54
40884112
(i32.const 4)
40894113
)
4114+
;;@ ~lib/rt/tlsf.ts:97:72
40904115
(i32.and
40914116
(call $~lib/rt/common/BLOCK#get:mmInfo
40924117
(local.get $block|6)
40934118
)
4119+
;;@ ~lib/rt/tlsf.ts:97:87
40944120
(i32.xor
4121+
;;@ ~lib/rt/tlsf.ts:97:88
40954122
(i32.const 3)
40964123
(i32.const -1)
40974124
)

0 commit comments

Comments
 (0)