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

Unified Diff: runtime/lib/mirrors_impl.dart

Issue 135913003: Optimize getField by caching a closure generated from a specialized function kind. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors_impl.dart
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart
index 310c9f7b48b997589ce658ab2ed42fdff2009365..cf5c54a781f1d0b5d8c68267463b5b3255da46f8 100644
--- a/runtime/lib/mirrors_impl.dart
+++ b/runtime/lib/mirrors_impl.dart
@@ -355,6 +355,33 @@ class _LocalInstanceMirror extends _LocalObjectMirror
return reflect(this._invoke(_reflectee, _n(memberName), arguments, names));
}
+ static Map _getFieldClosures = new Map.identity();
+ static Map _setFieldClosures = new Map.identity();
+
+ InstanceMirror getField(Symbol memberName) {
+ var f = _getFieldClosures[memberName];
+ if (f == null) {
+ f = _makeGetter(_n(memberName), _ScratchClass);
+ _getFieldClosures[memberName] = f;
+ }
+ return reflect(f(_reflectee));
+ }
+
+ InstanceMirror setField(Symbol memberName, value) {
+ var f = _setFieldClosures[memberName];
+ if (f == null) {
+ f = _makeSetter(_n(memberName), _ScratchClass);
+ _setFieldClosures[memberName] = f;
+ }
+ return reflect(f(_reflectee, value));
+ }
+
+ static _makeGetter(selector, scratchClass)
+ native "Mirrors_makeGetter";
+
+ static _makeSetter(selector, scratchClass)
+ native "Mirrors_makeSetter";
+
_invoke(reflectee, functionName, arguments, argumentNames)
native 'InstanceMirror_invoke';
@@ -368,6 +395,8 @@ class _LocalInstanceMirror extends _LocalObjectMirror
native 'InstanceMirror_computeType';
}
+class _ScratchClass {}
+
class _LocalClosureMirror extends _LocalInstanceMirror
implements ClosureMirror {
_LocalClosureMirror(reflectee) : super(reflectee);
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698