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

Side by Side Diff: runtime/vm/dart_entry.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/object_store.h » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/dart_entry.h" 5 #include "vm/dart_entry.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, 314 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function,
315 args)); 315 args));
316 ASSERT(result.IsInstance() || result.IsError()); 316 ASSERT(result.IsInstance() || result.IsError());
317 return result.raw(); 317 return result.raw();
318 } 318 }
319 319
320 320
321 RawObject* DartLibraryCalls::HandleMessage(Dart_Port dest_port_id, 321 RawObject* DartLibraryCalls::HandleMessage(Dart_Port dest_port_id,
322 Dart_Port reply_port_id, 322 Dart_Port reply_port_id,
323 const Instance& message) { 323 const Instance& message) {
324 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 324 Isolate* isolate = Isolate::Current();
325 ASSERT(!isolate_lib.IsNull()); 325 Function& function =
326 const String& public_class_name = 326 Function::Handle(isolate,
327 String::Handle(Symbols::New("_ReceivePortImpl")); 327 isolate->object_store()->handle_message_function());
328 const String& class_name =
329 String::Handle(isolate_lib.PrivateName(public_class_name));
330 const String& function_name =
331 String::Handle(Symbols::New("_handleMessage"));
332 const int kNumArguments = 3; 328 const int kNumArguments = 3;
333 const Array& kNoArgumentNames = Array::Handle(); 329 if (function.IsNull()) {
334 const Function& function = Function::Handle( 330 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
335 Resolver::ResolveStatic(isolate_lib, 331 ASSERT(!isolate_lib.IsNull());
336 class_name, 332 const String& public_class_name =
337 function_name, 333 String::Handle(Symbols::New("_ReceivePortImpl"));
338 kNumArguments, 334 const String& class_name =
339 kNoArgumentNames, 335 String::Handle(isolate_lib.PrivateName(public_class_name));
340 Resolver::kIsQualified)); 336 const String& function_name =
341 const Array& args = Array::Handle(Array::New(kNumArguments)); 337 String::Handle(Symbols::New("_handleMessage"));
342 args.SetAt(0, Integer::Handle(Integer::New(dest_port_id))); 338 const Array& kNoArgumentNames = Array::Handle();
343 args.SetAt(1, Integer::Handle(Integer::New(reply_port_id))); 339 function = Resolver::ResolveStatic(isolate_lib,
340 class_name,
341 function_name,
342 kNumArguments,
343 kNoArgumentNames,
344 Resolver::kIsQualified);
345 isolate->object_store()->set_handle_message_function(function);
346 }
347 const Array& args = Array::Handle(isolate, Array::New(kNumArguments));
348 args.SetAt(0, Integer::Handle(isolate, Integer::New(dest_port_id)));
349 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id)));
344 args.SetAt(2, message); 350 args.SetAt(2, message);
345 const Object& result = Object::Handle(DartEntry::InvokeStatic(function, 351 const Object& result =
346 args)); 352 Object::Handle(isolate, DartEntry::InvokeStatic(function, args));
347 ASSERT(result.IsNull() || result.IsError()); 353 ASSERT(result.IsNull() || result.IsError());
348 return result.raw(); 354 return result.raw();
349 } 355 }
350 356
351 357
352 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { 358 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) {
353 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 359 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
354 ASSERT(!isolate_lib.IsNull()); 360 ASSERT(!isolate_lib.IsNull());
355 const String& public_class_name = 361 const String& public_class_name =
356 String::Handle(String::New("_SendPortImpl")); 362 String::Handle(String::New("_SendPortImpl"));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 const String& func_name = String::Handle(Field::GetterName(field_name)); 402 const String& func_name = String::Handle(Field::GetterName(field_name));
397 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); 403 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
398 ASSERT(!func.IsNull()); 404 ASSERT(!func.IsNull());
399 const Array& args = Array::Handle(Array::New(1)); 405 const Array& args = Array::Handle(Array::New(1));
400 args.SetAt(0, port); 406 args.SetAt(0, port);
401 return DartEntry::InvokeDynamic(func, args); 407 return DartEntry::InvokeDynamic(func, args);
402 } 408 }
403 409
404 410
405 } // namespace dart 411 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698