Skip to content

Instantly share code, notes, and snippets.

@hashseed
Last active February 19, 2018 14:26
Show Gist options
  • Save hashseed/c8eaa6513f6b4309d89350b12dfa8377 to your computer and use it in GitHub Desktop.
Save hashseed/c8eaa6513f6b4309d89350b12dfa8377 to your computer and use it in GitHub Desktop.
verify that WeakMap works.
[2018-02-19 15:22:01] yangguo@yangguo2:~/v8$ g out.gn/x64.debug/d8 --expose-gc --allow-natives-syntax
GNU gdb (GDB) 7.9-gg19
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-grtev4-linux-gnu".
Type "show configuration" for configuration details.
<http://go/gdb-home FAQ: http://go/gdb-faq Email: c-toolchain-team IRC: gdb>
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Reading symbols from out.gn/x64.debug/d8...done.
Unable to determine compiler version.
Skipping loading of libstdc++ pretty-printers for now.
Non-google3 binary detected.
(gdb) r
Starting program: /usr/local/google/home/yangguo/v8/out.gn/x64.debug/d8 --expose-gc --allow-natives-syntax
V8 version 6.6.0 (candidate)
d8> var x = (function() { var o1 = {z:12}; var o2 = {z:13}; var m = new WeakMap(); m.set(o1, o2); return [o1, m]; })()
undefined
d8> %DebugPrint(x[1])
DebugPrint: 0x1d7ba0c0d559: [JSWeakMap]
- map: 0x3dd5bd084191 <Map(HOLEY_ELEMENTS)> [FastProperties]
- prototype: 0x12cc36091ed9 <Object map = 0x3dd5bd0841e1>
- elements: 0x38bb5bb82251 <FixedArray[0]> [HOLEY_ELEMENTS]
- table: 0x1d7ba0c0d581 <HashTable[11]>
- properties: 0x38bb5bb82251 <FixedArray[0]> {}
0x3dd5bd084191: [Map]
- type: JS_WEAK_MAP_TYPE
- instance size: 40
- inobject properties: 0
- elements kind: HOLEY_ELEMENTS
- unused property fields: 0
- enum length: invalid
- stable_map
- back pointer: 0x38bb5bb822e1 <undefined>
- instance descriptors (own) #0: 0x38bb5bb82231 <DescriptorArray[2]>
- layout descriptor: (nil)
- prototype: 0x12cc36091ed9 <Object map = 0x3dd5bd0841e1>
- constructor: 0x12cc36091df1 <JSFunction WeakMap (sfi = 0x38bb5bbaae91)>
- dependent code: 0x38bb5bb82251 <FixedArray[0]>
- construction counter: 0
[object WeakMap]
d8> ^C[New Thread 0x7f199a51c700 (LWP 249498)]
[New Thread 0x7f199ad1d700 (LWP 249497)]
[New Thread 0x7f199b51e700 (LWP 249496)]
[New Thread 0x7f199bd1f700 (LWP 249495)]
[New Thread 0x7f199c520700 (LWP 249494)]
[New Thread 0x7f199cd21700 (LWP 249493)]
[New Thread 0x7f199d522700 (LWP 249492)]
[New Thread 0x7f199dd23700 (LWP 249491)]
Program received signal SIGINT, Interrupt.
0x00007f199e21e6ad in read () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) job 0x1d7ba0c0d581
0x1d7ba0c0d581: [HashTable]
- map: 0x206db52826b1 <Map(HOLEY_ELEMENTS)>
- length: 11
0: 1
1: 0
2: 4
3-6: 0x38bb5bb822e1 <undefined>
7: 0x1d7ba0c0d4e1 <Object map = 0x3dd5bd08c021>
8: 0x1d7ba0c0d539 <Object map = 0x3dd5bd08c021>
9-10: 0x38bb5bb822e1 <undefined>
(gdb) job 0x1d7ba0c0d539
0x1d7ba0c0d539: [JS_OBJECT_TYPE]
- map: 0x3dd5bd08c021 <Map(HOLEY_ELEMENTS)> [FastProperties]
- prototype: 0x12cc360847d1 <Object map = 0x3dd5bd0822a1>
- elements: 0x38bb5bb82251 <FixedArray[0]> [HOLEY_ELEMENTS]
- properties: 0x38bb5bb82251 <FixedArray[0]> {
#z: 13 (data field 0)
}
(gdb) c
Continuing.
x[0] = null
null
d8> gc()
undefined
d8> %DebugPrint(x[1])
DebugPrint: 0xe781cb08451: [JSWeakMap]
- map: 0x3dd5bd084191 <Map(HOLEY_ELEMENTS)> [FastProperties]
- prototype: 0x12cc36091ed9 <Object map = 0x3dd5bd0841e1>
- elements: 0x38bb5bb82251 <FixedArray[0]> [HOLEY_ELEMENTS]
- table: 0xe781cb08479 <HashTable[11]>
- properties: 0x38bb5bb82251 <FixedArray[0]> {}
0x3dd5bd084191: [Map]
- type: JS_WEAK_MAP_TYPE
- instance size: 40
- inobject properties: 0
- elements kind: HOLEY_ELEMENTS
- unused property fields: 0
- enum length: invalid
- stable_map
- back pointer: 0x38bb5bb822e1 <undefined>
- instance descriptors (own) #0: 0x38bb5bb82231 <DescriptorArray[2]>
- layout descriptor: (nil)
- prototype: 0x12cc36091ed9 <Object map = 0x3dd5bd0841e1>
- constructor: 0x12cc36091df1 <JSFunction WeakMap (sfi = 0x38bb5bbaae91)>
- dependent code: 0x38bb5bb82251 <FixedArray[0]>
- construction counter: 0
[object WeakMap]
d8> ^C
Program received signal SIGINT, Interrupt.
0x00007f199e21e6ad in read () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) job 0xe781cb08479
0xe781cb08479: [HashTable]
- map: 0x206db52826b1 <Map(HOLEY_ELEMENTS)>
- length: 11
0: 0
1: 1
2: 4
3-6: 0x38bb5bb822e1 <undefined>
7-8: 0x38bb5bb82321 <the_hole>
9-10: 0x38bb5bb822e1 <undefined>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment