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

Unified Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10021070: Move type check elimination from backend to graph builder in new compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_compiler_x64.cc
===================================================================
--- runtime/vm/flow_graph_compiler_x64.cc (revision 6710)
+++ runtime/vm/flow_graph_compiler_x64.cc (working copy)
@@ -129,7 +129,7 @@
__ CompareObject(RCX, type_class);
__ j(EQUAL, is_instance);
}
- // Fall through to runtime class.
+ // Fall through to runtime call.
}
} else { // type has NO type arguments.
Label compare_classes;
@@ -295,52 +295,16 @@
void FlowGraphCompiler::GenerateAssertAssignable(intptr_t node_id,
intptr_t token_index,
intptr_t try_index,
- Value* value,
const AbstractType& dst_type,
const String& dst_name) {
ASSERT(FLAG_enable_type_checks);
ASSERT(token_index >= 0);
ASSERT(!dst_type.IsNull());
ASSERT(dst_type.IsFinalized());
+ ASSERT(dst_type.IsMalformed() ||
+ (!dst_type.IsDynamicType() && !dst_type.IsObjectType()));
+ ASSERT(!dst_type.IsVoidType());
- // Any expression is assignable to the Dynamic type and to the Object type.
- // Skip the test.
- if (!dst_type.IsMalformed() &&
- (dst_type.IsDynamicType() || dst_type.IsObjectType())) {
- return;
- }
-
- // It is a compile-time error to explicitly return a value (including null)
- // from a void function. However, functions that do not explicitly return a
- // value, implicitly return null. This includes void functions. Therefore, we
- // skip the type test here and trust the parser to only return null in void
- // function.
- if (dst_type.IsVoidType()) {
- return;
- }
-
- // TODO(regis): Move this compile time check to the graph builder.
- // Eliminate the test if it can be performed successfully at compile time.
- if ((value != NULL) && value->IsConstant()) {
- Instance& literal_value = Instance::Handle();
- literal_value ^= value->AsConstant()->value().raw();
- const Class& cls = Class::Handle(literal_value.clazz());
- if (cls.IsNullClass()) {
- ASSERT(literal_value.IsNull() ||
- (literal_value.raw() == Object::sentinel()) ||
- (literal_value.raw() == Object::transition_sentinel()));
- return;
- }
- Error& malformed_error = Error::Handle();
- if (!dst_type.IsMalformed() &&
- dst_type.IsInstantiated() &&
- literal_value.IsInstanceOf(dst_type,
- TypeArguments::Handle(),
- &malformed_error)) {
- return;
- }
- }
-
// A null object is always assignable and is returned as result.
const Immediate raw_null =
Immediate(reinterpret_cast<intptr_t>(Object::null()));
@@ -427,14 +391,13 @@
void FlowGraphCompiler::VisitAssertAssignable(AssertAssignableComp* comp) {
- if (comp->type_arguments() != NULL) {
+ if (comp->instantiator_type_arguments() != NULL) {
__ popq(RDX);
}
LoadValue(RAX, comp->value());
GenerateAssertAssignable(comp->node_id(),
comp->token_index(),
comp->try_index(),
- comp->value(),
comp->dst_type(),
comp->dst_name());
}
@@ -840,7 +803,6 @@
void FlowGraphCompiler::GenerateInstanceOf(intptr_t node_id,
intptr_t token_index,
intptr_t try_index,
- Value* value,
const AbstractType& type,
bool negate_result) {
ASSERT(type.IsFinalized() && !type.IsMalformed());
@@ -916,7 +878,6 @@
GenerateInstanceOf(comp->node_id(),
comp->token_index(),
comp->try_index(),
- comp->value(),
comp->type(),
comp->negate_result());
}

Powered by Google App Engine
This is Rietveld 408576698