front-cpu 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +475 -0
- package/README.zh-CN.md +474 -0
- package/dist/Pipeline.d.ts +119 -0
- package/dist/Pipeline.d.ts.map +1 -0
- package/dist/Pipeline.js +373 -0
- package/dist/Pipeline.js.map +1 -0
- package/dist/debug.d.ts +3 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +12 -0
- package/dist/debug.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +49 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +8 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/isa/index.d.ts +20 -0
- package/dist/isa/index.d.ts.map +1 -0
- package/dist/isa/index.js +26 -0
- package/dist/isa/index.js.map +1 -0
- package/dist/isa/types.d.ts +144 -0
- package/dist/isa/types.d.ts.map +1 -0
- package/dist/isa/types.js +10 -0
- package/dist/isa/types.js.map +1 -0
- package/dist/logging/CPUConsole.d.ts +105 -0
- package/dist/logging/CPUConsole.d.ts.map +1 -0
- package/dist/logging/CPUConsole.js +471 -0
- package/dist/logging/CPUConsole.js.map +1 -0
- package/dist/logging/CPUDebugger.d.ts +91 -0
- package/dist/logging/CPUDebugger.d.ts.map +1 -0
- package/dist/logging/CPUDebugger.js +166 -0
- package/dist/logging/CPUDebugger.js.map +1 -0
- package/dist/logging/CPUEventCollector.d.ts +90 -0
- package/dist/logging/CPUEventCollector.d.ts.map +1 -0
- package/dist/logging/CPUEventCollector.js +353 -0
- package/dist/logging/CPUEventCollector.js.map +1 -0
- package/dist/logging/CPULogger.d.ts +150 -0
- package/dist/logging/CPULogger.d.ts.map +1 -0
- package/dist/logging/CPULogger.js +336 -0
- package/dist/logging/CPULogger.js.map +1 -0
- package/dist/logging/index.d.ts +10 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +16 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/runtime.d.ts +37 -0
- package/dist/logging/runtime.d.ts.map +1 -0
- package/dist/logging/runtime.js +42 -0
- package/dist/logging/runtime.js.map +1 -0
- package/dist/logging/stack-parser.d.ts +22 -0
- package/dist/logging/stack-parser.d.ts.map +1 -0
- package/dist/logging/stack-parser.js +144 -0
- package/dist/logging/stack-parser.js.map +1 -0
- package/dist/logging/types.d.ts +73 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +47 -0
- package/dist/logging/types.js.map +1 -0
- package/dist/scheduling/ResourceStrategyRegistry.d.ts +61 -0
- package/dist/scheduling/ResourceStrategyRegistry.d.ts.map +1 -0
- package/dist/scheduling/ResourceStrategyRegistry.js +109 -0
- package/dist/scheduling/ResourceStrategyRegistry.js.map +1 -0
- package/dist/scheduling/index.d.ts +6 -0
- package/dist/scheduling/index.d.ts.map +1 -0
- package/dist/scheduling/index.js +5 -0
- package/dist/scheduling/index.js.map +1 -0
- package/dist/scheduling/types.d.ts +44 -0
- package/dist/scheduling/types.d.ts.map +1 -0
- package/dist/scheduling/types.js +5 -0
- package/dist/scheduling/types.js.map +1 -0
- package/dist/stages/EX.d.ts +17 -0
- package/dist/stages/EX.d.ts.map +1 -0
- package/dist/stages/EX.js +95 -0
- package/dist/stages/EX.js.map +1 -0
- package/dist/stages/IF.d.ts +41 -0
- package/dist/stages/IF.d.ts.map +1 -0
- package/dist/stages/IF.js +83 -0
- package/dist/stages/IF.js.map +1 -0
- package/dist/stages/RES.d.ts +17 -0
- package/dist/stages/RES.d.ts.map +1 -0
- package/dist/stages/RES.js +37 -0
- package/dist/stages/RES.js.map +1 -0
- package/dist/stages/SCH.d.ts +77 -0
- package/dist/stages/SCH.d.ts.map +1 -0
- package/dist/stages/SCH.js +270 -0
- package/dist/stages/SCH.js.map +1 -0
- package/dist/stages/WB.d.ts +19 -0
- package/dist/stages/WB.d.ts.map +1 -0
- package/dist/stages/WB.js +102 -0
- package/dist/stages/WB.js.map +1 -0
- package/dist/types.d.ts +111 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +26 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/InstructionCancellation.d.ts +31 -0
- package/dist/utils/InstructionCancellation.d.ts.map +1 -0
- package/dist/utils/InstructionCancellation.js +53 -0
- package/dist/utils/InstructionCancellation.js.map +1 -0
- package/dist/utils/abortable.d.ts +30 -0
- package/dist/utils/abortable.d.ts.map +1 -0
- package/dist/utils/abortable.js +76 -0
- package/dist/utils/abortable.js.map +1 -0
- package/dist/utils/request.d.ts +27 -0
- package/dist/utils/request.d.ts.map +1 -0
- package/dist/utils/request.js +96 -0
- package/dist/utils/request.js.map +1 -0
- package/package.json +74 -0
- package/src/Pipeline.ts +475 -0
- package/src/debug.ts +15 -0
- package/src/index.ts +67 -0
- package/src/interfaces.ts +53 -0
- package/src/isa/index.ts +34 -0
- package/src/isa/types.ts +178 -0
- package/src/logging/CPUConsole.md +843 -0
- package/src/logging/CPUConsole.ts +631 -0
- package/src/logging/CPUDebugger.ts +235 -0
- package/src/logging/CPUEventCollector.ts +418 -0
- package/src/logging/CPULogger.ts +435 -0
- package/src/logging/CPU_LOGGING_DESIGN.md +1319 -0
- package/src/logging/USAGE_GUIDE.md +505 -0
- package/src/logging/index.ts +21 -0
- package/src/logging/runtime.ts +96 -0
- package/src/logging/stack-parser.ts +168 -0
- package/src/logging/types.ts +101 -0
- package/src/scheduling/ResourceStrategyRegistry.ts +124 -0
- package/src/scheduling/index.ts +13 -0
- package/src/scheduling/types.ts +47 -0
- package/src/stages/EX.ts +121 -0
- package/src/stages/IF.ts +103 -0
- package/src/stages/RES.ts +46 -0
- package/src/stages/SCH.ts +331 -0
- package/src/stages/WB.ts +127 -0
- package/src/types.ts +118 -0
- package/src/utils/InstructionCancellation.ts +73 -0
- package/src/utils/abortable.ts +89 -0
- package/src/utils/request.ts +125 -0
package/dist/Pipeline.js
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CPU流水线主控制器(解耦版)
|
|
3
|
+
*
|
|
4
|
+
* 通过依赖注入实现零耦合架构
|
|
5
|
+
*/
|
|
6
|
+
import { InstructionFetchStage } from './stages/IF';
|
|
7
|
+
import { SchedulerStage } from './stages/SCH';
|
|
8
|
+
import { ExecuteStage } from './stages/EX';
|
|
9
|
+
import { ResponseStage } from './stages/RES';
|
|
10
|
+
import { WriteBackStage } from './stages/WB';
|
|
11
|
+
import { cpuEventCollector, cpuConsole, captureCallSource } from './logging/runtime';
|
|
12
|
+
import { InstructionStatus } from './types';
|
|
13
|
+
import { isInstructionCancelled, cancelInstruction } from './utils/InstructionCancellation';
|
|
14
|
+
/**
|
|
15
|
+
* 默认状态实现(非响应式)
|
|
16
|
+
*/
|
|
17
|
+
function createPlainState(initialValue) {
|
|
18
|
+
let value = initialValue;
|
|
19
|
+
const subscribers = [];
|
|
20
|
+
return {
|
|
21
|
+
get value() {
|
|
22
|
+
return value;
|
|
23
|
+
},
|
|
24
|
+
setValue(newValue) {
|
|
25
|
+
value = newValue;
|
|
26
|
+
subscribers.forEach((cb) => cb(value));
|
|
27
|
+
},
|
|
28
|
+
subscribe(callback) {
|
|
29
|
+
subscribers.push(callback);
|
|
30
|
+
return () => {
|
|
31
|
+
const index = subscribers.indexOf(callback);
|
|
32
|
+
if (index > -1)
|
|
33
|
+
subscribers.splice(index, 1);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export class Pipeline {
|
|
39
|
+
constructor(config = {}) {
|
|
40
|
+
this.isRunning = false;
|
|
41
|
+
this.tickInterval = null;
|
|
42
|
+
this.totalCompleted = 0;
|
|
43
|
+
this.totalFailed = 0;
|
|
44
|
+
this.totalCancelled = 0;
|
|
45
|
+
// 🔥 Promise resolvers for awaitable dispatch
|
|
46
|
+
this.promiseResolvers = new Map();
|
|
47
|
+
// 配置参数
|
|
48
|
+
this.TICK_INTERVAL_MS = config.tickInterval ?? 16;
|
|
49
|
+
this.MAX_CONCURRENCY = config.maxConcurrency ?? 10;
|
|
50
|
+
// 创建响应式状态
|
|
51
|
+
const stateFactory = config.reactiveStateFactory ?? createPlainState;
|
|
52
|
+
this.status = stateFactory({
|
|
53
|
+
ifBufferSize: 0,
|
|
54
|
+
schPendingSize: 0,
|
|
55
|
+
schActiveSize: 0,
|
|
56
|
+
totalCompleted: 0,
|
|
57
|
+
totalFailed: 0,
|
|
58
|
+
totalCancelled: 0,
|
|
59
|
+
});
|
|
60
|
+
// 创建流水线阶段
|
|
61
|
+
this.IF = new InstructionFetchStage();
|
|
62
|
+
this.SCH = new SchedulerStage(this.MAX_CONCURRENCY);
|
|
63
|
+
this.EX = new ExecuteStage();
|
|
64
|
+
this.RES = new ResponseStage();
|
|
65
|
+
this.WB = new WriteBackStage();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 发射指令(外部API)
|
|
69
|
+
*
|
|
70
|
+
* @returns Promise that resolves with the instruction result or rejects with error
|
|
71
|
+
*/
|
|
72
|
+
dispatch(type, payload, source = 'user', options) {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
// 🔒 检查流水线是否在运行
|
|
75
|
+
if (!this.isRunning) {
|
|
76
|
+
console.warn('%c⚠️ 流水线未启动,指令被拒绝', 'color: #FF9800; font-weight: bold', {
|
|
77
|
+
type,
|
|
78
|
+
payload,
|
|
79
|
+
});
|
|
80
|
+
reject(new Error('Pipeline is not running'));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// 🔍 捕获调用源(跳过 1 层:Promise constructor)
|
|
84
|
+
const callSource = captureCallSource(1);
|
|
85
|
+
// IF: 获取指令
|
|
86
|
+
const instruction = this.IF.fetchInstruction(type, payload, source, callSource, options?.tags);
|
|
87
|
+
// 🔥 保存 Promise resolvers
|
|
88
|
+
this.promiseResolvers.set(instruction.id, { resolve, reject });
|
|
89
|
+
// 🎯 记录指令创建事件
|
|
90
|
+
cpuEventCollector.onInstructionCreated(instruction);
|
|
91
|
+
cpuConsole.onInstructionCreated(instruction);
|
|
92
|
+
// 加入调度队列
|
|
93
|
+
this.SCH.addInstruction(instruction);
|
|
94
|
+
// 立即尝试调度
|
|
95
|
+
this.SCH.tick();
|
|
96
|
+
// 🔥 立即执行新发射的指令(避免tick延迟)
|
|
97
|
+
this.processActiveInstructions();
|
|
98
|
+
// 更新状态
|
|
99
|
+
this.updateStatus();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* 启动流水线
|
|
104
|
+
*/
|
|
105
|
+
start() {
|
|
106
|
+
if (this.isRunning)
|
|
107
|
+
return;
|
|
108
|
+
this.isRunning = true;
|
|
109
|
+
// 启动调度器的tick循环
|
|
110
|
+
this.tickInterval = globalThis.setInterval(() => {
|
|
111
|
+
this.SCH.tick();
|
|
112
|
+
this.processActiveInstructions();
|
|
113
|
+
this.updateStatus();
|
|
114
|
+
}, this.TICK_INTERVAL_MS);
|
|
115
|
+
console.log('%c🚀 CPU流水线已启动', 'color: #2196F3; font-weight: bold');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 停止流水线
|
|
119
|
+
*/
|
|
120
|
+
stop() {
|
|
121
|
+
if (!this.isRunning)
|
|
122
|
+
return;
|
|
123
|
+
this.isRunning = false;
|
|
124
|
+
if (this.tickInterval !== null) {
|
|
125
|
+
globalThis.clearInterval(this.tickInterval);
|
|
126
|
+
this.tickInterval = null;
|
|
127
|
+
}
|
|
128
|
+
console.log('%c⏸️ CPU流水线已停止', 'color: #FF9800; font-weight: bold');
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 重置流水线
|
|
132
|
+
*/
|
|
133
|
+
reset() {
|
|
134
|
+
this.stop();
|
|
135
|
+
// 清空所有阶段
|
|
136
|
+
this.IF.clear();
|
|
137
|
+
this.SCH.clear();
|
|
138
|
+
// 🔥 Reject all pending promises
|
|
139
|
+
for (const [, resolver] of this.promiseResolvers.entries()) {
|
|
140
|
+
resolver.reject(new Error('Pipeline was reset'));
|
|
141
|
+
}
|
|
142
|
+
this.promiseResolvers.clear();
|
|
143
|
+
// 重置状态
|
|
144
|
+
this.totalCompleted = 0;
|
|
145
|
+
this.totalFailed = 0;
|
|
146
|
+
this.totalCancelled = 0;
|
|
147
|
+
this.status.setValue({
|
|
148
|
+
ifBufferSize: 0,
|
|
149
|
+
schPendingSize: 0,
|
|
150
|
+
schActiveSize: 0,
|
|
151
|
+
totalCompleted: 0,
|
|
152
|
+
totalFailed: 0,
|
|
153
|
+
totalCancelled: 0,
|
|
154
|
+
});
|
|
155
|
+
console.log('%c🔄 CPU流水线已重置', 'color: #9C27B0; font-weight: bold');
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* 处理正在执行的指令
|
|
159
|
+
*/
|
|
160
|
+
async processActiveInstructions() {
|
|
161
|
+
const activeInstructions = this.SCH.getActiveInstructions();
|
|
162
|
+
for (const instruction of activeInstructions) {
|
|
163
|
+
// 已经在执行中,跳过
|
|
164
|
+
if (instruction.timestamps.EX) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// 🔥 检查是否已被取消(switchMap 等场景)
|
|
168
|
+
if (isInstructionCancelled(instruction)) {
|
|
169
|
+
// 立即处理取消,不再进入执行流程
|
|
170
|
+
this.handleCancelledInstruction(instruction);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
// 异步执行指令
|
|
174
|
+
this.executeInstruction(instruction);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 处理已取消的指令
|
|
179
|
+
* 直接完成清理工作,不再进入 EX/RES/WB 流程
|
|
180
|
+
*/
|
|
181
|
+
handleCancelledInstruction(instruction) {
|
|
182
|
+
// 标记 WB 时间戳(虽然没有真正执行 WB)
|
|
183
|
+
instruction.timestamps.WB = Date.now();
|
|
184
|
+
// 释放资源
|
|
185
|
+
this.SCH.releaseInstruction(instruction.id);
|
|
186
|
+
// 计算持续时间
|
|
187
|
+
const duration = (instruction.timestamps.WB || Date.now()) - (instruction.timestamps.IF || Date.now());
|
|
188
|
+
// 记录取消事件
|
|
189
|
+
cpuEventCollector.onInstructionCancelled(instruction);
|
|
190
|
+
cpuConsole.onInstructionCancelled(instruction, duration);
|
|
191
|
+
this.totalCancelled += 1;
|
|
192
|
+
// Reject Promise
|
|
193
|
+
const resolver = this.promiseResolvers.get(instruction.id);
|
|
194
|
+
if (resolver) {
|
|
195
|
+
resolver.reject(instruction.error || new Error('Instruction was cancelled'));
|
|
196
|
+
this.promiseResolvers.delete(instruction.id);
|
|
197
|
+
}
|
|
198
|
+
// 更新状态
|
|
199
|
+
this.updateStatus();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 执行单个指令
|
|
203
|
+
*/
|
|
204
|
+
async executeInstruction(instruction) {
|
|
205
|
+
let executionError;
|
|
206
|
+
try {
|
|
207
|
+
// EX: 执行
|
|
208
|
+
await this.EX.execute(instruction);
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
executionError = err;
|
|
212
|
+
}
|
|
213
|
+
// RES: 处理响应
|
|
214
|
+
const { success } = this.RES.processResponse(instruction, executionError);
|
|
215
|
+
// WB: 写回
|
|
216
|
+
await this.WB.writeBack(instruction, success);
|
|
217
|
+
// 释放资源
|
|
218
|
+
this.SCH.releaseInstruction(instruction.id);
|
|
219
|
+
// 🎯 获取最终错误信息
|
|
220
|
+
// 优先级:instruction.error(可能在 SCH/EX/RES 任何阶段设置) > 执行时捕获的错误 > 未知错误
|
|
221
|
+
const finalError = instruction.error || executionError || new Error('未知错误');
|
|
222
|
+
// 🎯 记录指令完成/失败/取消事件
|
|
223
|
+
const duration = (instruction.timestamps.WB || Date.now()) - (instruction.timestamps.IF || Date.now());
|
|
224
|
+
if (success) {
|
|
225
|
+
// 成功
|
|
226
|
+
cpuEventCollector.onInstructionCommitted(instruction);
|
|
227
|
+
cpuConsole.onInstructionSuccess(instruction, duration);
|
|
228
|
+
this.totalCompleted += 1;
|
|
229
|
+
}
|
|
230
|
+
else if (instruction.status === InstructionStatus.CANCELLED) {
|
|
231
|
+
// 被取消(不算失败)
|
|
232
|
+
cpuEventCollector.onInstructionCancelled(instruction);
|
|
233
|
+
cpuConsole.onInstructionCancelled(instruction, duration);
|
|
234
|
+
this.totalCancelled += 1;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
// 失败
|
|
238
|
+
cpuEventCollector.onInstructionFailed(instruction, finalError);
|
|
239
|
+
cpuConsole.onInstructionFailure(instruction, finalError, duration);
|
|
240
|
+
this.totalFailed += 1;
|
|
241
|
+
}
|
|
242
|
+
// 🔥 Resolve/Reject Promise (if awaited)
|
|
243
|
+
const resolver = this.promiseResolvers.get(instruction.id);
|
|
244
|
+
if (resolver) {
|
|
245
|
+
if (success) {
|
|
246
|
+
resolver.resolve(instruction.result);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
resolver.reject(finalError);
|
|
250
|
+
}
|
|
251
|
+
this.promiseResolvers.delete(instruction.id);
|
|
252
|
+
}
|
|
253
|
+
// 更新状态
|
|
254
|
+
this.updateStatus();
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 按标签批量取消指令
|
|
258
|
+
* @param tags 要取消的标签(字符串或字符串数组)
|
|
259
|
+
* @returns 取消的指令数量
|
|
260
|
+
*/
|
|
261
|
+
flush(tags) {
|
|
262
|
+
const targetTags = Array.isArray(tags) ? tags : [tags];
|
|
263
|
+
let cancelledCount = 0;
|
|
264
|
+
// 1. 取消 SCH 中的 pending 指令
|
|
265
|
+
const pendingInstructions = this.SCH.getPendingInstructions();
|
|
266
|
+
for (const instruction of pendingInstructions) {
|
|
267
|
+
if (this.hasMatchingTags(instruction, targetTags)) {
|
|
268
|
+
cancelInstruction(instruction, `Flushed by tags: ${targetTags.join(', ')}`, 'SCH');
|
|
269
|
+
cancelledCount++;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
// 2. 取消 SCH 中的 active 指令
|
|
273
|
+
const activeInstructions = this.SCH.getActiveInstructions();
|
|
274
|
+
for (const instruction of activeInstructions) {
|
|
275
|
+
if (this.hasMatchingTags(instruction, targetTags)) {
|
|
276
|
+
cancelInstruction(instruction, `Flushed by tags: ${targetTags.join(', ')}`, 'SCH');
|
|
277
|
+
cancelledCount++;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return cancelledCount;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 检查指令是否包含匹配的标签
|
|
284
|
+
*/
|
|
285
|
+
hasMatchingTags(instruction, targetTags) {
|
|
286
|
+
if (!instruction.tags || instruction.tags.length === 0) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
return targetTags.some(tag => instruction.tags.includes(tag));
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* 获取带特定标签的指令
|
|
293
|
+
*/
|
|
294
|
+
getInstructionsByTags(tags) {
|
|
295
|
+
const allInstructions = [
|
|
296
|
+
...this.SCH.getPendingInstructions(),
|
|
297
|
+
...this.SCH.getActiveInstructions()
|
|
298
|
+
];
|
|
299
|
+
return allInstructions.filter(instruction => this.hasMatchingTags(instruction, tags));
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* 获取所有活跃标签
|
|
303
|
+
*/
|
|
304
|
+
getActiveTags() {
|
|
305
|
+
const allInstructions = [
|
|
306
|
+
...this.SCH.getPendingInstructions(),
|
|
307
|
+
...this.SCH.getActiveInstructions()
|
|
308
|
+
];
|
|
309
|
+
const tagSet = new Set();
|
|
310
|
+
for (const instruction of allInstructions) {
|
|
311
|
+
if (instruction.tags) {
|
|
312
|
+
instruction.tags.forEach(tag => tagSet.add(tag));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return Array.from(tagSet);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 获取标签统计信息
|
|
319
|
+
*/
|
|
320
|
+
getTagStats() {
|
|
321
|
+
const allInstructions = [
|
|
322
|
+
...this.SCH.getPendingInstructions(),
|
|
323
|
+
...this.SCH.getActiveInstructions()
|
|
324
|
+
];
|
|
325
|
+
const tagStats = {};
|
|
326
|
+
for (const instruction of allInstructions) {
|
|
327
|
+
if (instruction.tags) {
|
|
328
|
+
instruction.tags.forEach(tag => {
|
|
329
|
+
tagStats[tag] = (tagStats[tag] || 0) + 1;
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return tagStats;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* 更新流水线状态
|
|
337
|
+
*/
|
|
338
|
+
updateStatus() {
|
|
339
|
+
this.status.setValue({
|
|
340
|
+
ifBufferSize: this.IF.getBufferSize(),
|
|
341
|
+
schPendingSize: this.SCH.getPendingQueueSize(),
|
|
342
|
+
schActiveSize: this.SCH.getActiveCount(),
|
|
343
|
+
totalCompleted: this.totalCompleted,
|
|
344
|
+
totalFailed: this.totalFailed,
|
|
345
|
+
totalCancelled: this.totalCancelled,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* 获取流水线状态(供外部使用)
|
|
350
|
+
*/
|
|
351
|
+
getStatus() {
|
|
352
|
+
return this.status.value;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* 获取IF缓冲区
|
|
356
|
+
*/
|
|
357
|
+
getIFBuffer() {
|
|
358
|
+
return this.IF.getBuffer();
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* 获取SCH pending队列
|
|
362
|
+
*/
|
|
363
|
+
getSCHPendingQueue() {
|
|
364
|
+
return this.SCH.getPendingQueue();
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* 获取SCH active指令
|
|
368
|
+
*/
|
|
369
|
+
getSCHActiveInstructions() {
|
|
370
|
+
return this.SCH.getActiveInstructions();
|
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AC,CAAC,GAAG,CAAC,CAAA;gBAC1C,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;OAEG;IACK,YAAY;QAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YACnB,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE;YACrC,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE;YAC9C,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE;YACxC,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAA;IAC1B,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,wBAAwB;QACtB,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,CAAA;IACzC,CAAC;CACF"}
|
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAWA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
|
package/dist/debug.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { cpuEventCollector, cpuConsole, cpuLogger } from './logging';
|
|
2
|
+
import { captureCallSource } from './logging/stack-parser';
|
|
3
|
+
import { setLoggingProvider } from './logging/runtime';
|
|
4
|
+
setLoggingProvider({
|
|
5
|
+
cpuEventCollector,
|
|
6
|
+
cpuConsole,
|
|
7
|
+
cpuLogger,
|
|
8
|
+
captureCallSource,
|
|
9
|
+
});
|
|
10
|
+
export * from './index';
|
|
11
|
+
export * from './logging';
|
|
12
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,kBAAkB,CAAC;IACjB,iBAAiB;IACjB,UAAU;IACV,SAAS;IACT,iBAAiB;CAClB,CAAC,CAAA;AAEF,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FrontCPU - 前端指令执行系统
|
|
3
|
+
*
|
|
4
|
+
* 解耦版:通过依赖注入实现零耦合架构
|
|
5
|
+
*/
|
|
6
|
+
export { Pipeline } from './Pipeline';
|
|
7
|
+
export type { PipelineStatus, PipelineConfig } from './Pipeline';
|
|
8
|
+
export type { QueuedInstruction, InstructionContext, InstructionStatus, PipelineStage, WriteBackExecution, } from './types';
|
|
9
|
+
export { PipelineStage as PipelineStageEnum, InstructionStatus as InstructionStatusEnum, } from './types';
|
|
10
|
+
export { registerISA, getISA, clearISA } from './isa';
|
|
11
|
+
export type { ISADefinition, InstructionDefinition } from './isa/types';
|
|
12
|
+
export type { InstructionMeta, HttpMethod, RequestConfig, MultiRequestConfig, OptimisticSnapshot, OptimisticConfig, SchedulingStrategy, } from './isa/types';
|
|
13
|
+
export type { ResourceStrategyConfig, StrategyContext } from './scheduling';
|
|
14
|
+
export { registerResourceStrategy, registerResourceStrategies, setDefaultSchedulingStrategy, } from './scheduling';
|
|
15
|
+
export { setHttpClient } from './utils/request';
|
|
16
|
+
export { setCorrelationIdGenerator } from './stages/IF';
|
|
17
|
+
export type { IHttpClient, ILogger, ICorrelationIdGenerator, IReactiveState, RequestConfig as IRequestConfig, } from './interfaces';
|
|
18
|
+
export { cancelInstruction, isInstructionCancelled, getCancellationInfo, cancelInstructions, } from './utils/InstructionCancellation';
|
|
19
|
+
export { makeAbortable, cancellableDelay } from './utils/abortable';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGhE,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACnB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,iBAAiB,IAAI,qBAAqB,GAC3C,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACrD,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACvE,YAAY,EACV,eAAe,EACf,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAA;AAGpB,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,cAAc,CAAA;AAGrB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAGvD,YAAY,EACV,WAAW,EACX,OAAO,EACP,uBAAuB,EACvB,cAAc,EACd,aAAa,IAAI,cAAc,GAChC,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,iCAAiC,CAAA;AAGxC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FrontCPU - 前端指令执行系统
|
|
3
|
+
*
|
|
4
|
+
* 解耦版:通过依赖注入实现零耦合架构
|
|
5
|
+
*/
|
|
6
|
+
// 核心Pipeline
|
|
7
|
+
export { Pipeline } from './Pipeline';
|
|
8
|
+
export { PipelineStage as PipelineStageEnum, InstructionStatus as InstructionStatusEnum, } from './types';
|
|
9
|
+
// ISA相关
|
|
10
|
+
export { registerISA, getISA, clearISA } from './isa';
|
|
11
|
+
export { registerResourceStrategy, registerResourceStrategies, setDefaultSchedulingStrategy, } from './scheduling';
|
|
12
|
+
// 依赖注入
|
|
13
|
+
export { setHttpClient } from './utils/request';
|
|
14
|
+
export { setCorrelationIdGenerator } from './stages/IF';
|
|
15
|
+
// 指令取消工具
|
|
16
|
+
export { cancelInstruction, isInstructionCancelled, getCancellationInfo, cancelInstructions, } from './utils/InstructionCancellation';
|
|
17
|
+
// 可取消工具
|
|
18
|
+
export { makeAbortable, cancellableDelay } from './utils/abortable';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,aAAa;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAWrC,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,iBAAiB,IAAI,qBAAqB,GAC3C,MAAM,SAAS,CAAA;AAEhB,QAAQ;AACR,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAcrD,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,cAAc,CAAA;AAErB,OAAO;AACP,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAWvD,SAAS;AACT,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,iCAAiC,CAAA;AAExC,QAAQ;AACR,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FrontCPU 抽象接口定义
|
|
3
|
+
*
|
|
4
|
+
* 这些接口用于解耦CPU核心系统与具体实现,
|
|
5
|
+
* 通过依赖注入实现零耦合架构。
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* HTTP客户端接口
|
|
9
|
+
*/
|
|
10
|
+
export interface IHttpClient {
|
|
11
|
+
get<T>(url: string, config?: RequestConfig): Promise<T>;
|
|
12
|
+
post<T>(url: string, data?: any, config?: RequestConfig): Promise<T>;
|
|
13
|
+
patch<T>(url: string, data?: any, config?: RequestConfig): Promise<T>;
|
|
14
|
+
put<T>(url: string, data?: any, config?: RequestConfig): Promise<T>;
|
|
15
|
+
delete<T>(url: string, config?: RequestConfig): Promise<T>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* HTTP请求配置
|
|
19
|
+
*/
|
|
20
|
+
export interface RequestConfig {
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 日志接口
|
|
26
|
+
*/
|
|
27
|
+
export interface ILogger {
|
|
28
|
+
debug(tag: string, message: string, data?: any): void;
|
|
29
|
+
info(tag: string, message: string, data?: any): void;
|
|
30
|
+
warn(tag: string, message: string, data?: any): void;
|
|
31
|
+
error(tag: string, message: string, data?: any): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* CorrelationId生成器接口
|
|
35
|
+
*/
|
|
36
|
+
export interface ICorrelationIdGenerator {
|
|
37
|
+
generate(): string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 响应式状态接口
|
|
41
|
+
*
|
|
42
|
+
* 用于适配不同框架的响应式系统(Vue、React、Svelte等)
|
|
43
|
+
*/
|
|
44
|
+
export interface IReactiveState<T> {
|
|
45
|
+
value: T;
|
|
46
|
+
setValue(newValue: T): void;
|
|
47
|
+
subscribe(callback: (value: T) => void): () => void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACvD,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACpE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IACrE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,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G"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISA(指令集架构)管理
|
|
3
|
+
*
|
|
4
|
+
* 提供全局ISA注册和访问机制
|
|
5
|
+
*/
|
|
6
|
+
import type { ISADefinition } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* 注册ISA(由项目调用)
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerISA(isa: ISADefinition): void;
|
|
11
|
+
/**
|
|
12
|
+
* 获取ISA(供Pipeline内部使用)
|
|
13
|
+
*/
|
|
14
|
+
export declare function getISA(): ISADefinition;
|
|
15
|
+
/**
|
|
16
|
+
* 清空ISA(用于测试)
|
|
17
|
+
*/
|
|
18
|
+
export declare function clearISA(): void;
|
|
19
|
+
export type { ISADefinition, InstructionDefinition } from './types';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/isa/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAK5C;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAEpD;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,aAAa,CAEtC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,IAAI,CAE/B;AAGD,YAAY,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISA(指令集架构)管理
|
|
3
|
+
*
|
|
4
|
+
* 提供全局ISA注册和访问机制
|
|
5
|
+
*/
|
|
6
|
+
// 全局ISA存储
|
|
7
|
+
let globalISA = {};
|
|
8
|
+
/**
|
|
9
|
+
* 注册ISA(由项目调用)
|
|
10
|
+
*/
|
|
11
|
+
export function registerISA(isa) {
|
|
12
|
+
globalISA = { ...globalISA, ...isa };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 获取ISA(供Pipeline内部使用)
|
|
16
|
+
*/
|
|
17
|
+
export function getISA() {
|
|
18
|
+
return globalISA;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 清空ISA(用于测试)
|
|
22
|
+
*/
|
|
23
|
+
export function clearISA() {
|
|
24
|
+
globalISA = {};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/isa/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,UAAU;AACV,IAAI,SAAS,GAAkB,EAAE,CAAA;AAEjC;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,GAAkB;IAC5C,SAAS,GAAG,EAAE,GAAG,SAAS,EAAE,GAAG,GAAG,EAAE,CAAA;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,SAAS,GAAG,EAAE,CAAA;AAChB,CAAC"}
|