| Index: runtime/lib/function.cc
|
| diff --git a/runtime/lib/function.cc b/runtime/lib/function.cc
|
| index 607e29e4067bf1f9bec49e922aa589c2ff9d5d0f..b7424f5ef84aa22666d6cea97ac135a25d99c0f8 100644
|
| --- a/runtime/lib/function.cc
|
| +++ b/runtime/lib/function.cc
|
| @@ -28,21 +28,21 @@ DEFINE_NATIVE_ENTRY(Function_apply, 2) {
|
| }
|
|
|
|
|
| -DEFINE_NATIVE_ENTRY(FunctionImpl_equals, 2) {
|
| - const Instance& receiver = Instance::CheckedHandle(
|
| +DEFINE_NATIVE_ENTRY(Closure_equals, 2) {
|
| + const Closure& receiver = Closure::CheckedHandle(
|
| zone, arguments->NativeArgAt(0));
|
| - ASSERT(receiver.IsClosure());
|
| GET_NATIVE_ARGUMENT(Instance, other, arguments->NativeArgAt(1));
|
| ASSERT(!other.IsNull());
|
| if (receiver.raw() == other.raw()) return Bool::True().raw();
|
| if (other.IsClosure()) {
|
| - const Function& func_a = Function::Handle(Closure::function(receiver));
|
| - const Function& func_b = Function::Handle(Closure::function(other));
|
| + const Function& func_a = Function::Handle(receiver.function());
|
| + const Function& func_b = Function::Handle(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(Closure::context(receiver));
|
| - const Context& context_b = Context::Handle(Closure::context(other));
|
| + const Context& context_a = Context::Handle(receiver.context());
|
| + const Context& context_b = Context::Handle(
|
| + Closure::Cast(other).context());
|
| const Object& receiver_a = Object::Handle(context_a.At(0));
|
| const Object& receiver_b = Object::Handle(context_b.At(0));
|
| if (receiver_a.raw() == receiver_b.raw()) return Bool::True().raw();
|
| @@ -53,48 +53,38 @@ DEFINE_NATIVE_ENTRY(FunctionImpl_equals, 2) {
|
| }
|
|
|
|
|
| -DEFINE_NATIVE_ENTRY(FunctionImpl_hashCode, 1) {
|
| - const Instance& receiver = Instance::CheckedHandle(
|
| +DEFINE_NATIVE_ENTRY(Closure_hashCode, 1) {
|
| + const Closure& receiver = Closure::CheckedHandle(
|
| zone, arguments->NativeArgAt(0));
|
| - if (receiver.IsClosure()) {
|
| - const Function& func = Function::Handle(Closure::function(receiver));
|
| - // Hash together name, class name and signature.
|
| - const Class& cls = Class::Handle(func.Owner());
|
| - intptr_t result = String::Handle(func.name()).Hash();
|
| - result += String::Handle(func.Signature()).Hash();
|
| - result += String::Handle(cls.Name()).Hash();
|
| - // Finalize hash value like for strings so that it fits into a smi.
|
| - result += result << 3;
|
| - result ^= result >> 11;
|
| - result += result << 15;
|
| - result &= ((static_cast<intptr_t>(1) << String::kHashBits) - 1);
|
| - return Smi::New(result);
|
| - }
|
| - UNREACHABLE();
|
| - return Object::null();
|
| + const Function& func = Function::Handle(receiver.function());
|
| + // Hash together name, class name and signature.
|
| + const Class& cls = Class::Handle(func.Owner());
|
| + intptr_t result = String::Handle(func.name()).Hash();
|
| + result += String::Handle(func.Signature()).Hash();
|
| + result += String::Handle(cls.Name()).Hash();
|
| + // Finalize hash value like for strings so that it fits into a smi.
|
| + result += result << 3;
|
| + result ^= result >> 11;
|
| + result += result << 15;
|
| + result &= ((static_cast<intptr_t>(1) << String::kHashBits) - 1);
|
| + return Smi::New(result);
|
| }
|
|
|
|
|
| -DEFINE_NATIVE_ENTRY(FunctionImpl_clone, 1) {
|
| - const Instance& receiver = Instance::CheckedHandle(
|
| +DEFINE_NATIVE_ENTRY(Closure_clone, 1) {
|
| + const Closure& receiver = Closure::CheckedHandle(
|
| zone, arguments->NativeArgAt(0));
|
| - ASSERT(receiver.IsClosure());
|
| - if (receiver.IsClosure()) {
|
| - const Function& func =
|
| - Function::Handle(zone, Closure::function(receiver));
|
| - const Context& ctx =
|
| - Context::Handle(zone, Closure::context(receiver));
|
| - Context& cloned_ctx =
|
| - Context::Handle(zone, Context::New(ctx.num_variables()));
|
| - cloned_ctx.set_parent(Context::Handle(zone, ctx.parent()));
|
| - Object& inst = Object::Handle(zone);
|
| - for (int i = 0; i < ctx.num_variables(); i++) {
|
| - inst = ctx.At(i);
|
| - cloned_ctx.SetAt(i, inst);
|
| - }
|
| - return Closure::New(func, cloned_ctx);
|
| + const Function& func = Function::Handle(zone, receiver.function());
|
| + const Context& ctx = Context::Handle(zone, receiver.context());
|
| + Context& cloned_ctx =
|
| + Context::Handle(zone, Context::New(ctx.num_variables()));
|
| + cloned_ctx.set_parent(Context::Handle(zone, ctx.parent()));
|
| + Object& inst = Object::Handle(zone);
|
| + for (int i = 0; i < ctx.num_variables(); i++) {
|
| + inst = ctx.At(i);
|
| + cloned_ctx.SetAt(i, inst);
|
| }
|
| - return Object::null();
|
| + return Closure::New(func, cloned_ctx);
|
| }
|
|
|
|
|
|
|