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

Unified Diff: runtime/vm/object.cc

Issue 2723643002: Properly handle instantiator when allocating or cloning closure instance. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 4da9ecd01ec1304147118f93a32f9d8a29ea3896..04c77edc519f1770ccc368e887f5020028213dca 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -6907,8 +6907,9 @@ RawInstance* Function::ImplicitStaticClosure() const {
ObjectStore* object_store = isolate->object_store();
const Context& context =
Context::Handle(zone, object_store->empty_context());
- Instance& closure =
- Instance::Handle(zone, Closure::New(*this, context, Heap::kOld));
+ const TypeArguments& instantiator = TypeArguments::Handle(zone);
+ Instance& closure = Instance::Handle(
+ zone, Closure::New(instantiator, *this, context, Heap::kOld));
set_implicit_static_closure(closure);
}
return implicit_static_closure();
@@ -6917,17 +6918,16 @@ RawInstance* Function::ImplicitStaticClosure() const {
RawInstance* Function::ImplicitInstanceClosure(const Instance& receiver) const {
ASSERT(IsImplicitClosureFunction());
- const Type& signature_type = Type::Handle(SignatureType());
- const Class& cls = Class::Handle(signature_type.type_class());
- const Context& context = Context::Handle(Context::New(1));
+ Zone* zone = Thread::Current()->zone();
+ const Type& signature_type = Type::Handle(zone, SignatureType());
+ const Class& cls = Class::Handle(zone, signature_type.type_class());
+ const Context& context = Context::Handle(zone, Context::New(1));
context.SetAt(0, receiver);
- const Instance& result = Instance::Handle(Closure::New(*this, context));
+ TypeArguments& instantiator = TypeArguments::Handle(zone);
if (cls.IsGeneric()) {
- const TypeArguments& type_arguments =
- TypeArguments::Handle(receiver.GetTypeArguments());
- result.SetTypeArguments(type_arguments);
+ instantiator = receiver.GetTypeArguments();
}
- return result.raw();
+ return Closure::New(instantiator, *this, context);
}
@@ -22385,7 +22385,8 @@ const char* Closure::ToCString() const {
}
-RawClosure* Closure::New(const Function& function,
+RawClosure* Closure::New(const TypeArguments& instantiator,
+ const Function& function,
const Context& context,
Heap::Space space) {
Closure& result = Closure::Handle();
@@ -22394,6 +22395,7 @@ RawClosure* Closure::New(const Function& function,
Object::Allocate(Closure::kClassId, Closure::InstanceSize(), space);
NoSafepointScope no_safepoint;
result ^= raw;
+ result.StorePointer(&result.raw_ptr()->instantiator_, instantiator.raw());
result.StorePointer(&result.raw_ptr()->function_, function.raw());
result.StorePointer(&result.raw_ptr()->context_, context.raw());
}
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698