dart-sdk/runtime/vm/bootstrap_natives.h

489 lines
36 KiB
C
Raw Normal View History

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_BOOTSTRAP_NATIVES_H_
#define RUNTIME_VM_BOOTSTRAP_NATIVES_H_
#include "vm/native_entry.h"
// bootstrap dart natives used in the core dart library.
namespace dart {
// List of bootstrap native entry points used in the core dart library.
Reland "Scaffolding for dart:wasm" This reverts commit 9198813a553c6ce230c8c545d33fbad14ffef340. Reason for revert: Relanding with a fix Original change's description: > Revert "Scaffolding for dart:wasm" > > This reverts commit f39a3f188e3bd259d4d7e41c48516e507c1303f1. > > Reason for revert: https://golem.corp.goog/BuildInfo?target=flutter-profile&machine-type=android-armv7&revision=84750 > > Original change's description: > > Scaffolding for dart:wasm > > > > This CL doesn't have any tests because it's just boilerplate. I'll > > add a test in the follow up CLs where I add actual functionality. > > > > Bug: https://github.com/dart-lang/sdk/issues/37882 > > Change-Id: I47c81f5f1be724f8226e756ba5d01880a45f1ac7 > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112841 > > Reviewed-by: Siva Annamalai <asiva@google.com> > > Reviewed-by: Liam Appelbe <liama@google.com> > > Commit-Queue: Liam Appelbe <liama@google.com> > > TBR=asiva@google.com,liama@google.com > > Change-Id: I0fd0f29d66a07fc29e840ddaec2d4161c8d599cb > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: https://github.com/dart-lang/sdk/issues/37882 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114044 > Reviewed-by: Liam Appelbe <liama@google.com> > Commit-Queue: Liam Appelbe <liama@google.com> TBR=asiva@google.com,liama@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: https://github.com/dart-lang/sdk/issues/37882 Change-Id: Idb43cbd3a0521776ac420bfef91c8a9a4362f18e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114757 Reviewed-by: Liam Appelbe <liama@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
2019-08-28 23:11:21 +00:00
// V(function_name, argument_count)
#define BOOTSTRAP_NATIVE_LIST(V) \
V(AsyncStarMoveNext_debuggerStepCheck, 1) \
V(DartAsync_fatal, 1) \
V(Object_equals, 2) \
V(Object_getHash, 1) \
V(Object_toString, 1) \
V(Object_runtimeType, 1) \
V(Object_haveSameRuntimeType, 2) \
V(Object_instanceOf, 4) \
V(Object_simpleInstanceOf, 2) \
V(Function_apply, 2) \
V(Closure_equals, 2) \
Reapply "Improve hashCode for closure objects" with fixes. This CL includes the following fixes: * Fix for incorrect non-nullable assumption about _Closure._hash field. * Add error handling into BecomeMapTraits::Hash. * Correct assertions for validating layout of Closure objects. * Add identityHashCode to the list of VM entry points in precompiler. Closes #30211. Original code review: https://codereview.chromium.org/2983823002/ Original CL description: This performance improvement is inspired by Flutter listeners stored in the HashSet (see ObserverList) and frequently checked using HashSet.contains(). If there are many such listeners and they are implicit instance closures (for example, created by 'new Listenable.merge(...)'), HashSet.contains() becomes very slow. It spends a lot of time in Closure_equals native method due to hash collisions between closure objects with same function but different receivers. This CL improves hashCode() calculation for implicit instance closures by mixing function hashcode with identity hashcode of the receiver. For explicit closures and static implicit closures hashCode() is improved by using identityHashCode() of a closure object. Also, hashcode is calculated once and cached in each closure instance. The size of a closure instance doesn't grow up because there was unused word-size padding both on 32-bit and 64-bit architectures. The execution time of the following micro-benchmark is reduced from 47665ms to 135ms on my Linux/x64 box. ------------------------------------- import "dart:collection"; class Foo { int _a; Foo(this._a); void bar() {} } main() { HashSet hs = new HashSet(); for (int i = 0; i < 1000; ++i) { hs.add(new Foo(i).bar); } var watch = new Stopwatch()..start(); for (int i = 0; i < 1000; ++i) { for (var c in hs) { hs.contains(c); } } int time = watch.elapsedMilliseconds; print("Time: ${time}ms\n"); } ------------------------------------- R=zra@google.com Review-Url: https://codereview.chromium.org/2988493002 .
2017-07-20 22:22:15 +00:00
V(Closure_computeHash, 1) \
V(AbstractType_toString, 1) \
V(Type_getHashCode, 1) \
V(Type_equality, 2) \
V(FunctionType_getHashCode, 1) \
V(FunctionType_equality, 2) \
Reland "[vm] Check prefix.loadLibrary is called and returns before prefix members are used." This reverts commit 9a87cf91744975e4c6d305d635697fa76ed2c0b7. Reason for revert: Broken test disabled Original change's description: > Revert "[vm] Check prefix.loadLibrary is called and returns before prefix members are used." > > This reverts commit b0484ecbde5e09b0addf73bab016ac988800d888. > > Reason for revert: timeouts on Flutter integration tests > (https://github.com/dart-lang/sdk/issues/42350). > > Original change's description: > > [vm] Check prefix.loadLibrary is called and returns before prefix members are used. > > > > Restore checks against reloading a library with deferred prefixes. > > > > No loading is actually deferred. > > > > Bug: https://github.com/dart-lang/sdk/issues/26878 > > Bug: https://github.com/dart-lang/sdk/issues/41974 > > Change-Id: Iec2662de117453d596cca28dd9481a9751091ce9 > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149613 > > Commit-Queue: Ryan Macnak <rmacnak@google.com> > > Reviewed-by: Alexander Markov <alexmarkov@google.com> > > Reviewed-by: Siva Annamalai <asiva@google.com> > > TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com > > # Not skipping CQ checks because original CL landed > 1 day ago. > > Bug: https://github.com/dart-lang/sdk/issues/26878, https://github.com/dart-lang/sdk/issues/41974 > Change-Id: I78709650e91d206b84a8ddd9171ef66d6cf1b008 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151169 > Reviewed-by: Alexander Markov <alexmarkov@google.com> > Commit-Queue: Alexander Markov <alexmarkov@google.com> TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com # Not skipping CQ checks because this is a reland. Bug: https://github.com/dart-lang/sdk/issues/26878, https://github.com/dart-lang/sdk/issues/41974 Change-Id: Ife76bd51db65ca58e08655a9b8406c8ca483447f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151326 Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-06-16 21:11:40 +00:00
V(LibraryPrefix_isLoaded, 1) \
V(LibraryPrefix_setLoaded, 1) \
[vm] Initial implementation of deferred loading. (Assignment of libraries to loading units is already done in the kernel generation step.) After compiling and before serializing, we walk the program and for each Code we assign its Instructions, CodeSourceMap and CompressedStackMap to the loading unit of that Code's defining library. Deduplication may cause Instructions, CodeSourceMaps and CompressedStackMaps to belong to more than one loading unit; in this case the objects are assigned to the root loading unit. Later they can be more precisely assigned to the dominating loading unit. All objects except some Instructions, CodeSourceMaps and CompressedStackMaps belong to the root loading unit's snapshot. This snapshot is written like an unsplit snapshot, except that when serializing Code, we will write a reference to a stub or null when the Code's Instructions, CodeSourceMap or CompressedStackMap belongs to a non-root loading unit. The snapshots of non-root loading units contain these deferred objects and references to the corresponding Code objects to patch. The types of objects we defer (Instructions, CodeSourceMaps and CompressedStackMaps) usually represent 70+% of the snapshot size. Bare instructions mode must be disabled when splitting because we cannot have PC-relative calls between loading units. Later we can re-enable this for calls within loading units. Broken: Compactor probably crashes we can now have an unbounded number of image pages and the compactor assumes a fixed number. Embedder's guide: At compile-time, gen_snapshot should be passed --loading_unit_manifest with a path, which will enable splitting and output a mapping from loading unit ids to snapshot output paths. At runtime, sometime during isolate startup, an embedder should call Dart_SetDeferredLoadHandler, probably near an existing call to Dart_SetLibraryTagHandler. The callback is given a loading unit id, and should eventually call Dart_DeferredLoadComplete[Error]. Bug: https://github.com/dart-lang/sdk/issues/41974 Change-Id: Ib597eb87c8cd634416d5ee1f00629c5550aebb00 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152427 Commit-Queue: Ryan Macnak <rmacnak@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-07-17 19:29:47 +00:00
V(LibraryPrefix_loadingUnit, 1) \
V(LibraryPrefix_issueLoad, 1) \
V(Identical_comparison, 2) \
V(Integer_bitAndFromInteger, 2) \
V(Integer_bitOrFromInteger, 2) \
V(Integer_bitXorFromInteger, 2) \
V(Integer_addFromInteger, 2) \
V(Integer_subFromInteger, 2) \
V(Integer_mulFromInteger, 2) \
V(Integer_truncDivFromInteger, 2) \
V(Integer_moduloFromInteger, 2) \
V(Integer_greaterThanFromInteger, 2) \
V(Integer_equalToInteger, 2) \
V(Integer_fromEnvironment, 3) \
V(Integer_parse, 1) \
V(Integer_shlFromInteger, 2) \
V(Integer_shrFromInteger, 2) \
V(Integer_ushrFromInteger, 2) \
V(Bool_fromEnvironment, 3) \
V(Bool_hasEnvironment, 2) \
V(CapabilityImpl_factory, 1) \
V(CapabilityImpl_equals, 2) \
V(CapabilityImpl_get_hashcode, 1) \
V(RawReceivePortImpl_factory, 2) \
V(RawReceivePortImpl_get_id, 1) \
V(RawReceivePortImpl_get_sendport, 1) \
V(RawReceivePortImpl_closeInternal, 1) \
V(RawReceivePortImpl_setActive, 2) \
V(SendPortImpl_get_id, 1) \
V(SendPortImpl_get_hashcode, 1) \
V(SendPortImpl_sendInternal_, 2) \
V(Smi_bitNegate, 1) \
V(Smi_bitLength, 1) \
V(SuspendState_instantiateClosureWithFutureTypeArgument, 2) \
V(Mint_bitNegate, 1) \
V(Mint_bitLength, 1) \
V(Developer_debugger, 2) \
V(Developer_getIsolateIDFromSendPort, 1) \
V(Developer_getServerInfo, 1) \
V(Developer_getServiceMajorVersion, 0) \
V(Developer_getServiceMinorVersion, 0) \
V(Developer_inspect, 1) \
V(Developer_lookupExtension, 1) \
V(Developer_registerExtension, 2) \
V(Developer_log, 8) \
V(Developer_postEvent, 2) \
V(Developer_webServerControl, 3) \
V(Double_hashCode, 1) \
V(Double_getIsNegative, 1) \
V(Double_getIsInfinite, 1) \
V(Double_getIsNaN, 1) \
V(Double_add, 2) \
V(Double_sub, 2) \
V(Double_mul, 2) \
V(Double_div, 2) \
V(Double_remainder, 2) \
V(Double_modulo, 2) \
V(Double_greaterThanFromInteger, 2) \
V(Double_equalToInteger, 2) \
V(Double_greaterThan, 2) \
V(Double_equal, 2) \
V(Double_doubleFromInteger, 2) \
V(Double_round, 1) \
V(Double_floor, 1) \
V(Double_ceil, 1) \
V(Double_truncate, 1) \
V(Double_toInt, 1) \
V(Double_parse, 3) \
V(Double_toString, 1) \
V(Double_toStringAsFixed, 2) \
V(Double_toStringAsExponential, 2) \
V(Double_toStringAsPrecision, 2) \
V(Double_flipSignBit, 1) \
Reland "[vm] Finish adding support for ECMAScript 2018 features." This work pulls in v8 support for these features with appropriate changes for Dart and closes https://github.com/dart-lang/sdk/issues/34935. This adds support for the following features: * Interpreting patterns as Unicode patterns instead of BMP patterns * the dotAll flag (`/s`) for changing the behavior of '.' to also match line terminators * Escapes for character classes described by Unicode property groups (e.g., \p{Greek} to match all Greek characters, or \P{Greek} for all non-Greek characters). The following TC39 proposals describe some of the added features: * https://github.com/tc39/proposal-regexp-dotall-flag * https://github.com/tc39/proposal-regexp-unicode-property-escapes These additional changes are included: * Extends named capture group names to include the full range of identifier characters supported by ECMAScript, not just ASCII. * Changing the RegExp interface to return RegExpMatch objects, not Match objects, so that downcasting is not necessary to use named capture groups from Dart **Note**: The changes to the RegExp interface are a breaking change for implementers of the RegExp interface. Current users of the RegExp interface (i.e., code using Dart RegExp objects) will not be affected. Change-Id: Ie62e6082a0e2fedc1680ef2576ce0c6db80fc19a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100641 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Stevie Strickland <sstrickl@google.com>
2019-04-29 09:11:48 +00:00
V(RegExp_factory, 6) \
V(RegExp_getPattern, 1) \
V(RegExp_getIsMultiLine, 1) \
V(RegExp_getIsCaseSensitive, 1) \
Reland "[vm] Finish adding support for ECMAScript 2018 features." This work pulls in v8 support for these features with appropriate changes for Dart and closes https://github.com/dart-lang/sdk/issues/34935. This adds support for the following features: * Interpreting patterns as Unicode patterns instead of BMP patterns * the dotAll flag (`/s`) for changing the behavior of '.' to also match line terminators * Escapes for character classes described by Unicode property groups (e.g., \p{Greek} to match all Greek characters, or \P{Greek} for all non-Greek characters). The following TC39 proposals describe some of the added features: * https://github.com/tc39/proposal-regexp-dotall-flag * https://github.com/tc39/proposal-regexp-unicode-property-escapes These additional changes are included: * Extends named capture group names to include the full range of identifier characters supported by ECMAScript, not just ASCII. * Changing the RegExp interface to return RegExpMatch objects, not Match objects, so that downcasting is not necessary to use named capture groups from Dart **Note**: The changes to the RegExp interface are a breaking change for implementers of the RegExp interface. Current users of the RegExp interface (i.e., code using Dart RegExp objects) will not be affected. Change-Id: Ie62e6082a0e2fedc1680ef2576ce0c6db80fc19a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100641 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Stevie Strickland <sstrickl@google.com>
2019-04-29 09:11:48 +00:00
V(RegExp_getIsUnicode, 1) \
V(RegExp_getIsDotAll, 1) \
V(RegExp_getGroupCount, 1) \
V(RegExp_getGroupNameMap, 1) \
V(RegExp_ExecuteMatch, 3) \
V(RegExp_ExecuteMatchSticky, 3) \
V(List_new, 2) \
V(List_allocate, 2) \
V(List_getIndexed, 2) \
V(List_setIndexed, 3) \
V(List_getLength, 1) \
V(List_slice, 4) \
V(ImmutableList_from, 4) \
V(StringBase_createFromCodePoints, 3) \
V(StringBase_substringUnchecked, 3) \
V(StringBase_joinReplaceAllResult, 4) \
V(StringBuffer_createStringFromUint16Array, 3) \
V(OneByteString_substringUnchecked, 3) \
V(OneByteString_allocateFromOneByteList, 3) \
V(TwoByteString_allocateFromTwoByteList, 3) \
V(String_getHashCode, 1) \
V(String_getLength, 1) \
V(String_charAt, 2) \
V(String_codeUnitAt, 2) \
V(String_concat, 2) \
V(String_fromEnvironment, 3) \
V(String_toLowerCase, 1) \
V(String_toUpperCase, 1) \
V(String_concatRange, 3) \
V(Math_doublePow, 2) \
V(Random_initialSeed, 0) \
V(SecureRandom_getBytes, 1) \
V(DateTime_currentTimeMicros, 0) \
V(DateTime_timeZoneName, 1) \
V(DateTime_timeZoneOffsetInSeconds, 1) \
V(AssertionError_throwNew, 3) \
V(AssertionError_throwNewSource, 4) \
V(Error_throwWithStackTrace, 2) \
V(StackTrace_current, 0) \
V(TypeError_throwNew, 4) \
V(Stopwatch_now, 0) \
V(Stopwatch_frequency, 0) \
V(Timeline_getNextTaskId, 0) \
V(Timeline_getTraceClock, 0) \
V(Timeline_isDartStreamEnabled, 0) \
V(Timeline_reportFlowEvent, 5) \
V(Timeline_reportInstantEvent, 3) \
V(Timeline_reportTaskEvent, 5) \
V(TypedData_Int8Array_new, 2) \
V(TypedData_Uint8Array_new, 2) \
V(TypedData_Uint8ClampedArray_new, 2) \
V(TypedData_Int16Array_new, 2) \
V(TypedData_Uint16Array_new, 2) \
V(TypedData_Int32Array_new, 2) \
V(TypedData_Uint32Array_new, 2) \
V(TypedData_Int64Array_new, 2) \
V(TypedData_Uint64Array_new, 2) \
V(TypedData_Float32Array_new, 2) \
V(TypedData_Float64Array_new, 2) \
V(TypedData_Float32x4Array_new, 2) \
V(TypedData_Int32x4Array_new, 2) \
V(TypedData_Float64x2Array_new, 2) \
V(TypedDataBase_length, 1) \
V(TypedDataBase_setRange, 7) \
V(TypedData_GetInt8, 2) \
V(TypedData_SetInt8, 3) \
V(TypedData_GetUint8, 2) \
V(TypedData_SetUint8, 3) \
V(TypedData_GetInt16, 2) \
V(TypedData_SetInt16, 3) \
V(TypedData_GetUint16, 2) \
V(TypedData_SetUint16, 3) \
V(TypedData_GetInt32, 2) \
V(TypedData_SetInt32, 3) \
V(TypedData_GetUint32, 2) \
V(TypedData_SetUint32, 3) \
V(TypedData_GetInt64, 2) \
V(TypedData_SetInt64, 3) \
V(TypedData_GetUint64, 2) \
V(TypedData_SetUint64, 3) \
V(TypedData_GetFloat32, 2) \
V(TypedData_SetFloat32, 3) \
V(TypedData_GetFloat64, 2) \
V(TypedData_SetFloat64, 3) \
V(TypedData_GetFloat32x4, 2) \
V(TypedData_SetFloat32x4, 3) \
V(TypedData_GetInt32x4, 2) \
V(TypedData_SetInt32x4, 3) \
V(TypedData_GetFloat64x2, 2) \
V(TypedData_SetFloat64x2, 3) \
V(TypedDataView_ByteDataView_new, 4) \
V(TypedDataView_Int8ArrayView_new, 4) \
V(TypedDataView_Uint8ArrayView_new, 4) \
V(TypedDataView_Uint8ClampedArrayView_new, 4) \
V(TypedDataView_Int16ArrayView_new, 4) \
V(TypedDataView_Uint16ArrayView_new, 4) \
V(TypedDataView_Int32ArrayView_new, 4) \
V(TypedDataView_Uint32ArrayView_new, 4) \
V(TypedDataView_Int64ArrayView_new, 4) \
V(TypedDataView_Uint64ArrayView_new, 4) \
V(TypedDataView_Float32ArrayView_new, 4) \
V(TypedDataView_Float64ArrayView_new, 4) \
V(TypedDataView_Float32x4ArrayView_new, 4) \
V(TypedDataView_Int32x4ArrayView_new, 4) \
V(TypedDataView_Float64x2ArrayView_new, 4) \
V(TypedDataView_offsetInBytes, 1) \
V(TypedDataView_typedData, 1) \
V(Float32x4_fromDoubles, 4) \
V(Float32x4_splat, 1) \
V(Float32x4_fromInt32x4Bits, 2) \
V(Float32x4_fromFloat64x2, 2) \
V(Float32x4_zero, 1) \
V(Float32x4_add, 2) \
V(Float32x4_negate, 1) \
V(Float32x4_sub, 2) \
V(Float32x4_mul, 2) \
V(Float32x4_div, 2) \
V(Float32x4_cmplt, 2) \
V(Float32x4_cmplte, 2) \
V(Float32x4_cmpgt, 2) \
V(Float32x4_cmpgte, 2) \
V(Float32x4_cmpequal, 2) \
V(Float32x4_cmpnequal, 2) \
V(Float32x4_scale, 2) \
V(Float32x4_abs, 1) \
V(Float32x4_clamp, 3) \
V(Float32x4_getX, 1) \
V(Float32x4_getY, 1) \
V(Float32x4_getZ, 1) \
V(Float32x4_getW, 1) \
V(Float32x4_getSignMask, 1) \
V(Float32x4_shuffle, 2) \
V(Float32x4_shuffleMix, 3) \
V(Float32x4_setX, 2) \
V(Float32x4_setY, 2) \
V(Float32x4_setZ, 2) \
V(Float32x4_setW, 2) \
V(Float32x4_min, 2) \
V(Float32x4_max, 2) \
V(Float32x4_sqrt, 1) \
V(Float32x4_reciprocal, 1) \
V(Float32x4_reciprocalSqrt, 1) \
V(Float64x2_fromDoubles, 2) \
V(Float64x2_splat, 1) \
V(Float64x2_zero, 1) \
V(Float64x2_fromFloat32x4, 2) \
V(Float64x2_add, 2) \
V(Float64x2_negate, 1) \
V(Float64x2_sub, 2) \
V(Float64x2_mul, 2) \
V(Float64x2_div, 2) \
V(Float64x2_scale, 2) \
V(Float64x2_abs, 1) \
V(Float64x2_clamp, 3) \
V(Float64x2_getX, 1) \
V(Float64x2_getY, 1) \
V(Float64x2_getSignMask, 1) \
V(Float64x2_setX, 2) \
V(Float64x2_setY, 2) \
V(Float64x2_min, 2) \
V(Float64x2_max, 2) \
V(Float64x2_sqrt, 1) \
V(Int32x4_fromInts, 4) \
V(Int32x4_fromBools, 4) \
V(Int32x4_fromFloat32x4Bits, 2) \
V(Int32x4_or, 2) \
V(Int32x4_and, 2) \
V(Int32x4_xor, 2) \
V(Int32x4_add, 2) \
V(Int32x4_sub, 2) \
V(Int32x4_getX, 1) \
V(Int32x4_getY, 1) \
V(Int32x4_getZ, 1) \
V(Int32x4_getW, 1) \
V(Int32x4_setX, 2) \
V(Int32x4_setY, 2) \
V(Int32x4_setZ, 2) \
V(Int32x4_setW, 2) \
V(Int32x4_getSignMask, 1) \
V(Int32x4_shuffle, 2) \
V(Int32x4_shuffleMix, 3) \
V(Int32x4_getFlagX, 1) \
V(Int32x4_getFlagY, 1) \
V(Int32x4_getFlagZ, 1) \
V(Int32x4_getFlagW, 1) \
V(Int32x4_setFlagX, 2) \
V(Int32x4_setFlagY, 2) \
V(Int32x4_setFlagZ, 2) \
V(Int32x4_setFlagW, 2) \
V(Int32x4_select, 3) \
V(Isolate_exit_, 2) \
V(Isolate_getCurrentRootUriStr, 0) \
V(Isolate_getDebugName, 1) \
V(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) \
V(Isolate_registerKernelBlob, 1) \
V(Isolate_unregisterKernelBlob, 1) \
V(Isolate_sendOOB, 2) \
V(Isolate_spawnFunction, 10) \
V(Isolate_spawnUri, 12) \
V(GrowableList_allocate, 2) \
V(GrowableList_getIndexed, 2) \
V(GrowableList_setIndexed, 3) \
V(GrowableList_getLength, 1) \
V(GrowableList_getCapacity, 1) \
V(GrowableList_setLength, 2) \
V(GrowableList_setData, 2) \
V(Internal_unsafeCast, 1) \
V(Internal_nativeEffect, 1) \
V(Internal_collectAllGarbage, 0) \
V(Internal_makeListFixedLength, 1) \
V(Internal_makeFixedListUnmodifiable, 1) \
V(Internal_extractTypeArguments, 2) \
V(Internal_prependTypeArguments, 4) \
V(Internal_boundsCheckForPartialInstantiation, 2) \
V(Internal_allocateOneByteString, 1) \
V(Internal_allocateTwoByteString, 1) \
V(Internal_writeIntoOneByteString, 3) \
V(Internal_writeIntoTwoByteString, 3) \
V(Internal_deoptimizeFunctionsOnStack, 0) \
Reland "[pkg/native_stack_traces] Support Mach-O dSYM debugging information." This is a reland of commit 08c13f173c3715fd768d768566eeccf1f9f14c3b Fixes test failures on non-x64 architectures, both in the test harness and due to DWARF5 line number program headers having a non-backwards compatible format. (We generate DWARF2 in the ELF snapshot writer, but the assembler used for assembly snapshots may generate DWARF5.) TEST=vm/dart{,_2}/use_dwarf_stack_traces_flag Original change's description: > [pkg/native_stack_traces] Support Mach-O dSYM debugging information. > > TEST=vm/dart{,_2}/use_dwarf_stack_traces_flag > > Bug: https://github.com/dart-lang/sdk/issues/43612 > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-product-x64-try,pkg-mac-release-arm64-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try > Change-Id: Icda21bb14dcc0cf4784cea118e6ba7dd4edd35aa > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250381 > Commit-Queue: Tess Strickland <sstrickl@google.com> > Reviewed-by: Slava Egorov <vegorov@google.com> Bug: https://github.com/dart-lang/sdk/issues/43612 Change-Id: I8a9cb70e78bc8594bcae004809c5a1be778d691d Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-mac-product-x64-try,pkg-mac-release-arm64-try,vm-kernel-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-nnbd-mac-release-simarm64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251464 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2022-07-22 07:05:26 +00:00
V(Internal_randomInstructionsOffsetInsideAllocateObjectStub, 0) \
V(InvocationMirror_unpackTypeArguments, 2) \
V(NoSuchMethodError_existingMethodSignature, 3) \
V(Uri_isWindowsPlatform, 0) \
V(UserTag_new, 2) \
V(UserTag_label, 1) \
V(UserTag_defaultTag, 0) \
V(UserTag_makeCurrent, 1) \
V(Profiler_getCurrentTag, 0) \
V(VMService_SendIsolateServiceMessage, 2) \
V(VMService_SendRootServiceMessage, 1) \
V(VMService_SendObjectRootServiceMessage, 1) \
V(VMService_OnStart, 0) \
V(VMService_OnExit, 0) \
V(VMService_OnServerAddressChange, 1) \
V(VMService_ListenStream, 2) \
V(VMService_CancelStream, 1) \
V(VMService_RequestAssets, 0) \
V(VMService_DecodeAssets, 1) \
V(VMService_AddUserTagsToStreamableSampleList, 1) \
V(VMService_RemoveUserTagsFromStreamableSampleList, 1) \
V(Ffi_loadInt8, 2) \
V(Ffi_loadInt16, 2) \
V(Ffi_loadInt32, 2) \
V(Ffi_loadInt64, 2) \
V(Ffi_loadUint8, 2) \
V(Ffi_loadUint16, 2) \
V(Ffi_loadUint32, 2) \
V(Ffi_loadUint64, 2) \
V(Ffi_loadFloat, 2) \
V(Ffi_loadDouble, 2) \
V(Ffi_loadPointer, 2) \
V(Ffi_loadStruct, 2) \
V(Ffi_storeInt8, 3) \
V(Ffi_storeInt16, 3) \
V(Ffi_storeInt32, 3) \
V(Ffi_storeInt64, 3) \
V(Ffi_storeUint8, 3) \
V(Ffi_storeUint16, 3) \
V(Ffi_storeUint32, 3) \
V(Ffi_storeUint64, 3) \
V(Ffi_storeFloat, 3) \
V(Ffi_storeDouble, 3) \
V(Ffi_storePointer, 3) \
V(Ffi_address, 1) \
V(Ffi_fromAddress, 1) \
[VM/FFI] Adds FFI leaf calls. This CL adds FFI leaf calls by adding `lookupFunction(.., isLeaf)` and `_asFunctionInternal(.., isLeaf)`, which generate FFI leaf calls. These calls skip a lot of the usual frame building and generated <-> native transition overhead. `benchmark/FfiCall/` shows a 1.1x - 4.3x speed-up between the regular FFI calls and their leaf call counterparts (JIT, x64, release). TEST=Adds `tests/ffi{,_2}/vmspecific_leaf_call_test.dart`. Tested FFI tests. Closes: https://github.com/dart-lang/sdk/issues/36707 Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-release-arm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-product-arm64-try,vm-ffi-android-product-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-precomp-nnbd-mac-release-simarm64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try Bug: https://github.com/dart-lang/sdk/issues/36707 Change-Id: Id8824f36b0006bf09951207bd004356fe6e9f46e Cq-Do-Not-Cancel-Tryjobs: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179768 Commit-Queue: Clement Skau <cskau@google.com> Reviewed-by: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-21 11:12:02 +00:00
V(Ffi_asFunctionInternal, 2) \
V(Ffi_nativeCallbackFunction, 2) \
V(Ffi_pointerFromFunction, 1) \
V(Ffi_dl_open, 1) \
V(Ffi_dl_lookup, 2) \
[vm/isolate] Add TransferableTypedData class that allows low-cost passing of Uint8List between isolates. TransferableTypedData instances are one-use kind of thing: once receiver materializes it, it can't be used again, once sender sends it out to an isolate, sender can't send it to different isolate. Example of use: sender isolate: ``` Future<TransferableTypedData> consolidateHttpClientResponseBytes(HttpClientResponse response) { final completer = Completer<TransferableTypedData>(); final chunks = <Uint8List>[]; response.listen((List<int> chunk) { chunks.add(chunk); }, onDone: () { completer.complete(TransferableTypedData.fromList(chunks)); }); return completer.future; } ... sendPort.send(await consolidateHttpClientResponseBytes(response)); ``` receiver isolate: ``` RawReceivePort port = RawReceivePort((TransferableTypedData transferable) { Uint8List content = transferable.materialize().asUint8List(); ... }); ``` 31959[tr] and 31960[tr] tests were inspired by dartbug.com/31959, dartbug.com/31960 that this CL attempts to address: ``` ╰─➤ out/ReleaseX64/dart 31960.dart sending... 163ms for round-trip sending... 81ms for round-trip sending... 20ms for round-trip sending... 14ms for round-trip sending... 20ms for round-trip sending... 14ms for round-trip ``` (notice no "since last checking" pauses") vs ``` ╰─➤ out/ReleaseX64/dart 31960.dart sending... 154ms since last checkin 174ms for round-trip sending... 68ms since last checkin 9ms since last checkin 171ms for round-trip sending... 13ms since last checkin 108ms for round-trip sending... 14ms since last checkin 108ms for round-trip sending... 14ms since last checkin 107ms for round-trip ``` Change-Id: I0fcb5ce285394f498c3f1db4414204531f98199d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99623 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-06-06 19:49:07 +00:00
V(Ffi_dl_getHandle, 1) \
V(Ffi_dl_providesSymbol, 2) \
V(Ffi_asExternalTypedDataInt8, 2) \
V(Ffi_asExternalTypedDataInt16, 2) \
V(Ffi_asExternalTypedDataInt32, 2) \
V(Ffi_asExternalTypedDataInt64, 2) \
V(Ffi_asExternalTypedDataUint8, 2) \
V(Ffi_asExternalTypedDataUint16, 2) \
V(Ffi_asExternalTypedDataUint32, 2) \
V(Ffi_asExternalTypedDataUint64, 2) \
V(Ffi_asExternalTypedDataFloat, 2) \
V(Ffi_asExternalTypedDataDouble, 2) \
V(Ffi_dl_processLibrary, 0) \
V(Ffi_dl_executableLibrary, 0) \
V(Ffi_GetFfiNativeResolver, 0) \
[vm/ffi] Expose a subset of dart_(native_)api.h for dynamic linking. This CL introduces dart_api_dl.h which exposes a subset of dart_api.h and dart_native_api.h for dynamic linking at runtime through the FFI. Dynamic linking is done through including dart_api_dl.cc in a shared library and passing NativeApi.initializeApiDLData to the init function. This CL also includes Native API versioning to deal with possible version skew between native api version against which native libraries are compiled and the version in the DartVM the code is run on. The subset of symbols in the CL includes handle related symbols, error related symbols, handle scope symbols, and native port sumbols. Design: http://go/dart-ffi-expose-dart-api Closes: https://github.com/dart-lang/sdk/issues/40607 Closes: https://github.com/dart-lang/sdk/issues/36858 Closes: https://github.com/dart-lang/sdk/issues/41319 Closes: https://github.com/flutter/flutter/issues/46887 Closes: https://github.com/flutter/flutter/issues/47061 Misc: Closes: https://github.com/dart-lang/sdk/issues/42260 Change-Id: I9e557808dbc99b341f23964cbddbb05f26d7a6c5 Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145592 Commit-Queue: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-06-18 07:30:43 +00:00
V(DartApiDLInitializeData, 0) \
V(DartApiDLMajorVersion, 0) \
V(DartApiDLMinorVersion, 0) \
V(DartNativeApiFunctionPointer, 1) \
[vm/isolate] Add TransferableTypedData class that allows low-cost passing of Uint8List between isolates. TransferableTypedData instances are one-use kind of thing: once receiver materializes it, it can't be used again, once sender sends it out to an isolate, sender can't send it to different isolate. Example of use: sender isolate: ``` Future<TransferableTypedData> consolidateHttpClientResponseBytes(HttpClientResponse response) { final completer = Completer<TransferableTypedData>(); final chunks = <Uint8List>[]; response.listen((List<int> chunk) { chunks.add(chunk); }, onDone: () { completer.complete(TransferableTypedData.fromList(chunks)); }); return completer.future; } ... sendPort.send(await consolidateHttpClientResponseBytes(response)); ``` receiver isolate: ``` RawReceivePort port = RawReceivePort((TransferableTypedData transferable) { Uint8List content = transferable.materialize().asUint8List(); ... }); ``` 31959[tr] and 31960[tr] tests were inspired by dartbug.com/31959, dartbug.com/31960 that this CL attempts to address: ``` ╰─➤ out/ReleaseX64/dart 31960.dart sending... 163ms for round-trip sending... 81ms for round-trip sending... 20ms for round-trip sending... 14ms for round-trip sending... 20ms for round-trip sending... 14ms for round-trip ``` (notice no "since last checking" pauses") vs ``` ╰─➤ out/ReleaseX64/dart 31960.dart sending... 154ms since last checkin 174ms for round-trip sending... 68ms since last checkin 9ms since last checkin 171ms for round-trip sending... 13ms since last checkin 108ms for round-trip sending... 14ms since last checkin 108ms for round-trip sending... 14ms since last checkin 107ms for round-trip ``` Change-Id: I0fcb5ce285394f498c3f1db4414204531f98199d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99623 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-06-06 19:49:07 +00:00
V(TransferableTypedData_factory, 2) \
V(TransferableTypedData_materialize, 1)
// List of bootstrap native entry points used in the dart:mirror library.
#define MIRRORS_BOOTSTRAP_NATIVE_LIST(V) \
V(Mirrors_makeLocalClassMirror, 1) \
V(Mirrors_makeLocalTypeMirror, 1) \
V(Mirrors_instantiateGenericType, 2) \
V(Mirrors_mangleName, 2) \
V(MirrorReference_equals, 2) \
V(MirrorSystem_libraries, 0) \
V(MirrorSystem_isolate, 0) \
V(IsolateMirror_loadUri, 1) \
V(InstanceMirror_invoke, 5) \
V(InstanceMirror_invokeGetter, 3) \
V(InstanceMirror_invokeSetter, 4) \
V(InstanceMirror_computeType, 1) \
V(ClosureMirror_function, 1) \
V(TypeMirror_subtypeTest, 2) \
V(ClassMirror_libraryUri, 1) \
V(ClassMirror_supertype, 1) \
V(ClassMirror_supertype_instantiated, 1) \
V(ClassMirror_interfaces, 1) \
V(ClassMirror_interfaces_instantiated, 1) \
V(ClassMirror_mixin, 1) \
V(ClassMirror_mixin_instantiated, 2) \
V(ClassMirror_members, 3) \
V(ClassMirror_constructors, 3) \
V(LibraryMirror_members, 2) \
V(LibraryMirror_libraryDependencies, 2) \
V(ClassMirror_invoke, 5) \
V(ClassMirror_invokeGetter, 3) \
V(ClassMirror_invokeSetter, 4) \
V(ClassMirror_invokeConstructor, 5) \
V(ClassMirror_type_variables, 1) \
V(ClassMirror_type_arguments, 1) \
V(LibraryMirror_fromPrefix, 1) \
V(LibraryMirror_invoke, 5) \
V(LibraryMirror_invokeGetter, 3) \
V(LibraryMirror_invokeSetter, 4) \
V(TypeVariableMirror_owner, 1) \
V(TypeVariableMirror_upper_bound, 1) \
V(DeclarationMirror_location, 1) \
V(DeclarationMirror_metadata, 1) \
V(FunctionTypeMirror_call_method, 2) \
V(FunctionTypeMirror_parameters, 2) \
V(FunctionTypeMirror_return_type, 1) \
V(MethodMirror_owner, 2) \
V(MethodMirror_parameters, 2) \
V(MethodMirror_return_type, 2) \
V(MethodMirror_source, 1) \
V(ParameterMirror_type, 3) \
V(VariableMirror_type, 2)
[vm] Implement `NativeFinalizer` This CL implements `NativeFinalizer` in the GC. `FinalizerEntry`s are extended to track `external_size` and in which `Heap::Space` the finalizable value is. On attaching a native finalizer, the external size is added to the relevant heap. When the finalizable value is promoted from new to old space, the external size is promoted as well. And when a native finalizer is run or is detached, the external size is removed from the relevant heap again. In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate shutdown. When the `NativeFinalizer`s themselves are collected, the finalizers are not run. Users should stick the native finalizer in a global variable to ensure finalization. We will revisit this design when we add send and exit support, because there is a design space to explore what to do in that case. This current solution promises the least to users. In this implementation native finalizers have a Dart entry to clean up the entries from the `all_entries` field of the finalizer. We should consider using another data structure that avoids the need for this Dart entry. See the TODO left in the code. Bug: https://github.com/dart-lang/sdk/issues/47777 TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart TEST=runtime/vm/object_test.cc TEST=tests/ffi(_2)/vmspecific_native_finalizer_* Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121 Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
#define BOOTSTRAP_FFI_NATIVE_LIST(V) \
V(FinalizerEntry_SetExternalSize, void, (Dart_Handle, intptr_t))
class BootstrapNatives : public AllStatic {
public:
static Dart_NativeFunction Lookup(Dart_Handle name,
int argument_count,
bool* auto_setup_scope);
[vm] Implement `NativeFinalizer` This CL implements `NativeFinalizer` in the GC. `FinalizerEntry`s are extended to track `external_size` and in which `Heap::Space` the finalizable value is. On attaching a native finalizer, the external size is added to the relevant heap. When the finalizable value is promoted from new to old space, the external size is promoted as well. And when a native finalizer is run or is detached, the external size is removed from the relevant heap again. In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate shutdown. When the `NativeFinalizer`s themselves are collected, the finalizers are not run. Users should stick the native finalizer in a global variable to ensure finalization. We will revisit this design when we add send and exit support, because there is a design space to explore what to do in that case. This current solution promises the least to users. In this implementation native finalizers have a Dart entry to clean up the entries from the `all_entries` field of the finalizer. We should consider using another data structure that avoids the need for this Dart entry. See the TODO left in the code. Bug: https://github.com/dart-lang/sdk/issues/47777 TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart TEST=runtime/vm/object_test.cc TEST=tests/ffi(_2)/vmspecific_native_finalizer_* Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121 Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
// For use with @FfiNative.
static void* LookupFfiNative(const char* name, uintptr_t argument_count);
static const uint8_t* Symbol(Dart_NativeFunction nf);
#define DECLARE_BOOTSTRAP_NATIVE(name, ignored) \
static ObjectPtr DN_##name(Thread* thread, Zone* zone, \
NativeArguments* arguments);
BOOTSTRAP_NATIVE_LIST(DECLARE_BOOTSTRAP_NATIVE)
#if !defined(DART_PRECOMPILED_RUNTIME)
MIRRORS_BOOTSTRAP_NATIVE_LIST(DECLARE_BOOTSTRAP_NATIVE)
#endif
#undef DECLARE_BOOTSTRAP_NATIVE
[vm] Implement `NativeFinalizer` This CL implements `NativeFinalizer` in the GC. `FinalizerEntry`s are extended to track `external_size` and in which `Heap::Space` the finalizable value is. On attaching a native finalizer, the external size is added to the relevant heap. When the finalizable value is promoted from new to old space, the external size is promoted as well. And when a native finalizer is run or is detached, the external size is removed from the relevant heap again. In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate shutdown. When the `NativeFinalizer`s themselves are collected, the finalizers are not run. Users should stick the native finalizer in a global variable to ensure finalization. We will revisit this design when we add send and exit support, because there is a design space to explore what to do in that case. This current solution promises the least to users. In this implementation native finalizers have a Dart entry to clean up the entries from the `all_entries` field of the finalizer. We should consider using another data structure that avoids the need for this Dart entry. See the TODO left in the code. Bug: https://github.com/dart-lang/sdk/issues/47777 TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart TEST=runtime/vm/object_test.cc TEST=tests/ffi(_2)/vmspecific_native_finalizer_* Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121 Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
#define DECLARE_BOOTSTRAP_FFI_NATIVE(name, return_type, argument_types) \
static return_type FN_##name argument_types;
BOOTSTRAP_FFI_NATIVE_LIST(DECLARE_BOOTSTRAP_FFI_NATIVE)
#undef DECLARE_BOOTSTRAP_FFI_NATIVE
};
} // namespace dart
#endif // RUNTIME_VM_BOOTSTRAP_NATIVES_H_