Snapshot questions

46 views
Skip to first unread message

Ronald Fenner

unread,
Jun 1, 2024, 12:43:47 AMJun 1
to v8-dev
I'm working on code to take a snapshot of v8 isolate and context and while I have ogtten snapshotting working with function templates, I'm running into a problem with tryingt otest snapshotting a js object wrapped with a cpp class.
When i snapshot the object seems to be getting CGed as the wek ref callback gets called and thus the object is deleted and the serializer function is never called for it.

Not sure how to keep the obj alive for the snapshot the test js code is

test('test');
test2('test2');
let snapObj = new TestSnapObject();
snapObj.value = 100;
The object does get created and i can se the value change from the cpp side.

How would i need to keep it alive so it gets snapshotted.

Another question if i hold a global the context in a class should i have to cleat it for snapshotting? I have tried to hold but get an error where as if i clear it will snapshot ok.
When I hold i get this error

global handle not serialized: 0x1248082824cd: [NativeContext] in OldSpace
 - map: 0x1248082824a5 <Map(NATIVE_CONTEXT_TYPE)>
 - type: NATIVE_CONTEXT_TYPE
 - scope_info: 0x1248080061d5 <ScopeInfo SCRIPT_SCOPE>
 - previous: 0
 - native_context: 0x1248082824cd <NativeContext[287]>
 - extension: 0x1248082936d1 <JSGlobalObject>
 - length: 287
 - elements:
           0: 0x1248080061d5 <ScopeInfo SCRIPT_SCOPE>
           1: 0
           2: 0x1248082936d1 <JSGlobalObject>
           3: 0x124808282471 <JSGlobalProxy>
           4: 0x12480820f2a5 <Other heap object (EMBEDDER_DATA_ARRAY_TYPE)>
           5: 0x124808000069 <undefined>
           6: 0x12480828d929 <JSFunction next (sfi = 0x1248080f4a31)>
           7: 0x12480828d945 <JSFunction next (sfi = 0x1248080f4a5d)>
           8: 0x12480828b099 <JSFunction apply (sfi = 0x1248080fa93d)>
           9: 0x12480828af49 <JSFunction construct (sfi = 0x1248080fa969)>
          10: 0x12480828a065 <JSFunction then (sfi = 0x1248080f7161)>
          11: 0x124808282ce9 <JSFunction apply (sfi = 0x1248080f51c1)>
          12: 0x124808284519 <JSFunction Uint8Array (sfi = 0x1248080f9c2d)>
          13: 0x124808284685 <JSFunction Int8Array (sfi = 0x1248080f9c59)>
          14: 0x124808289771 <JSFunction Uint16Array (sfi = 0x1248080f9c85)>
          15: 0x12480828ad1d <JSFunction Int16Array (sfi = 0x1248080f9cb1)>
          16: 0x12480828a2d9 <JSFunction Uint32Array (sfi = 0x1248080f9cdd)>
          17: 0x1248082851e1 <JSFunction Int32Array (sfi = 0x1248080f9d09)>
          18: 0x1248082898dd <JSFunction Float32Array (sfi = 0x1248080f9d35)>
          19: 0x12480828abb1 <JSFunction Float64Array (sfi = 0x1248080f9d61)>
          20: 0x1248082843ad <JSFunction Uint8ClampedArray (sfi = 0x1248080f9d8d)>
          21: 0x124808284aa1 <JSFunction BigUint64Array (sfi = 0x1248080f9db9)>
          22: 0x12480828aa45 <JSFunction BigInt64Array (sfi = 0x1248080f9de5)>
          23: 0x124808000069 <undefined>
          24: 0x12480828d961 <Map[72](RAB_GSAB_UINT8ELEMENTS)>
          25: 0x12480828d989 <Map[72](RAB_GSAB_INT8ELEMENTS)>
          26: 0x12480828d9b1 <Map[72](RAB_GSAB_UINT16ELEMENTS)>
          27: 0x12480828d9d9 <Map[72](RAB_GSAB_INT16ELEMENTS)>
          28: 0x12480828da01 <Map[72](RAB_GSAB_UINT32ELEMENTS)>
          29: 0x12480828da29 <Map[72](RAB_GSAB_INT32ELEMENTS)>
          30: 0x12480828da51 <Map[72](RAB_GSAB_FLOAT32ELEMENTS)>
          31: 0x12480828da79 <Map[72](RAB_GSAB_FLOAT64ELEMENTS)>
          32: 0x12480828daa1 <Map[72](RAB_GSAB_UINT8_CLAMPEDELEMENTS)>
          33: 0x12480828dac9 <Map[72](RAB_GSAB_BIGUINT64ELEMENTS)>
          34: 0x12480828daf1 <Map[72](RAB_GSAB_BIGINT64ELEMENTS)>
          35: 0x124808000069 <undefined>
          36: 0x12480828db19 <Map[28](HOLEY_ELEMENTS)>
          37: 0x124808000069 <undefined>
          38: 0x12480828a861 <JSFunction ArrayBuffer (sfi = 0x1248080f9185)>
          39: 0x12480828a8b1 <Map[68](HOLEY_ELEMENTS)>
          40: 0x12480828db81 <JSFunction arrayBufferConstructor_DoNotInitialize (sfi = 0x1248080f9261)>
          41: 0x12480828ce75 <JSFunction Array (sfi = 0x1248080f529d)>
       42-43: 0x124808000069 <undefined>
          44: 0x12480828db9d <Map[20](HOLEY_ELEMENTS)>
          45: 0x12480828dd81 <JSFunction AsyncFunction (sfi = 0x1248080fad31)>
          46: 0x12480828de8d <Map[44](HOLEY_ELEMENTS)>
          47: 0x12480828df1d <JSFunction AsyncGeneratorFunction (sfi = 0x1248080facad)>
          48: 0x124808284c19 <JSFunction BigInt (sfi = 0x1248080fa441)>
          49: 0x1248082888c5 <JSFunction Boolean (sfi = 0x1248080f5c69)>
          50: 0x12480828e139 <Map[24](HOLEY_ELEMENTS)>
          51: 0x12480828e189 <Map[24](HOLEY_ELEMENTS)>
          52: 0x12480828e1d9 <JSFunction (sfi = 0x1248080fac55)>
          53: 0x12480828e1f5 <JSFunction (sfi = 0x1248080fac29)>
          54: 0x12480828e211 <JSFunction CallSite (sfi = 0x1248080fad5d)>
          55: 0x12480828e6a1 <JSFunction (sfi = 0x12480820df21)>
          56: 0x12480828e765 <Map[28](HOLEY_ELEMENTS)>
          57: 0x124808288171 <JSFunction DataView (sfi = 0x1248080f9e11)>
          58: 0x124808288db9 <JSFunction Date (sfi = 0x1248080f6769)>
          59: 0x124808000069 <undefined>
          60: 0x124808282b4d <JSFunction (sfi = 0x124808209569)>
       61-62: 0x124808000069 <undefined>
          63: 0
          64: 0x12480828e829 <Object map = 0x12480828e7cd>
          65: 0x12480828e87d <Map[20](FAST_SLOPPY_ARGUMENTS_ELEMENTS)>
          66: 0x12480828e955 <FixedArray[1024]>
          67: 0x124808282bf1 <JSFunction Function (sfi = 0x1248080f5195)>
          68: 0x124808282b4d <JSFunction (sfi = 0x124808209569)>
          69: 0x1248082902b9 <JSFunction GeneratorFunction (sfi = 0x1248080fac81)>
          70: 0x12480829056d <Map[12](HOLEY_ELEMENTS)>
          71: 0x124808290595 <Map[12](HOLEY_ELEMENTS)>
          72: 0x1248082905bd <Map[24](HOLEY_ELEMENTS)>
          73: 0x124808290651 <Object map = 0x1248082905e5>
          74: 0x12480828d17d <JSArray[0]>
          75: 0x124808285471 <Object map = 0x1248082853ed>
          76: 0x1248082904b5 <Object map = 0x1248082903a9>
          77: 0x12480828dc31 <Object map = 0x12480828dbed>
          78: 0x12480828e081 <Object map = 0x12480828e00d>
          79: 0x124808290431 <Object map = 0x1248082903d1>
          80: 0x124808290715 <Object map = 0x1248082906a9>
          81: 0x124808284ecd <Map[28](HOLEY_ELEMENTS)>
          82: 0x12480828336d <Object map = 0x1248082829a9>
          83: 0x1248082907b9 <Object map = 0x12480829074d>
          84: 0x124808287fe9 <Object map = 0x124808287edd>
          85: 0x124808287edd <Map[28](HOLEY_ELEMENTS)>
          86: 0x1248082907f1 <Map[20](HOLEY_ELEMENTS)>
          87: 0x124808290885 <Object map = 0x124808290819>
          88: 0x124808287755 <Object map = 0x1248082874a1 value = 0x1248080000a1 <String[0]: #>>
          89: 0x124808287209 <Map[28](HOLEY_ELEMENTS)>
          90: 0x124808284905 <Map[28](HOLEY_ELEMENTS)>
          91: 0x12480828b4b5 <JSFunction Collator (sfi = 0x1248080f8761)>
          92: 0x12480828c825 <JSFunction DateTimeFormat (sfi = 0x1248080f84f9)>
          93: 0x12480828c465 <JSFunction DisplayNames (sfi = 0x1248080f8fa1)>
          94: 0x124808000069 <undefined>
          95: 0x12480828b259 <JSFunction NumberFormat (sfi = 0x1248080f862d)>
          96: 0x12480828bf0d <JSFunction Locale (sfi = 0x1248080f8c05)>
          97: 0x12480828bd19 <JSFunction ListFormat (sfi = 0x1248080f8b29)>
          98: 0x12480828b919 <JSFunction PluralRules (sfi = 0x1248080f8971)>
          99: 0x12480828bb19 <JSFunction RelativeTimeFormat (sfi = 0x1248080f8a4d)>
         100: 0x12480828c629 <JSFunction Segmenter (sfi = 0x1248080f9051)>
         101: 0x1248082908dd <Map[28](HOLEY_ELEMENTS)>
         102: 0x1248082909e5 <Map[28](HOLEY_ELEMENTS)>
     103-109: 0x124808000069 <undefined>
         110: 0x124808290ad1 <Map[20](HOLEY_ELEMENTS)>
         111: 0x12480828cf09 <Map[16](PACKED_SMI_ELEMENTS)>
         112: 0x12480828d7c9 <Map[16](HOLEY_SMI_ELEMENTS)>
         113: 0x12480828d889 <Map[16](PACKED_ELEMENTS)>
         114: 0x12480828d8c9 <Map[16](HOLEY_ELEMENTS)>
         115: 0x12480828d809 <Map[16](PACKED_DOUBLE_ELEMENTS)>
         116: 0x12480828d849 <Map[16](HOLEY_DOUBLE_ELEMENTS)>
         117: 0x124808290b71 <Map[28](PACKED_FROZEN_ELEMENTS)>
         118: 0x124808284e71 <JSFunction Map (sfi = 0x1248080fa231)>
         119: 0x124808284ea5 <Map[16](HOLEY_ELEMENTS)>
         120: 0x124808290bd9 <Map[20](HOLEY_ELEMENTS)>
         121: 0x124808000069 <undefined>
         122: 0x124808287e81 <JSFunction Set (sfi = 0x1248080fa549)>
         123: 0x124808287eb5 <Map[16](HOLEY_ELEMENTS)>
         124: 0x1248082871ad <JSFunction WeakMap (sfi = 0x1248080fa701)>
         125: 0x1248082848a9 <JSFunction WeakSet (sfi = 0x1248080fa7dd)>
         126: 0x12480828870d <JSFunction WeakRef (sfi = 0x1248080fabd1)>
         127: 0x12480828cab9 <JSFunction FinalizationRegistry (sfi = 0x1248080fab21)>
     128-137: 0x124808000069 <undefined>
         138: 0x1248082847d9 <Object map = 0x12480828477d>
     139-142: 0x124808000069 <undefined>
         143: 0x12480828247d <MetaMap (0x1248082824cd <NativeContext[287]>)>
         144: 0x124808290c1d <Map(FUNCTION_CONTEXT_TYPE)>
         145: 0x124808290c45 <Map(MODULE_CONTEXT_TYPE)>
         146: 0x124808290c6d <Map(EVAL_CONTEXT_TYPE)>
         147: 0x124808290c95 <Map(SCRIPT_CONTEXT_TYPE)>
         148: 0x124808290cbd <Map(AWAIT_CONTEXT_TYPE)>
         149: 0x124808290ce5 <Map(BLOCK_CONTEXT_TYPE)>
         150: 0x124808290d0d <Map(CATCH_CONTEXT_TYPE)>
         151: 0x124808290d35 <Map(WITH_CONTEXT_TYPE)>
         152: 0x124808290d5d <Map(DEBUG_EVALUATE_CONTEXT_TYPE)>
         153: 0x124808290d85 <Map[60](HOLEY_ELEMENTS)>
         154: 0x124808290dad <Other heap object (WEAK_FIXED_ARRAY_TYPE)>
         155: 0x124808290fb5 <Map[20](HOLEY_ELEMENTS)>
         156: 0x124808290ffd <Map[20](HOLEY_ELEMENTS)>
         157: 0x124808291025 <Map[20](HOLEY_ELEMENTS)>
         158: 0
         159: 0x12480829104d <ByteArray[16]>
         160: 0x124808291065 <FixedDoubleArray[64]>
         161: 0x12480829126d <Other heap object (WEAK_FIXED_ARRAY_TYPE)>
         162: 0x12480828a511 <JSFunction Number (sfi = 0x1248080f5a2d)>
         163: 0x124808282eb1 <JSFunction Object (sfi = 0x1248080f4955)>
         164: 0x12480828336d <Object map = 0x1248082829a9>
         165: 0x1248082829a9 <Map[28](HOLEY_ELEMENTS)>
     166-169: 0x124808000069 <undefined>
         170: 0x124808291375 <Map[16](JS_PROXY_TYPE)>
         171: 0x12480829139d <Map[16](JS_PROXY_TYPE)>
         172: 0x124808289a45 <JSFunction Proxy (sfi = 0x1248080fa88d)>
         173: 0x1248082913c5 <Map[16](JS_PROXY_TYPE)>
         174: 0x1248082913ed <Map[20](HOLEY_ELEMENTS)>
         175: 0x12480828a019 <Object map = 0x124808289f89>
         176: 0x124808000069 <undefined>
         177: 0x124808286ec1 <JSFunction exec (sfi = 0x1248080f7211)>
         178: 0x124808286ae1 <JSFunction RegExp (sfi = 0x1248080f71e5)>
         179: 0x12480829143d <Other heap object (REG_EXP_MATCH_INFO_TYPE)>
         180: 0x124808286e51 <JSFunction [Symbol.matchAll] (sfi = 0x1248080f7479)>
         181: 0x124808286e35 <JSFunction [Symbol.match] (sfi = 0x1248080f744d)>
         182: 0x124808286ddd <Object map = 0x124808286b3d>
         183: 0x124808286b3d <Map[28](HOLEY_ELEMENTS)>
         184: 0x124808286e6d <JSFunction [Symbol.replace] (sfi = 0x1248080f74a5)>
         185: 0x124808291469 <Map[40](HOLEY_ELEMENTS)>
         186: 0x1248082914f5 <Map[44](HOLEY_ELEMENTS)>
         187: 0x12480829158d <Map[20](HOLEY_ELEMENTS)>
         188: 0x124808286e89 <JSFunction [Symbol.search] (sfi = 0x1248080f74d1)>
         189: 0x124808286ea5 <JSFunction [Symbol.split] (sfi = 0x1248080f74fd)>
         190: 0x1248082915dd <Map[24](HOLEY_ELEMENTS)>
         191: 0x1248082916c9 <ScriptContextTable[16]>
         192: 0x124808000069 <undefined>
         193: 0x12480820f2b5 <String[36]: "d34eb7dc-8045-4301-930f-0cc982e1753e">
         194: 0x1248080006fd <FixedArray[0]>
         195: 0x124808291851 <Map[20](HOLEY_ELEMENTS)>
         196: 0x124808291899 <Map[20](HOLEY_ELEMENTS)>
         197: 0x12480829195d <JSFunction SharedArrayBuffer (sfi = 0x1248080f928d)>
         198: 0x12480828e8c5 <Map[20](PACKED_ELEMENTS)>
         199: 0x124808291a9d <Map[20](SLOW_SLOPPY_ARGUMENTS_ELEMENTS)>
         200: 0x124808291af9 <Map[16](PACKED_ELEMENTS)>
         201: 0x124808291b61 <Map[12](HOLEY_ELEMENTS)>
         202: 0x124808291b89 <Map[12](HOLEY_ELEMENTS)>
         203: 0x124808291bb1 <SimpleNumberDictionary[1027]>
         204: 0x124808292bc5 <OrderedHashSet[13]>
         205: 0x1248080006fd <FixedArray[0]>
         206: 0x124808292c01 <PropertyCell name=0x1248080000a1 <String[0]: #> value=1>
         207: 0x124808282c25 <Map[32](HOLEY_ELEMENTS)>
         208: 0x124808292c15 <Map[36](HOLEY_ELEMENTS)>
         209: 0x124808292c89 <Map[28](HOLEY_ELEMENTS)>
         210: 0x12480828fb49 <Map[32](HOLEY_ELEMENTS)>
         211: 0x124808283505 <Map[32](HOLEY_ELEMENTS)>
         212: 0x124808292cf1 <Map[36](HOLEY_ELEMENTS)>
         213: 0x12480828328d <Map[32](HOLEY_ELEMENTS)>
         214: 0x124808282c99 <Map[28](HOLEY_ELEMENTS)>
         215: 0x124808292d4d <Map[32](HOLEY_ELEMENTS)>
         216: 0x12480828ddb5 <Map[28](HOLEY_ELEMENTS)>
         217: 0x124808292d9d <Map[32](HOLEY_ELEMENTS)>
         218: 0x1248082902ed <Map[32](HOLEY_ELEMENTS)>
         219: 0x124808292ded <Map[36](HOLEY_ELEMENTS)>
         220: 0x12480828df51 <Map[32](HOLEY_ELEMENTS)>
         221: 0x124808292e49 <Map[36](HOLEY_ELEMENTS)>
         222: 0x124808292ea5 <Map[32](HOLEY_ELEMENTS)>
         223: 0x1248082873e5 <JSFunction String (sfi = 0x1248080f5ced)>
         224: 0x1248082874a1 <Map[16](FAST_STRING_WRAPPER_ELEMENTS)>
         225: 0x1248082838f9 <JSFunction Symbol (sfi = 0x1248080f6635)>
         226: 0
         227: 0x124808293161 <WebAssembly map = 0x124808292ef5>
         228: 0x124808292c89 <Map[28](HOLEY_ELEMENTS)>
         229: 0x124808290071 <JSFunction Tag (sfi = 0x12480820e9f5)>
         230: 0x124808290125 <JSFunction Exception (sfi = 0x12480820eabd)>
         231: 0x12480828ff45 <JSFunction Global (sfi = 0x12480820e7f1)>
         232: 0x12480828fbd9 <JSFunction Instance (sfi = 0x12480820e2b5)>
         233: 0x1248082931b1 <Tag map = 0x124808290091>
         234: 0x12480828fe35 <JSFunction Memory (sfi = 0x12480820e655)>
         235: 0x12480828fa49 <JSFunction Module (sfi = 0x12480820e1e9)>
         236: 0x12480828fcc1 <JSFunction Table (sfi = 0x12480820e3e9)>
     237-238: 0x124808000069 <undefined>
         239: 0x124808283be9 <JSFunction TypedArray (sfi = 0x1248080f9579)>
         240: 0x124808283f61 <Object map = 0x124808283c7d>
         241: 0x12480828d489 <JSFunction entries (sfi = 0x1248080f5715)>
         242: 0x12480828d4c1 <JSFunction forEach (sfi = 0x1248080f576d)>
         243: 0x12480828d46d <JSFunction keys (sfi = 0x1248080f56e9)>
         244: 0x12480828d4a5 <JSFunction values (sfi = 0x1248080f5741)>
         245: 0x124808285375 <JSFunction Error (sfi = 0x1248080f7c09)>
         246: 0x12480828548d <JSFunction toString (sfi = 0x1248080f7c61)>
         247: 0x124808288bf5 <JSFunction EvalError (sfi = 0x1248080f7cb9)>
         248: 0x124808286fdd <JSFunction AggregateError (sfi = 0x1248080f7c8d)>
         249: 0x124808289aa5 <JSFunction eval (sfi = 0x1248080fb259)>
         250: 0x124808286411 <JSFunction parseFloat (sfi = 0x1248080f5c11)>
         251: 0x12480828882d <JSFunction parseInt (sfi = 0x1248080f5c3d)>
         252: 0x124808293735 <JSFunction (sfi = 0x124808293709)>
         253: 0x124808285049 <JSFunction delete (sfi = 0x1248080fa2e1)>
         254: 0x1248082850f1 <JSFunction get (sfi = 0x1248080fa25d)>
         255: 0x12480828502d <JSFunction has (sfi = 0x1248080fa2b5)>
         256: 0x12480828510d <JSFunction set (sfi = 0x1248080fa289)>
         257: 0x1248082935f1 <JSFunction cleanupSome (sfi = 0x1248080faba5)>
         258: 0x124808282d59 <JSFunction [Symbol.hasInstance] (sfi = 0x1248080f5271)>
         259: 0x124808282d3d <JSFunction toString (sfi = 0x1248080f5245)>
         260: 0x124808283425 <JSFunction toString (sfi = 0x1248080f50b9)>
         261: 0x124808283441 <JSFunction valueOf (sfi = 0x1248080f50e5)>
         262: 0x124808289eb9 <JSFunction all (sfi = 0x1248080f7059)>
         263: 0x124808289ed5 <JSFunction allSettled (sfi = 0x1248080f7085)>
         264: 0x124808289ef1 <JSFunction any (sfi = 0x1248080f70b1)>
         265: 0x124808289e6d <JSFunction Promise (sfi = 0x1248080f7001)>
         266: 0x12480828a12d <JSFunction RangeError (sfi = 0x1248080f7ce5)>
         267: 0x124808288a55 <JSFunction ReferenceError (sfi = 0x1248080f7d11)>
         268: 0x1248082880d9 <JSFunction add (sfi = 0x1248080fa5a1)>
         269: 0x124808288031 <JSFunction delete (sfi = 0x1248080fa5cd)>
         270: 0x1248082880bd <JSFunction has (sfi = 0x1248080fa575)>
     271-272: 0x124808000069 <undefined>
         273: 0x12480828cc7d <JSFunction SyntaxError (sfi = 0x1248080f7d3d)>
         274: 0x124808285bdd <JSFunction TypeError (sfi = 0x1248080f7d69)>
         275: 0x12480828551d <JSFunction URIError (sfi = 0x1248080f7d95)>
         276: 0x1248082931dd <JSFunction CompileError (sfi = 0x1248080f7dc1)>
         277: 0x124808293301 <JSFunction LinkError (sfi = 0x1248080f7ded)>
         278: 0x124808293425 <JSFunction RuntimeError (sfi = 0x1248080f7e19)>
         279: 0x124808287329 <JSFunction set (sfi = 0x1248080fa785)>
         280: 0x12480828730d <JSFunction get (sfi = 0x1248080fa759)>
         281: 0x1248082872f1 <JSFunction delete (sfi = 0x1248080fa72d)>
         282: 0x1248082849fd <JSFunction add (sfi = 0x1248080fa861)>
         283: 0x124808000069 <undefined>
         284: 0x12480800070d <Other heap object (WEAK_ARRAY_LIST_TYPE)>
     285-286: 0x124808000069 <undefined>
 - microtask_queue: 0x138005990

