Chromium Code Reviews| Index: vm/dart_api_impl.cc |
| =================================================================== |
| --- vm/dart_api_impl.cc (revision 4985) |
| +++ vm/dart_api_impl.cc (working copy) |
| @@ -2011,18 +2011,31 @@ |
| Dart_Handle* arguments) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| - // Finalize all classes. |
| - const char* msg = CheckIsolateState(isolate); |
| - if (msg != NULL) { |
| - return Api::NewError(msg); |
| - } |
| - |
| - // Now try to resolve and invoke the static function. |
| + // Check whether class finalization is needed. |
| + bool finalize_classes = true; |
| const Library& library = |
| Library::CheckedHandle(Api::UnwrapHandle(library_in)); |
| if (library.IsNull()) { |
| return Api::NewError("No library specified"); |
| } |
| + |
| + // When calling functions in the dart:builtin library do not finalize as it |
| + // should have been prefinalized. |
| + Library& builtin = |
| + Library::Handle(isolate->object_store()->builtin_library()); |
|
siva
2012/03/07 18:32:17
if (builtin.IsNull()) {
return Api::NewError("..
Ivan Posva
2012/03/08 00:49:33
Discussed offline.
|
| + if (builtin.raw() == library.raw()) { |
| + finalize_classes = false; |
| + } |
| + |
| + // Finalize all classes if needed. |
| + if (finalize_classes) { |
| + const char* msg = CheckIsolateState(isolate); |
| + if (msg != NULL) { |
| + return Api::NewError(msg); |
| + } |
| + } |
| + |
| + // Now try to resolve and invoke the static function. |
| const String& class_name = |
| String::CheckedHandle(Api::UnwrapHandle(class_name_in)); |
| const String& function_name = |
| @@ -2649,6 +2662,14 @@ |
| library.set_import_map(mapping_array); |
| } |
| library.Register(); |
| + // If this is the dart:builtin library register it with the VM. |
| + if (url_str.Equals("dart:builtin")) { |
| + isolate->object_store()->set_builtin_library(library); |
| + const char* msg = CheckIsolateState(isolate); |
| + if (msg != NULL) { |
| + return Api::NewError(msg); |
| + } |
| + } |
| } else if (!library.LoadNotStarted()) { |
| // The source for this library has either been loaded or is in the |
| // process of loading. Return an error. |