Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Remove objectAllocator concept #51913

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1df98f9
Refactor node constructors in utilities to be classes
rbuckton Dec 15, 2022
3b862b6
Move services Node classes to compiler
rbuckton Dec 16, 2022
cadf6e8
Remove objectAllocator
rbuckton Dec 16, 2022
c6ffac9
Remove baseNodeFactory
rbuckton Dec 17, 2022
9f19e4c
Merge branch 'main' into no-objectAllocator
rbuckton Apr 5, 2024
a1da7e1
Move the rest of services's NodeObject to compiler
rbuckton Apr 5, 2024
1bb7e2f
Define concrete fields for known inputs
rbuckton Apr 5, 2024
1a48252
Run formatter
rbuckton Apr 5, 2024
15ad90e
Fix lint warnings
rbuckton Apr 5, 2024
6caf908
Fixes and baseline updates
rbuckton Apr 5, 2024
77ac753
Migrate additional Node/Symbol/etc. methods from services to compiler
rbuckton Apr 6, 2024
2b58861
PR feedback
rbuckton Apr 6, 2024
33d6204
Switch back to instance-only 'kind' fields
rbuckton Apr 6, 2024
bb7688f
Base method and namespace cleanup
rbuckton Apr 12, 2024
dc35984
Simplify Debug.enableDebugInfo()
rbuckton Apr 12, 2024
4ce5648
Fix formatting
rbuckton Apr 12, 2024
42065d5
Add notes for possible future improvements for memory overhead
rbuckton Apr 12, 2024
90a5def
Update baselines
rbuckton Apr 15, 2024
d1ae0e8
Avoid mutating SymbolObject.prototype in services
rbuckton Apr 15, 2024
c0ce585
Shallow constructors for NodeObject et al.
rbuckton Apr 16, 2024
7160f82
Merge branch 'main' into no-objectAllocator
rbuckton Apr 17, 2024
1b39a6d
Remove unnecessary import alias for SymbolObject
rbuckton Apr 17, 2024
cf125da
Update classes to more closely align with recent changes to services
rbuckton Apr 17, 2024
b07f7da
Merge branch 'main' into no-objectAllocator
rbuckton Apr 17, 2024
74b510a
Update baselines
rbuckton Apr 18, 2024
9e56c70
Don't mutate SignatureObject from services
rbuckton Apr 18, 2024
1f0d71f
Fix format and lint
rbuckton Apr 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ TEST-results.xml
package-lock.json
.eslintcache
*v8.log
*.heapsnapshot
*.heapprofile
/lib/
6 changes: 2 additions & 4 deletions .vscode/launch.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@
"sourceMaps": true,
"smartStep": true,
"preLaunchTask": "npm: build:tests",
"console": "integratedTerminal",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
"console": "integratedTerminal"
},
{
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
"type": "node",
"request": "attach",
"name": "Attach to VS Code TS Server via Port",
"processId": "${command:PickProcess}",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
"processId": "${command:PickProcess}"
}
]
}
4 changes: 3 additions & 1 deletion scripts/build/options.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import os from "os";
const ci = ["1", "true"].includes(process.env.CI ?? "");