global handle not serialized: 0x12480820f2fd: [[api object] 0] in OldSpace
 - map: 0x124808294315 <Map[28](HOLEY_ELEMENTS)> [FastProperties]
 - prototype: 0x12480820f171 <Object map = 0x124808294381>
 - elements: 0x1248080006fd <FixedArray[0]> [HOLEY_ELEMENTS]
 - embedder fields: 2
 - properties: 0x1248080006fd <FixedArray[0]>
 - All own properties (excluding elements): {
    0x124808000ddd: [String] in ReadOnlySpace: #value: 0x124808294309 <AccessorPair> (const accessor descriptor), location: descriptor
 }
 - embedder fields = {
    45850764, aligned pointer: 0x105774118
    469786088, aligned pointer: 0x13800bbd0
 }
Thanks for any pointers

Leszek Swirski

unread,
Jun 3, 2024, 8:04:56 AMJun 3
to v8-...@googlegroups.com
Hi Ronald,

Can you clarify what you're trying to do, with the full example code or a link to a patch? The error you're getting is to do with active global handles, so the cause for the error really depends on what the rest of your code is doing.

- Leszek

--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/fd563308-f895-4b47-8493-b38084840b52n%40googlegroups.com.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Ronald Fenner

unread,
Jun 4, 2024, 5:30:05 AMJun 4
to v8-dev
Yes I have a global to the context sill open, I guess my question does it have to be reset before snapshotting or is there a way to ignore them or serialize it.
I know if i reset the global it works. That suggest to me that any global/persistent handles tracking JS objects in c++ code all have to be closed before the snapshot and you don't want to use eternals either.
You can see the can view the src of my playground test where i'm working through the snapshot process here: https://github.com/v8App/v8App/blob/snapshots/src/testing/libs/jsRuntime/runtime/JSSnapshotCreatorTest.cc

