Chromium Code Reviews| Index: vm/dart_api_impl.cc |
| =================================================================== |
| --- vm/dart_api_impl.cc (revision 17645) |
| +++ vm/dart_api_impl.cc (working copy) |
| @@ -192,7 +192,8 @@ |
| Dart_Handle Api::NewError(const char* format, ...) { |
| Isolate* isolate = Isolate::Current(); |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| va_list args; |
| va_start(args, format); |
| @@ -210,6 +211,23 @@ |
| } |
| +void Api::SetupCallbackError(Isolate* isolate) { |
| + ASSERT(isolate != NULL); |
| + ApiState* state = isolate->api_state(); |
| + ASSERT(state != NULL); |
| + state->SetupCallbackError(); |
| +} |
| + |
| + |
| +Dart_Handle Api::CallbackError(Isolate* isolate) { |
| + ASSERT(isolate != NULL); |
| + ApiState* state = isolate->api_state(); |
| + ASSERT(state != NULL); |
| + PersistentHandle* callback_error_handle = state->CallbackError(); |
| + return reinterpret_cast<Dart_Handle>(callback_error_handle); |
| +} |
| + |
| + |
| Dart_Handle Api::Null(Isolate* isolate) { |
| ASSERT(isolate != NULL); |
| ApiState* state = isolate->api_state(); |
| @@ -396,6 +414,7 @@ |
| DART_EXPORT Dart_Handle Dart_Error(const char* format, ...) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| va_list args; |
| va_start(args, format); |
| @@ -418,6 +437,7 @@ |
| DART_EXPORT Dart_Handle Dart_NewApiError(const char* format, ...) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| va_list args; |
| va_start(args, format); |
| @@ -438,6 +458,8 @@ |
| DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| const Instance& obj = Api::UnwrapInstanceHandle(isolate, exception); |
| if (obj.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, exception, Instance); |
| @@ -501,9 +523,11 @@ |
| if (obj.IsString()) { |
| return Api::NewHandle(isolate, obj.raw()); |
| } else if (obj.IsInstance()) { |
| + CHECK_CALLBACK_STATE(isolate); |
| const Instance& receiver = Instance::Cast(obj); |
| return Api::NewHandle(isolate, DartLibraryCalls::ToString(receiver)); |
| } else { |
| + CHECK_CALLBACK_STATE(isolate); |
| // This is a VM internal object. Call the C++ method of printing. |
| return Api::NewHandle(isolate, String::New(obj.ToCString())); |
| } |
| @@ -520,8 +544,7 @@ |
| DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object) { |
| Isolate* isolate = Isolate::Current(); |
| - CHECK_ISOLATE(isolate); |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| ApiState* state = isolate->api_state(); |
| ASSERT(state != NULL); |
| const Object& old_ref = Object::Handle(isolate, Api::UnwrapHandle(object)); |
| @@ -550,8 +573,7 @@ |
| void* peer, |
| Dart_WeakPersistentHandleFinalizer callback) { |
| Isolate* isolate = Isolate::Current(); |
| - CHECK_ISOLATE(isolate); |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| ApiState* state = isolate->api_state(); |
| ASSERT(state != NULL); |
| return AllocateFinalizableHandle(isolate, |
| @@ -567,8 +589,7 @@ |
| void* peer, |
| Dart_WeakPersistentHandleFinalizer callback) { |
| Isolate* isolate = Isolate::Current(); |
| - CHECK_ISOLATE(isolate); |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| ApiState* state = isolate->api_state(); |
| ASSERT(state != NULL); |
| return AllocateFinalizableHandle(isolate, |
| @@ -810,7 +831,7 @@ |
| free(isolate_name); |
| { |
| StackZone zone(isolate); |
| - DARTSCOPE_NOCHECKS(isolate); |
| + HANDLESCOPE(isolate); |
| const Error& error_obj = |
| Error::Handle(isolate, |
| Dart::InitializeIsolate(snapshot, callback_data)); |
| @@ -964,6 +985,7 @@ |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| Monitor monitor; |
| MonitorLocker ml(&monitor); |
| { |
| @@ -1046,8 +1068,7 @@ |
| DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { |
| Isolate* isolate = Isolate::Current(); |
| - CHECK_ISOLATE(isolate); |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| const Object& object = Object::Handle(isolate, Api::UnwrapHandle(handle)); |
| uint8_t* data = NULL; |
| MessageWriter writer(&data, &allocator); |
| @@ -1093,6 +1114,7 @@ |
| DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, DartLibraryCalls::NewSendPort(port_id)); |
| } |
| @@ -1100,6 +1122,8 @@ |
| DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary()); |
| ASSERT(!isolate_lib.IsNull()); |
| const String& class_name = String::Handle( |
| @@ -1191,6 +1215,7 @@ |
| bool* value) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| const Instance& expected = |
| Instance::CheckedHandle(isolate, Api::UnwrapHandle(obj1)); |
| const Instance& actual = |
| @@ -1235,6 +1260,7 @@ |
| return Api::NewError("%s", msg); |
| } |
| if (obj.IsInstance()) { |
| + CHECK_CALLBACK_STATE(isolate); |
| const Type& type = Type::Handle(isolate, |
| Type::NewNonParameterizedType(cls)); |
| Error& malformed_type_error = Error::Handle(isolate); |
| @@ -1299,7 +1325,7 @@ |
| return Api::Success(isolate); |
| } |
| // Slow path for Mints and Bigints. |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer); |
| if (int_obj.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, integer, Integer); |
| @@ -1320,7 +1346,7 @@ |
| return Api::Success(isolate); |
| } |
| // Slow path for Mints and Bigints. |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer); |
| if (int_obj.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, integer, Integer); |
| @@ -1344,7 +1370,8 @@ |
| return Api::NewHandle(isolate, Smi::New(static_cast<intptr_t>(value))); |
| } |
| // Slow path for Mints and Bigints. |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, Integer::New(value)); |
| } |
| @@ -1352,6 +1379,7 @@ |
| DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* str) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| const String& str_obj = String::Handle(isolate, String::New(str)); |
| return Api::NewHandle(isolate, Integer::New(str_obj)); |
| } |
| @@ -1367,7 +1395,7 @@ |
| return Api::Success(isolate); |
| } |
| // Slow path for Mints and Bigints. |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer); |
| if (int_obj.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, integer, Integer); |
| @@ -1401,7 +1429,7 @@ |
| } |
| } |
| // Slow path for Mints and Bigints. |
| - DARTSCOPE_NOCHECKS(isolate); |
| + DARTSCOPE(isolate); |
| const Integer& int_obj = Api::UnwrapIntegerHandle(isolate, integer); |
| if (int_obj.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, integer, Integer); |
| @@ -1500,6 +1528,7 @@ |
| DART_EXPORT Dart_Handle Dart_NewDouble(double value) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, Double::New(value)); |
| } |
| @@ -1548,6 +1577,7 @@ |
| if (str == NULL) { |
| RETURN_NULL_ERROR(str); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, String::New(str)); |
| } |
| @@ -1564,6 +1594,7 @@ |
| return Api::NewError("%s expects argument 'str' to be valid UTF-8.", |
| CURRENT_FUNC); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, String::FromUTF8(utf8_array, length)); |
| } |
| @@ -1576,6 +1607,7 @@ |
| RETURN_NULL_ERROR(utf16_array); |
| } |
| CHECK_LENGTH(length, String::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, String::FromUTF16(utf16_array, length)); |
| } |
| @@ -1588,6 +1620,7 @@ |
| RETURN_NULL_ERROR(utf32_array); |
| } |
| CHECK_LENGTH(length, String::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, String::FromUTF32(utf32_array, length)); |
| } |
| @@ -1630,6 +1663,7 @@ |
| RETURN_NULL_ERROR(latin1_array); |
| } |
| CHECK_LENGTH(length, String::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, |
| String::NewExternal(latin1_array, length, peer, cback)); |
| } |
| @@ -1645,6 +1679,7 @@ |
| RETURN_NULL_ERROR(utf16_array); |
| } |
| CHECK_LENGTH(length, String::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, |
| String::NewExternal(utf16_array, length, peer, cback)); |
| } |
| @@ -1853,6 +1888,7 @@ |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| CHECK_LENGTH(length, Array::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, Array::New(length)); |
| } |
| @@ -1881,6 +1917,8 @@ |
| if (obj.IsGrowableObjectArray()) { |
| GET_LIST_LENGTH(isolate, GrowableObjectArray, obj, len); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| // Now check and handle a dart object that implements the List interface. |
| const Instance& instance = |
| Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| @@ -1948,6 +1986,8 @@ |
| } else if (obj.IsError()) { |
| return list; |
| } else { |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| // Check and handle a dart object that implements the List interface. |
| const Instance& instance = |
| Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| @@ -1999,6 +2039,8 @@ |
| } else if (obj.IsError()) { |
| return list; |
| } else { |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| // Check and handle a dart object that implements the List interface. |
| const Instance& instance = |
| Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| @@ -2085,6 +2127,8 @@ |
| } else if (obj.IsError()) { |
| return list; |
| } else { |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| // Check and handle a dart object that implements the List interface. |
| const Instance& instance = |
| Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| @@ -2173,7 +2217,9 @@ |
| } else if (obj.IsError()) { |
| return list; |
| } else { |
| - // Check and handle a dart object that implements the List interface. |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| + // Check and handle a dart object that implements the List interface. |
| const Instance& instance = |
| Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| if (!instance.IsNull()) { |
| @@ -2225,6 +2271,7 @@ |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| CHECK_LENGTH(length, Uint8Array::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle(isolate, Uint8Array::New(length)); |
| } |
| @@ -2239,6 +2286,7 @@ |
| RETURN_NULL_ERROR(data); |
| } |
| CHECK_LENGTH(length, ExternalUint8Array::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
| return Api::NewHandle( |
| isolate, ExternalUint8Array::New(data, length, peer, callback)); |
| } |
| @@ -2255,6 +2303,7 @@ |
| RETURN_NULL_ERROR(data); |
| } |
| CHECK_LENGTH(length, ExternalUint8ClampedArray::kMaxElements); |
| + CHECK_CALLBACK_STATE(isolate); |
|
Ivan Posva
2013/01/29 01:54:03
Is there a way to make sure that this macro was ad
siva
2013/01/31 01:54:45
I have added an assert in the 3 entrypoints to dar
|
| return Api::NewHandle( |
| isolate, ExternalUint8ClampedArray::New(data, length, peer, callback)); |
| } |
| @@ -2294,182 +2343,46 @@ |
| } |
| -template<typename T> |
| -Dart_Handle ByteArrayGetAt(T* value, Dart_Handle array, intptr_t offset) { |
| +DART_EXPORT Dart_Handle Dart_ScalarListAcquireData(Dart_Handle array, |
| + Dart_Scalar_Type* type, |
| + void** data, |
| + intptr_t* len) { |
| Isolate* isolate = Isolate::Current(); |
| - CHECK_ISOLATE(isolate); |
| - const ByteArray& array_obj = Api::UnwrapByteArrayHandle(isolate, array); |
| - if (array_obj.IsNull()) { |
| - RETURN_TYPE_ERROR(isolate, array, ByteArray); |
| + DARTSCOPE(isolate); |
| + if (!RawObject::IsByteArrayClassId(Api::ClassId(array))) { |
| + RETURN_TYPE_ERROR(isolate, array, 'scalar list'); |
| } |
| - intptr_t length = sizeof(T); |
| - if (!Utils::RangeCheck(offset, length, array_obj.ByteLength())) { |
| - return Api::NewError("Invalid index passed in to get byte array element"); |
| + if (type == NULL) { |
| + RETURN_NULL_ERROR(type); |
| } |
| - uint8_t* dst = reinterpret_cast<uint8_t*>(value); |
| - ByteArray::Copy(dst, array_obj, offset, length); |
| + if (data == NULL) { |
| + RETURN_NULL_ERROR(data); |
| + } |
| + if (len == NULL) { |
| + RETURN_NULL_ERROR(len); |
| + } |
| + isolate->IncrementNoGCScopeDepth(); |
| + START_NO_CALLBACK_SCOPE(isolate); |
| + |
| + UNIMPLEMENTED(); |
| return Api::Success(isolate); |
| } |
| -template<typename T> |
| -Dart_Handle ByteArraySetAt(Dart_Handle array, intptr_t offset, T value) { |
| +DART_EXPORT Dart_Handle Dart_ScalarListReleaseData(Dart_Handle array) { |
| Isolate* isolate = Isolate::Current(); |
| - CHECK_ISOLATE(isolate); |
| - const ByteArray& array_obj = Api::UnwrapByteArrayHandle(isolate, array); |
| - if (array_obj.IsNull()) { |
| - RETURN_TYPE_ERROR(isolate, array, ByteArray); |
| + DARTSCOPE(isolate); |
| + if (!RawObject::IsByteArrayClassId(Api::ClassId(array))) { |
| + RETURN_TYPE_ERROR(isolate, array, 'scalar list'); |
| } |
| - intptr_t length = sizeof(T); |
| - if (!Utils::RangeCheck(offset, length, array_obj.ByteLength())) { |
| - return Api::NewError("Invalid index passed in to get byte array element"); |
| - } |
| - const uint8_t* src = reinterpret_cast<uint8_t*>(&value); |
| - ByteArray::Copy(array_obj, offset, src, length); |
| + |
| + UNIMPLEMENTED(); |
| + isolate->DecrementNoGCScopeDepth(); |
| + END_NO_CALLBACK_SCOPE(isolate); |
| return Api::Success(isolate); |
| } |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetInt8At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int8_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetInt8At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int8_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetUint8At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint8_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetUint8At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint8_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetInt16At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int16_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetInt16At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int16_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetUint16At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint16_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetUint16At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint16_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetInt32At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int32_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetInt32At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int32_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetUint32At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint32_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetUint32At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint32_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetInt64At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int64_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetInt64At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - int64_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetUint64At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint64_t* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetUint64At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - uint64_t value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetFloat32At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - float* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetFloat32At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - float value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArrayGetFloat64At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - double* value) { |
| - return ByteArrayGetAt(value, array, byte_offset); |
| -} |
| - |
| - |
| -DART_EXPORT Dart_Handle Dart_ByteArraySetFloat64At(Dart_Handle array, |
| - intptr_t byte_offset, |
| - double value) { |
| - return ByteArraySetAt(array, byte_offset, value); |
| -} |
| - |
| - |
| // --- Closures --- |
| @@ -2503,6 +2416,7 @@ |
| Dart_Handle* arguments) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| const Instance& closure_obj = Api::UnwrapInstanceHandle(isolate, closure); |
| if (closure_obj.IsNull() || !closure_obj.IsCallable(NULL, NULL)) { |
| RETURN_TYPE_ERROR(isolate, closure, Instance); |
| @@ -3351,6 +3265,7 @@ |
| Dart_Handle* arguments) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| Object& result = Object::Handle(isolate); |
| if (number_of_arguments < 0) { |
| @@ -3365,6 +3280,7 @@ |
| if (cls.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, clazz, Class); |
| } |
| + |
| String& base_constructor_name = String::Handle(); |
| base_constructor_name = cls.Name(); |
| @@ -3451,6 +3367,7 @@ |
| Dart_Handle* arguments) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| const String& function_name = Api::UnwrapStringHandle(isolate, name); |
| if (function_name.IsNull()) { |
| @@ -3594,6 +3511,7 @@ |
| DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| const String& field_name = Api::UnwrapStringHandle(isolate, name); |
| if (field_name.IsNull()) { |
| @@ -3708,6 +3626,7 @@ |
| Dart_Handle value) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| const String& field_name = Api::UnwrapStringHandle(isolate, name); |
| if (field_name.IsNull()) { |
| @@ -3861,6 +3780,7 @@ |
| return Api::NewError( |
| "Negative field_count passed to Dart_CreateNativeWrapperClass"); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| String& cls_symbol = String::Handle(isolate, Symbols::New(cls_name)); |
| const Class& cls = Class::Handle( |
| @@ -3931,6 +3851,7 @@ |
| DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) { |
| Isolate* isolate = Isolate::Current(); |
| CHECK_ISOLATE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| { |
| const Instance& excp = Api::UnwrapInstanceHandle(isolate, exception); |
| if (excp.IsNull()) { |
| @@ -3942,6 +3863,7 @@ |
| // throw an exception here. |
| return Api::NewError("No Dart frames on stack, cannot throw exception"); |
| } |
| + |
| // Unwind all the API scopes till the exit frame before throwing an |
| // exception. |
| ApiState* state = isolate->api_state(); |
| @@ -3963,6 +3885,7 @@ |
| Dart_Handle stacktrace) { |
| Isolate* isolate = Isolate::Current(); |
| CHECK_ISOLATE(isolate); |
| + CHECK_CALLBACK_STATE(isolate); |
| { |
| const Instance& excp = Api::UnwrapInstanceHandle(isolate, exception); |
| if (excp.IsNull()) { |
| @@ -3978,6 +3901,7 @@ |
| // throw an exception here. |
| return Api::NewError("No Dart frames on stack, cannot throw exception"); |
| } |
| + |
| // Unwind all the API scopes till the exit frame before throwing an |
| // exception. |
| ApiState* state = isolate->api_state(); |
| @@ -4094,6 +4018,8 @@ |
| return Api::NewError("%s: A script has already been loaded from '%s'.", |
| CURRENT_FUNC, library_url.ToCString()); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| library = Library::New(url_str); |
| library.set_debuggable(true); |
| library.Register(); |
| @@ -4137,6 +4063,7 @@ |
| return Api::NewError("%s: argument 'col_offset' must be positive number", |
| CURRENT_FUNC); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| library = Library::New(url_str); |
| library.set_debuggable(true); |
| @@ -4171,6 +4098,8 @@ |
| return Api::NewError("%s: A script has already been loaded from '%s'.", |
| CURRENT_FUNC, library_url.ToCString()); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| SnapshotReader reader(snapshot->content(), |
| snapshot->length(), |
| snapshot->kind(), |
| @@ -4215,6 +4144,7 @@ |
| if (msg != NULL) { |
| return Api::NewError("%s", msg); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| CompileAll(isolate, &result); |
| return result; |
| } |
| @@ -4338,6 +4268,8 @@ |
| if (source_str.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, source, String); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| Library& library = Library::Handle(isolate, Library::LookupLibrary(url_str)); |
| if (library.IsNull()) { |
| library = Library::New(url_str); |
| @@ -4390,6 +4322,8 @@ |
| if (prefix_vm.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, prefix, String); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| const String& prefix_symbol = |
| String::Handle(isolate, Symbols::New(prefix_vm)); |
| const Namespace& import_ns = Namespace::Handle( |
| @@ -4428,6 +4362,8 @@ |
| if (source_str.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, source, String); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| const Script& script = Script::Handle( |
| isolate, Script::New(url_str, source_str, RawScript::kSourceTag)); |
| Dart_Handle result; |
| @@ -4454,6 +4390,8 @@ |
| if (source_str.IsNull()) { |
| RETURN_TYPE_ERROR(isolate, patch_source, String); |
| } |
| + CHECK_CALLBACK_STATE(isolate); |
| + |
| const Script& script = Script::Handle( |
| isolate, Script::New(url_str, source_str, RawScript::kPatchTag)); |
| Dart_Handle result; |