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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 1584223006: Remove signature classes from the VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index fed89bb839218c291a3920f01c5a5f423a0a8c91..cb800111bcdf543ce65638533013cffdf2ea6530 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -1502,7 +1502,7 @@ void EffectGraphVisitor::BuildTypecheckPushArguments(
const Class& instantiator_class = Class::Handle(
Z, owner()->function().Owner());
// Since called only when type tested against is not instantiated.
- ASSERT(instantiator_class.NumTypeParameters() > 0);
+ ASSERT(instantiator_class.IsGeneric());
Value* instantiator_type_arguments = NULL;
Value* instantiator = BuildInstantiator(instantiator_class);
if (instantiator == NULL) {
@@ -1527,7 +1527,7 @@ void EffectGraphVisitor::BuildTypecheckArguments(
const Class& instantiator_class = Class::Handle(
Z, owner()->function().Owner());
// Since called only when type tested against is not instantiated.
- ASSERT(instantiator_class.NumTypeParameters() > 0);
+ ASSERT(instantiator_class.IsGeneric());
instantiator = BuildInstantiator(instantiator_class);
if (instantiator == NULL) {
// No instantiator when inside factory.
@@ -2500,34 +2500,38 @@ void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) {
isolate()->AddClosureFunction(function);
}
}
- ZoneGrowableArray<PushArgumentInstr*>* arguments =
- new(Z) ZoneGrowableArray<PushArgumentInstr*>(1);
ASSERT(function.context_scope() != ContextScope::null());
// The function type of a closure may have type arguments. In that case,
// pass the type arguments of the instantiator.
- const Class& cls = Class::ZoneHandle(Z, function.signature_class());
- ASSERT(!cls.IsNull());
- const bool requires_type_arguments = cls.NumTypeArguments() > 0;
- Value* type_arguments = NULL;
- if (requires_type_arguments) {
- ASSERT(cls.type_arguments_field_offset() ==
- Closure::type_arguments_offset());
- ASSERT(cls.instance_size() == Closure::InstanceSize());
- const Class& instantiator_class = Class::Handle(
- Z, owner()->function().Owner());
- type_arguments = BuildInstantiatorTypeArguments(node->token_pos(),
- instantiator_class,
- NULL);
- arguments->Add(PushArgument(type_arguments));
- }
+ const Class& closure_class =
+ Class::ZoneHandle(Z, isolate()->object_store()->closure_class());
+ ZoneGrowableArray<PushArgumentInstr*>* no_arguments =
+ new(Z) ZoneGrowableArray<PushArgumentInstr*>(0);
AllocateObjectInstr* alloc = new(Z) AllocateObjectInstr(node->token_pos(),
- cls,
- arguments);
+ closure_class,
+ no_arguments);
alloc->set_closure_function(function);
Value* closure_val = Bind(alloc);
{ LocalVariable* closure_tmp_var = EnterTempLocalScope(closure_val);
+ // Store type arguments if scope class is generic.
+ const FunctionType& function_type =
+ FunctionType::ZoneHandle(Z, function.SignatureType());
+ const Class& scope_cls = Class::ZoneHandle(Z, function_type.scope_class());
+ if (scope_cls.IsGeneric()) {
+ ASSERT(function.Owner() == scope_cls.raw());
+ Value* closure_tmp_val = Bind(new(Z) LoadLocalInstr(*closure_tmp_var));
+ Value* type_arguments = BuildInstantiatorTypeArguments(node->token_pos(),
+ scope_cls,
+ NULL);
+ Do(new(Z) StoreInstanceFieldInstr(Closure::type_arguments_offset(),
+ closure_tmp_val,
+ type_arguments,
+ kEmitStoreBarrier,
+ node->token_pos()));
+ }
+
// Store function.
Value* closure_tmp_val = Bind(new(Z) LoadLocalInstr(*closure_tmp_var));
Value* func_val =
@@ -2887,7 +2891,7 @@ void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) {
Value* EffectGraphVisitor::BuildInstantiator(const Class& instantiator_class) {
- ASSERT(instantiator_class.NumTypeParameters() > 0);
+ ASSERT(instantiator_class.IsGeneric());
Function& outer_function = Function::Handle(Z, owner()->function().raw());
while (outer_function.IsLocalFunction()) {
outer_function = outer_function.parent_function();
@@ -4420,7 +4424,7 @@ StaticCallInstr* EffectGraphVisitor::BuildThrowNoSuchMethodError(
ZoneGrowableArray<PushArgumentInstr*>* arguments =
new(Z) ZoneGrowableArray<PushArgumentInstr*>();
// Object receiver, actually a class literal of the unresolved method's owner.
- Type& type = Type::ZoneHandle(
+ AbstractType& type = Type::ZoneHandle(
Z,
Type::New(function_class,
TypeArguments::Handle(Z, TypeArguments::null()),

Powered by Google App Engine
This is Rietveld 408576698