My main question was how do i keep an obj created via new in JS backed by a C++ class from being GCed before snapshotting. I gues I may not understand what objects get sent to the SerializeInternalFields callbaclk.

Ronald Fenner

unread,
Jun 4, 2024, 5:30:06 AMJun 4
to v8-dev
Yes i still have an open global to the context when this error occurs. I'm wondering if there is way to ignore them since the wrapper class for the context holds it. I know if I close the handle it will work.
This has suggested to me that any globals/persistent handles have to be reset on the C++ side before a snapshot and you can't use eternals as they don't serialize as well.
You can see my code that i'm iterating on for the snapshot process here https://github.com/v8App/v8App/blob/snapshots/src/testing/libs/jsRuntime/runtime/JSSnapshotCreatorTest.cc

The main question i had was how to prevent an object created via new backed by a C++ object from being GC'ed when the snapshot is taking. I'm not sure if i'm missing something and it seems like the object should be persisted since it's held by a variable.
I may not understand what the SerializeInteralFiels callback does or for what objects it's called for.

On Monday, June 3, 2024 at 7:04:56 AM UTC-5 les...@chromium.org wrote:

Ronald Fenner

unread,
Jun 4, 2024, 5:30:42 AMJun 4
to v8-dev
Can you not post links in a  message? My last message apparently has been deleted twice with a link to the code in github.

