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

Unified Diff: runtime/vm/flow_graph_type_propagator.cc

Issue 705063002: VM: Normalize function result type void to null in the flow graph. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed AssertAssignable::UpdateType Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_type_propagator.cc
===================================================================
--- runtime/vm/flow_graph_type_propagator.cc (revision 41558)
+++ runtime/vm/flow_graph_type_propagator.cc (working copy)
@@ -590,19 +590,16 @@
// Consider the compile type of the value.
const AbstractType& compile_type = *ToAbstractType();
+
+ // The compile-type of a value should never be void. The result of a void
+ // function must always be null, which wass checked to be null at the return
+ // statement inside the function.
+ ASSERT(!compile_type.IsVoidType());
+
if (compile_type.IsMalformedOrMalbounded()) {
return false;
}
- // If the compile type of the value is void, we are type checking the result
- // of a void function, which was checked to be null at the return statement
- // inside the function.
- if (compile_type.IsVoidType()) {
- ASSERT(FLAG_enable_type_checks);
- *is_instance = true;
- return true;
- }
-
// The Null type is only a subtype of Object and of dynamic.
// Functions that do not explicitly return a value, implicitly return null,
// except generative constructors, which return the object being constructed.
@@ -767,30 +764,24 @@
}
-CompileType* AssertAssignableInstr::ComputeInitialType() const {
+CompileType AssertAssignableInstr::ComputeType() const {
CompileType* value_type = value()->Type();
if (value_type->IsMoreSpecificThan(dst_type())) {
- return ZoneCompileType::Wrap(*value_type);
+ return *value_type;
}
if (dst_type().IsVoidType()) {
// The only value assignable to void is null.
- return ZoneCompileType::Wrap(CompileType::Null());
+ return CompileType::Null();
}
- return ZoneCompileType::Wrap(
- CompileType::FromAbstractType(dst_type(), value_type->is_nullable()));
+ return CompileType::FromAbstractType(dst_type(), value_type->is_nullable());
}
bool AssertAssignableInstr::RecomputeType() {
- CompileType* value_type = value()->Type();
- return UpdateType(
- value_type->IsMoreSpecificThan(dst_type())
- ? *value_type
- : CompileType::FromAbstractType(dst_type(),
- value_type->is_nullable()));
+ return UpdateType(ComputeType());
}
@@ -870,8 +861,13 @@
}
if (FLAG_enable_type_checks) {
- return CompileType::FromAbstractType(
- AbstractType::ZoneHandle(function().result_type()));
+ // Void functions are known to return null, which is checked at the return
+ // from the function.
+ const AbstractType& result_type =
+ AbstractType::ZoneHandle(function().result_type());
+ return CompileType::FromAbstractType(result_type.IsVoidType()
+ ? AbstractType::ZoneHandle(Type::NullType())
+ : result_type);
}
return CompileType::Dynamic();
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698