@@ -22,17 +22,13 @@ Dart_Handle DartWrappable::CreateDartWrapper(DartState* dart_state) {
2222 Dart_PersistentHandle type = dart_state->class_library ().GetClass (info);
2323 TONIC_DCHECK (!LogIfError (type));
2424
25- Dart_Handle private_constructor_name = Dart_NewStringFromCString (" _" );
26- Dart_Handle wrapper = Dart_New (type, private_constructor_name, 0 , nullptr );
25+ intptr_t native_fields[kNumberOfNativeFields ];
26+ native_fields[kPeerIndex ] = reinterpret_cast <intptr_t >(this );
27+ native_fields[kWrapperInfoIndex ] = reinterpret_cast <intptr_t >(&info);
28+ Dart_Handle wrapper =
29+ Dart_AllocateWithNativeFields (type, kNumberOfNativeFields , native_fields);
2730 TONIC_DCHECK (!LogIfError (wrapper));
2831
29- Dart_Handle res = Dart_SetNativeInstanceField (
30- wrapper, kPeerIndex , reinterpret_cast <intptr_t >(this ));
31- TONIC_DCHECK (!LogIfError (res));
32- res = Dart_SetNativeInstanceField (wrapper, kWrapperInfoIndex ,
33- reinterpret_cast <intptr_t >(&info));
34- TONIC_DCHECK (!LogIfError (res));
35-
3632 this ->RetainDartWrappableReference (); // Balanced in FinalizeDartWrapper.
3733 dart_wrapper_ = Dart_NewWeakPersistentHandle (
3834 wrapper, this , GetAllocationSize (), &FinalizeDartWrapper);
0 commit comments