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

Unified Diff: runtime/lib/mirrors.cc

Issue 144383007: Optimize getField by caching a closure generated from eval. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | « no previous file | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
diff --git a/runtime/lib/mirrors.cc b/runtime/lib/mirrors.cc
index 3b7391caf42238dba40a43e93faefaf52a13fafe..9f5c7634be0c0632f0e48c6c48bd960eb6d520c7 100644
--- a/runtime/lib/mirrors.cc
+++ b/runtime/lib/mirrors.cc
@@ -1301,6 +1301,33 @@ DEFINE_NATIVE_ENTRY(TypeVariableMirror_upper_bound, 1) {
}
+DEFINE_NATIVE_ENTRY(Mirrors_evalInLibraryWithPrivateKey, 2) {
+ GET_NON_NULL_NATIVE_ARGUMENT(String, expression, arguments->NativeArgAt(0));
+ GET_NATIVE_ARGUMENT(String, private_key, arguments->NativeArgAt(1));
+
+ const GrowableObjectArray& libraries =
+ GrowableObjectArray::Handle(isolate->object_store()->libraries());
+ const int num_libraries = libraries.Length();
+ Library& each_library = Library::Handle();
+ Library& ctxt_library = Library::Handle();
+ String& library_key = String::Handle();
+
+ if (library_key.IsNull()) {
+ ctxt_library = Library::CoreLibrary();
+ } else {
+ for (int i = 0; i < num_libraries; i++) {
+ each_library ^= libraries.At(i);
+ library_key = each_library.private_key();
+ if (library_key.Equals(private_key)) {
+ ctxt_library = each_library.raw();
+ break;
+ }
+ }
+ }
+ ASSERT(!ctxt_library.IsNull());
+ return ctxt_library.Evaluate(expression);
+}
+
DEFINE_NATIVE_ENTRY(TypedefMirror_declaration, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(Type, type, arguments->NativeArgAt(0));
const Class& cls = Class::Handle(type.type_class());
« 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