Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1211)

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 2761933002: Add Genericity enum in VM to distinguish how a type is uninstantiated. (Closed)
Patch Set: sync Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/constant_propagator.h" 10 #include "vm/constant_propagator.h"
(...skipping 2051 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 Definition* AssertAssignableInstr::Canonicalize(FlowGraph* flow_graph) { 2062 Definition* AssertAssignableInstr::Canonicalize(FlowGraph* flow_graph) {
2063 if (FLAG_eliminate_type_checks && 2063 if (FLAG_eliminate_type_checks &&
2064 value()->Type()->IsAssignableTo(dst_type())) { 2064 value()->Type()->IsAssignableTo(dst_type())) {
2065 return value()->definition(); 2065 return value()->definition();
2066 } 2066 }
2067 2067
2068 // For uninstantiated target types: If the instantiator type arguments 2068 // For uninstantiated target types: If the instantiator type arguments
2069 // are constant, instantiate the target type here. 2069 // are constant, instantiate the target type here.
2070 if (dst_type().IsInstantiated()) return this; 2070 if (dst_type().IsInstantiated()) return this;
2071 2071
2072 // TODO(regis): Only try to instantiate here if function_type_args is constant
2073 // or null and dst_type does not refer to parent function type parameters.
2072 ConstantInstr* constant_type_args = 2074 ConstantInstr* constant_type_args =
2073 instantiator_type_arguments()->definition()->AsConstant(); 2075 instantiator_type_arguments()->definition()->AsConstant();
2074 if (constant_type_args != NULL && !constant_type_args->value().IsNull() && 2076 if (constant_type_args != NULL && !constant_type_args->value().IsNull() &&
2075 constant_type_args->value().IsTypeArguments()) { 2077 constant_type_args->value().IsTypeArguments()) {
2076 const TypeArguments& instantiator_type_args = 2078 const TypeArguments& instantiator_type_args =
2077 TypeArguments::Cast(constant_type_args->value()); 2079 TypeArguments::Cast(constant_type_args->value());
2078 Error& bound_error = Error::Handle(); 2080 Error& bound_error = Error::Handle();
2079 AbstractType& new_dst_type = 2081 AbstractType& new_dst_type =
2080 AbstractType::Handle(dst_type().InstantiateFrom( 2082 AbstractType::Handle(dst_type().InstantiateFrom(
2081 instantiator_type_args, &bound_error, NULL, NULL, Heap::kOld)); 2083 instantiator_type_args, /* function_type_args, */
2084 &bound_error, NULL, NULL, Heap::kOld));
2082 if (new_dst_type.IsMalformedOrMalbounded() || !bound_error.IsNull()) { 2085 if (new_dst_type.IsMalformedOrMalbounded() || !bound_error.IsNull()) {
2083 return this; 2086 return this;
2084 } 2087 }
2085 if (new_dst_type.IsTypeRef()) { 2088 if (new_dst_type.IsTypeRef()) {
2086 new_dst_type = TypeRef::Cast(new_dst_type).type(); 2089 new_dst_type = TypeRef::Cast(new_dst_type).type();
2087 } 2090 }
2088 new_dst_type = new_dst_type.Canonicalize(); 2091 new_dst_type = new_dst_type.Canonicalize();
2089 set_dst_type(new_dst_type); 2092 set_dst_type(new_dst_type);
2090 2093
2091 if (new_dst_type.IsDynamicType() || new_dst_type.IsObjectType() || 2094 if (new_dst_type.IsDynamicType() || new_dst_type.IsObjectType() ||
2092 (FLAG_eliminate_type_checks && 2095 (FLAG_eliminate_type_checks &&
2093 value()->Type()->IsAssignableTo(new_dst_type))) { 2096 value()->Type()->IsAssignableTo(new_dst_type))) {
2094 return value()->definition(); 2097 return value()->definition();
2095 } 2098 }
2096 2099
2097 ConstantInstr* null_constant = flow_graph->constant_null(); 2100 ConstantInstr* null_constant = flow_graph->constant_null();
2098 instantiator_type_arguments()->BindTo(null_constant); 2101 instantiator_type_arguments()->BindTo(null_constant);
2102 // TODO(regis): function_type_arguments()->BindTo(null_constant);
2099 } 2103 }
2100 return this; 2104 return this;
2101 } 2105 }
2102 2106
2103 2107
2104 Definition* InstantiateTypeArgumentsInstr::Canonicalize(FlowGraph* flow_graph) { 2108 Definition* InstantiateTypeArgumentsInstr::Canonicalize(FlowGraph* flow_graph) {
2105 return (Isolate::Current()->type_checks() || HasUses()) ? this : NULL; 2109 return (Isolate::Current()->type_checks() || HasUses()) ? this : NULL;
2106 } 2110 }
2107 2111
2108 2112
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after
3981 set_native_c_function(native_function); 3985 set_native_c_function(native_function);
3982 function().SetIsNativeAutoSetupScope(auto_setup_scope); 3986 function().SetIsNativeAutoSetupScope(auto_setup_scope);
3983 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 3987 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
3984 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); 3988 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver);
3985 set_is_bootstrap_native(is_bootstrap_native); 3989 set_is_bootstrap_native(is_bootstrap_native);
3986 } 3990 }
3987 3991
3988 #undef __ 3992 #undef __
3989 3993
3990 } // namespace dart 3994 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/jit_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698