| 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | #ifndef RUNTIME_VM_SYMBOLS_H_ |
| 6 | #define RUNTIME_VM_SYMBOLS_H_ |
| 7 | |
| 8 | #include "vm/growable_array.h" |
| 9 | #include "vm/object.h" |
| 10 | #include "vm/snapshot_ids.h" |
| 11 | |
| 12 | namespace dart { |
| 13 | |
| 14 | // Forward declarations. |
| 15 | class Isolate; |
| 16 | class ObjectPointerVisitor; |
| 17 | |
| 18 | // One-character symbols are added implicitly. |
| 19 | #define PREDEFINED_SYMBOLS_LIST(V) \ |
| 20 | V(AbstractClassInstantiationError, "AbstractClassInstantiationError") \ |
| 21 | V(AllocateInvocationMirror, "_allocateInvocationMirror") \ |
| 22 | V(AllocateInvocationMirrorForClosure, "_allocateInvocationMirrorForClosure") \ |
| 23 | V(AnonymousClosure, "<anonymous closure>") \ |
| 24 | V(AnonymousSignature, "<anonymous signature>") \ |
| 25 | V(ApiError, "ApiError") \ |
| 26 | V(ArgDescVar, ":arg_desc") \ |
| 27 | V(ArgumentError, "ArgumentError") \ |
| 28 | V(AsFunctionInternal, "_asFunctionInternal") \ |
| 29 | V(AssertionError, "_AssertionError") \ |
| 30 | V(AssignIndexToken, "[]=") \ |
| 31 | V(AsyncCompleter, ":async_completer") \ |
| 32 | V(AsyncOperation, ":async_op") \ |
| 33 | V(AsyncStackTraceVar, ":async_stack_trace") \ |
| 34 | V(AsyncStarMoveNextHelper, "_asyncStarMoveNextHelper") \ |
| 35 | V(AwaitContextVar, ":await_ctx_var") \ |
| 36 | V(AwaitJumpVar, ":await_jump_var") \ |
| 37 | V(Bool, "bool") \ |
| 38 | V(BooleanExpression, "boolean expression") \ |
| 39 | V(BoundsCheckForPartialInstantiation, "_boundsCheckForPartialInstantiation") \ |
| 40 | V(ByteData, "ByteData") \ |
| 41 | V(ByteDataDot, "ByteData.") \ |
| 42 | V(ByteDataDot_view, "ByteData._view") \ |
| 43 | V(Bytecode, "Bytecode") \ |
| 44 | V(Call, "call") \ |
| 45 | V(Cancel, "cancel") \ |
| 46 | V(CastError, "_CastError") \ |
| 47 | V(CheckLoaded, "_checkLoaded") \ |
| 48 | V(Class, "Class") \ |
| 49 | V(ClassID, "ClassID") \ |
| 50 | V(ClearAsyncThreadStackTrace, "_clearAsyncThreadStackTrace") \ |
| 51 | V(ClosureData, "ClosureData") \ |
| 52 | V(ClosureParameter, ":closure") \ |
| 53 | V(Code, "Code") \ |
| 54 | V(CodeSourceMap, "CodeSourceMap") \ |
| 55 | V(ColonMatcher, ":matcher") \ |
| 56 | V(CommaSpace, ", ") \ |
| 57 | V(Completer, "Completer") \ |
| 58 | V(CompleterFuture, "future") \ |
| 59 | V(CompleterGetFuture, "get:future") \ |
| 60 | V(CompleterSyncConstructor, "Completer.sync") \ |
| 61 | V(CompressedStackMaps, "CompressedStackMaps") \ |
| 62 | V(ConstructorStacktracePrefix, "new ") \ |
| 63 | V(Context, "Context") \ |
| 64 | V(ContextScope, "ContextScope") \ |
| 65 | V(Controller, ":controller") \ |
| 66 | V(ControllerStream, ":controller_stream") \ |
| 67 | V(Current, "current") \ |
| 68 | V(CurrentContextVar, ":current_context_var") \ |
| 69 | V(CyclicInitializationError, "CyclicInitializationError") \ |
| 70 | V(LateInitializationError, "_LateInitializationError") \ |
| 71 | V(DartAsync, "dart:async") \ |
| 72 | V(DartCollection, "dart:collection") \ |
| 73 | V(DartCore, "dart:core") \ |
| 74 | V(DartDeveloper, "dart:developer") \ |
| 75 | V(DartDeveloperCausalAsyncStacks, "dart.developer.causal_async_stacks") \ |
| 76 | V(DartDeveloperTimeline, "dart.developer.timeline") \ |
| 77 | V(DartExtensionScheme, "dart-ext:") \ |
| 78 | V(DartFfi, "dart:ffi") \ |
| 79 | V(DartFfiLibName, "ffi") \ |
| 80 | V(DartWasm, "dart:wasm") \ |
| 81 | V(DartWasmLibName, "wasm") \ |
| 82 | V(DartLibraryWasm, "dart.library.wasm") \ |
| 83 | V(DartIOLibName, "dart.io") \ |
| 84 | V(DartInternal, "dart:_internal") \ |
| 85 | V(DartIsVM, "dart.isVM") \ |
| 86 | V(DartIsolate, "dart:isolate") \ |
| 87 | V(DartLibrary, "dart.library.") \ |
| 88 | V(DartLibraryFfi, "dart.library.ffi") \ |
| 89 | V(DartLibraryMirrors, "dart.library.mirrors") \ |
| 90 | V(DartMirrors, "dart:mirrors") \ |
| 91 | V(DartNativeWrappers, "dart:nativewrappers") \ |
| 92 | V(DartNativeWrappersLibName, "nativewrappers") \ |
| 93 | V(DartScheme, "dart:") \ |
| 94 | V(DartSchemePrivate, "dart:_") \ |
| 95 | V(DartTypedData, "dart:typed_data") \ |
| 96 | V(DartVMProduct, "dart.vm.product") \ |
| 97 | V(DartVMService, "dart:_vmservice") \ |
| 98 | V(DartVMServiceIO, "dart:vmservice_io") \ |
| 99 | V(DebugClassName, "#DebugClass") \ |
| 100 | V(DebugProcedureName, ":Eval") \ |
| 101 | V(Default, "Default") \ |
| 102 | V(DefaultLabel, ":L") \ |
| 103 | V(DotCreate, "._create") \ |
| 104 | V(DotRange, ".range") \ |
| 105 | V(DotUnder, "._") \ |
| 106 | V(DotValue, ".value") \ |
| 107 | V(DotWithType, "._withType") \ |
| 108 | V(Double, "double") \ |
| 109 | V(Dynamic, "dynamic") \ |
| 110 | V(DynamicCall, "dyn:call") \ |
| 111 | V(DynamicPrefix, "dyn:") \ |
| 112 | V(EntryPointsTemp, ":entry_points_temp") \ |
| 113 | V(EqualOperator, "==") \ |
| 114 | V(Error, "Error") \ |
| 115 | V(EvalSourceUri, "evaluate:source") \ |
| 116 | V(EvaluateAssertion, "_evaluateAssertion") \ |
| 117 | V(ExceptionHandlers, "ExceptionHandlers") \ |
| 118 | V(ExceptionParameter, ":exception") \ |
| 119 | V(ExceptionVar, ":exception_var") \ |
| 120 | V(ExprTemp, ":expr_temp") \ |
| 121 | V(ExternalName, "ExternalName") \ |
| 122 | V(ExternalOneByteString, "_ExternalOneByteString") \ |
| 123 | V(ExternalTwoByteString, "_ExternalTwoByteString") \ |
| 124 | V(FactoryResult, "factory result") \ |
| 125 | V(FallThroughError, "FallThroughError") \ |
| 126 | V(FfiCallback, "_FfiCallback") \ |
| 127 | V(FfiDouble, "Double") \ |
| 128 | V(FfiDynamicLibrary, "DynamicLibrary") \ |
| 129 | V(FfiFloat, "Float") \ |
| 130 | V(FfiInt16, "Int16") \ |
| 131 | V(FfiInt32, "Int32") \ |
| 132 | V(FfiInt64, "Int64") \ |
| 133 | V(FfiInt8, "Int8") \ |
| 134 | V(FfiIntPtr, "IntPtr") \ |
| 135 | V(FfiNativeFunction, "NativeFunction") \ |
| 136 | V(FfiNativeType, "NativeType") \ |
| 137 | V(FfiPointer, "Pointer") \ |
| 138 | V(FfiTrampolineData, "FfiTrampolineData") \ |
| 139 | V(FfiUint16, "Uint16") \ |
| 140 | V(FfiUint32, "Uint32") \ |
| 141 | V(FfiUint64, "Uint64") \ |
| 142 | V(FfiUint8, "Uint8") \ |
| 143 | V(FfiVoid, "Void") \ |
| 144 | V(FfiHandle, "Handle") \ |
| 145 | V(Field, "Field") \ |
| 146 | V(FinallyRetVal, ":finally_ret_val") \ |
| 147 | V(FirstArg, "x") \ |
| 148 | V(Float32List, "Float32List") \ |
| 149 | V(Float32x4, "Float32x4") \ |
| 150 | V(Float32x4List, "Float32x4List") \ |
| 151 | V(Float64List, "Float64List") \ |
| 152 | V(Float64x2, "Float64x2") \ |
| 153 | V(Float64x2List, "Float64x2List") \ |
| 154 | V(FormatException, "FormatException") \ |
| 155 | V(ForwardingCorpse, "ForwardingCorpse") \ |
| 156 | V(FreeListElement, "FreeListElement") \ |
| 157 | V(Function, "Function") \ |
| 158 | V(FunctionResult, "function result") \ |
| 159 | V(FunctionTypeArgumentsVar, ":function_type_arguments_var") \ |
| 160 | V(Future, "Future") \ |
| 161 | V(FutureCatchError, "catchError") \ |
| 162 | V(FutureImpl, "_Future") \ |
| 163 | V(FutureMicrotask, "Future.microtask") \ |
| 164 | V(FutureOr, "FutureOr") \ |
| 165 | V(FutureThen, "then") \ |
| 166 | V(FutureValue, "Future.value") \ |
| 167 | V(Get, "get") \ |
| 168 | V(GetCall, "get:call") \ |
| 169 | V(GetLength, "get:length") \ |
| 170 | V(GetRuntimeType, "get:runtimeType") \ |
| 171 | V(GetterPrefix, "get:") \ |
| 172 | V(GreaterEqualOperator, ">=") \ |
| 173 | V(GrowRegExpStack, "_growRegExpStack") \ |
| 174 | V(HandleExposedException, "_handleExposedException") \ |
| 175 | V(HaveSameRuntimeType, "_haveSameRuntimeType") \ |
| 176 | V(ICData, "ICData") \ |
| 177 | V(Identical, "identical") \ |
| 178 | V(ImmutableMap, "_ImmutableMap") \ |
| 179 | V(ImmutableMapConstructor, "_ImmutableMap._create") \ |
| 180 | V(InTypeCast, " in type cast") \ |
| 181 | V(Index, "index") \ |
| 182 | V(IndexToken, "[]") \ |
| 183 | V(InitPrefix, "init:") \ |
| 184 | V(Instructions, "Instructions") \ |
| 185 | V(InstructionsSection, "InstructionsSection") \ |
| 186 | V(Int, "int") \ |
| 187 | V(Int16List, "Int16List") \ |
| 188 | V(Int32List, "Int32List") \ |
| 189 | V(Int32x4, "Int32x4") \ |
| 190 | V(Int32x4List, "Int32x4List") \ |
| 191 | V(Int64List, "Int64List") \ |
| 192 | V(Int8List, "Int8List") \ |
| 193 | V(IntegerDivisionByZeroException, "IntegerDivisionByZeroException") \ |
| 194 | V(Interpolate, "_interpolate") \ |
| 195 | V(InterpolateSingle, "_interpolateSingle") \ |
| 196 | V(InvocationMirror, "_InvocationMirror") \ |
| 197 | V(IsolateSpawnException, "IsolateSpawnException") \ |
| 198 | V(Iterator, "iterator") \ |
| 199 | V(IteratorParameter, ":iterator") \ |
| 200 | V(KernelProgramInfo, "KernelProgramInfo") \ |
| 201 | V(LanguageError, "LanguageError") \ |
| 202 | V(LeftShiftOperator, "<<") \ |
| 203 | V(Length, "length") \ |
| 204 | V(LessEqualOperator, "<=") \ |
| 205 | V(LibraryClass, "Library") \ |
| 206 | V(LibraryPrefix, "LibraryPrefix") \ |
| 207 | V(List, "List") \ |
| 208 | V(ListFactory, "List.") \ |
| 209 | V(ListFilledFactory, "List.filled") \ |
| 210 | V(ListLiteralFactory, "List._fromLiteral") \ |
| 211 | V(LoadLibrary, "_loadLibrary") \ |
| 212 | V(LocalVarDescriptors, "LocalVarDescriptors") \ |
| 213 | V(Map, "Map") \ |
| 214 | V(MapLiteralFactory, "Map._fromLiteral") \ |
| 215 | V(MegamorphicCache, "MegamorphicCache") \ |
| 216 | V(MonomorphicSmiableCall, "MonomorphicSmiableCall") \ |
| 217 | V(MoveNext, "moveNext") \ |
| 218 | V(Namespace, "Namespace") \ |
| 219 | V(Native, "native") \ |
| 220 | V(Never, "Never") \ |
| 221 | V(NoSuchMethod, "noSuchMethod") \ |
| 222 | V(NoSuchMethodError, "NoSuchMethodError") \ |
| 223 | V(NotInitialized, "<not initialized>") \ |
| 224 | V(NotNamed, "<not named>") \ |
| 225 | V(Null, "Null") \ |
| 226 | V(NullThrownError, "NullThrownError") \ |
| 227 | V(Number, "num") \ |
| 228 | V(Object, "Object") \ |
| 229 | V(ObjectPool, "ObjectPool") \ |
| 230 | V(OneByteString, "_OneByteString") \ |
| 231 | V(OptimizedOut, "<optimized out>") \ |
| 232 | V(OriginalParam, ":original:") \ |
| 233 | V(Other, "other") \ |
| 234 | V(OutOfMemoryError, "OutOfMemoryError") \ |
| 235 | V(PackageScheme, "package:") \ |
| 236 | V(ParameterTypeCheck, "ParameterTypeCheck") \ |
| 237 | V(Patch, "patch") \ |
| 238 | V(PatchClass, "PatchClass") \ |
| 239 | V(PcDescriptors, "PcDescriptors") \ |
| 240 | V(Pragma, "pragma") \ |
| 241 | V(PrependTypeArguments, "_prependTypeArguments") \ |
| 242 | V(QuoteIsNotASubtypeOf, "' is not a subtype of ") \ |
| 243 | V(RParenArrow, ") => ") \ |
| 244 | V(RangeError, "RangeError") \ |
| 245 | V(RedirectionData, "RedirectionData") \ |
| 246 | V(RegExp, "RegExp") \ |
| 247 | V(RightShiftOperator, ">>") \ |
| 248 | V(SavedTryContextVar, ":saved_try_context_var") \ |
| 249 | V(Script, "Script") \ |
| 250 | V(SecondArg, "y") \ |
| 251 | V(Set, "set") \ |
| 252 | V(SetAsyncThreadStackTrace, "_setAsyncThreadStackTrace") \ |
| 253 | V(SetterPrefix, "set:") \ |
| 254 | V(SignatureData, "SignatureData") \ |
| 255 | V(SingleTargetCache, "SingleTargetCache") \ |
| 256 | V(SizeOfStructField, "#sizeOf") \ |
| 257 | V(SpaceExtendsSpace, " extends ") \ |
| 258 | V(SpaceIsFromSpace, " is from ") \ |
| 259 | V(SpaceOfSpace, " of ") \ |
| 260 | V(SpaceWhereNewLine, " where\n") \ |
| 261 | V(StackOverflowError, "StackOverflowError") \ |
| 262 | V(StackTraceParameter, ":stack_trace") \ |
| 263 | V(StackTraceVar, ":stack_trace_var") \ |
| 264 | V(Stream, "stream") \ |
| 265 | V(StreamController, "StreamController") \ |
| 266 | V(StreamIterator, "StreamIterator") \ |
| 267 | V(StreamIteratorConstructor, "StreamIterator.") \ |
| 268 | V(StringBase, "_StringBase") \ |
| 269 | V(Struct, "Struct") \ |
| 270 | V(StructFromPointer, "#fromPointer") \ |
| 271 | V(SubtypeTestCache, "SubtypeTestCache") \ |
| 272 | V(LoadingUnit, "LoadingUnit") \ |
| 273 | V(SwitchExpr, ":switch_expr") \ |
| 274 | V(Symbol, "Symbol") \ |
| 275 | V(SymbolCtor, "Symbol.") \ |
| 276 | V(ThrowNew, "_throwNew") \ |
| 277 | V(ThrowNewInvocation, "_throwNewInvocation") \ |
| 278 | V(ThrowNewNullAssertion, "_throwNewNullAssertion") \ |
| 279 | V(TopLevel, "::") \ |
| 280 | V(TransferableTypedData, "TransferableTypedData") \ |
| 281 | V(TruncDivOperator, "~/") \ |
| 282 | V(TryFinallyReturnValue, ":try_finally_return_value") \ |
| 283 | V(TwoByteString, "_TwoByteString") \ |
| 284 | V(TwoSpaces, " ") \ |
| 285 | V(Type, "Type") \ |
| 286 | V(TypeArguments, "TypeArguments") \ |
| 287 | V(TypeArgumentsParameter, ":type_arguments") \ |
| 288 | V(TypeError, "_TypeError") \ |
| 289 | V(TypeQuote, "type '") \ |
| 290 | V(Uint16List, "Uint16List") \ |
| 291 | V(Uint32List, "Uint32List") \ |
| 292 | V(Uint64List, "Uint64List") \ |
| 293 | V(Uint8ClampedList, "Uint8ClampedList") \ |
| 294 | V(Uint8List, "Uint8List") \ |
| 295 | V(UnaryMinus, "unary-") \ |
| 296 | V(UnhandledException, "UnhandledException") \ |
| 297 | V(UnlinkedCall, "UnlinkedCall") \ |
| 298 | V(UnsafeCast, "unsafeCast") \ |
| 299 | V(UnsupportedError, "UnsupportedError") \ |
| 300 | V(UnwindError, "UnwindError") \ |
| 301 | V(Value, "value") \ |
| 302 | V(Values, "values") \ |
| 303 | V(WasmInt32, "Int32") \ |
| 304 | V(WasmInt64, "Int64") \ |
| 305 | V(WasmFloat, "Float") \ |
| 306 | V(WasmDouble, "Double") \ |
| 307 | V(WasmVoid, "Void") \ |
| 308 | V(YieldKw, "yield") \ |
| 309 | V(_AsyncAwaitCompleter, "_AsyncAwaitCompleter") \ |
| 310 | V(_AsyncAwaitCompleterConstructor, "_AsyncAwaitCompleter.") \ |
| 311 | V(_AsyncAwaitCompleterStart, "_AsyncAwaitCompleter.start") \ |
| 312 | V(_AsyncAwaitStart, "start") \ |
| 313 | V(_AsyncStarListenHelper, "_asyncStarListenHelper") \ |
| 314 | V(_AsyncStarStreamController, "_AsyncStarStreamController") \ |
| 315 | V(_AsyncStarStreamControllerConstructor, "_AsyncStarStreamController.") \ |
| 316 | V(_AsyncStreamController, "_AsyncStreamController") \ |
| 317 | V(_Awaiter, "_awaiter") \ |
| 318 | V(_BufferingStreamSubscription, "_BufferingStreamSubscription") \ |
| 319 | V(_ByteBuffer, "_ByteBuffer") \ |
| 320 | V(_ByteBufferDot_New, "_ByteBuffer._New") \ |
| 321 | V(_ByteDataView, "_ByteDataView") \ |
| 322 | V(_CapabilityImpl, "_CapabilityImpl") \ |
| 323 | V(_ClassMirror, "_ClassMirror") \ |
| 324 | V(_Closure, "_Closure") \ |
| 325 | V(_ClosureCall, "_Closure.call") \ |
| 326 | V(_CombinatorMirror, "_CombinatorMirror") \ |
| 327 | V(_CompileTimeError, "_CompileTimeError") \ |
| 328 | V(_CompleteOnAsyncReturn, "_completeOnAsyncReturn") \ |
| 329 | V(_ControllerSubscription, "_ControllerSubscription") \ |
| 330 | V(_DeletedEnumPrefix, "Deleted enum value from ") \ |
| 331 | V(_DeletedEnumSentinel, "_deleted_enum_sentinel") \ |
| 332 | V(_Double, "_Double") \ |
| 333 | V(_ExternalFloat32Array, "_ExternalFloat32Array") \ |
| 334 | V(_ExternalFloat32x4Array, "_ExternalFloat32x4Array") \ |
| 335 | V(_ExternalFloat64Array, "_ExternalFloat64Array") \ |
| 336 | V(_ExternalFloat64x2Array, "_ExternalFloat64x2Array") \ |
| 337 | V(_ExternalInt16Array, "_ExternalInt16Array") \ |
| 338 | V(_ExternalInt32Array, "_ExternalInt32Array") \ |
| 339 | V(_ExternalInt32x4Array, "_ExternalInt32x4Array") \ |
| 340 | V(_ExternalInt64Array, "_ExternalInt64Array") \ |
| 341 | V(_ExternalInt8Array, "_ExternalInt8Array") \ |
| 342 | V(_ExternalUint16Array, "_ExternalUint16Array") \ |
| 343 | V(_ExternalUint32Array, "_ExternalUint32Array") \ |
| 344 | V(_ExternalUint64Array, "_ExternalUint64Array") \ |
| 345 | V(_ExternalUint8Array, "_ExternalUint8Array") \ |
| 346 | V(_ExternalUint8ClampedArray, "_ExternalUint8ClampedArray") \ |
| 347 | V(_Float32ArrayFactory, "Float32List.") \ |
| 348 | V(_Float32ArrayView, "_Float32ArrayView") \ |
| 349 | V(_Float32List, "_Float32List") \ |
| 350 | V(_Float32x4, "_Float32x4") \ |
| 351 | V(_Float32x4ArrayFactory, "Float32x4List.") \ |
| 352 | V(_Float32x4ArrayView, "_Float32x4ArrayView") \ |
| 353 | V(_Float32x4List, "_Float32x4List") \ |
| 354 | V(_Float64ArrayFactory, "Float64List.") \ |
| 355 | V(_Float64ArrayView, "_Float64ArrayView") \ |
| 356 | V(_Float64List, "_Float64List") \ |
| 357 | V(_Float64x2, "_Float64x2") \ |
| 358 | V(_Float64x2ArrayFactory, "Float64x2List.") \ |
| 359 | V(_Float64x2ArrayView, "_Float64x2ArrayView") \ |
| 360 | V(_Float64x2List, "_Float64x2List") \ |
| 361 | V(_FunctionTypeMirror, "_FunctionTypeMirror") \ |
| 362 | V(_FutureListener, "_FutureListener") \ |
| 363 | V(_GrowableList, "_GrowableList") \ |
| 364 | V(_GrowableListFactory, "_GrowableList.") \ |
| 365 | V(_GrowableListFilledFactory, "_GrowableList.filled") \ |
| 366 | V(_GrowableListGenerateFactory, "_GrowableList.generate") \ |
| 367 | V(_GrowableListWithData, "_GrowableList._withData") \ |
| 368 | V(_ImmutableList, "_ImmutableList") \ |
| 369 | V(_Int16ArrayFactory, "Int16List.") \ |
| 370 | V(_Int16ArrayView, "_Int16ArrayView") \ |
| 371 | V(_Int16List, "_Int16List") \ |
| 372 | V(_Int32ArrayFactory, "Int32List.") \ |
| 373 | V(_Int32ArrayView, "_Int32ArrayView") \ |
| 374 | V(_Int32List, "_Int32List") \ |
| 375 | V(_Int32x4, "_Int32x4") \ |
| 376 | V(_Int32x4ArrayFactory, "Int32x4List.") \ |
| 377 | V(_Int32x4ArrayView, "_Int32x4ArrayView") \ |
| 378 | V(_Int32x4List, "_Int32x4List") \ |
| 379 | V(_Int64ArrayFactory, "Int64List.") \ |
| 380 | V(_Int64ArrayView, "_Int64ArrayView") \ |
| 381 | V(_Int64List, "_Int64List") \ |
| 382 | V(_Int8ArrayFactory, "Int8List.") \ |
| 383 | V(_Int8ArrayView, "_Int8ArrayView") \ |
| 384 | V(_Int8List, "_Int8List") \ |
| 385 | V(_IntegerImplementation, "_IntegerImplementation") \ |
| 386 | V(_IsolateMirror, "_IsolateMirror") \ |
| 387 | V(_LibraryDependencyMirror, "_LibraryDependencyMirror") \ |
| 388 | V(_LibraryMirror, "_LibraryMirror") \ |
| 389 | V(_LibraryPrefix, "_LibraryPrefix") \ |
| 390 | V(_LinkedHashMap, "_InternalLinkedHashMap") \ |
| 391 | V(_LinkedHashSet, "_CompactLinkedHashSet") \ |
| 392 | V(_List, "_List") \ |
| 393 | V(_ListFactory, "_List.") \ |
| 394 | V(_ListFilledFactory, "_List.filled") \ |
| 395 | V(_ListGenerateFactory, "_List.generate") \ |
| 396 | V(_MethodMirror, "_MethodMirror") \ |
| 397 | V(_Mint, "_Mint") \ |
| 398 | V(_MirrorReference, "_MirrorReference") \ |
| 399 | V(_MirrorSystem, "_MirrorSystem") \ |
| 400 | V(_ParameterMirror, "_ParameterMirror") \ |
| 401 | V(_Random, "_Random") \ |
| 402 | V(_RawReceivePortImpl, "_RawReceivePortImpl") \ |
| 403 | V(_RegExp, "_RegExp") \ |
| 404 | V(_SendPortImpl, "_SendPortImpl") \ |
| 405 | V(_Smi, "_Smi") \ |
| 406 | V(_SourceLocation, "_SourceLocation") \ |
| 407 | V(_SpecialTypeMirror, "_SpecialTypeMirror") \ |
| 408 | V(_StackTrace, "_StackTrace") \ |
| 409 | V(_StreamController, "_StreamController") \ |
| 410 | V(_StreamImpl, "_StreamImpl") \ |
| 411 | V(_StreamIterator, "_StreamIterator") \ |
| 412 | V(_String, "String") \ |
| 413 | V(_SyncIterable, "_SyncIterable") \ |
| 414 | V(_SyncIterableConstructor, "_SyncIterable.") \ |
| 415 | V(_SyncIterator, "_SyncIterator") \ |
| 416 | V(_TransferableTypedDataImpl, "_TransferableTypedDataImpl") \ |
| 417 | V(_Type, "_Type") \ |
| 418 | V(_TypeParameter, "_TypeParameter") \ |
| 419 | V(_TypeRef, "_TypeRef") \ |
| 420 | V(_TypeVariableMirror, "_TypeVariableMirror") \ |
| 421 | V(_TypedefMirror, "_TypedefMirror") \ |
| 422 | V(_Uint16ArrayFactory, "Uint16List.") \ |
| 423 | V(_Uint16ArrayView, "_Uint16ArrayView") \ |
| 424 | V(_Uint16List, "_Uint16List") \ |
| 425 | V(_Uint32ArrayFactory, "Uint32List.") \ |
| 426 | V(_Uint32ArrayView, "_Uint32ArrayView") \ |
| 427 | V(_Uint32List, "_Uint32List") \ |
| 428 | V(_Uint64ArrayFactory, "Uint64List.") \ |
| 429 | V(_Uint64ArrayView, "_Uint64ArrayView") \ |
| 430 | V(_Uint64List, "_Uint64List") \ |
| 431 | V(_Uint8ArrayFactory, "Uint8List.") \ |
| 432 | V(_Uint8ArrayView, "_Uint8ArrayView") \ |
| 433 | V(_Uint8ClampedArrayFactory, "Uint8ClampedList.") \ |
| 434 | V(_Uint8ClampedArrayView, "_Uint8ClampedArrayView") \ |
| 435 | V(_Uint8ClampedList, "_Uint8ClampedList") \ |
| 436 | V(_Uint8List, "_Uint8List") \ |
| 437 | V(_UserTag, "_UserTag") \ |
| 438 | V(_Utf8Decoder, "_Utf8Decoder") \ |
| 439 | V(_VariableMirror, "_VariableMirror") \ |
| 440 | V(_WeakProperty, "_WeakProperty") \ |
| 441 | V(_classRangeCheck, "_classRangeCheck") \ |
| 442 | V(_current, "_current") \ |
| 443 | V(_ensureScheduleImmediate, "_ensureScheduleImmediate") \ |
| 444 | V(_future, "_future") \ |
| 445 | V(_get, "_get") \ |
| 446 | V(_handleMessage, "_handleMessage") \ |
| 447 | V(_instanceOf, "_instanceOf") \ |
| 448 | V(_lookupHandler, "_lookupHandler") \ |
| 449 | V(_name, "_name") \ |
| 450 | V(_onData, "_onData") \ |
| 451 | V(_rehashObjects, "_rehashObjects") \ |
| 452 | V(_resultOrListeners, "_resultOrListeners") \ |
| 453 | V(_runExtension, "_runExtension") \ |
| 454 | V(_runPendingImmediateCallback, "_runPendingImmediateCallback") \ |
| 455 | V(_scanFlags, "_scanFlags") \ |
| 456 | V(_setLength, "_setLength") \ |
| 457 | V(_simpleInstanceOf, "_simpleInstanceOf") \ |
| 458 | V(_simpleInstanceOfFalse, "_simpleInstanceOfFalse") \ |
| 459 | V(_simpleInstanceOfTrue, "_simpleInstanceOfTrue") \ |
| 460 | V(_stackTrace, "_stackTrace") \ |
| 461 | V(_state, "_state") \ |
| 462 | V(_stateData, "_stateData") \ |
| 463 | V(_varData, "_varData") \ |
| 464 | V(_wordCharacterMap, "_wordCharacterMap") \ |
| 465 | V(add, "add") \ |
| 466 | V(callback, "callback") \ |
| 467 | V(capture_length, ":capture_length") \ |
| 468 | V(capture_start_index, ":capture_start_index") \ |
| 469 | V(char_in_capture, ":char_in_capture") \ |
| 470 | V(char_in_match, ":char_in_match") \ |
| 471 | V(clear, "clear") \ |
| 472 | V(controller, "controller") \ |
| 473 | V(current_character, ":current_character") \ |
| 474 | V(current_position, ":current_position") \ |
| 475 | V(getID, "getID") \ |
| 476 | V(hashCode, "get:hashCode") \ |
| 477 | V(identityHashCode, "identityHashCode") \ |
| 478 | V(index_temp, ":index_temp") \ |
| 479 | V(isPaused, "isPaused") \ |
| 480 | V(isSync, "isSync") \ |
| 481 | V(last, "last") \ |
| 482 | V(match_end_index, ":match_end_index") \ |
| 483 | V(match_start_index, ":match_start_index") \ |
| 484 | V(name, "name") \ |
| 485 | V(null, "null") \ |
| 486 | V(options, "options") \ |
| 487 | V(position_registers, ":position_registers") \ |
| 488 | V(print, "print") \ |
| 489 | V(removeLast, "removeLast") \ |
| 490 | V(result, ":result") \ |
| 491 | V(stack, ":stack") \ |
| 492 | V(stack_pointer, ":stack_pointer") \ |
| 493 | V(start_index_param, ":start_index_param") \ |
| 494 | V(string_param, ":string_param") \ |
| 495 | V(string_param_length, ":string_param_length") \ |
| 496 | V(timeout, "timeout") \ |
| 497 | V(toString, "toString") \ |
| 498 | V(vm_prefer_inline, "vm:prefer-inline") \ |
| 499 | V(vm_entry_point, "vm:entry-point") \ |
| 500 | V(vm_exact_result_type, "vm:exact-result-type") \ |
| 501 | V(vm_inferred_type_metadata, "vm.inferred-type.metadata") \ |
| 502 | V(vm_never_inline, "vm:never-inline") \ |
| 503 | V(vm_non_nullable_result_type, "vm:non-nullable-result-type") \ |
| 504 | V(vm_trace_entrypoints, "vm:testing.unsafe.trace-entrypoints-fn") \ |
| 505 | V(vm_procedure_attributes_metadata, "vm.procedure-attributes.metadata") |
| 506 | |
| 507 | // Contains a list of frequently used strings in a canonicalized form. This |
| 508 | // list is kept in the vm_isolate in order to share the copy across isolates |
| 509 | // without having to maintain copies in each isolate. |
| 510 | class Symbols : public AllStatic { |
| 511 | public: |
| 512 | enum { kMaxOneCharCodeSymbol = 0xFF }; |
| 513 | |
| 514 | // List of strings that are pre created in the vm isolate. |
| 515 | enum SymbolId { |
| 516 | // clang-format off |
| 517 | kIllegal = 0, |
| 518 | |
| 519 | #define DEFINE_SYMBOL_INDEX(symbol, literal) k##symbol##Id, |
| 520 | PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_INDEX) |
| 521 | #undef DEFINE_SYMBOL_INDEX |
| 522 | |
| 523 | kTokenTableStart, // First token at kTokenTableStart + 1. |
| 524 | |
| 525 | #define DEFINE_TOKEN_SYMBOL_INDEX(t, s, p, a) t##Id, |
| 526 | DART_TOKEN_LIST(DEFINE_TOKEN_SYMBOL_INDEX) DART_KEYWORD_LIST( |
| 527 | DEFINE_TOKEN_SYMBOL_INDEX) |
| 528 | #undef DEFINE_TOKEN_SYMBOL_INDEX |
| 529 | |
| 530 | kNullCharId, // One char code symbol starts here and takes up 256 entries. |
| 531 | kMaxPredefinedId = kNullCharId + kMaxOneCharCodeSymbol + 1, |
| 532 | // clang-format on |
| 533 | }; |
| 534 | |
| 535 | // Number of one character symbols being predefined in the predefined_ array. |
| 536 | static const int kNumberOfOneCharCodeSymbols = |
| 537 | (kMaxPredefinedId - kNullCharId); |
| 538 | |
| 539 | // Offset of Null character which is the predefined character symbol. |
| 540 | static const int kNullCharCodeSymbolOffset = 0; |
| 541 | |
| 542 | static const String& Symbol(intptr_t index) { |
| 543 | ASSERT((index > kIllegal) && (index < kMaxPredefinedId)); |
| 544 | return *(symbol_handles_[index]); |
| 545 | } |
| 546 | |
| 547 | // Access methods for one byte character symbols stored in the vm isolate. |
| 548 | static const String& Dot() { return *(symbol_handles_[kNullCharId + '.']); } |
| 549 | static const String& Equals() { |
| 550 | return *(symbol_handles_[kNullCharId + '=']); |
| 551 | } |
| 552 | static const String& Plus() { return *(symbol_handles_[kNullCharId + '+']); } |
| 553 | static const String& Minus() { return *(symbol_handles_[kNullCharId + '-']); } |
| 554 | static const String& BitOr() { return *(symbol_handles_[kNullCharId + '|']); } |
| 555 | static const String& BitAnd() { |
| 556 | return *(symbol_handles_[kNullCharId + '&']); |
| 557 | } |
| 558 | static const String& LAngleBracket() { |
| 559 | return *(symbol_handles_[kNullCharId + '<']); |
| 560 | } |
| 561 | static const String& RAngleBracket() { |
| 562 | return *(symbol_handles_[kNullCharId + '>']); |
| 563 | } |
| 564 | static const String& LParen() { |
| 565 | return *(symbol_handles_[kNullCharId + '(']); |
| 566 | } |
| 567 | static const String& RParen() { |
| 568 | return *(symbol_handles_[kNullCharId + ')']); |
| 569 | } |
| 570 | static const String& LBracket() { |
| 571 | return *(symbol_handles_[kNullCharId + '[']); |
| 572 | } |
| 573 | static const String& RBracket() { |
| 574 | return *(symbol_handles_[kNullCharId + ']']); |
| 575 | } |
| 576 | static const String& LBrace() { |
| 577 | return *(symbol_handles_[kNullCharId + '{']); |
| 578 | } |
| 579 | static const String& RBrace() { |
| 580 | return *(symbol_handles_[kNullCharId + '}']); |
| 581 | } |
| 582 | static const String& Blank() { return *(symbol_handles_[kNullCharId + ' ']); } |
| 583 | static const String& Dollar() { |
| 584 | return *(symbol_handles_[kNullCharId + '$']); |
| 585 | } |
| 586 | static const String& NewLine() { |
| 587 | return *(symbol_handles_[kNullCharId + '\n']); |
| 588 | } |
| 589 | static const String& DoubleQuote() { |
| 590 | return *(symbol_handles_[kNullCharId + '"']); |
| 591 | } |
| 592 | static const String& SingleQuote() { |
| 593 | return *(symbol_handles_[kNullCharId + '\'']); |
| 594 | } |
| 595 | static const String& LowercaseR() { |
| 596 | return *(symbol_handles_[kNullCharId + 'r']); |
| 597 | } |
| 598 | static const String& Dash() { return *(symbol_handles_[kNullCharId + '-']); } |
| 599 | static const String& Ampersand() { |
| 600 | return *(symbol_handles_[kNullCharId + '&']); |
| 601 | } |
| 602 | static const String& Backtick() { |
| 603 | return *(symbol_handles_[kNullCharId + '`']); |
| 604 | } |
| 605 | static const String& Slash() { return *(symbol_handles_[kNullCharId + '/']); } |
| 606 | static const String& At() { return *(symbol_handles_[kNullCharId + '@']); } |
| 607 | static const String& HashMark() { |
| 608 | return *(symbol_handles_[kNullCharId + '#']); |
| 609 | } |
| 610 | static const String& Semicolon() { |
| 611 | return *(symbol_handles_[kNullCharId + ';']); |
| 612 | } |
| 613 | static const String& Star() { return *(symbol_handles_[kNullCharId + '*']); } |
| 614 | static const String& Percent() { |
| 615 | return *(symbol_handles_[kNullCharId + '%']); |
| 616 | } |
| 617 | static const String& QuestionMark() { |
| 618 | return *(symbol_handles_[kNullCharId + '?']); |
| 619 | } |
| 620 | static const String& Caret() { return *(symbol_handles_[kNullCharId + '^']); } |
| 621 | static const String& Tilde() { return *(symbol_handles_[kNullCharId + '~']); } |
| 622 | |
| 623 | static const String& Empty() { return *(symbol_handles_[kTokenTableStart]); } |
| 624 | static const String& False() { return *(symbol_handles_[kFALSEId]); } |
| 625 | static const String& Library() { return *(symbol_handles_[kLIBRARYId]); } |
| 626 | static const String& Super() { return *(symbol_handles_[kSUPERId]); } |
| 627 | static const String& This() { return *(symbol_handles_[kTHISId]); } |
| 628 | static const String& True() { return *(symbol_handles_[kTRUEId]); } |
| 629 | static const String& Void() { return *(symbol_handles_[kVOIDId]); } |
| 630 | |
| 631 | // Access methods for symbol handles stored in the vm isolate for predefined |
| 632 | // symbols. |
| 633 | #define DEFINE_SYMBOL_HANDLE_ACCESSOR(symbol, literal) \ |
| 634 | static const String& symbol() { return *(symbol_handles_[k##symbol##Id]); } |
| 635 | PREDEFINED_SYMBOLS_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) |
| 636 | #undef DEFINE_SYMBOL_HANDLE_ACCESSOR |
| 637 | |
| 638 | // Access methods for symbol handles stored in the vm isolate for keywords. |
| 639 | #define DEFINE_SYMBOL_HANDLE_ACCESSOR(t, s, p, a) \ |
| 640 | static const String& t() { return *(symbol_handles_[t##Id]); } |
| 641 | DART_TOKEN_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) |
| 642 | DART_KEYWORD_LIST(DEFINE_SYMBOL_HANDLE_ACCESSOR) |
| 643 | #undef DEFINE_SYMBOL_HANDLE_ACCESSOR |
| 644 | |
| 645 | // Get symbol for scanner token. |
| 646 | static const String& Token(Token::Kind token); |
| 647 | |
| 648 | // Initialize frequently used symbols in the vm isolate. |
| 649 | static void Init(Isolate* isolate); |
| 650 | static void InitFromSnapshot(Isolate* isolate); |
| 651 | |
| 652 | // Initialize and setup a symbol table for the isolate. |
| 653 | static void SetupSymbolTable(Isolate* isolate); |
| 654 | |
| 655 | // Treat the symbol table as weak and collect garbage. |
| 656 | static void Compact(); |
| 657 | |
| 658 | // Creates a Symbol given a C string that is assumed to contain |
| 659 | // UTF-8 encoded characters and '\0' is considered a termination character. |
| 660 | // TODO(7123) - Rename this to FromCString(....). |
| 661 | static StringPtr New(Thread* thread, const char* cstr) { |
| 662 | return New(thread, cstr, strlen(cstr)); |
| 663 | } |
| 664 | static StringPtr New(Thread* thread, const char* cstr, intptr_t length); |
| 665 | |
| 666 | // Creates a new Symbol from an array of UTF-8 encoded characters. |
| 667 | static StringPtr FromUTF8(Thread* thread, |
| 668 | const uint8_t* utf8_array, |
| 669 | intptr_t len); |
| 670 | |
| 671 | // Creates a new Symbol from an array of Latin-1 encoded characters. |
| 672 | static StringPtr FromLatin1(Thread* thread, |
| 673 | const uint8_t* latin1_array, |
| 674 | intptr_t len); |
| 675 | |
| 676 | // Creates a new Symbol from an array of UTF-16 encoded characters. |
| 677 | static StringPtr FromUTF16(Thread* thread, |
| 678 | const uint16_t* utf16_array, |
| 679 | intptr_t len); |
| 680 | |
| 681 | // Creates a new Symbol from an array of UTF-32 encoded characters. |
| 682 | static StringPtr FromUTF32(Thread* thread, |
| 683 | const int32_t* utf32_array, |
| 684 | intptr_t len); |
| 685 | |
| 686 | static StringPtr New(Thread* thread, const String& str); |
| 687 | static StringPtr New(Thread* thread, |
| 688 | const String& str, |
| 689 | intptr_t begin_index, |
| 690 | intptr_t length); |
| 691 | |
| 692 | static StringPtr NewFormatted(Thread* thread, const char* format, ...) |
| 693 | PRINTF_ATTRIBUTE(2, 3); |
| 694 | static StringPtr NewFormattedV(Thread* thread, |
| 695 | const char* format, |
| 696 | va_list args); |
| 697 | |
| 698 | static StringPtr FromConcat(Thread* thread, |
| 699 | const String& str1, |
| 700 | const String& str2); |
| 701 | |
| 702 | static StringPtr FromConcatAll( |
| 703 | Thread* thread, |
| 704 | const GrowableHandlePtrArray<const String>& strs); |
| 705 | |
| 706 | static StringPtr FromGet(Thread* thread, const String& str); |
| 707 | static StringPtr FromSet(Thread* thread, const String& str); |
| 708 | static StringPtr FromDot(Thread* thread, const String& str); |
| 709 | |
| 710 | // Returns char* of predefined symbol. |
| 711 | static const char* Name(SymbolId symbol); |
| 712 | |
| 713 | static StringPtr FromCharCode(Thread* thread, int32_t char_code); |
| 714 | |
| 715 | static StringPtr* PredefinedAddress() { |
| 716 | return reinterpret_cast<StringPtr*>(&predefined_); |
| 717 | } |
| 718 | |
| 719 | static void DumpStats(Isolate* isolate); |
| 720 | static void DumpTable(Isolate* isolate); |
| 721 | |
| 722 | // Returns Symbol::Null if no symbol is found. |
| 723 | template <typename StringType> |
| 724 | static StringPtr Lookup(Thread* thread, const StringType& str); |
| 725 | |
| 726 | // Returns Symbol::Null if no symbol is found. |
| 727 | static StringPtr LookupFromConcat(Thread* thread, |
| 728 | const String& str1, |
| 729 | const String& str2); |
| 730 | |
| 731 | static StringPtr LookupFromGet(Thread* thread, const String& str); |
| 732 | static StringPtr LookupFromSet(Thread* thread, const String& str); |
| 733 | static StringPtr LookupFromDot(Thread* thread, const String& str); |
| 734 | |
| 735 | static void GetStats(Isolate* isolate, intptr_t* size, intptr_t* capacity); |
| 736 | |
| 737 | private: |
| 738 | enum { kInitialVMIsolateSymtabSize = 1024, kInitialSymtabSize = 2048 }; |
| 739 | |
| 740 | template <typename StringType> |
| 741 | static StringPtr NewSymbol(Thread* thread, const StringType& str); |
| 742 | |
| 743 | static intptr_t LookupPredefinedSymbol(ObjectPtr obj); |
| 744 | static ObjectPtr GetPredefinedSymbol(intptr_t object_id); |
| 745 | static bool IsPredefinedSymbolId(intptr_t object_id) { |
| 746 | return (object_id >= kMaxPredefinedObjectIds && |
| 747 | object_id < (kMaxPredefinedObjectIds + kMaxPredefinedId)); |
| 748 | } |
| 749 | |
| 750 | // List of Latin1 characters stored in the vm isolate as symbols |
| 751 | // in order to make Symbols::FromCharCode fast. This structure is |
| 752 | // used in generated dart code for direct access to these objects. |
| 753 | static StringPtr predefined_[kNumberOfOneCharCodeSymbols]; |
| 754 | |
| 755 | // List of handles for predefined symbols. |
| 756 | static String* symbol_handles_[kMaxPredefinedId]; |
| 757 | |
| 758 | friend class Dart; |
| 759 | friend class String; |
| 760 | friend class SnapshotReader; |
| 761 | friend class SnapshotWriter; |
| 762 | friend class Serializer; |
| 763 | friend class Deserializer; |
| 764 | friend class ApiMessageReader; |
| 765 | |
| 766 | DISALLOW_COPY_AND_ASSIGN(Symbols); |
| 767 | }; |
| 768 | |
| 769 | } // namespace dart |
| 770 | |
| 771 | #endif // RUNTIME_VM_SYMBOLS_H_ |
| 772 | |