| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "lib/stacktrace.h" | 9 #include "lib/stacktrace.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 } | 908 } |
| 909 } | 909 } |
| 910 const Object& object1 = Object::Handle(Z, Api::UnwrapHandle(obj1)); | 910 const Object& object1 = Object::Handle(Z, Api::UnwrapHandle(obj1)); |
| 911 const Object& object2 = Object::Handle(Z, Api::UnwrapHandle(obj2)); | 911 const Object& object2 = Object::Handle(Z, Api::UnwrapHandle(obj2)); |
| 912 if (object1.IsInstance() && object2.IsInstance()) { | 912 if (object1.IsInstance() && object2.IsInstance()) { |
| 913 return Instance::Cast(object1).IsIdenticalTo(Instance::Cast(object2)); | 913 return Instance::Cast(object1).IsIdenticalTo(Instance::Cast(object2)); |
| 914 } | 914 } |
| 915 return false; | 915 return false; |
| 916 } | 916 } |
| 917 | 917 |
| 918 DART_EXPORT uint64_t Dart_IdentityHash(Dart_Handle obj) { | |
| 919 DARTSCOPE(Thread::Current()); | |
| 920 | |
| 921 const Object& object = Object::Handle(Z, Api::UnwrapHandle(obj)); | |
| 922 if (!object.IsInstance() && !object.IsNull()) { | |
| 923 return 0; | |
| 924 } | |
| 925 | |
| 926 const Library& libcore = Library::Handle(Z, Library::CoreLibrary()); | |
| 927 const String& function_name = | |
| 928 String::Handle(Z, String::New("identityHashCode")); | |
| 929 const Function& function = | |
| 930 Function::Handle(Z, libcore.LookupFunctionAllowPrivate(function_name)); | |
| 931 if (function.IsNull()) { | |
| 932 UNREACHABLE(); | |
| 933 return 0; | |
| 934 } | |
| 935 | |
| 936 const Array& arguments = Array::Handle(Z, Array::New(1)); | |
| 937 arguments.SetAt(0, object); | |
| 938 const Object& result = | |
| 939 Object::Handle(Z, DartEntry::InvokeFunction(function, arguments)); | |
| 940 | |
| 941 if (result.IsSmi()) { | |
| 942 return Smi::Cast(result).Value(); | |
| 943 } | |
| 944 if (result.IsMint()) { | |
| 945 const Mint& mint = Mint::Cast(result); | |
| 946 if (!mint.IsNegative()) { | |
| 947 return mint.AsInt64Value(); | |
| 948 } | |
| 949 } | |
| 950 if (result.IsBigint()) { | |
| 951 const Bigint& bigint = Bigint::Cast(result); | |
| 952 if (bigint.FitsIntoUint64()) { | |
| 953 return bigint.AsUint64Value(); | |
| 954 } | |
| 955 } | |
| 956 return 0; | |
| 957 } | |
| 958 | |
| 959 DART_EXPORT Dart_Handle | 918 DART_EXPORT Dart_Handle |
| 960 Dart_HandleFromPersistent(Dart_PersistentHandle object) { | 919 Dart_HandleFromPersistent(Dart_PersistentHandle object) { |
| 961 Thread* thread = Thread::Current(); | 920 Thread* thread = Thread::Current(); |
| 962 Isolate* isolate = thread->isolate(); | 921 Isolate* isolate = thread->isolate(); |
| 963 CHECK_ISOLATE(isolate); | 922 CHECK_ISOLATE(isolate); |
| 964 NoSafepointScope no_safepoint_scope; | 923 NoSafepointScope no_safepoint_scope; |
| 965 ApiState* state = isolate->api_state(); | 924 ApiState* state = isolate->api_state(); |
| 966 ASSERT(state != NULL); | 925 ASSERT(state != NULL); |
| 967 PersistentHandle* ref = PersistentHandle::Cast(object); | 926 PersistentHandle* ref = PersistentHandle::Cast(object); |
| 968 return Api::NewHandle(thread, ref->raw()); | 927 return Api::NewHandle(thread, ref->raw()); |
| (...skipping 5728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6697 #endif | 6656 #endif |
| 6698 } | 6657 } |
| 6699 | 6658 |
| 6700 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6659 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6701 #ifndef PRODUCT | 6660 #ifndef PRODUCT |
| 6702 Profiler::DumpStackTrace(context); | 6661 Profiler::DumpStackTrace(context); |
| 6703 #endif | 6662 #endif |
| 6704 } | 6663 } |
| 6705 | 6664 |
| 6706 } // namespace dart | 6665 } // namespace dart |
| OLD | NEW |