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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 17503002: Stop unwanted class finalization when using dart:io HttpClient from builtin.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/isolate.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 FinalizablePersistentHandle* Api::UnwrapAsPrologueWeakPersistentHandle( 127 FinalizablePersistentHandle* Api::UnwrapAsPrologueWeakPersistentHandle(
128 Dart_WeakPersistentHandle object) { 128 Dart_WeakPersistentHandle object) {
129 ASSERT(Isolate::Current()->api_state()->IsValidPrologueWeakPersistentHandle( 129 ASSERT(Isolate::Current()->api_state()->IsValidPrologueWeakPersistentHandle(
130 object)); 130 object));
131 return reinterpret_cast<FinalizablePersistentHandle*>(object); 131 return reinterpret_cast<FinalizablePersistentHandle*>(object);
132 } 132 }
133 133
134 134
135 Dart_Handle Api::CheckIsolateState(Isolate* isolate) { 135 Dart_Handle Api::CheckIsolateState(Isolate* isolate) {
136 if (!isolate->AllowClassFinalization()) {
137 // Class finalization is blocked for the isolate. Do nothing.
138 return Api::Success();
139 }
136 if (ClassFinalizer::FinalizePendingClasses() && 140 if (ClassFinalizer::FinalizePendingClasses() &&
137 isolate->object_store()->PreallocateObjects()) { 141 isolate->object_store()->PreallocateObjects()) {
138 return Api::Success(); 142 return Api::Success();
139 } 143 }
140 ASSERT(isolate->object_store()->sticky_error() != Object::null()); 144 ASSERT(isolate->object_store()->sticky_error() != Object::null());
141 return Api::NewHandle(isolate, isolate->object_store()->sticky_error()); 145 return Api::NewHandle(isolate, isolate->object_store()->sticky_error());
142 } 146 }
143 147
144 148
145 Dart_Isolate Api::CastIsolate(Isolate* isolate) { 149 Dart_Isolate Api::CastIsolate(Isolate* isolate) {
(...skipping 2813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 return Api::NewHandle(isolate, 2963 return Api::NewHandle(isolate,
2960 DartEntry::InvokeNoSuchMethod(instance, 2964 DartEntry::InvokeNoSuchMethod(instance,
2961 function_name, 2965 function_name,
2962 args, 2966 args,
2963 args_descriptor)); 2967 args_descriptor));
2964 } 2968 }
2965 return Api::NewHandle(isolate, DartEntry::InvokeFunction(function, args)); 2969 return Api::NewHandle(isolate, DartEntry::InvokeFunction(function, args));
2966 2970
2967 } else if (obj.IsLibrary()) { 2971 } else if (obj.IsLibrary()) {
2968 // Check whether class finalization is needed. 2972 // Check whether class finalization is needed.
2969 bool finalize_classes = true;
2970 const Library& lib = Library::Cast(obj); 2973 const Library& lib = Library::Cast(obj);
2971 2974
2972 // When calling functions in the dart:builtin library do not finalize as it
2973 // should have been prefinalized.
2974 Library& builtin =
2975 Library::Handle(isolate, isolate->object_store()->builtin_library());
2976 if (builtin.raw() == lib.raw()) {
2977 finalize_classes = false;
2978 }
2979
2980 // Finalize all classes if needed. 2975 // Finalize all classes if needed.
2981 if (finalize_classes) { 2976 Dart_Handle state = Api::CheckIsolateState(isolate);
2982 Dart_Handle state = Api::CheckIsolateState(isolate); 2977 if (::Dart_IsError(state)) {
2983 if (::Dart_IsError(state)) { 2978 return state;
2984 return state;
2985 }
2986 } 2979 }
2987 2980
2988 Function& function = Function::Handle(isolate); 2981 Function& function = Function::Handle(isolate);
2989 function = lib.LookupFunctionAllowPrivate(function_name); 2982 function = lib.LookupFunctionAllowPrivate(function_name);
2990 if (function.IsNull()) { 2983 if (function.IsNull()) {
2991 return Api::NewError("%s: did not find top-level function '%s'.", 2984 return Api::NewError("%s: did not find top-level function '%s'.",
2992 CURRENT_FUNC, 2985 CURRENT_FUNC,
2993 function_name.ToCString()); 2986 function_name.ToCString());
2994 } 2987 }
2995 // LookupFunctionAllowPrivate does not check argument arity, so we 2988 // LookupFunctionAllowPrivate does not check argument arity, so we
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3067 const String& field_name = Api::UnwrapStringHandle(isolate, name); 3060 const String& field_name = Api::UnwrapStringHandle(isolate, name);
3068 if (field_name.IsNull()) { 3061 if (field_name.IsNull()) {
3069 RETURN_TYPE_ERROR(isolate, name, String); 3062 RETURN_TYPE_ERROR(isolate, name, String);
3070 } 3063 }
3071 3064
3072 // Finalize all classes. 3065 // Finalize all classes.
3073 Dart_Handle state = Api::CheckIsolateState(isolate); 3066 Dart_Handle state = Api::CheckIsolateState(isolate);
3074 if (::Dart_IsError(state)) { 3067 if (::Dart_IsError(state)) {
3075 return state; 3068 return state;
3076 } 3069 }
3070
3077 Field& field = Field::Handle(isolate); 3071 Field& field = Field::Handle(isolate);
3078 Function& getter = Function::Handle(isolate); 3072 Function& getter = Function::Handle(isolate);
3079 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container)); 3073 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(container));
3080 if (obj.IsNull()) { 3074 if (obj.IsNull()) {
3081 return Api::NewError("%s expects argument 'container' to be non-null.", 3075 return Api::NewError("%s expects argument 'container' to be non-null.",
3082 CURRENT_FUNC); 3076 CURRENT_FUNC);
3083 } else if (obj.IsType() || obj.IsClass()) { 3077 } else if (obj.IsType() || obj.IsClass()) {
3084 // To access a static field we may need to use the Field or the 3078 // To access a static field we may need to use the Field or the
3085 // getter Function. 3079 // getter Function.
3086 // For backwards compatibility we allow class objects to be passed in 3080 // For backwards compatibility we allow class objects to be passed in
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 } 3986 }
3993 { 3987 {
3994 NoGCScope no_gc; 3988 NoGCScope no_gc;
3995 RawObject* raw_obj = obj.raw(); 3989 RawObject* raw_obj = obj.raw();
3996 isolate->heap()->SetPeer(raw_obj, peer); 3990 isolate->heap()->SetPeer(raw_obj, peer);
3997 } 3991 }
3998 return Api::Success(); 3992 return Api::Success();
3999 } 3993 }
4000 3994
4001 } // namespace dart 3995 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698