Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl.cc (revision 1428) |
| +++ runtime/vm/dart_api_impl.cc (working copy) |
| @@ -55,9 +55,8 @@ |
| DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle) { |
| - ASSERT(Isolate::Current() != NULL); |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| // Make sure that the object isn't an ApiFailure. |
| const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); |
| @@ -76,9 +75,9 @@ |
| DART_EXPORT const char* Dart_GetError(const Dart_Handle& handle) { |
| - ASSERT(Isolate::Current() != NULL); |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| + |
| const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); |
| if (!obj.IsApiFailure()) { |
| return ""; |
| @@ -97,8 +96,8 @@ |
| // TODO(turnidge): This clonse Api::Error. I need to use va_copy to |
| // fix this but not sure if it available on all of our builds. |
| DART_EXPORT Dart_Handle Dart_Error(const char* format, ...) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| va_list args; |
| va_start(args, format); |
| @@ -139,10 +138,9 @@ |
| return reinterpret_cast<Dart_Isolate>(isolate); |
| } else { |
| { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + DARTSCOPE(isolate); |
| const String& error = |
| - String::Handle(Isolate::Current()->object_store()->sticky_error()); |
| + String::Handle(isolate->object_store()->sticky_error()); |
| // TODO(asiva): Need to return this as a error. |
| OS::PrintErr(error.ToCString()); |
| } |
| @@ -229,8 +227,9 @@ |
| DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port, |
| Dart_Port reply_port, |
| Dart_Message dart_message) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| + |
| const Instance& msg = Instance::Handle(DeserializeMessage(dart_message)); |
| const String& class_name = |
| String::Handle(String::NewSymbol("ReceivePortImpl")); |
| @@ -264,10 +263,9 @@ |
| DART_EXPORT Dart_Handle Dart_RunLoop() { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| - |
| Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| + |
| LongJump* base = isolate->long_jump_base(); |
| LongJump jump; |
| Dart_Handle result; |
| @@ -286,13 +284,13 @@ |
| // NOTE: Need to pass 'result' as a parameter here in order to avoid |
| // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
| // which shows up because of the use of setjmp. |
| -static void CompileSource(const Library& lib, |
| +static void CompileSource(Isolate* isolate, |
| + const Library& lib, |
| const String& url, |
| const String& source, |
| RawScript::Kind kind, |
| Dart_Handle* result) { |
| const Script& script = Script::Handle(Script::New(url, source, kind)); |
| - Isolate* isolate = Isolate::Current(); |
| ASSERT(isolate != NULL); |
| LongJump* base = isolate->long_jump_base(); |
| LongJump jump; |
| @@ -311,9 +309,7 @@ |
| Dart_Handle source, |
| Dart_LibraryTagHandler handler) { |
| Isolate* isolate = Isolate::Current(); |
| - ASSERT(isolate != NULL); |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + DARTSCOPE(isolate); |
| TIMERSCOPE(time_script_loading); |
| const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url)); |
| const String& source_str = String::CheckedHandle(Api::UnwrapHandle(source)); |
| @@ -326,17 +322,21 @@ |
| library.Register(); |
| isolate->object_store()->set_root_library(library); |
| Dart_Handle result; |
| - CompileSource(library, url_str, source_str, RawScript::kScript, &result); |
| + CompileSource(isolate, |
| + library, |
| + url_str, |
| + source_str, |
| + RawScript::kScript, |
| + &result); |
| return result; |
| } |
| DEFINE_FLAG(bool, compile_all, false, "Eagerly compile all code."); |
| -static void CompileAll(Dart_Handle* result) { |
| +static void CompileAll(Isolate* isolate, Dart_Handle* result) { |
| *result = Api::Success(); |
| if (FLAG_compile_all) { |
| - Isolate* isolate = Isolate::Current(); |
| ASSERT(isolate != NULL); |
| LongJump* base = isolate->long_jump_base(); |
| LongJump jump; |
| @@ -353,12 +353,12 @@ |
| // Return error if isolate is in an inconsistent state. |
| // Return NULL when no error condition exists. |
| -static const char* CheckIsolateState() { |
| +static const char* CheckIsolateState(Isolate* isolate) { |
| if (!ClassFinalizer::FinalizePendingClasses()) { |
| // Make a copy of the error message as the original message string |
| // may get deallocated when we return back from the Dart API call. |
| const String& err = |
| - String::Handle(Isolate::Current()->object_store()->sticky_error()); |
| + String::Handle(isolate->object_store()->sticky_error()); |
| const char* errmsg = err.ToCString(); |
| intptr_t errlen = strlen(errmsg) + 1; |
| char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); |
| @@ -370,29 +370,29 @@ |
| DART_EXPORT Dart_Handle Dart_CompileAll() { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| Dart_Handle result; |
| - const char* msg = CheckIsolateState(); |
| + const char* msg = CheckIsolateState(isolate); |
| if (msg != NULL) { |
| return Api::Error(msg); |
| } |
| - CompileAll(&result); |
| + CompileAll(isolate, &result); |
| return result; |
| } |
| DART_EXPORT bool Dart_IsLibrary(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsLibrary(); |
| } |
| DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
|
Ivan Posva
2011/11/11 22:07:07
How about changing this to:
DARTSCOPE(Isolate::Cur
siva
2011/11/12 03:01:05
Done.
|
| const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library)); |
| if (lib.IsNull()) { |
| return Api::Error("Null library"); |
| @@ -405,8 +405,8 @@ |
| DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library_in, |
| Dart_Handle import_in) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Library& library = |
| Library::CheckedHandle(Api::UnwrapHandle(library_in)); |
| if (library.IsNull()) { |
| @@ -420,8 +420,8 @@ |
| DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| String& url_str = String::Handle(); |
| UNWRAP_NONNULL(url, url_str, String); |
| const Library& library = Library::Handle(Library::LookupLibrary(url_str)); |
| @@ -435,8 +435,8 @@ |
| DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, Dart_Handle source) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const String& url_str = String::CheckedHandle(Api::UnwrapHandle(url)); |
| const String& source_str = String::CheckedHandle(Api::UnwrapHandle(source)); |
| Library& library = Library::Handle(Library::LookupLibrary(url_str)); |
| @@ -445,7 +445,12 @@ |
| library.Register(); |
| } |
| Dart_Handle result; |
| - CompileSource(library, url_str, source_str, RawScript::kLibrary, &result); |
| + CompileSource(isolate, |
| + library, |
| + url_str, |
| + source_str, |
| + RawScript::kLibrary, |
| + &result); |
| return result; |
| } |
| @@ -453,14 +458,14 @@ |
| DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library_in, |
| Dart_Handle url_in, |
| Dart_Handle source_in) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const String& url = String::CheckedHandle(Api::UnwrapHandle(url_in)); |
| const String& source = String::CheckedHandle(Api::UnwrapHandle(source_in)); |
| const Library& library = |
| Library::CheckedHandle(Api::UnwrapHandle(library_in)); |
| Dart_Handle result; |
| - CompileSource(library, url, source, RawScript::kSource, &result); |
| + CompileSource(isolate, library, url, source, RawScript::kSource, &result); |
| return result; |
| } |
| @@ -468,8 +473,8 @@ |
| DART_EXPORT Dart_Handle Dart_SetNativeResolver( |
| Dart_Handle library, |
| Dart_NativeEntryResolver resolver) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Library& lib = Library::CheckedHandle(Api::UnwrapHandle(library)); |
| if (lib.IsNull()) { |
| return Api::Error("Invalid parameter, Unknown library specified"); |
| @@ -480,8 +485,8 @@ |
| DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| Object& result = Object::Handle(); |
| if (obj.IsString()) { |
| @@ -507,24 +512,24 @@ |
| DART_EXPORT bool Dart_IsNull(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsNull(); |
| } |
| DART_EXPORT bool Dart_IsClosure(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsClosure(); |
| } |
| DART_EXPORT int64_t Dart_ClosureSmrck(Dart_Handle object) { |
| - Zone zone; |
| - HandleScope scope; |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Closure& obj = Closure::CheckedHandle(Api::UnwrapHandle(object)); |
| const Integer& smrck = Integer::Handle(obj.smrck()); |
| return smrck.IsNull() ? 0 : smrck.AsInt64Value(); |
| @@ -532,8 +537,8 @@ |
| DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value) { |
| - Zone zone; |
| - HandleScope scope; |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Closure& obj = Closure::CheckedHandle(Api::UnwrapHandle(object)); |
| const Integer& smrck = Integer::Handle(Integer::New(value)); |
| obj.set_smrck(smrck); |
| @@ -542,8 +547,8 @@ |
| DART_EXPORT Dart_Handle Dart_ObjectEquals(Dart_Handle obj1, Dart_Handle obj2, |
| bool* value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Instance& expected = Instance::CheckedHandle(Api::UnwrapHandle(obj1)); |
| const Instance& actual = Instance::CheckedHandle(Api::UnwrapHandle(obj2)); |
| const Instance& result = |
| @@ -561,8 +566,8 @@ |
| DART_EXPORT Dart_Handle Dart_IsSame(Dart_Handle obj1, Dart_Handle obj2, |
| bool* value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& expected = Object::Handle(Api::UnwrapHandle(obj1)); |
| const Object& actual = Object::Handle(Api::UnwrapHandle(obj2)); |
| *value = (expected.raw() == actual.raw()); |
| @@ -571,8 +576,8 @@ |
| DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& param = Object::Handle(Api::UnwrapHandle(name)); |
| if (param.IsNull() || !param.IsString()) { |
| return Api::Error("Invalid class name specified"); |
| @@ -599,8 +604,8 @@ |
| DART_EXPORT Dart_Handle Dart_ObjectIsType(Dart_Handle object, |
| Dart_Handle clazz, |
| bool* value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Class& cls = Class::CheckedHandle(Api::UnwrapHandle(clazz)); |
| if (cls.IsNull()) { |
| return Api::Error("instanceof check against null class"); |
| @@ -609,7 +614,7 @@ |
| Instance& instance = Instance::Handle(); |
| instance ^= obj.raw(); |
| // Finalize all classes. |
| - const char* msg = CheckIsolateState(); |
| + const char* msg = CheckIsolateState(isolate); |
| if (msg != NULL) { |
| return Api::Error(msg); |
| } |
| @@ -621,32 +626,32 @@ |
| // TODO(iposva): The argument should be an instance. |
| DART_EXPORT bool Dart_IsNumber(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsNumber(); |
| } |
| DART_EXPORT bool Dart_IsInteger(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsInteger(); |
| } |
| DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Integer& obj = Integer::Handle(Integer::New(value)); |
| return Api::NewLocalHandle(obj); |
| } |
| DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* str) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const String& str_obj = String::Handle(String::New(str)); |
| const Integer& obj = Integer::Handle(Integer::New(str_obj)); |
| return Api::NewLocalHandle(obj); |
| @@ -654,8 +659,8 @@ |
| DART_EXPORT Dart_Handle Dart_IntegerValue(Dart_Handle integer, int64_t* value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(integer)); |
| if (obj.IsSmi() || obj.IsMint()) { |
| Integer& integer = Integer::Handle(); |
| @@ -679,8 +684,8 @@ |
| DART_EXPORT Dart_Handle Dart_IntegerValueHexCString(Dart_Handle integer, |
| const char** value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(integer)); |
| Bigint& bigint = Bigint::Handle(); |
| if (obj.IsSmi() || obj.IsMint()) { |
| @@ -701,8 +706,8 @@ |
| DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer, |
| bool* fits) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(integer)); |
| if (obj.IsSmi() || obj.IsMint()) { |
| *fits = true; |
| @@ -731,8 +736,8 @@ |
| DART_EXPORT bool Dart_IsBoolean(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsBool(); |
| } |
| @@ -745,8 +750,8 @@ |
| DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object, |
| bool* value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(bool_object)); |
| if (obj.IsBool()) { |
| Bool& bool_obj = Bool::Handle(); |
| @@ -759,24 +764,24 @@ |
| DART_EXPORT bool Dart_IsDouble(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsDouble(); |
| } |
| DART_EXPORT Dart_Handle Dart_NewDouble(double value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Double& obj = Double::Handle(Double::New(value)); |
| return Api::NewLocalHandle(obj); |
| } |
| DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(integer)); |
| if (obj.IsDouble()) { |
| Double& double_obj = Double::Handle(); |
| @@ -789,16 +794,16 @@ |
| DART_EXPORT bool Dart_IsString(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsString(); |
| } |
| DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(str)); |
| if (obj.IsString()) { |
| String& string_obj = String::Handle(); |
| @@ -811,8 +816,8 @@ |
| DART_EXPORT Dart_Handle Dart_NewString(const char* str) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const String& obj = String::Handle(String::New(str)); |
| return Api::NewLocalHandle(obj); |
| } |
| @@ -820,8 +825,8 @@ |
| DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints, |
| intptr_t length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const String& obj = String::Handle(String::New(codepoints, length)); |
| return Api::NewLocalHandle(obj); |
| } |
| @@ -829,8 +834,8 @@ |
| DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints, |
| intptr_t length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const String& obj = String::Handle(String::New(codepoints, length)); |
| return Api::NewLocalHandle(obj); |
| } |
| @@ -838,24 +843,24 @@ |
| DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints, |
| intptr_t length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const String& obj = String::Handle(String::New(codepoints, length)); |
| return Api::NewLocalHandle(obj); |
| } |
| DART_EXPORT bool Dart_IsString8(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsOneByteString(); |
| } |
| DART_EXPORT bool Dart_IsString16(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| return obj.IsOneByteString() || obj.IsTwoByteString(); |
| } |
| @@ -864,8 +869,8 @@ |
| DART_EXPORT Dart_Handle Dart_StringGet8(Dart_Handle str, |
| uint8_t* codepoints, |
| intptr_t* length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(str)); |
| if (obj.IsOneByteString()) { |
| OneByteString& string_obj = OneByteString::Handle(); |
| @@ -887,8 +892,8 @@ |
| DART_EXPORT Dart_Handle Dart_StringGet16(Dart_Handle str, |
| uint16_t* codepoints, |
| intptr_t* length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(str)); |
| if (obj.IsOneByteString() || obj.IsTwoByteString()) { |
| String& string_obj = String::Handle(); |
| @@ -910,8 +915,8 @@ |
| DART_EXPORT Dart_Handle Dart_StringGet32(Dart_Handle str, |
| uint32_t* codepoints, |
| intptr_t* length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(str)); |
| if (obj.IsString()) { |
| String& string_obj = String::Handle(); |
| @@ -930,8 +935,8 @@ |
| DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle object, |
| const char** result) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| if (obj.IsString()) { |
| const char* string_value = obj.ToCString(); |
| @@ -961,26 +966,26 @@ |
| DART_EXPORT bool Dart_IsList(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| return (obj.IsArray() || |
| - (GetListInstance(Isolate::Current(), obj) != Instance::null())); |
| + (GetListInstance(isolate, obj) != Instance::null())); |
| } |
| DART_EXPORT Dart_Handle Dart_NewList(intptr_t length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Array& obj = Array::Handle(Array::New(length)); |
| return Api::NewLocalHandle(obj); |
| } |
| DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| if (obj.IsArray()) { |
| Array& array_obj = Array::Handle(); |
| @@ -990,7 +995,6 @@ |
| } |
| // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| // Now check and handle a dart object that implements the List interface. |
| - Isolate* isolate = Isolate::Current(); |
| const Instance& instance = Instance::Handle(GetListInstance(isolate, obj)); |
| if (!instance.IsNull()) { |
| String& name = String::Handle(String::New("length")); |
| @@ -1075,8 +1079,8 @@ |
| intptr_t offset, |
| uint8_t* native_array, |
| intptr_t length) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| if (obj.IsArray()) { |
| Array& array_obj = Array::Handle(); |
| @@ -1098,7 +1102,6 @@ |
| } |
| // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| // Now check and handle a dart object that implements the List interface. |
| - Isolate* isolate = Isolate::Current(); |
| const Instance& instance = Instance::Handle(GetListInstance(isolate, obj)); |
| if (!instance.IsNull()) { |
| String& name = String::Handle(String::New("[]")); |
| @@ -1128,8 +1131,8 @@ |
| DART_EXPORT Dart_Handle Dart_ListGetAt(Dart_Handle list, intptr_t index) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| if (obj.IsArray()) { |
| Array& array_obj = Array::Handle(); |
| @@ -1142,7 +1145,6 @@ |
| } |
| // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| // Now check and handle a dart object that implements the List interface. |
| - Isolate* isolate = Isolate::Current(); |
| const Instance& instance = Instance::Handle(GetListInstance(isolate, obj)); |
| if (!instance.IsNull()) { |
| String& name = String::Handle(String::New("[]")); |
| @@ -1201,8 +1203,8 @@ |
| intptr_t offset, |
| uint8_t* native_array, |
| intptr_t length) { |
| - Zone zone; |
| - HandleScope scope; |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| if (obj.IsArray()) { |
| Array& array_obj = Array::Handle(); |
| @@ -1219,7 +1221,6 @@ |
| } |
| // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| // Now check and handle a dart object that implements the List interface. |
| - Isolate* isolate = Isolate::Current(); |
| const Instance& instance = Instance::Handle(GetListInstance(isolate, obj)); |
| if (!instance.IsNull()) { |
| String& name = String::Handle(String::New("[]=")); |
| @@ -1247,8 +1248,8 @@ |
| DART_EXPORT Dart_Handle Dart_ListSetAt(Dart_Handle list, |
| intptr_t index, |
| Dart_Handle value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| if (obj.IsArray()) { |
| Array& array_obj = Array::Handle(); |
| @@ -1262,7 +1263,6 @@ |
| } |
| // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| // Now check and handle a dart object that implements the List interface. |
| - Isolate* isolate = Isolate::Current(); |
| const Instance& instance = Instance::Handle(GetListInstance(isolate, obj)); |
| if (!instance.IsNull()) { |
| String& name = String::Handle(String::New("[]=")); |
| @@ -1283,10 +1283,10 @@ |
| // NOTE: Need to pass 'result' as a parameter here in order to avoid |
| // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
| // which shows up because of the use of setjmp. |
| -static void InvokeStatic(const Function& function, |
| +static void InvokeStatic(Isolate* isolate, |
| + const Function& function, |
| GrowableArray<const Object*>& args, |
| Dart_Handle* result) { |
| - Isolate* isolate = Isolate::Current(); |
| ASSERT(isolate != NULL); |
| LongJump* base = isolate->long_jump_base(); |
| LongJump jump; |
| @@ -1306,11 +1306,11 @@ |
| // NOTE: Need to pass 'result' as a parameter here in order to avoid |
| // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
| // which shows up because of the use of setjmp. |
| -static void InvokeDynamic(const Instance& receiver, |
| +static void InvokeDynamic(Isolate* isolate, |
| + const Instance& receiver, |
| const Function& function, |
| GrowableArray<const Object*>& args, |
| Dart_Handle* result) { |
| - Isolate* isolate = Isolate::Current(); |
| ASSERT(isolate != NULL); |
| LongJump* base = isolate->long_jump_base(); |
| LongJump jump; |
| @@ -1330,10 +1330,10 @@ |
| // NOTE: Need to pass 'result' as a parameter here in order to avoid |
| // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
| // which shows up because of the use of setjmp. |
| -static void InvokeClosure(const Closure& closure, |
| +static void InvokeClosure(Isolate* isolate, |
| + const Closure& closure, |
| GrowableArray<const Object*>& args, |
| Dart_Handle* result) { |
| - Isolate* isolate = Isolate::Current(); |
| ASSERT(isolate != NULL); |
| LongJump* base = isolate->long_jump_base(); |
| LongJump jump; |
| @@ -1355,10 +1355,10 @@ |
| Dart_Handle function_name_in, |
| int number_of_arguments, |
| Dart_Handle* arguments) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| // Finalize all classes. |
| - const char* msg = CheckIsolateState(); |
| + const char* msg = CheckIsolateState(isolate); |
| if (msg != NULL) { |
| return Api::Error(msg); |
| } |
| @@ -1405,7 +1405,7 @@ |
| const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i])); |
| dart_arguments.Add(&arg); |
| } |
| - InvokeStatic(function, dart_arguments, &retval); |
| + InvokeStatic(isolate, function, dart_arguments, &retval); |
| return retval; |
| } |
| @@ -1414,8 +1414,8 @@ |
| Dart_Handle function_name, |
| int number_of_arguments, |
| Dart_Handle* arguments) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(object)); |
| // Let the resolver figure out the correct target for null receiver. |
| // E.g., (null).toString() should execute correctly. |
| @@ -1448,7 +1448,7 @@ |
| const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i])); |
| dart_arguments.Add(&arg); |
| } |
| - InvokeDynamic(receiver, function, dart_arguments, &retval); |
| + InvokeDynamic(isolate, receiver, function, dart_arguments, &retval); |
| return retval; |
| } |
| @@ -1456,8 +1456,8 @@ |
| DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure, |
| int number_of_arguments, |
| Dart_Handle* arguments) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(closure)); |
| if (obj.IsNull()) { |
| return Api::Error("Null object passed in to invoke closure"); |
| @@ -1476,15 +1476,15 @@ |
| const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i])); |
| dart_arguments.Add(&arg); |
| } |
| - InvokeClosure(closure_obj, dart_arguments, &retval); |
| + InvokeClosure(isolate, closure_obj, dart_arguments, &retval); |
| return retval; |
| } |
| DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, |
| int index) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
| const Object& obj = Object::Handle(arguments->At(index)); |
| return Api::NewLocalHandle(obj); |
| @@ -1499,24 +1499,24 @@ |
| DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args, |
| Dart_Handle retval) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
| arguments->SetReturn(Object::Handle(Api::UnwrapHandle(retval))); |
| } |
| DART_EXPORT bool Dart_ExceptionOccurred(Dart_Handle result) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& retval = Object::Handle(Api::UnwrapHandle(result)); |
| return retval.IsUnhandledException(); |
| } |
| DART_EXPORT Dart_Handle Dart_GetException(Dart_Handle result) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& retval = Object::Handle(Api::UnwrapHandle(result)); |
| if (retval.IsUnhandledException()) { |
| const UnhandledException& unhandled = UnhandledException::Handle( |
| @@ -1529,8 +1529,8 @@ |
| DART_EXPORT Dart_Handle Dart_GetStacktrace(Dart_Handle unhandled_excp) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& retval = Object::Handle(Api::UnwrapHandle(unhandled_excp)); |
| if (retval.IsUnhandledException()) { |
| const UnhandledException& unhandled = UnhandledException::Handle( |
| @@ -1544,9 +1544,7 @@ |
| DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) { |
| Isolate* isolate = Isolate::Current(); |
| - ASSERT(isolate != NULL); |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + DARTSCOPE(isolate); |
| if (isolate->top_exit_frame_info() == 0) { |
| // There are no dart frames on the stack so it would be illegal to |
| // throw an exception here. |
| @@ -1572,8 +1570,7 @@ |
| // throw an exception here. |
| return Api::Error("No Dart frames on stack, cannot throw exception"); |
| } |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + DARTSCOPE(isolate); |
| const Instance& excp = Instance::CheckedHandle(Api::UnwrapHandle(exception)); |
| const Instance& stk = Instance::CheckedHandle(Api::UnwrapHandle(stacktrace)); |
| // Unwind all the API scopes till the exit frame before throwing an |
| @@ -1611,10 +1608,8 @@ |
| DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| Isolate* isolate = Isolate::Current(); |
| - ASSERT(isolate != NULL); |
| + DARTSCOPE(isolate); |
| ApiState* state = isolate->api_state(); |
| ASSERT(state != NULL); |
| const Object& old_ref = Object::Handle(Api::UnwrapHandle(object)); |
| @@ -1735,8 +1730,8 @@ |
| DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls, |
| Dart_Handle name) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| Dart_Handle result = LookupStaticField(cls, name, kGetter); |
| if (!::Dart_IsValid(result)) { |
| return result; |
| @@ -1752,7 +1747,7 @@ |
| Function& func = Function::Handle(); |
| func ^= obj.raw(); |
| GrowableArray<const Object*> args; |
| - InvokeStatic(func, args, &result); |
| + InvokeStatic(isolate, func, args, &result); |
| if (::Dart_IsValid(result)) { |
| if (Dart_ExceptionOccurred(result)) { |
| return Api::Error( |
| @@ -1768,8 +1763,8 @@ |
| DART_EXPORT Dart_Handle Dart_SetStaticField(Dart_Handle cls, |
| Dart_Handle name, |
| Dart_Handle value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| Dart_Handle result = LookupStaticField(cls, name, kSetter); |
| if (!::Dart_IsValid(result)) { |
| return result; |
| @@ -1789,8 +1784,8 @@ |
| DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj, |
| Dart_Handle name) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& param = Object::Handle(Api::UnwrapHandle(obj)); |
| if (param.IsNull() || !param.IsInstance()) { |
| return Api::Error("Invalid object passed in to access instance field"); |
| @@ -1804,7 +1799,7 @@ |
| Function& func = Function::Handle(); |
| func ^= Api::UnwrapHandle(result); |
| GrowableArray<const Object*> arguments; |
| - InvokeDynamic(object, func, arguments, &result); |
| + InvokeDynamic(isolate, object, func, arguments, &result); |
| if (::Dart_IsValid(result)) { |
| if (Dart_ExceptionOccurred(result)) { |
| return Api::Error( |
| @@ -1818,8 +1813,8 @@ |
| DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj, |
| Dart_Handle name, |
| Dart_Handle value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& param = Object::Handle(Api::UnwrapHandle(obj)); |
| if (param.IsNull() || !param.IsInstance()) { |
| return Api::Error("Invalid object passed in to access instance field"); |
| @@ -1835,7 +1830,7 @@ |
| GrowableArray<const Object*> arguments(1); |
| const Object& arg = Object::Handle(Api::UnwrapHandle(value)); |
| arguments.Add(&arg); |
| - InvokeDynamic(object, func, arguments, &result); |
| + InvokeDynamic(isolate, object, func, arguments, &result); |
| if (::Dart_IsValid(result)) { |
| if (Dart_ExceptionOccurred(result)) { |
| return Api::Error( |
| @@ -1849,8 +1844,8 @@ |
| DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library, |
| Dart_Handle name, |
| int field_count) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& param = Object::Handle(Api::UnwrapHandle(name)); |
| if (param.IsNull() || !param.IsString() || field_count <= 0) { |
| return Api::Error( |
| @@ -1879,8 +1874,8 @@ |
| DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj, |
| int index, |
| intptr_t* value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& param = Object::Handle(Api::UnwrapHandle(obj)); |
| if (param.IsNull() || !param.IsInstance()) { |
| return Api::Error( |
| @@ -1900,8 +1895,8 @@ |
| DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj, |
| int index, |
| intptr_t value) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& param = Object::Handle(Api::UnwrapHandle(obj)); |
| if (param.IsNull() || !param.IsInstance()) { |
| return Api::Error("Invalid object passed in to set native instance field"); |
| @@ -1928,17 +1923,16 @@ |
| DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** snapshot_buffer, |
| intptr_t* snapshot_size) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| if (snapshot_buffer == NULL || snapshot_size == NULL) { |
| return Api::Error("Invalid input parameters to Dart_CreateSnapshot"); |
| } |
| - const char* msg = CheckIsolateState(); |
| + const char* msg = CheckIsolateState(isolate); |
| if (msg != NULL) { |
| return Api::Error(msg); |
| } |
| // Since this is only a snapshot the root library should not be set. |
| - Isolate* isolate = Isolate::Current(); |
| isolate->object_store()->set_root_library(Library::Handle()); |
| SnapshotWriter writer(true, snapshot_buffer, ApiAllocator); |
| writer.WriteFullSnapshot(); |
| @@ -1967,8 +1961,8 @@ |
| DART_EXPORT bool Dart_Post(Dart_Port port, Dart_Handle handle) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| const Object& object = Object::Handle(Api::UnwrapHandle(handle)); |
| uint8_t* data = NULL; |
| SnapshotWriter writer(false, &data, &allocator); |
| @@ -2069,8 +2063,8 @@ |
| Dart_Handle Api::Error(const char* format, ...) { |
| - Zone zone; // Setup a VM zone as we are creating some handles. |
| - HandleScope scope; // Setup a VM handle scope. |
| + Isolate* isolate = Isolate::Current(); |
| + DARTSCOPE(isolate); |
| va_list args; |
| va_start(args, format); |