Skip to content

Commit

Permalink
[REFACTOR] Removes AoT mode
Browse files Browse the repository at this point in the history
The existing AoT mode is significantly different than the future
direction that we want to go with precompiling templates. In particular,
it relied on static analysis of programs at compile time, including
being able to resolve all components ahead of time. With the direction
we're moving with template imports, this will not be possible without a
significant investment in static build tooling, so we want to focus on a
solution that does not require this.

This PR removes the existing AoT mode and refactors everything to assume
that there is only one major mode for Glimmer apps to run in, which is
effectively "JIT" mode as it exists today. We will continue to iterate
on and improve JIT mode, until it can precompile and ship byte code
templates like AoT mode could.
  • Loading branch information
Chris Garrett authored and rwjblue committed Sep 1, 2020
1 parent a716e5c commit ddbfb2c
Show file tree
Hide file tree
Showing 88 changed files with 517 additions and 2,885 deletions.
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glimmer-benchmark",
"version": "0.59.0",
"version": "0.60.0",
"private": true,
"dependencies": {
"@glimmer/benchmark-env": "*",
Expand Down
2 changes: 1 addition & 1 deletion lib/local-linker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "local-linker",
"version": "0.59.0",
"version": "0.60.0",
"private": true,
"keywords": [
"ember-addon"
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer/benchmark-env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"repository": "https://github.com/glimmerjs/glimmer-vm/tree/master/packages/@glimmer/benchmark-env",
"dependencies": {
"@glimmer/global-context": "^0.60.0",
"@glimmer/program": "^0.60.0",
"@glimmer/reference": "^0.60.0",
"@glimmer/runtime": "^0.60.0",
"@glimmer/validator": "^0.60.0",
Expand Down
27 changes: 21 additions & 6 deletions packages/@glimmer/benchmark-env/src/benchmark/create-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {
ModifierManager,
CompilableProgram,
Dict,
PartialDefinition,
} from '@glimmer/interfaces';
import { JitContext } from '@glimmer/opcode-compiler';
import { syntaxCompilationContext } from '@glimmer/opcode-compiler';
import { artifacts } from '@glimmer/program';
import { SimpleComponentManager } from '@glimmer/runtime';
import { SimpleElement } from '@simple-dom/interface';

Expand Down Expand Up @@ -128,20 +130,33 @@ export default function createRegistry(): Registry {
);
},
render: (entry, args, element, isIteractive) => {
const context = JitContext({
lookupHelper: (name) => helpers.get(name)?.handle,
lookupModifier: (name) => modifiers.get(name)?.handle,
lookupComponent: (name) => components.get(name),
const sharedArtifacts = artifacts();
const context = syntaxCompilationContext(sharedArtifacts, {
lookupHelper: (name) => helpers.get(name)?.handle ?? null,
lookupModifier: (name) => modifiers.get(name)?.handle ?? null,
lookupComponent: (name) => components.get(name) ?? null,
lookupPartial: () => null,
resolve: () => null,
});
const component = components.get(entry);
if (!component) {
throw new Error(`missing ${entry} component`);
}

return renderBenchmark(
sharedArtifacts,
context,
{
resolve: (handle) => values[handle].definition,
resolve<U extends ComponentDefinition | Helper | ModifierDefinition | PartialDefinition>(
handle: number
): U {
return values[handle].definition as U;
},
lookupComponent: () => null,
lookupPartial: () => null,
compilable() {
throw new Error('not implemented');
},
},
component.definition,
component.compilable,
Expand Down
25 changes: 11 additions & 14 deletions packages/@glimmer/benchmark-env/src/benchmark/render-benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import { SimpleElement } from '@simple-dom/interface';
import {
Dict,
RuntimeResolverDelegate,
RuntimeResolver,
SyntaxCompilationContext,
ComponentDefinition,
CompilableProgram,
RuntimeArtifacts,
} from '@glimmer/interfaces';
import { createConstRef, Reference, childRefFor } from '@glimmer/reference';
import {
NewElementBuilder,
JitRuntime,
JitSyntaxCompilationContext,
renderSync,
renderJitComponent,
} from '@glimmer/runtime';
import { NewElementBuilder, runtimeContext, renderComponent, renderSync } from '@glimmer/runtime';

import createEnvDelegate, { registerResult } from './create-env-delegate';
import { measureRender } from './util';
import { UpdateBenchmark } from '../interfaces';

export default async function renderBenchmark(
context: JitSyntaxCompilationContext,
runtimeResolverDelegate: RuntimeResolverDelegate,
artifacts: RuntimeArtifacts,
context: SyntaxCompilationContext,
runtimeResolver: RuntimeResolver,
component: ComponentDefinition,
layout: CompilableProgram,
root: Dict,
Expand All @@ -32,13 +29,13 @@ export default async function renderBenchmark(
await measureRender('render', 'renderStart', 'renderEnd', () => {
const document = element.ownerDocument;
const envDelegate = createEnvDelegate(isInteractive);
const runtime = JitRuntime(
const runtime = runtimeContext(
{
document,
},
envDelegate,
context,
runtimeResolverDelegate
artifacts,
runtimeResolver
);
const env = runtime.env;
const cursor = { element, nextSibling: null };
Expand All @@ -52,7 +49,7 @@ export default async function renderBenchmark(

const result = renderSync(
env,
renderJitComponent(runtime, treeBuilder, context, component, layout, args)
renderComponent(runtime, treeBuilder, context, component, layout, args)
);

registerResult(result, () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/benchmark-env/src/benchmark/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {
} from '@glimmer/interfaces';
import { unwrapTemplate, unwrapHandle } from '@glimmer/util';
import { templateFactory } from '@glimmer/opcode-compiler';
import { JitSyntaxCompilationContext } from '@glimmer/interfaces';
import { SyntaxCompilationContext } from '@glimmer/interfaces';

export function createProgram(
template: SerializedTemplateWithLazyBlock<unknown>
): CompilableProgram {
return unwrapTemplate(templateFactory(template).create()).asLayout();
}

export function compileEntry(entry: CompileTimeComponent, context: JitSyntaxCompilationContext) {
export function compileEntry(entry: CompileTimeComponent, context: SyntaxCompilationContext) {
return unwrapHandle(entry.compilable!.compile(context));
}

Expand Down
1 change: 0 additions & 1 deletion packages/@glimmer/bundle-compiler/.npmignore

This file was deleted.

14 changes: 0 additions & 14 deletions packages/@glimmer/bundle-compiler/index.ts

This file was deleted.

Loading

0 comments on commit ddbfb2c

Please sign in to comment.