Update localsMap when inlining or looking at super constructors.

Bug:
Change-Id: I60b2d0d87d84901817d7d03b685a068c9d2f6100
Reviewed-on: https://dart-review.googlesource.com/14621
Commit-Queue: Emily Fortuna <efortuna@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
This commit is contained in:
Emily Fortuna 2017-10-18 17:58:32 +00:00
parent b51d5035aa
commit 2b33f79dd1
6 changed files with 29 additions and 17 deletions

View file

@ -93,7 +93,6 @@ class KernelSsaBuilder implements SsaBuilder {
@override
HGraph build(CodegenWorkItem work, ClosedWorld closedWorld) {
KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(work.element);
KernelSsaGraphBuilder builder = new KernelSsaGraphBuilder(
work.element,
_elementMap.getMemberThisType(work.element),
@ -101,7 +100,7 @@ class KernelSsaBuilder implements SsaBuilder {
_elementMap,
new KernelToTypeInferenceMapImpl(
work.element, _compiler.globalInference.results),
localsMap,
_globalLocalsMap,
closedWorld,
_compiler.codegenWorldBuilder,
work.registry,

View file

@ -26,7 +26,7 @@ import '../io/source_information.dart';
import '../js/js.dart' as js;
import '../js_backend/backend.dart' show JavaScriptBackend;
import '../js_emitter/js_emitter.dart' show NativeEmitter;
import '../js_model/locals.dart' show JumpVisitor;
import '../js_model/locals.dart' show GlobalLocalsMap, JumpVisitor;
import '../kernel/element_map.dart';
import '../native/native.dart' as native;
import '../resolution/tree_elements.dart';
@ -90,7 +90,8 @@ class KernelSsaGraphBuilder extends ir.Visitor
SourceInformationBuilder sourceInformationBuilder;
final KernelToElementMapForBuilding _elementMap;
final KernelToTypeInferenceMap _typeInferenceMap;
final KernelToLocalsMap localsMap;
final GlobalLocalsMap _globalLocalsMap;
KernelToLocalsMap _localsMap;
LoopHandler<ir.Node> loopHandler;
TypeBuilder typeBuilder;
@ -110,7 +111,7 @@ class KernelSsaGraphBuilder extends ir.Visitor
this.compiler,
this._elementMap,
this._typeInferenceMap,
this.localsMap,
this._globalLocalsMap,
this.closedWorld,
this._worldBuilder,
this.registry,
@ -119,6 +120,7 @@ class KernelSsaGraphBuilder extends ir.Visitor
// TODO(het): Should sourceInformationBuilder be in GraphBuilder?
this.sourceInformationBuilder,
this.functionNode) {
_localsMap = _globalLocalsMap.getLocalsMap(targetElement);
this.loopHandler = new KernelLoopHandler(this);
typeBuilder = new KernelTypeBuilder(this, _elementMap);
graph.element = targetElement;
@ -129,6 +131,8 @@ class KernelSsaGraphBuilder extends ir.Visitor
_targetStack.add(targetElement);
}
KernelToLocalsMap get localsMap => _localsMap;
CommonElements get _commonElements => _elementMap.commonElements;
HGraph build() {
@ -384,6 +388,9 @@ class KernelSsaGraphBuilder extends ir.Visitor
ConstructorEntity constructorElement = _elementMap.getConstructor(body);
KernelToLocalsMap oldLocalsMap = _localsMap;
_localsMap = _globalLocalsMap.getLocalsMap(constructorElement);
void handleParameter(ir.VariableDeclaration node) {
Local parameter = localsMap.getLocalVariable(node);
// If [parameter] is boxed, it will be a field in the box passed as the
@ -419,6 +426,7 @@ class KernelSsaGraphBuilder extends ir.Visitor
}
_invokeConstructorBody(body, bodyCallInputs);
_localsMap = oldLocalsMap;
}
closeAndGotoExit(new HReturn(newObject, null));
@ -678,6 +686,10 @@ class KernelSsaGraphBuilder extends ir.Visitor
Map<FieldEntity, HInstruction> fieldValues,
ir.Constructor caller) {
var index = 0;
KernelToLocalsMap oldLocalsMap = _localsMap;
ConstructorEntity element = _elementMap.getConstructor(constructor);
_localsMap = _globalLocalsMap.getLocalsMap(element);
void handleParameter(ir.VariableDeclaration node) {
Local parameter = localsMap.getLocalVariable(node);
HInstruction argument = arguments[index++];
@ -694,7 +706,6 @@ class KernelSsaGraphBuilder extends ir.Visitor
..forEach(handleParameter);
// Set the locals handler state as if we were inlining the constructor.
ConstructorEntity element = _elementMap.getConstructor(constructor);
ScopeInfo oldScopeInfo = localsHandler.scopeInfo;
ScopeInfo newScopeInfo = closureDataLookup.getScopeInfo(element);
localsHandler.scopeInfo = newScopeInfo;
@ -703,6 +714,7 @@ class KernelSsaGraphBuilder extends ir.Visitor
_buildInitializers(constructor, constructorChain, fieldValues);
});
localsHandler.scopeInfo = oldScopeInfo;
_localsMap = oldLocalsMap;
}
/// Builds generative constructor body.

View file

@ -321,8 +321,8 @@ class LocalsHandler {
if (local is TypeVariableLocal) {
failedAt(
CURRENT_ELEMENT_SPANNABLE,
"Runtime type information not available for $local in ${directLocals.keys}"
"in $executableContext.");
"Runtime type information not available for $local "
"in ${directLocals.keys} for $executableContext.");
} else {
failedAt(
local,

View file

@ -389,6 +389,10 @@ custom_element_method_clash_test/test: RuntimeError
custom_element_method_clash_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed assertion: line 405 pos 12: 'element.name == '=='': is not true.
custom_element_name_clash_test/test: RuntimeError
custom_element_name_clash_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed assertion: line 405 pos 12: 'element.name == '=='': is not true.
custom_elements_23127_test/baseline: RuntimeError
custom_elements_23127_test/c1t: RuntimeError
custom_elements_23127_test/c2: RuntimeError
custom_elements_23127_test/c2t: RuntimeError
custom_elements_23127_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed assertion: line 405 pos 12: 'element.name == '=='': is not true.
custom_elements_test/innerHtml: RuntimeError
custom_elements_test/lifecycle: RuntimeError
@ -717,7 +721,6 @@ webgl_1_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed
webgl_extensions_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed assertion: line 405 pos 12: 'element.name == '=='': is not true.
websocket_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed assertion: line 405 pos 12: 'element.name == '=='': is not true.
websql_test/functional: RuntimeError
websql_test/supported: RuntimeError
websql_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed assertion: line 405 pos 12: 'element.name == '=='': is not true.
wheelevent_test: RuntimeError
window_eq_test: RuntimeError
@ -812,6 +815,10 @@ custom_element_method_clash_test/test: RuntimeError
custom_element_method_clash_test: Crash # NoSuchMethodError: Class 'JMethod' has no instance getter 'implementation'.
custom_element_name_clash_test/test: RuntimeError
custom_element_name_clash_test: Crash # NoSuchMethodError: Class 'JMethod' has no instance getter 'implementation'.
custom_elements_23127_test/baseline: RuntimeError
custom_elements_23127_test/c1t: RuntimeError
custom_elements_23127_test/c2: RuntimeError
custom_elements_23127_test/c2t: RuntimeError
custom_elements_23127_test: Crash # Assertion failure: Cannot find value local(B2T.created#a) in (type_variable_local(B2T.T), local(C2T.created#a), local(C2T.created#b), local(C2T.created#c), BoxLocal(_box_0)) for j:constructor(C2T.created).
custom_elements_test/innerHtml: RuntimeError
custom_elements_test/lifecycle: RuntimeError

View file

@ -373,7 +373,6 @@ class_cycle_test/03: MissingCompileTimeError
closure_in_field_test/01: Crash # Assertion failure: Runtime type information not available for type_variable_local(Mixin.S) in (type_variable_local(Class.T), type_variable_local(_Object&Mixin^^#T0.#T0))in j:constructor(Class.).
closure_in_field_test/02: Crash # Assertion failure: Runtime type information not available for type_variable_local(Mixin.S) in (type_variable_local(Class.T), type_variable_local(_Object&Mixin^^#T0.#T0))in j:constructor(Class.).
closure_in_field_test/none: Crash # Assertion failure: Runtime type information not available for type_variable_local(Mixin.S) in (type_variable_local(Class.T), type_variable_local(_Object&Mixin^^#T0.#T0))in j:constructor(Class.).
closure_in_initializer_test: Crash # Assertion failure: Cannot find value local(A.#a) in (local(C.#a), BoxLocal(_box_0), local(C.#a), BoxLocal(_box_0)) for j:constructor(C.).
closure_self_reference_test: Crash # 'file:*/pkg/compiler/lib/src/ssa/nodes.dart': Failed assertion: line 641 pos 12: 'isClosed()': is not true.
conditional_import_string_test: CompileTimeError
conditional_import_test: CompileTimeError
@ -393,7 +392,7 @@ constants_test/05: MissingCompileTimeError
constructor2_test: RuntimeError
constructor3_test: RuntimeError
constructor5_test: RuntimeError
constructor6_test: Crash # Assertion failure: Cannot find value local(A.#arg) in (local(C.#x), local(C.#y), local(B.#arg), BoxLocal(_box_0)) for j:constructor(C.).
constructor6_test: RuntimeError
constructor_named_arguments_test/none: RuntimeError
constructor_redirect1_negative_test: Crash # Issue 30856
constructor_redirect2_negative_test: Crash # Issue 30856
@ -751,7 +750,6 @@ class_cycle_test/03: MissingCompileTimeError
closure_in_field_test/01: Crash # Assertion failure: Runtime type information not available for type_variable_local(Mixin.S) in (type_variable_local(Class.T), type_variable_local(_Object&Mixin^^#T0.#T0))in j:constructor(Class.).
closure_in_field_test/02: Crash # Assertion failure: Runtime type information not available for type_variable_local(Mixin.S) in (type_variable_local(Class.T), type_variable_local(_Object&Mixin^^#T0.#T0))in j:constructor(Class.).
closure_in_field_test/none: Crash # Assertion failure: Runtime type information not available for type_variable_local(Mixin.S) in (type_variable_local(Class.T), type_variable_local(_Object&Mixin^^#T0.#T0))in j:constructor(Class.).
closure_in_initializer_test: Crash # Assertion failure: Cannot find value local(A.#a) in (local(C.#a), BoxLocal(_box_0), local(C.#a), BoxLocal(_box_0)) for j:constructor(C.).
conditional_import_string_test: CompileTimeError
conditional_import_test: CompileTimeError
config_import_corelib_test: RuntimeError
@ -770,7 +768,7 @@ constants_test/05: MissingCompileTimeError
constructor2_test: RuntimeError
constructor3_test: RuntimeError
constructor5_test: RuntimeError
constructor6_test: Crash # Assertion failure: Cannot find value local(A.#arg) in (local(C.#x), local(C.#y), local(B.#arg), BoxLocal(_box_0)) for j:constructor(C.).
constructor6_test: RuntimeError
constructor_named_arguments_test/none: RuntimeError
constructor_redirect1_negative_test: Crash # Issue 30856
constructor_redirect2_negative_test: Crash # Issue 30856

View file

@ -1192,7 +1192,6 @@ cha_deopt2_test: CompileTimeError
cha_deopt3_test: CompileTimeError
class_cycle_test/02: MissingCompileTimeError
class_cycle_test/03: MissingCompileTimeError
closure_in_initializer_test: Crash # Assertion failure: Cannot find value local(A.#a) in (local(C.#a), BoxLocal(_box_0), local(C.#a), BoxLocal(_box_0)) for j:constructor(C.).
closure_invoked_through_interface_target_field_test: MissingCompileTimeError
closure_invoked_through_interface_target_getter_test: MissingCompileTimeError
closure_self_reference_test: Crash # 'file:*/pkg/compiler/lib/src/ssa/nodes.dart': Failed assertion: line 641 pos 12: 'isClosed()': is not true.
@ -1279,7 +1278,6 @@ const_types_test/35: MissingCompileTimeError
const_types_test/39: MissingCompileTimeError
const_types_test/40: MissingCompileTimeError
constants_test/05: MissingCompileTimeError
constructor6_test: Crash # Assertion failure: Cannot find value local(A.#arg) in (local(C.#x), local(C.#y), local(B.#arg), BoxLocal(_box_0)) for j:constructor(C.).
constructor_duplicate_final_test/01: MissingCompileTimeError
constructor_duplicate_final_test/02: MissingCompileTimeError
constructor_named_arguments_test/01: MissingCompileTimeError
@ -1642,7 +1640,6 @@ cha_deopt2_test: CompileTimeError
cha_deopt3_test: CompileTimeError
class_cycle_test/02: MissingCompileTimeError
class_cycle_test/03: MissingCompileTimeError
closure_in_initializer_test: Crash # Assertion failure: Cannot find value local(A.#a) in (local(C.#a), BoxLocal(_box_0), local(C.#a), BoxLocal(_box_0)) for j:constructor(C.).
closure_invoked_through_interface_target_field_test: MissingCompileTimeError
closure_invoked_through_interface_target_getter_test: MissingCompileTimeError
compile_time_constant_o_test/01: MissingCompileTimeError
@ -1728,7 +1725,6 @@ const_types_test/35: MissingCompileTimeError
const_types_test/39: MissingCompileTimeError
const_types_test/40: MissingCompileTimeError
constants_test/05: MissingCompileTimeError
constructor6_test: Crash # Assertion failure: Cannot find value local(A.#arg) in (local(C.#x), local(C.#y), local(B.#arg), BoxLocal(_box_0)) for j:constructor(C.).
constructor_duplicate_final_test/01: MissingCompileTimeError
constructor_duplicate_final_test/02: MissingCompileTimeError
constructor_named_arguments_test/01: MissingCompileTimeError