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

Unified Diff: runtime/lib/isolate.cc

Issue 11636017: Cache resolution of two static functions frequently used in I/O. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/vm/dart_entry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate.cc
===================================================================
--- runtime/lib/isolate.cc (revision 16317)
+++ runtime/lib/isolate.cc (working copy)
@@ -51,27 +51,34 @@
// TODO(turnidge): Move to DartLibraryCalls.
-RawObject* ReceivePortCreate(intptr_t port_id) {
- Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
- ASSERT(!isolate_lib.IsNull());
- const String& public_class_name =
- String::Handle(Symbols::New("_ReceivePortImpl"));
- const String& class_name =
- String::Handle(isolate_lib.PrivateName(public_class_name));
- const String& function_name =
- String::Handle(Symbols::New("_get_or_create"));
+static RawObject* ReceivePortCreate(intptr_t port_id) {
+ Isolate* isolate = Isolate::Current();
+ Function& func =
+ Function::Handle(isolate,
+ isolate->object_store()->receive_port_create_function());
const int kNumArguments = 1;
- const Array& kNoArgumentNames = Array::Handle();
- const Function& func = Function::Handle(
- Resolver::ResolveStatic(isolate_lib,
- class_name,
- function_name,
- kNumArguments,
- kNoArgumentNames,
- Resolver::kIsQualified));
- const Array& args = Array::Handle(Array::New(kNumArguments));
- args.SetAt(0, Integer::Handle(Integer::New(port_id)));
- const Object& result = Object::Handle(DartEntry::InvokeStatic(func, args));
+ if (func.IsNull()) {
+ Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
+ ASSERT(!isolate_lib.IsNull());
+ const String& public_class_name =
+ String::Handle(Symbols::New("_ReceivePortImpl"));
+ const String& class_name =
+ String::Handle(isolate_lib.PrivateName(public_class_name));
+ const String& function_name =
+ String::Handle(Symbols::New("_get_or_create"));
+ const Array& kNoArgumentNames = Array::Handle();
+ func = Resolver::ResolveStatic(isolate_lib,
+ class_name,
+ function_name,
+ kNumArguments,
+ kNoArgumentNames,
+ Resolver::kIsQualified);
+ isolate->object_store()->set_receive_port_create_function(func);
+ }
+ const Array& args = Array::Handle(isolate, Array::New(kNumArguments));
+ args.SetAt(0, Integer::Handle(isolate, Integer::New(port_id)));
+ const Object& result =
+ Object::Handle(isolate, DartEntry::InvokeStatic(func, args));
if (!result.IsError()) {
PortMap::SetLive(port_id);
}
« no previous file with comments | « no previous file | runtime/vm/dart_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698