Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2b11d0e

Browse files
添加使用 v8 的调试方式
Signed-off-by: 迷渡 <justjavac@gmail.com>
1 parent 3f4901a commit 2b11d0e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

‎README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,43 @@ V8 JavaScript 内存占用分析。
3939
1. `__proto__` 是原型链。
4040
2. `map` 就是很多文章都在介绍的 V8 对象的黑魔法 Hidden Class。
4141

42+
## 使用 V8 进行调试
43+
44+
V8 的 `%DebugPrint()` 函数可以打印出对象的调试信息。这需要手动使用 `--is_debug=true` 参数来编译 V8。
45+
46+
代码:
47+
48+
```js
49+
let o = {};
50+
%DebugPrint(o);
51+
```
52+
53+
运行:`d8 --allow_natives_syntax heap.js`
54+
55+
输出:
56+
57+
```plain
58+
DebugPrint: 0x2604080c60e9: [JS_OBJECT_TYPE]
59+
- map: 0x2604082802d9 <Map(HOLEY_ELEMENTS)> [FastProperties]
60+
- prototype: 0x2604082413c9 <Object map = 0x2604082801c1>
61+
- elements: 0x2604080406e9 <FixedArray[0]> [HOLEY_ELEMENTS]
62+
- properties: 0x2604080406e9 <FixedArray[0]> {}
63+
0x2604082802d9: [Map]
64+
- type: JS_OBJECT_TYPE
65+
- instance size: 28
66+
- inobject properties: 4
67+
- elements kind: HOLEY_ELEMENTS
68+
- unused property fields: 4
69+
- enum length: invalid
70+
- back pointer: 0x26040804030d <undefined>
71+
- prototype_validity cell: 0x2604081c0451 <Cell value= 1>
72+
- instance descriptors (own) #0: 0x2604080401b5 <DescriptorArray[0]>
73+
- prototype: 0x2604082413c9 <Object map = 0x2604082801c1>
74+
- constructor: 0x2604082413e5 <JSFunction Object (sfi = 0x2604081c5869)>
75+
- dependent code: 0x2604080401ed <Other heap object (WEAK_FIXED_ARRAY_TYPE)>
76+
- construction counter: 0
77+
```
78+
4279
## License
4380

4481
本<span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" rel="dct:type">作品</span>由 <a xmlns:cc="https://creativecommons.org/ns#" href="https://justjavac.com" property="cc:attributionName" rel="cc:attributionURL">justjavac</a> 创作,采用<a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/3.0/cn/">知识共享署名-非商业性使用-相同方式共享 3.0 中国大陆许可协议</a>进行许可。凡是转载的文章,翻译的文章,或者由其他作者投稿的文章,版权归原作者所有。

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /