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

Side by Side Diff: runtime/vm/dart_api_impl.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 unified diff | Download patch
OLDNEW
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 "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 funcHandle_(Function::Handle(thread->zone())), 100 funcHandle_(Function::Handle(thread->zone())),
101 typeHandle_(AbstractType::Handle(thread->zone())) {} 101 typeHandle_(AbstractType::Handle(thread->zone())) {}
102 102
103 void VisitObject(RawObject* obj) { 103 void VisitObject(RawObject* obj) {
104 if (obj->IsFunction()) { 104 if (obj->IsFunction()) {
105 funcHandle_ ^= obj; 105 funcHandle_ ^= obj;
106 classHandle_ ^= funcHandle_.Owner(); 106 classHandle_ ^= funcHandle_.Owner();
107 // Verify that the result type of a function is canonical or a 107 // Verify that the result type of a function is canonical or a
108 // TypeParameter. 108 // TypeParameter.
109 typeHandle_ ^= funcHandle_.result_type(); 109 typeHandle_ ^= funcHandle_.result_type();
110 ASSERT(typeHandle_.IsNull() || 110 ASSERT(typeHandle_.IsMalformed() ||
111 !typeHandle_.IsResolved() || 111 !typeHandle_.IsResolved() ||
112 typeHandle_.IsTypeParameter() || 112 typeHandle_.IsTypeParameter() ||
113 typeHandle_.IsCanonical()); 113 typeHandle_.IsCanonical());
114 // Verify that the types in the function signature are all canonical or 114 // Verify that the types in the function signature are all canonical or
115 // a TypeParameter. 115 // a TypeParameter.
116 const intptr_t num_parameters = funcHandle_.NumParameters(); 116 const intptr_t num_parameters = funcHandle_.NumParameters();
117 for (intptr_t i = 0; i < num_parameters; i++) { 117 for (intptr_t i = 0; i < num_parameters; i++) {
118 typeHandle_ = funcHandle_.ParameterTypeAt(i); 118 typeHandle_ = funcHandle_.ParameterTypeAt(i);
119 ASSERT(typeHandle_.IsTypeParameter() || 119 ASSERT(typeHandle_.IsMalformed() ||
120 !typeHandle_.IsResolved() || 120 !typeHandle_.IsResolved() ||
121 typeHandle_.IsTypeParameter() ||
121 typeHandle_.IsCanonical()); 122 typeHandle_.IsCanonical());
122 } 123 }
123 } 124 }
124 } 125 }
125 126
126 private: 127 private:
127 Class& classHandle_; 128 Class& classHandle_;
128 Function& funcHandle_; 129 Function& funcHandle_;
129 AbstractType& typeHandle_; 130 AbstractType& typeHandle_;
130 }; 131 };
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 return Api::ClassId(handle) == kFieldCid; 1848 return Api::ClassId(handle) == kFieldCid;
1848 } 1849 }
1849 1850
1850 1851
1851 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle) { 1852 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle) {
1852 return Api::ClassId(handle) == kTypeParameterCid; 1853 return Api::ClassId(handle) == kTypeParameterCid;
1853 } 1854 }
1854 1855
1855 1856
1856 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) { 1857 DART_EXPORT bool Dart_IsClosure(Dart_Handle object) {
1857 // We can't use a fast class index check here because there are many 1858 return Api::ClassId(object) == kClosureCid;
1858 // different signature classes for closures.
1859 Thread* thread = Thread::Current();
1860 CHECK_ISOLATE(thread->isolate());
1861 ReusableObjectHandleScope reused_obj_handle(thread);
1862 const Instance& closure_obj =
1863 Api::UnwrapInstanceHandle(reused_obj_handle, object);
1864 return (!closure_obj.IsNull() && closure_obj.IsClosure());
1865 } 1859 }
1866 1860
1867 1861
1868 DART_EXPORT bool Dart_IsTypedData(Dart_Handle handle) { 1862 DART_EXPORT bool Dart_IsTypedData(Dart_Handle handle) {
1869 intptr_t cid = Api::ClassId(handle); 1863 intptr_t cid = Api::ClassId(handle);
1870 return RawObject::IsTypedDataClassId(cid) || 1864 return RawObject::IsTypedDataClassId(cid) ||
1871 RawObject::IsExternalTypedDataClassId(cid) || 1865 RawObject::IsExternalTypedDataClassId(cid) ||
1872 RawObject::IsTypedDataViewClassId(cid); 1866 RawObject::IsTypedDataViewClassId(cid);
1873 } 1867 }
1874 1868
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 API_TIMELINE_DURATION; 1900 API_TIMELINE_DURATION;
1907 DARTSCOPE(Thread::Current()); 1901 DARTSCOPE(Thread::Current());
1908 Isolate* I = T->isolate(); 1902 Isolate* I = T->isolate();
1909 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(instance)); 1903 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(instance));
1910 if (obj.IsNull()) { 1904 if (obj.IsNull()) {
1911 return Api::NewHandle(T, I->object_store()->null_type()); 1905 return Api::NewHandle(T, I->object_store()->null_type());
1912 } 1906 }
1913 if (!obj.IsInstance()) { 1907 if (!obj.IsInstance()) {
1914 RETURN_TYPE_ERROR(Z, instance, Instance); 1908 RETURN_TYPE_ERROR(Z, instance, Instance);
1915 } 1909 }
1916 const Type& type = Type::Handle(Instance::Cast(obj).GetType()); 1910 const AbstractType& type =
1911 AbstractType::Handle(Instance::Cast(obj).GetType());
1917 return Api::NewHandle(T, type.Canonicalize()); 1912 return Api::NewHandle(T, type.Canonicalize());
1918 } 1913 }
1919 1914
1920 1915
1921 // --- Numbers, Integers and Doubles ---- 1916 // --- Numbers, Integers and Doubles ----
1922 1917
1923 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, 1918 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
1924 bool* fits) { 1919 bool* fits) {
1925 API_TIMELINE_DURATION; 1920 API_TIMELINE_DURATION;
1926 // Fast path for Smis and Mints. 1921 // Fast path for Smis and Mints.
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 RETURN_TYPE_ERROR(Z, object, Instance); 3872 RETURN_TYPE_ERROR(Z, object, Instance);
3878 } 3873 }
3879 3874
3880 // Since we have allocated an object it would mean that the type 3875 // Since we have allocated an object it would mean that the type
3881 // is finalized. 3876 // is finalized.
3882 // TODO(asiva): How do we ensure that a constructor is not called more than 3877 // TODO(asiva): How do we ensure that a constructor is not called more than
3883 // once for the same object. 3878 // once for the same object.
3884 3879
3885 // Construct name of the constructor to invoke. 3880 // Construct name of the constructor to invoke.
3886 const String& constructor_name = Api::UnwrapStringHandle(Z, name); 3881 const String& constructor_name = Api::UnwrapStringHandle(Z, name);
3887 const Type& type_obj = Type::Handle(Z, instance.GetType()); 3882 const AbstractType& type_obj = AbstractType::Handle(Z, instance.GetType());
3888 const Class& cls = Class::Handle(Z, type_obj.type_class()); 3883 const Class& cls = Class::Handle(Z, type_obj.type_class());
3889 const String& class_name = String::Handle(Z, cls.Name()); 3884 const String& class_name = String::Handle(Z, cls.Name());
3890 const Array& strings = Array::Handle(Z, Array::New(3)); 3885 const Array& strings = Array::Handle(Z, Array::New(3));
3891 strings.SetAt(0, class_name); 3886 strings.SetAt(0, class_name);
3892 strings.SetAt(1, Symbols::Dot()); 3887 strings.SetAt(1, Symbols::Dot());
3893 if (constructor_name.IsNull()) { 3888 if (constructor_name.IsNull()) {
3894 strings.SetAt(2, Symbols::Empty()); 3889 strings.SetAt(2, Symbols::Empty());
3895 } else { 3890 } else {
3896 strings.SetAt(2, constructor_name); 3891 strings.SetAt(2, constructor_name);
3897 } 3892 }
(...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after
5974 return Api::Success(); 5969 return Api::Success();
5975 } 5970 }
5976 #endif // DART_PRECOMPILED 5971 #endif // DART_PRECOMPILED
5977 5972
5978 5973
5979 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { 5974 DART_EXPORT bool Dart_IsRunningPrecompiledCode() {
5980 return Dart::IsRunningPrecompiledCode(); 5975 return Dart::IsRunningPrecompiledCode();
5981 } 5976 }
5982 5977
5983 } // namespace dart 5978 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698