| Index: runtime/lib/function.cc
|
| diff --git a/runtime/lib/function.cc b/runtime/lib/function.cc
|
| index af6969d1a912bb1bbbe5a43b2871bca77dc4ebbd..0bd2c70d429b5d098b97b05524b2a60a447c9335 100644
|
| --- a/runtime/lib/function.cc
|
| +++ b/runtime/lib/function.cc
|
| @@ -35,30 +35,33 @@ DEFINE_NATIVE_ENTRY(Closure_equals, 2) {
|
| Closure::CheckedHandle(zone, arguments->NativeArgAt(0));
|
| GET_NATIVE_ARGUMENT(Instance, other, arguments->NativeArgAt(1));
|
| ASSERT(!other.IsNull());
|
| - // For implicit instance closures compare receiver instance and function's
|
| - // name and owner (multiple function objects could exist for the same
|
| - // function due to hot reload).
|
| - // Objects of other closure kinds are unique, so use identity comparison.
|
| - if (receiver.raw() == other.raw()) {
|
| - return Bool::True().raw();
|
| - }
|
| - const Function& func_a = Function::Handle(zone, receiver.function());
|
| - if (func_a.IsImplicitInstanceClosureFunction()) {
|
| - if (other.IsClosure()) {
|
| - const Closure& other_closure = Closure::Cast(other);
|
| - const Function& func_b = Function::Handle(zone, other_closure.function());
|
| - if (func_b.IsImplicitInstanceClosureFunction()) {
|
| + if (receiver.raw() == other.raw()) return Bool::True().raw();
|
| + if (other.IsClosure()) {
|
| + const Function& func_a = Function::Handle(zone, receiver.function());
|
| + const Function& func_b =
|
| + Function::Handle(zone, Closure::Cast(other).function());
|
| + if (func_a.raw() == func_b.raw()) {
|
| + ASSERT(!func_a.IsImplicitStaticClosureFunction());
|
| + if (func_a.IsImplicitInstanceClosureFunction()) {
|
| const Context& context_a = Context::Handle(zone, receiver.context());
|
| const Context& context_b =
|
| - Context::Handle(zone, other_closure.context());
|
| - RawObject* receiver_a = context_a.At(0);
|
| - RawObject* receiver_b = context_b.At(0);
|
| - if ((receiver_a == receiver_b) &&
|
| - ((func_a.raw() == func_b.raw()) ||
|
| - ((func_a.name() == func_b.name()) &&
|
| - (func_a.Owner() == func_b.Owner())))) {
|
| - return Bool::True().raw();
|
| - }
|
| + Context::Handle(zone, Closure::Cast(other).context());
|
| + const Object& receiver_a = Object::Handle(zone, context_a.At(0));
|
| + const Object& receiver_b = Object::Handle(zone, context_b.At(0));
|
| + if (receiver_a.raw() == receiver_b.raw()) return Bool::True().raw();
|
| + }
|
| + } else if (func_a.IsImplicitInstanceClosureFunction() &&
|
| + func_b.IsImplicitInstanceClosureFunction()) {
|
| + // TODO(rmacnak): Patch existing tears off during reload instead.
|
| + const Context& context_a = Context::Handle(zone, receiver.context());
|
| + const Context& context_b =
|
| + Context::Handle(zone, Closure::Cast(other).context());
|
| + const Object& receiver_a = Object::Handle(zone, context_a.At(0));
|
| + const Object& receiver_b = Object::Handle(zone, context_b.At(0));
|
| + if ((receiver_a.raw() == receiver_b.raw()) &&
|
| + (func_a.name() == func_b.name()) &&
|
| + (func_a.Owner() == func_b.Owner())) {
|
| + return Bool::True().raw();
|
| }
|
| }
|
| }
|
|
|