Index: runtime/vm/mirrors_api_impl.cc |
diff --git a/runtime/vm/mirrors_api_impl.cc b/runtime/vm/mirrors_api_impl.cc |
index d775e229131f8088ec46390ff18bf9ee08d46e1f..3d83d44aead4fac069a3eb0044c8dfb3c4998271 100644 |
--- a/runtime/vm/mirrors_api_impl.cc |
+++ b/runtime/vm/mirrors_api_impl.cc |
@@ -19,37 +19,38 @@ |
namespace dart { |
+// Facilitate quick access to the current zone once we have the curren thread. |
+#define Z (T->zone()) |
+ |
// --- Classes and Interfaces Reflection --- |
DART_EXPORT Dart_Handle Dart_TypeName(Dart_Handle object) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
+ DARTSCOPE(Thread::Current()); |
+ const Object& obj = Object::Handle(I, Api::UnwrapHandle(object)); |
if (obj.IsType()) { |
const Class& cls = Class::Handle(Type::Cast(obj).type_class()); |
- return Api::NewHandle(isolate, cls.UserVisibleName()); |
+ return Api::NewHandle(I, cls.UserVisibleName()); |
} else { |
- RETURN_TYPE_ERROR(isolate, object, Class/Type); |
+ RETURN_TYPE_ERROR(I, object, Class/Type); |
} |
} |
DART_EXPORT Dart_Handle Dart_QualifiedTypeName(Dart_Handle object) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
+ DARTSCOPE(Thread::Current()); |
+ const Object& obj = Object::Handle(Z, Api::UnwrapHandle(object)); |
if (obj.IsType() || obj.IsClass()) { |
const Class& cls = (obj.IsType()) ? |
- Class::Handle(Type::Cast(obj).type_class()) : Class::Cast(obj); |
+ Class::Handle(Z, Type::Cast(obj).type_class()) : Class::Cast(obj); |
const char* str = cls.ToCString(); |
if (str == NULL) { |
RETURN_NULL_ERROR(str); |
} |
- CHECK_CALLBACK_STATE(isolate); |
- return Api::NewHandle(isolate, String::New(str)); |
+ CHECK_CALLBACK_STATE(I); |
+ return Api::NewHandle(I, String::New(str)); |
} else { |
- RETURN_TYPE_ERROR(isolate, object, Class/Type); |
+ RETURN_TYPE_ERROR(I, object, Class/Type); |
} |
} |
@@ -69,25 +70,24 @@ static RawString* RemoveExternalSetterSuffix(const String& name) { |
DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target)); |
+ DARTSCOPE(Thread::Current()); |
+ const Object& obj = Object::Handle(Z, Api::UnwrapHandle(target)); |
if (obj.IsError()) { |
return target; |
} |
const GrowableObjectArray& names = |
- GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); |
- Function& func = Function::Handle(); |
- String& name = String::Handle(); |
+ GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); |
+ Function& func = Function::Handle(Z); |
+ String& name = String::Handle(Z); |
if (obj.IsType()) { |
- const Class& cls = Class::Handle(Type::Cast(obj).type_class()); |
- const Error& error = Error::Handle(isolate, cls.EnsureIsFinalized(isolate)); |
+ const Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); |
+ const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(I)); |
if (!error.IsNull()) { |
- return Api::NewHandle(isolate, error.raw()); |
+ return Api::NewHandle(I, error.raw()); |
} |
- const Array& func_array = Array::Handle(cls.functions()); |
+ const Array& func_array = Array::Handle(Z, cls.functions()); |
// Some special types like 'dynamic' have a null functions list. |
if (!func_array.IsNull()) { |
@@ -124,27 +124,26 @@ DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target) { |
"%s expects argument 'target' to be a class or library.", |
CURRENT_FUNC); |
} |
- return Api::NewHandle(isolate, Array::MakeArray(names)); |
+ return Api::NewHandle(I, Array::MakeArray(names)); |
} |
DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, |
Dart_Handle function_name) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(target)); |
+ DARTSCOPE(Thread::Current()); |
+ const Object& obj = Object::Handle(Z, Api::UnwrapHandle(target)); |
if (obj.IsError()) { |
return target; |
} |
- const String& func_name = Api::UnwrapStringHandle(isolate, function_name); |
+ const String& func_name = Api::UnwrapStringHandle(I, function_name); |
if (func_name.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, function_name, String); |
+ RETURN_TYPE_ERROR(I, function_name, String); |
} |
- Function& func = Function::Handle(isolate); |
- String& tmp_name = String::Handle(isolate); |
+ Function& func = Function::Handle(Z); |
+ String& tmp_name = String::Handle(Z); |
if (obj.IsType()) { |
- const Class& cls = Class::Handle(Type::Cast(obj).type_class()); |
+ const Class& cls = Class::Handle(Z, Type::Cast(obj).type_class()); |
// Case 1. Lookup the unmodified function name. |
func = cls.LookupFunctionAllowPrivate(func_name); |
@@ -206,60 +205,57 @@ DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, |
func_kind == RawFunction::kConstructor); |
} |
#endif |
- return Api::NewHandle(isolate, func.raw()); |
+ return Api::NewHandle(I, func.raw()); |
} |
DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Function& func = Api::UnwrapFunctionHandle(isolate, function); |
+ DARTSCOPE(Thread::Current()); |
+ const Function& func = Api::UnwrapFunctionHandle(I, function); |
if (func.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, function, Function); |
+ RETURN_TYPE_ERROR(I, function, Function); |
} |
- return Api::NewHandle(isolate, func.UserVisibleName()); |
+ return Api::NewHandle(I, func.UserVisibleName()); |
} |
DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Function& func = Api::UnwrapFunctionHandle(isolate, function); |
+ DARTSCOPE(Thread::Current()); |
+ const Function& func = Api::UnwrapFunctionHandle(I, function); |
if (func.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, function, Function); |
+ RETURN_TYPE_ERROR(I, function, Function); |
} |
if (func.IsNonImplicitClosureFunction()) { |
RawFunction* parent_function = func.parent_function(); |
- return Api::NewHandle(isolate, parent_function); |
+ return Api::NewHandle(I, parent_function); |
} |
- const Class& owner = Class::Handle(func.Owner()); |
+ const Class& owner = Class::Handle(Z, func.Owner()); |
ASSERT(!owner.IsNull()); |
if (owner.IsTopLevel()) { |
// Top-level functions are implemented as members of a hidden class. We hide |
// that class here and instead answer the library. |
#if defined(DEBUG) |
- const Library& lib = Library::Handle(owner.library()); |
+ const Library& lib = Library::Handle(Z, owner.library()); |
if (lib.IsNull()) { |
ASSERT(owner.IsDynamicClass() || owner.IsVoidClass()); |
} |
#endif |
- return Api::NewHandle(isolate, owner.library()); |
+ return Api::NewHandle(I, owner.library()); |
} else { |
- return Api::NewHandle(isolate, owner.RareType()); |
+ return Api::NewHandle(I, owner.RareType()); |
} |
} |
DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function, |
bool* is_static) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
+ DARTSCOPE(Thread::Current()); |
if (is_static == NULL) { |
RETURN_NULL_ERROR(is_static); |
} |
- const Function& func = Api::UnwrapFunctionHandle(isolate, function); |
+ const Function& func = Api::UnwrapFunctionHandle(I, function); |
if (func.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, function, Function); |
+ RETURN_TYPE_ERROR(I, function, Function); |
} |
*is_static = func.is_static(); |
return Api::Success(); |
@@ -268,14 +264,13 @@ DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function, |
DART_EXPORT Dart_Handle Dart_FunctionIsConstructor(Dart_Handle function, |
bool* is_constructor) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
+ DARTSCOPE(Thread::Current()); |
if (is_constructor == NULL) { |
RETURN_NULL_ERROR(is_constructor); |
} |
- const Function& func = Api::UnwrapFunctionHandle(isolate, function); |
+ const Function& func = Api::UnwrapFunctionHandle(I, function); |
if (func.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, function, Function); |
+ RETURN_TYPE_ERROR(I, function, Function); |
} |
*is_constructor = func.kind() == RawFunction::kConstructor; |
return Api::Success(); |
@@ -284,14 +279,13 @@ DART_EXPORT Dart_Handle Dart_FunctionIsConstructor(Dart_Handle function, |
DART_EXPORT Dart_Handle Dart_FunctionIsGetter(Dart_Handle function, |
bool* is_getter) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
+ DARTSCOPE(Thread::Current()); |
if (is_getter == NULL) { |
RETURN_NULL_ERROR(is_getter); |
} |
- const Function& func = Api::UnwrapFunctionHandle(isolate, function); |
+ const Function& func = Api::UnwrapFunctionHandle(I, function); |
if (func.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, function, Function); |
+ RETURN_TYPE_ERROR(I, function, Function); |
} |
*is_getter = func.IsGetterFunction(); |
return Api::Success(); |
@@ -300,14 +294,13 @@ DART_EXPORT Dart_Handle Dart_FunctionIsGetter(Dart_Handle function, |
DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, |
bool* is_setter) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
+ DARTSCOPE(Thread::Current()); |
if (is_setter == NULL) { |
RETURN_NULL_ERROR(is_setter); |
} |
- const Function& func = Api::UnwrapFunctionHandle(isolate, function); |
+ const Function& func = Api::UnwrapFunctionHandle(I, function); |
if (func.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, function, Function); |
+ RETURN_TYPE_ERROR(I, function, Function); |
} |
*is_setter = (func.kind() == RawFunction::kSetterFunction); |
return Api::Success(); |
@@ -317,30 +310,28 @@ DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, |
// --- Libraries Reflection --- |
DART_EXPORT Dart_Handle Dart_LibraryName(Dart_Handle library) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Library& lib = Api::UnwrapLibraryHandle(isolate, library); |
+ DARTSCOPE(Thread::Current()); |
+ const Library& lib = Api::UnwrapLibraryHandle(I, library); |
if (lib.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, library, Library); |
+ RETURN_TYPE_ERROR(I, library, Library); |
} |
- const String& name = String::Handle(isolate, lib.name()); |
+ const String& name = String::Handle(Z, lib.name()); |
ASSERT(!name.IsNull()); |
- return Api::NewHandle(isolate, name.raw()); |
+ return Api::NewHandle(I, name.raw()); |
} |
DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Library& lib = Api::UnwrapLibraryHandle(isolate, library); |
+ DARTSCOPE(Thread::Current()); |
+ const Library& lib = Api::UnwrapLibraryHandle(I, library); |
if (lib.IsNull()) { |
- RETURN_TYPE_ERROR(isolate, library, Library); |
+ RETURN_TYPE_ERROR(I, library, Library); |
} |
const GrowableObjectArray& names = |
- GrowableObjectArray::Handle(isolate, GrowableObjectArray::New()); |
+ GrowableObjectArray::Handle(Z, GrowableObjectArray::New()); |
ClassDictionaryIterator it(lib); |
- Class& cls = Class::Handle(); |
- String& name = String::Handle(); |
+ Class& cls = Class::Handle(Z); |
+ String& name = String::Handle(Z); |
while (it.HasNext()) { |
cls = it.GetNextClass(); |
if (cls.IsSignatureClass()) { |
@@ -356,24 +347,23 @@ DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library) { |
names.Add(name); |
} |
} |
- return Api::NewHandle(isolate, Array::MakeArray(names)); |
+ return Api::NewHandle(I, Array::MakeArray(names)); |
} |
// --- Closures Reflection --- |
DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure) { |
- Isolate* isolate = Isolate::Current(); |
- DARTSCOPE(isolate); |
- const Instance& closure_obj = Api::UnwrapInstanceHandle(isolate, closure); |
+ DARTSCOPE(Thread::Current()); |
+ const Instance& closure_obj = Api::UnwrapInstanceHandle(I, closure); |
if (closure_obj.IsNull() || !closure_obj.IsClosure()) { |
- RETURN_TYPE_ERROR(isolate, closure, Instance); |
+ RETURN_TYPE_ERROR(I, closure, Instance); |
} |
ASSERT(ClassFinalizer::AllClassesFinalized()); |
RawFunction* rf = Closure::function(closure_obj); |
- return Api::NewHandle(isolate, rf); |
+ return Api::NewHandle(I, rf); |
} |
} // namespace dart |