v8-natives-api

Exposes V8 natives syntax as an API

Usage no npm install needed!

<script type="module">
  import v8NativesApi from 'https://cdn.skypack.dev/v8-natives-api';
</script>

README

v8-natives-api

Exposes natives functions accessible with the --allow-natives-syntax flag as a Node API:

const api = require('v8-natives-syntax');

api.HasHoleyElements([1,,,3]); // true

api.OptimizeFunctionOnNextCall(someFunctionToOptimize);

Warning

The API here may break at any moment should V8 choose to change the internal functions.

Current function list

const methodNames = [
  'Abort',
  'AbortJS',
  'AbortCSAAssert',
  'ArraySpeciesProtector',
  'ClearFunctionFeedback',
  'ClearMegamorphicStubCache',
  'CompleteInobjectSlackTracking',
  'ConstructConsString',
  'ConstructDouble',
  'ConstructSlicedString',
  'DebugPrint',
  'DebugPrintPtr',
  'DebugTrace',
  'DebugTrackRetainingPath',
  'DeoptimizeFunction',
  'DeserializeWasmModule',
  'DisallowCodegenFromStrings',
  'DisallowWasmCodegen',
  'DisassembleFunction',
  'DynamicMapChecksEnabled',
  'EnableCodeLoggingForTesting',
  'EnsureFeedbackVectorForFunction',
  'FreezeWasmLazyCompilation',
  'GetCallable',
  'GetInitializerFunction',
  'GetOptimizationStatus',
  'GetUndetectable',
  'GetWasmExceptionId',
  'GetWasmExceptionValues',
  'GetWasmRecoveredTrapCount',
  'GlobalPrint',
  'HasDictionaryElements',
  'HasDoubleElements',
  'HasElementsInALargeObjectSpace',
  'HasFastElements',
  'HasFastProperties',
  'HasFixedBigInt64Elements',
  'HasFixedBigUint64Elements',
  'HasFixedFloat32Elements',
  'HasFixedFloat64Elements',
  'HasFixedInt16Elements',
  'HasFixedInt32Elements',
  'HasFixedInt8Elements',
  'HasFixedUint16Elements',
  'HasFixedUint32Elements',
  'HasFixedUint8ClampedElements',
  'HasFixedUint8Elements',
  'HasHoleyElements',
  'HasObjectElements',
  'HasPackedElements',
  'HasSloppyArgumentsElements',
  'HasSmiElements',
  'HasSmiOrObjectElements',
  'HaveSameMap',
  'HeapObjectVerify',
  'ICsAreEnabled',
  'InYoungGeneration',
  'IsAsmWasmCode',
  'IsBeingInterpreted',
  'IsConcurrentRecompilationSupported',
  'IsLiftoffFunction',
  'IsThreadInWasm',
  'IsWasmCode',
  'IsWasmTrapHandlerEnabled',
  'RegexpHasBytecode',
  'RegexpHasNativeCode',
  'RegexpTypeTag',
  'MapIteratorProtector',
  'NeverOptimizeFunction',
  'NotifyContextDisposed',
  'OptimizeFunctionOnNextCall',
  'OptimizeOsr',
  'NewRegExpWithBacktrackLimit',
  'PrepareFunctionForOptimization',
  'PrintWithNameForAssert',
  'RunningInSimulator',
  'RuntimeEvaluateREPL',
  'SerializeDeserializeNow',
  'SerializeWasmModule',
  'SetAllocationTimeout',
  'SetForceSlowPath',
  'SetIteratorProtector',
  'SetWasmCompileControls',
  'SetWasmInstantiateControls',
  'SetWasmThreadsEnabled',
  'SimulateNewspaceFull',
  'StringIteratorProtector',
  'SystemBreak',
  'TraceEnter',
  'TraceExit',
  'TurbofanStaticAssert',
  'UnblockConcurrentRecompilation',
  'WasmGetNumberOfInstances',
  'WasmNumCodeSpaces',
  'WasmTierDownModule',
  'WasmTierUpFunction',
  'WasmTierUpModule',
  'WasmTraceEnter',
  'WasmTraceExit',
  'WasmTraceMemory',
  'DeoptimizeNow',
  // Strings
  'FlattenString',
  'GetSubstitution',
  'InternalizeString',
  'StringAdd',
  'StringBuilderConcat',
  'StringCharCodeAt',
  'StringEqual',
  'StringEscapeQuotes',
  'StringGreaterThan',
  'StringGreaterThanOrEqual',
  'StringIncludes',
  'StringIndexOf',
  'StringIndexOfUnchecked',
  'StringLastIndexOf',
  'StringLessThan',
  'StringLessThanOrEqual',
  'StringMaxLength',
  'StringReplaceOneCharWithString',
  'StringCompareSequence',
  'StringSubstring',
  'StringToArray',
  'StringTrim',
];