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

Unified Diff: vm/dart_api_impl.cc

Issue 12036098: First set of changes towards cleaning up the bytearray access APIs (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vm/dart_api_impl.h ('k') | vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_impl.cc
===================================================================
--- vm/dart_api_impl.cc (revision 17884)
+++ 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));
@@ -1998,6 +2038,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));
@@ -2084,6 +2126,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));
@@ -2171,6 +2215,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));
@@ -2223,6 +2269,7 @@
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
CHECK_LENGTH(length, Uint8Array::kMaxElements);
+ CHECK_CALLBACK_STATE(isolate);
return Api::NewHandle(isolate, Uint8Array::New(length));
}
@@ -2237,6 +2284,7 @@
RETURN_NULL_ERROR(data);
}
CHECK_LENGTH(length, ExternalUint8Array::kMaxElements);
+ CHECK_CALLBACK_STATE(isolate);
return Api::NewHandle(
isolate, ExternalUint8Array::New(data, length, peer, callback));
}
@@ -2253,6 +2301,7 @@
RETURN_NULL_ERROR(data);
}
CHECK_LENGTH(length, ExternalUint8ClampedArray::kMaxElements);
+ CHECK_CALLBACK_STATE(isolate);
return Api::NewHandle(
isolate, ExternalUint8ClampedArray::New(data, length, peer, callback));
}
@@ -2292,182 +2341,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 ---
@@ -2501,6 +2414,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);
@@ -3349,6 +3263,7 @@
Dart_Handle* arguments) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
+ CHECK_CALLBACK_STATE(isolate);
Object& result = Object::Handle(isolate);
if (number_of_arguments < 0) {
@@ -3363,6 +3278,7 @@
if (cls.IsNull()) {
RETURN_TYPE_ERROR(isolate, clazz, Class);
}
+
String& base_constructor_name = String::Handle();
base_constructor_name = cls.Name();
@@ -3449,6 +3365,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()) {
@@ -3592,6 +3509,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()) {
@@ -3706,6 +3624,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()) {
@@ -3859,6 +3778,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(
@@ -3929,6 +3849,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()) {
@@ -3940,6 +3861,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();
@@ -3961,6 +3883,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()) {
@@ -3976,6 +3899,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();
@@ -4092,6 +4016,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();
@@ -4135,6 +4061,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);
@@ -4169,6 +4096,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(),
@@ -4213,6 +4142,7 @@
if (msg != NULL) {
return Api::NewError("%s", msg);
}
+ CHECK_CALLBACK_STATE(isolate);
CompileAll(isolate, &result);
return result;
}
@@ -4336,6 +4266,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);
@@ -4388,6 +4320,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(
@@ -4426,6 +4360,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;
@@ -4452,6 +4388,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;
« no previous file with comments | « vm/dart_api_impl.h ('k') | vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698