const parsed = minimist(process.argv.slice(2), {
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint", "coverage"],
boolean: ["dirty", "light", "colors", "lkg", "soft", "fix", "failed", "keepFailed", "force", "built", "ci", "bundle", "typecheck", "lint", "coverage", "bail"],
string: ["browser", "tests", "break", "host", "reporter", "stackTraceLimit", "timeout", "shards", "shardId"],
alias: {
b: "browser",
Expand Down Expand Up @@ -41,6 +41,7 @@ const parsed = minimist(process.argv.slice(2), {
typecheck: true,
lint: true,
coverage: false,
bail: false,
},
});

Expand Down Expand Up @@ -86,5 +87,6 @@ export default options;
* @property {boolean} typecheck
* @property {boolean} lint
* @property {boolean} coverage
* @property {boolean} bail
*/
void 0;
4 changes: 4 additions & 0 deletions scripts/build/tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
const shards = +cmdLineOptions.shards || undefined;
const shardId = +cmdLineOptions.shardId || undefined;
const coverage = cmdLineOptions.coverage;
const bail = cmdLineOptions.bail;
if (!cmdLineOptions.dirty) {
if (options.watching) {
console.log(chalk.yellowBright(`[watch] cleaning test directories...`));
Expand Down Expand Up @@ -90,6 +91,9 @@ export async function runConsoleTests(runJs, defaultReporter, runInParallel, opt
args.push(mochaJs);
args.push("-R", findUpFile("scripts/failed-tests.cjs"));
args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"');
if (bail) {
args.push("--bail");
}
if (tests) {
args.push("-g", `"${tests}"`);
}
Expand Down
1 change: 0 additions & 1 deletion src/compiler/_namespaces/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export * from "../diagnosticInformationMap.generated";
export * from "../scanner";
export * from "../utilitiesPublic";
export * from "../utilities";
export * from "../factory/baseNodeFactory";
export * from "../factory/parenthesizerRules";
export * from "../factory/nodeConverters";
export * from "../factory/nodeFactory";
Expand Down
7 changes: 2 additions & 5 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ import {
nodeIsPresent,
NonNullChain,
NonNullExpression,
objectAllocator,
ObjectLiteralExpression,
OptionalChain,
ParameterDeclaration,
Expand Down Expand Up @@ -322,6 +321,7 @@ import {
WithStatement,
} from "./_namespaces/ts";
import * as performance from "./_namespaces/ts.performance";
import { SymbolObject } from "./objectConstructors";

/** @internal */
export const enum ModuleInstanceState {
Expand Down Expand Up @@ -559,7 +559,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {

var symbolCount = 0;

var Symbol: new (flags: SymbolFlags, name: __String) => Symbol;
var classifiableNames: Set<__String>;

var unreachableFlow = createFlowNode(FlowFlags.Unreachable, /*node*/ undefined, /*antecedent*/ undefined);
Expand All @@ -586,8 +585,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
classifiableNames = new Set();
symbolCount = 0;

Symbol = objectAllocator.getSymbolConstructor();

// Attach debugging information if necessary
Debug.attachFlowNodeDebugInfo(unreachableFlow);
Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
Expand Down Expand Up @@ -639,7 +636,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {

function createSymbol(flags: SymbolFlags, name: __String): Symbol {
symbolCount++;
return new Symbol(flags, name);
return new SymbolObject(flags, name);
}

function addDeclarationToSymbol(symbol: Symbol, node: Declaration, symbolFlags: SymbolFlags) {
Expand Down
18 changes: 9 additions & 9 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,6 @@ import {
noTruncationMaximumTruncationLength,
NumberLiteralType,
NumericLiteral,
objectAllocator,
ObjectBindingPattern,
ObjectFlags,
ObjectFlagsType,
Expand Down Expand Up @@ -1100,6 +1099,11 @@ import {
} from "./_namespaces/ts";
import * as moduleSpecifiers from "./_namespaces/ts.moduleSpecifiers";
import * as performance from "./_namespaces/ts.performance";
import {
SignatureObject,
SymbolObject,
TypeObject,
} from "./objectConstructors";

const ambientModuleSymbolRegex = /^".+"$/;
const anon = "(anonymous)" as __String & string;
Expand Down Expand Up @@ -1445,10 +1449,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
var requestedExternalEmitHelpers: ExternalEmitHelpers;
var externalHelpersModule: Symbol;

var Symbol = objectAllocator.getSymbolConstructor();
var Type = objectAllocator.getTypeConstructor();
var Signature = objectAllocator.getSignatureConstructor();

var typeCount = 0;
var symbolCount = 0;
var totalInstantiationCount = 0;
Expand Down Expand Up @@ -2510,7 +2510,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {

function createSymbol(flags: SymbolFlags, name: __String, checkFlags?: CheckFlags) {
symbolCount++;
const symbol = new Symbol(flags | SymbolFlags.Transient, name) as TransientSymbol;
const symbol = new SymbolObject(flags | SymbolFlags.Transient, name) as Symbol as TransientSymbol;
symbol.links = new SymbolLinks() as TransientSymbolLinks;
symbol.links.checkFlags = checkFlags || CheckFlags.None;
return symbol;
Expand Down Expand Up @@ -5291,7 +5291,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function createType(flags: TypeFlags): Type {
const result = new Type(checker, flags);
const result = new TypeObject(checker, flags);
typeCount++;
result.id = typeCount;
tracing?.recordType(result);
Expand All @@ -5305,7 +5305,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function createOriginType(flags: TypeFlags): Type {
return new Type(checker, flags);
return new TypeObject(checker, flags);
}

function createIntrinsicType(kind: TypeFlags, intrinsicName: string, objectFlags = ObjectFlags.None, debugIntrinsicName?: string): IntrinsicType {
Expand Down Expand Up @@ -13016,7 +13016,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
minArgumentCount: number,
flags: SignatureFlags,
): Signature {
const sig = new Signature(checker, flags);
const sig = new SignatureObject(checker, flags);
sig.declaration = declaration;
sig.typeParameters = typeParameters;
sig.parameters = parameters;
Expand Down
Loading
Loading