Yes when the error occurs i have a global still held on the context my the wrapper class. I know if i close it it will work. Is there way to ignore or serialize it or am I correct in assuming any globals or persistents on the c++ side need to be clear/reset before a snapshot.
You can see my coee by going to github and looking at the v8App under branch snapshot in the src/testing/libs/jsRuntime/runtime/SnapshotCreatorTest.cc.

The main question was how to persist a object created via new backed by a c++ object and the one i create in the test above where i'm iterating on the snapshot prcess gets GC'ed when i take the snapshot it seems before the serializers is called as I don't hit the breakpoint in my serialization code for SerliazeInternalFields.

Thanks

On Monday, June 3, 2024 at 7:04:56 AM UTC-5 les...@chromium.org wrote:

Ronald Fenner

unread,
Jun 10, 2024, 3:57:04 PMJun 10
to v8-dev
Question when running a script source in context can you make any objects created via new survive passed the end of the script so if you run another script they are accessable still in the next script or is this not possible I looked at another test of mine where i did something similar to test the week callback and destruction getting called and could see that when i force the gc after the script run the object was garbage collected.

Would this be different if i was doing this in a module instead?

I looked over blink's snapshot code and it seems they mainly setup all the functions and object templates they require then snapshot so don't really run any code.
Node seems to do the same expect also run js to bootstrap their environment but it's kinda hard to follow their code at times.

Just trying to figure out what can be done on the JS side for a snapshot for object instances or if it's more static setup. Node suggest more can be done but they have the v8 source as part of their project and can make changes where as i'm doing this from the library side where i can't make changes.

Thanks

Ronald Fenner

unread,
Jun 13, 2024, 1:56:52 AMJun 13
to v8-dev
I found my issue i was not actually adding the context i ran the script in when adding a context to the snapshot creator. After i fixed this i can see the object serialization get hit. I was helped also by the sterilizer test in v8 ReinitializeHashSeedJSCollectionRehashable which showed that var created by new could be serialized even if they were they were built in classes. After i tried adding a 'var m = new Map();' and it was also undefined i started looking at what was different and found where i used the wrong context.
Reply all
Reply to author
Forward
0 new messages