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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 1080393006: Mirrors memory usage tweaks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "lib/mirrors.h" 5 #include "lib/mirrors.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 const Array& args = Array::Handle(Array::New(2)); 235 const Array& args = Array::Handle(Array::New(2));
236 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls))); 236 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(cls)));
237 args.SetAt(1, type); 237 args.SetAt(1, type);
238 return CreateMirror(Symbols::_LocalFunctionTypeMirror(), args); 238 return CreateMirror(Symbols::_LocalFunctionTypeMirror(), args);
239 } 239 }
240 240
241 241
242 static RawInstance* CreateMethodMirror(const Function& func, 242 static RawInstance* CreateMethodMirror(const Function& func,
243 const Instance& owner_mirror, 243 const Instance& owner_mirror,
244 const AbstractType& instantiator) { 244 const AbstractType& instantiator) {
245 const Array& args = Array::Handle(Array::New(13)); 245 const Array& args = Array::Handle(Array::New(6));
246 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func))); 246 args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func)));
247 247
248 String& name = String::Handle(func.name()); 248 String& name = String::Handle(func.name());
249 name = String::IdentifierPrettyNameRetainPrivate(name); 249 name = String::IdentifierPrettyNameRetainPrivate(name);
250 args.SetAt(1, name); 250 args.SetAt(1, name);
251
252 args.SetAt(2, owner_mirror); 251 args.SetAt(2, owner_mirror);
253 args.SetAt(3, instantiator); 252 args.SetAt(3, instantiator);
254 args.SetAt(4, Bool::Get(func.is_static())); 253 args.SetAt(4, Bool::Get(func.is_static()));
255 args.SetAt(5, Bool::Get(func.is_abstract()));
256 args.SetAt(6, Bool::Get(func.IsGetterFunction()));
257 args.SetAt(7, Bool::Get(func.IsSetterFunction()));
258 254
255 // These offsets much be kept in sync with those in mirrors_impl.dart.
siva 2015/04/22 00:00:47 Can you declare some constants in mirrors_impl.dar
rmacnak 2015/04/22 17:09:02 Added debug-only hook in CreateMirrorSystem, which
256 intptr_t kind_flags = 0;
257 kind_flags |= (func.is_abstract() << 0);
258 kind_flags |= (func.IsGetterFunction() << 1);
259 kind_flags |= (func.IsSetterFunction() << 2);
259 bool isConstructor = (func.kind() == RawFunction::kConstructor); 260 bool isConstructor = (func.kind() == RawFunction::kConstructor);
260 args.SetAt(8, Bool::Get(isConstructor)); 261 kind_flags |= (isConstructor << 3);
261 args.SetAt(9, Bool::Get(isConstructor && func.is_const())); 262 kind_flags |= ((isConstructor && func.is_const()) << 4);
262 args.SetAt(10, Bool::Get(isConstructor && func.IsGenerativeConstructor())); 263 kind_flags |= ((isConstructor && func.IsGenerativeConstructor()) << 5);
263 args.SetAt(11, Bool::Get(isConstructor && func.is_redirecting())); 264 kind_flags |= ((isConstructor && func.is_redirecting()) << 6);
264 args.SetAt(12, Bool::Get(isConstructor && func.IsFactory())); 265 kind_flags |= ((isConstructor && func.IsFactory()) << 7);
266 args.SetAt(5, Smi::Handle(Smi::New(kind_flags)));
265 267
266 return CreateMirror(Symbols::_LocalMethodMirror(), args); 268 return CreateMirror(Symbols::_LocalMethodMirror(), args);
267 } 269 }
268 270
269 271
270 static RawInstance* CreateVariableMirror(const Field& field, 272 static RawInstance* CreateVariableMirror(const Field& field,
271 const Instance& owner_mirror) { 273 const Instance& owner_mirror) {
272 const MirrorReference& field_ref = 274 const MirrorReference& field_ref =
273 MirrorReference::Handle(MirrorReference::New(field)); 275 MirrorReference::Handle(MirrorReference::New(field));
274 276
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 instantiator, 888 instantiator,
887 arguments->NativeArgAt(1)); 889 arguments->NativeArgAt(1));
888 const Class& cls = Class::Handle(ref.GetClassReferent()); 890 const Class& cls = Class::Handle(ref.GetClassReferent());
889 const Function& func = Function::Handle(CallMethod(cls)); 891 const Function& func = Function::Handle(CallMethod(cls));
890 ASSERT(!func.IsNull()); 892 ASSERT(!func.IsNull());
891 AbstractType& type = AbstractType::Handle(func.result_type()); 893 AbstractType& type = AbstractType::Handle(func.result_type());
892 return InstantiateType(type, instantiator); 894 return InstantiateType(type, instantiator);
893 } 895 }
894 896
895 897
896 DEFINE_NATIVE_ENTRY(ClassMirror_library, 1) { 898 DEFINE_NATIVE_ENTRY(ClassMirror_libraryUri, 1) {
897 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); 899 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0));
898 const Class& klass = Class::Handle(ref.GetClassReferent()); 900 const Class& klass = Class::Handle(ref.GetClassReferent());
899 const Library& library = Library::Handle(klass.library()); 901 const Library& library = Library::Handle(klass.library());
900 ASSERT(!library.IsNull()); 902 ASSERT(!library.IsNull());
901 return CreateLibraryMirror(library); 903 return library.url();
902 } 904 }
903 905
904 906
905 DEFINE_NATIVE_ENTRY(ClassMirror_supertype, 1) { 907 DEFINE_NATIVE_ENTRY(ClassMirror_supertype, 1) {
906 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0)); 908 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, type, arguments->NativeArgAt(0));
907 ASSERT(!type.IsMalformed()); 909 ASSERT(!type.IsMalformed());
908 ASSERT(type.IsFinalized()); 910 ASSERT(type.IsFinalized());
909 if (!type.HasResolvedTypeClass()) { 911 if (!type.HasResolvedTypeClass()) {
910 Exceptions::ThrowArgumentError(type); 912 Exceptions::ThrowArgumentError(type);
911 UNREACHABLE(); 913 UNREACHABLE();
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 } 2036 }
2035 2037
2036 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) { 2038 DEFINE_NATIVE_ENTRY(TypeMirror_moreSpecificTest, 2) {
2037 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2039 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2038 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2040 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2039 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw(); 2041 return Bool::Get(a.IsMoreSpecificThan(b, NULL)).raw();
2040 } 2042 }
2041 2043
2042 2044
2043 } // namespace dart 2045 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698