@@ -276,7 +276,6 @@ class MessageSerializer : public BaseSerializer {
276276 WriteUnsigned (index);
277277 }
278278
279- const char * exception_message () const { return exception_message_; }
280279 Thread* thread () const {
281280 return static_cast <Thread*>(StackResource::thread ());
282281 }
@@ -291,7 +290,6 @@ class MessageSerializer : public BaseSerializer {
291290 WeakTable* forward_table_new_;
292291 WeakTable* forward_table_old_;
293292 GrowableArray<Object*> stack_;
294- const char * exception_message_;
295293};
296294
297295class ApiMessageSerializer : public BaseSerializer {
@@ -2161,10 +2159,8 @@ class TransferableTypedDataMessageSerializationCluster
21612159 TransferableTypedDataPeer* tpeer =
21622160 reinterpret_cast <TransferableTypedDataPeer*>(peer);
21632161 if (tpeer->data () == nullptr ) {
2164- s->IllegalObject (
2165- *object,
2166- " Illegal argument in isolate message"
2167- " : (TransferableTypedData has been transferred already)" );
2162+ s->IllegalObject (*object,
2163+ " TransferableTypedData has been transferred already" );
21682164 }
21692165 }
21702166
@@ -3218,8 +3214,7 @@ MessageSerializer::MessageSerializer(Thread* thread)
32183214 : BaseSerializer(thread, thread->zone ()),
32193215 forward_table_new_(),
32203216 forward_table_old_(),
3221- stack_(thread->zone (), 0),
3222- exception_message_(nullptr ) {
3217+ stack_(thread->zone (), 0) {
32233218 isolate ()->set_forward_table_new (new WeakTable ());
32243219 isolate ()->set_forward_table_old (new WeakTable ());
32253220}
@@ -3274,27 +3269,20 @@ void MessageSerializer::Trace(Object* object) {
32743269 if ((clazz.library () != object_store->core_library ()) &&
32753270 (clazz.library () != object_store->collection_library ()) &&
32763271 (clazz.library () != object_store->typed_data_library ())) {
3277- IllegalObject (*object,
3278- " Illegal argument in isolate message"
3279- " : (object is a regular Dart Instance)" );
3272+ IllegalObject (*object, " is a regular instance" );
32803273 }
32813274 if (clazz.num_native_fields () != 0 ) {
3282- char * chars = OS::SCreate (thread ()->zone (),
3283- " Illegal argument in isolate message"
3284- " : (object extends NativeWrapper - %s)" ,
3285- clazz.ToCString ());
3286- IllegalObject (*object, chars);
3275+ IllegalObject (*object, " is a NativeWrapper" );
32873276 }
32883277 }
32893278
32903279 // Keep the list in sync with the one in lib/isolate.cc
32913280#define ILLEGAL (type ) \
32923281 if (cid == k##type##Cid) { \
3293- IllegalObject (*object, \
3294- " Illegal argument in isolate message" \
3295- " : (object is a " #type " )" ); \
3282+ IllegalObject (*object, " is a " #type); \
32963283 }
32973284
3285+ ILLEGAL (Closure)
32983286 ILLEGAL (FunctionType)
32993287 ILLEGAL (MirrorReference)
33003288 ILLEGAL (ReceivePort)
@@ -3314,15 +3302,6 @@ void MessageSerializer::Trace(Object* object) {
33143302
33153303#undef ILLEGAL
33163304
3317- if (cid == kClosureCid ) {
3318- Closure* closure = static_cast <Closure*>(object);
3319- const char * message = OS::SCreate (
3320- zone (),
3321- " Illegal argument in isolate message : (object is a closure - %s)" ,
3322- Function::Handle (closure->function ()).ToCString ());
3323- IllegalObject (*object, message);
3324- }
3325-
33263305 if (cid >= kNumPredefinedCids || cid == kInstanceCid ||
33273306 cid == kByteBufferCid ) {
33283307 Push (isolate_group ()->class_table ()->At (cid));
@@ -3570,8 +3549,10 @@ bool ApiMessageSerializer::Trace(Dart_CObject* object) {
35703549
35713550void MessageSerializer::IllegalObject (const Object& object,
35723551 const char * message) {
3573- exception_message_ = message;
3574- thread ()->long_jump_base ()->Jump (1 , Object::snapshot_writer_error ());
3552+ const Array& args = Array::Handle (zone (), Array::New (3 ));
3553+ args.SetAt (0 , object);
3554+ args.SetAt (2 , String::Handle (zone (), String::New (message)));
3555+ Exceptions::ThrowByType (Exceptions::kArgumentValue , args);
35753556}
35763557
35773558BaseDeserializer::BaseDeserializer (Zone* zone, Message* message)
@@ -3994,31 +3975,7 @@ std::unique_ptr<Message> WriteMessage(bool same_group,
39943975
39953976 Thread* thread = Thread::Current ();
39963977 MessageSerializer serializer (thread);
3997-
3998- volatile bool has_exception = false ;
3999- {
4000- LongJumpScope jump (thread);
4001- if (setjmp (*jump.Set ()) == 0 ) {
4002- serializer.Serialize (obj);
4003- } else {
4004- has_exception = true ;
4005- }
4006- }
4007-
4008- if (has_exception) {
4009- {
4010- NoSafepointScope no_safepoint;
4011- ErrorPtr error = thread->StealStickyError ();
4012- ASSERT (error == Object::snapshot_writer_error ().ptr ());
4013- }
4014-
4015- const String& msg_obj =
4016- String::Handle (String::New (serializer.exception_message ()));
4017- const Array& args = Array::Handle (Array::New (1 ));
4018- args.SetAt (0 , msg_obj);
4019- Exceptions::ThrowByType (Exceptions::kArgument , args);
4020- }
4021-
3978+ serializer.Serialize (obj);
40223979 return serializer.Finish (dest_port, priority);
40233980}
40243981
0 commit comments