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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/dart_entry.cc » ('j') | runtime/vm/dart_entry.cc » ('J')
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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 static void StoreError(Isolate* isolate, const Object& obj) { 45 static void StoreError(Isolate* isolate, const Object& obj) {
46 ASSERT(obj.IsError()); 46 ASSERT(obj.IsError());
47 Error& error = Error::Handle(); 47 Error& error = Error::Handle();
48 error ^= obj.raw(); 48 error ^= obj.raw();
49 isolate->object_store()->set_sticky_error(error); 49 isolate->object_store()->set_sticky_error(error);
50 } 50 }
51 51
52 52
53 // TODO(turnidge): Move to DartLibraryCalls. 53 // TODO(turnidge): Move to DartLibraryCalls.
54 RawObject* ReceivePortCreate(intptr_t port_id) { 54 static RawObject* ReceivePortCreate(intptr_t port_id) {
55 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 55 Isolate* isolate = Isolate::Current();
56 ASSERT(!isolate_lib.IsNull()); 56 Function& func = Function::Handle(isolate);
Ivan Posva 2012/12/19 19:11:31 We tend to write this kind of code this way: Func
Florian Schneider 2012/12/20 12:42:25 Done.
57 const String& public_class_name =
58 String::Handle(Symbols::New("_ReceivePortImpl"));
59 const String& class_name =
60 String::Handle(isolate_lib.PrivateName(public_class_name));
61 const String& function_name =
62 String::Handle(Symbols::New("_get_or_create"));
63 const int kNumArguments = 1; 57 const int kNumArguments = 1;
64 const Array& kNoArgumentNames = Array::Handle(); 58 if (isolate->object_store()->receive_port_create_function() !=
65 const Function& func = Function::Handle( 59 Function::null()) {
66 Resolver::ResolveStatic(isolate_lib, 60 func = isolate->object_store()->receive_port_create_function();
67 class_name, 61 } else {
68 function_name, 62 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
69 kNumArguments, 63 ASSERT(!isolate_lib.IsNull());
70 kNoArgumentNames, 64 const String& public_class_name =
71 Resolver::kIsQualified)); 65 String::Handle(Symbols::New("_ReceivePortImpl"));
72 const Array& args = Array::Handle(Array::New(kNumArguments)); 66 const String& class_name =
73 args.SetAt(0, Integer::Handle(Integer::New(port_id))); 67 String::Handle(isolate_lib.PrivateName(public_class_name));
74 const Object& result = Object::Handle(DartEntry::InvokeStatic(func, args)); 68 const String& function_name =
69 String::Handle(Symbols::New("_get_or_create"));
70 const Array& kNoArgumentNames = Array::Handle();
71 func = Resolver::ResolveStatic(isolate_lib,
72 class_name,
73 function_name,
74 kNumArguments,
75 kNoArgumentNames,
76 Resolver::kIsQualified);
77 isolate->object_store()->set_receive_port_create_function(func);
78 }
79 const Array& args = Array::Handle(isolate, Array::New(kNumArguments));
80 args.SetAt(0, Integer::Handle(isolate, Integer::New(port_id)));
81 const Object& result =
82 Object::Handle(isolate, DartEntry::InvokeStatic(func, args));
75 if (!result.IsError()) { 83 if (!result.IsError()) {
76 PortMap::SetLive(port_id); 84 PortMap::SetLive(port_id);
77 } 85 }
78 return result.raw(); 86 return result.raw();
79 } 87 }
80 88
81 89
82 static void ShutdownIsolate(uword parameter) { 90 static void ShutdownIsolate(uword parameter) {
83 Isolate* isolate = reinterpret_cast<Isolate*>(parameter); 91 Isolate* isolate = reinterpret_cast<Isolate*>(parameter);
84 { 92 {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 495
488 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { 496 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) {
489 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); 497 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port()));
490 if (port.IsError()) { 498 if (port.IsError()) {
491 Exceptions::PropagateError(Error::Cast(port)); 499 Exceptions::PropagateError(Error::Cast(port));
492 } 500 }
493 return port.raw(); 501 return port.raw();
494 } 502 }
495 503
496 } // namespace dart 504 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_entry.cc » ('j') | runtime/vm/dart_entry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698