mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:58:29 +00:00
Delete the lazy emitter
Change-Id: I6aff22c1106ee03604c888226e961e208b621de4 Reviewed-on: https://dart-review.googlesource.com/10802 Reviewed-by: Emily Fortuna <efortuna@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
a4189d36fd
commit
64fa2ad383
|
@ -661,9 +661,6 @@ _TODO: complete the documentation for the following files_.
|
|||
`lib/src/js_emitter/type_test_registry.dart`
|
||||
`lib/src/js_emitter/js_emitter.dart.rej`
|
||||
`lib/src/js_emitter/class_stub_generator.dart`
|
||||
`lib/src/js_emitter/lazy_emitter`
|
||||
`lib/src/js_emitter/lazy_emitter/model_emitter.dart`
|
||||
`lib/src/js_emitter/lazy_emitter/emitter.dart`
|
||||
`lib/src/js_emitter/startup_emitter`
|
||||
`lib/src/js_emitter/startup_emitter/deferred_fragment_hash.dart`
|
||||
`lib/src/js_emitter/startup_emitter/model_emitter.dart`
|
||||
|
|
|
@ -10,7 +10,6 @@ import '../common.dart';
|
|||
import '../options.dart';
|
||||
import '../dump_info.dart' show DumpInfoTask;
|
||||
import '../io/code_output.dart' show CodeBuffer;
|
||||
import '../js_emitter/js_emitter.dart' show USE_LAZY_EMITTER;
|
||||
import 'js_source_mapping.dart';
|
||||
|
||||
export 'package:js_ast/js_ast.dart';
|
||||
|
@ -22,7 +21,6 @@ String prettyPrint(Node node, CompilerOptions compilerOptions,
|
|||
JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(
|
||||
shouldCompressOutput: compilerOptions.enableMinification,
|
||||
minifyLocalVariables: allowVariableMinification,
|
||||
preferSemicolonToNewlineInMinifiedOutput: USE_LAZY_EMITTER,
|
||||
renamerForNames: renamerForNames);
|
||||
SimpleJavaScriptPrintingContext context =
|
||||
new SimpleJavaScriptPrintingContext();
|
||||
|
@ -39,7 +37,6 @@ CodeBuffer createCodeBuffer(Node node, CompilerOptions compilerOptions,
|
|||
JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(
|
||||
shouldCompressOutput: compilerOptions.enableMinification,
|
||||
minifyLocalVariables: allowVariableMinification,
|
||||
preferSemicolonToNewlineInMinifiedOutput: USE_LAZY_EMITTER,
|
||||
renamerForNames: renamerForNames);
|
||||
CodeBuffer outBuffer = new CodeBuffer();
|
||||
SourceInformationProcessor sourceInformationProcessor =
|
||||
|
|
|
@ -17,7 +17,6 @@ import '../js_backend/js_backend.dart' show JavaScriptBackend, Namer;
|
|||
import '../universe/world_builder.dart' show CodegenWorldBuilder;
|
||||
import '../world.dart' show ClosedWorld;
|
||||
import 'full_emitter/emitter.dart' as full_js_emitter;
|
||||
import 'lazy_emitter/emitter.dart' as lazy_js_emitter;
|
||||
import 'program_builder/program_builder.dart';
|
||||
import 'startup_emitter/emitter.dart' as startup_js_emitter;
|
||||
|
||||
|
@ -27,8 +26,6 @@ import 'native_emitter.dart' show NativeEmitter;
|
|||
import 'type_test_registry.dart' show TypeTestRegistry;
|
||||
import 'sorter.dart';
|
||||
|
||||
const USE_LAZY_EMITTER = const bool.fromEnvironment("dart2js.use.lazy.emitter");
|
||||
|
||||
/**
|
||||
* Generates the code for all used classes in the program. Static fields (even
|
||||
* in classes) are ignored, since they can be treated as non-class elements.
|
||||
|
@ -39,7 +36,7 @@ class CodeEmitterTask extends CompilerTask {
|
|||
TypeTestRegistry typeTestRegistry;
|
||||
NativeEmitter _nativeEmitter;
|
||||
MetadataCollector metadataCollector;
|
||||
EmitterFactory _emitterFactory;
|
||||
final EmitterFactory _emitterFactory;
|
||||
Emitter _emitter;
|
||||
final Compiler compiler;
|
||||
|
||||
|
@ -55,17 +52,12 @@ class CodeEmitterTask extends CompilerTask {
|
|||
CodeEmitterTask(
|
||||
Compiler compiler, bool generateSourceMap, bool useStartupEmitter)
|
||||
: compiler = compiler,
|
||||
super(compiler.measurer) {
|
||||
if (USE_LAZY_EMITTER) {
|
||||
_emitterFactory = new lazy_js_emitter.EmitterFactory();
|
||||
} else if (useStartupEmitter) {
|
||||
_emitterFactory = new startup_js_emitter.EmitterFactory(
|
||||
generateSourceMap: generateSourceMap);
|
||||
} else {
|
||||
_emitterFactory = new full_js_emitter.EmitterFactory(
|
||||
generateSourceMap: generateSourceMap);
|
||||
}
|
||||
}
|
||||
_emitterFactory = useStartupEmitter
|
||||
? new startup_js_emitter.EmitterFactory(
|
||||
generateSourceMap: generateSourceMap)
|
||||
: new full_js_emitter.EmitterFactory(
|
||||
generateSourceMap: generateSourceMap),
|
||||
super(compiler.measurer);
|
||||
|
||||
NativeEmitter get nativeEmitter {
|
||||
assert(
|
||||
|
|
|
@ -1,175 +0,0 @@
|
|||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
library dart2js.js_emitter.lazy_emitter;
|
||||
|
||||
import 'package:js_runtime/shared/embedded_names.dart' show JsBuiltin;
|
||||
|
||||
import '../../common.dart';
|
||||
import '../../compiler.dart' show Compiler;
|
||||
import '../../constants/values.dart' show ConstantValue;
|
||||
import '../../deferred_load.dart' show OutputUnit;
|
||||
import '../../elements/elements.dart'
|
||||
show ClassElement, FieldElement, MethodElement;
|
||||
import '../../elements/entities.dart';
|
||||
import '../../js/js.dart' as js;
|
||||
import '../../js_backend/js_backend.dart' show JavaScriptBackend, Namer;
|
||||
import '../../world.dart' show ClosedWorld;
|
||||
import '../js_emitter.dart' show CodeEmitterTask, NativeEmitter;
|
||||
import '../js_emitter.dart' as emitterTask show EmitterBase, EmitterFactory;
|
||||
import '../model.dart';
|
||||
import '../program_builder/program_builder.dart' show ProgramBuilder;
|
||||
import '../sorter.dart' show Sorter;
|
||||
import 'model_emitter.dart';
|
||||
|
||||
class EmitterFactory implements emitterTask.EmitterFactory {
|
||||
@override
|
||||
bool get supportsReflection => false;
|
||||
|
||||
@override
|
||||
Emitter createEmitter(CodeEmitterTask task, Namer namer,
|
||||
ClosedWorld closedWorld, Sorter sorter) {
|
||||
return new Emitter(
|
||||
task.compiler, namer, task.nativeEmitter, closedWorld, sorter, task);
|
||||
}
|
||||
}
|
||||
|
||||
class Emitter extends emitterTask.EmitterBase {
|
||||
final Compiler _compiler;
|
||||
final ClosedWorld _closedWorld;
|
||||
final Namer namer;
|
||||
final ModelEmitter _emitter;
|
||||
|
||||
JavaScriptBackend get _backend => _compiler.backend;
|
||||
|
||||
Emitter(this._compiler, this.namer, NativeEmitter nativeEmitter,
|
||||
this._closedWorld, Sorter sorter, CodeEmitterTask task)
|
||||
: _emitter = new ModelEmitter(
|
||||
_compiler, namer, nativeEmitter, _closedWorld, sorter, task);
|
||||
|
||||
DiagnosticReporter get reporter => _compiler.reporter;
|
||||
|
||||
@override
|
||||
int emitProgram(ProgramBuilder programBuilder) {
|
||||
Program program = programForTesting = programBuilder.buildProgram();
|
||||
return _emitter.emitProgram(program);
|
||||
}
|
||||
|
||||
// TODO(floitsch): copied from full emitter. Adjust or share.
|
||||
@override
|
||||
bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant) {
|
||||
return _emitter.isConstantInlinedOrAlreadyEmitted(constant);
|
||||
}
|
||||
|
||||
// TODO(floitsch): copied from full emitter. Adjust or share.
|
||||
@override
|
||||
int compareConstants(ConstantValue a, ConstantValue b) {
|
||||
return _emitter.compareConstants(a, b);
|
||||
}
|
||||
|
||||
@override
|
||||
js.Expression constantReference(ConstantValue value) {
|
||||
return _emitter.generateConstantReference(value);
|
||||
}
|
||||
|
||||
@override
|
||||
js.Expression generateEmbeddedGlobalAccess(String global) {
|
||||
return _emitter.generateEmbeddedGlobalAccess(global);
|
||||
}
|
||||
|
||||
@override
|
||||
// TODO(herhut): Use a single shared function.
|
||||
js.Expression generateFunctionThatReturnsNull() {
|
||||
return js.js('function() {}');
|
||||
}
|
||||
|
||||
@override
|
||||
js.Expression isolateLazyInitializerAccess(FieldElement element) {
|
||||
return js.js('#.#', [
|
||||
namer.globalObjectForMember(element),
|
||||
namer.lazyInitializerName(element)
|
||||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
js.Expression isolateStaticClosureAccess(MethodElement element) {
|
||||
return _emitter.generateStaticClosureAccess(element);
|
||||
}
|
||||
|
||||
@override
|
||||
js.PropertyAccess prototypeAccess(
|
||||
ClassElement element, bool hasBeenInstantiated) {
|
||||
js.Expression constructor =
|
||||
hasBeenInstantiated ? constructorAccess(element) : typeAccess(element);
|
||||
return js.js('#.prototype', constructor);
|
||||
}
|
||||
|
||||
@override
|
||||
js.Expression interceptorClassAccess(ClassEntity element) {
|
||||
// Some interceptors are eagerly constructed. However, native interceptors
|
||||
// aren't.
|
||||
return js.js('#.ensureResolved()', globalPropertyAccessForClass(element));
|
||||
}
|
||||
|
||||
@override
|
||||
js.Expression typeAccess(Entity element) {
|
||||
// TODO(floitsch): minify 'ensureResolved'.
|
||||
// TODO(floitsch): don't emit `ensureResolved` for eager classes.
|
||||
return js.js('#.ensureResolved()', globalPropertyAccessForType(element));
|
||||
}
|
||||
|
||||
@override
|
||||
js.Template templateForBuiltin(JsBuiltin builtin) {
|
||||
String typeNameProperty = ModelEmitter.typeNameProperty;
|
||||
|
||||
switch (builtin) {
|
||||
case JsBuiltin.dartObjectConstructor:
|
||||
return js.js.expressionTemplateYielding(
|
||||
typeAccess(_closedWorld.commonElements.objectClass));
|
||||
|
||||
case JsBuiltin.isCheckPropertyToJsConstructorName:
|
||||
int isPrefixLength = namer.operatorIsPrefix.length;
|
||||
return js.js.expressionTemplateFor('#.substring($isPrefixLength)');
|
||||
|
||||
case JsBuiltin.isFunctionType:
|
||||
return _backend.rtiEncoder.templateForIsFunctionType;
|
||||
|
||||
case JsBuiltin.rawRtiToJsConstructorName:
|
||||
return js.js.expressionTemplateFor("#.$typeNameProperty");
|
||||
|
||||
case JsBuiltin.rawRuntimeType:
|
||||
return js.js.expressionTemplateFor("#.constructor");
|
||||
|
||||
case JsBuiltin.createFunctionTypeRti:
|
||||
return _backend.rtiEncoder.templateForCreateFunctionType;
|
||||
|
||||
case JsBuiltin.isSubtype:
|
||||
// TODO(floitsch): move this closer to where is-check properties are
|
||||
// built.
|
||||
String isPrefix = namer.operatorIsPrefix;
|
||||
return js.js.expressionTemplateFor("('$isPrefix' + #) in #.prototype");
|
||||
|
||||
case JsBuiltin.isGivenTypeRti:
|
||||
return js.js.expressionTemplateFor('#.$typeNameProperty === #');
|
||||
|
||||
case JsBuiltin.getMetadata:
|
||||
return _emitter.templateForReadMetadata;
|
||||
|
||||
case JsBuiltin.getType:
|
||||
return _emitter.templateForReadType;
|
||||
|
||||
case JsBuiltin.createDartClosureFromNameOfStaticFunction:
|
||||
throw new UnsupportedError('createDartClosureFromNameOfStaticFunction');
|
||||
|
||||
default:
|
||||
reporter.internalError(
|
||||
NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
// TODO(het): Generate this correctly
|
||||
int generatedSize(OutputUnit unit) => 0;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -302,7 +302,7 @@ abstract class GraphBuilder {
|
|||
case 'USE_CONTENT_SECURITY_POLICY':
|
||||
return options.useContentSecurityPolicy;
|
||||
case 'IS_FULL_EMITTER':
|
||||
return !USE_LAZY_EMITTER && !options.useStartupEmitter;
|
||||
return !options.useStartupEmitter;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue