Add testing function to dump stencil
Categories
(Core :: JavaScript Engine, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox81 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Just like "parse", having a testing function that receives source string and dumps stencil would be nice for development.
Assignee | ||
Comment 1•4 years ago
|
||
I have WIP patch.
I'll post it here after bug 1653248 and optionally bug 1649968
Updated•4 years ago
|
Assignee | ||
Comment 2•4 years ago
|
||
Add dump method to stencil-related structs, that dumps the struct as JSON,
and dumpStencil()
shell-builtin as a consumer.
Some structs have dumpFields method, given that JSONPrinter only provide
beginObjectProperty/endObject to print a property with an object value.
There's some design decision about when to use string-representation and when
to use object.
Currently simple single-field struct like ScopeIndex uses string-representation
like "ScopeIndex(0)", and ScriptAtom also uses string-representation.
There's an exception in ScriptAtom case in DumpScriptThing,
that we need to differentiate string and string-representation of other
structs, and for simplicity, ScriptAtom case uses object with "type" property,
and other single-field structs use string-representation.
The current dumpStencil does not dump CompilationInfo.asmJS (FIXME) and
ScriptStencil.immutableScriptData.
Most of ScriptStencil.immutableScriptData field can be dumped by dis()
function.
Assignee | ||
Comment 3•4 years ago
|
||
input:
var s = `
var x = [1, 2, 3];
var y = { a: 10, 1: 20 };
var z = [1, 1.2, 20n, true, null, undefined, /abc/g];
function f() {
function g() {}
}
`;
dumpStencil(s);
output:
{
"topLevel": {
"immutableFlags": [
"NoScriptRval",
"TreatAsRunOnce",
"HasInnerFunctions"
],
"fieldInitializers": "Nothing",
"gcThings": [
"ScopeIndex(0)",
{
"type": "ScriptAtom",
"value": "x"
},
{
"type": "ScriptAtom",
"value": "y"
},
{
"type": "ScriptAtom",
"value": "z"
},
"FunctionIndex(0)",
{
"type": "ObjLiteralCreationData",
"value": {
"writer": {
"flags": [
"Array"
],
"code": [
{
"key": "ConstAtom(0)",
"op": "ConstValue(1.000000)"
},
{
"key": "ConstAtom(0)",
"op": "ConstValue(2.000000)"
},
{
"key": "ConstAtom(0)",
"op": "ConstValue(3.000000)"
}
]
},
"atoms": [
]
}
},
{
"type": "ObjLiteralCreationData",
"value": {
"writer": {
"flags": [
"SpecificGroup",
"Singleton"
],
"code": [
{
"key": "ConstAtom(0)",
"op": "ConstValue(10.000000)"
},
{
"key": "ArrayIndex(1)",
"op": "ConstValue(20.000000)"
}
]
},
"atoms": [
"a"
]
}
},
"BigIntIndex(0)",
{
"type": "ScriptAtom",
"value": "undefined"
},
"RegExpIndex(0)"
],
"immutableScriptData": "exists",
"extent": {
"sourceStart": 0,
"sourceEnd": 135,
"toStringStart": 0,
"toStringEnd": 135,
"lineno": 1,
"column": 0
}
},
"funcData": [
{
"immutableFlags": [
"IsFunction",
"HasInnerFunctions",
"HasMappedArgsObj"
],
"fieldInitializers": "Nothing",
"gcThings": [
"FunctionIndex(1)"
],
"immutableScriptData": null,
"extent": {
"sourceStart": 110,
"sourceEnd": 134,
"toStringStart": 100,
"toStringEnd": 134,
"lineno": 5,
"column": 10
},
"functionAtom": "f",
"functionFlags": [
"NORMAL_KIND",
"BASESCRIPT",
"CONSTRUCTOR"
],
"nargs": 0,
"lazyFunctionEnclosingScopeIndex": "Some(ScopeIndex(0))",
"isStandaloneFunction": false,
"wasFunctionEmitted": true,
"isSingletonFunction": true
},
{
"immutableFlags": [
"IsFunction",
"HasMappedArgsObj"
],
"fieldInitializers": "Nothing",
"gcThings": [
],
"immutableScriptData": null,
"extent": {
"sourceStart": 127,
"sourceEnd": 132,
"toStringStart": 117,
"toStringEnd": 132,
"lineno": 6,
"column": 12
},
"functionAtom": "g",
"functionFlags": [
"NORMAL_KIND",
"BASESCRIPT",
"CONSTRUCTOR"
],
"nargs": 0,
"lazyFunctionEnclosingScopeIndex": "Nothing",
"isStandaloneFunction": false,
"wasFunctionEmitted": false,
"isSingletonFunction": false
}
],
"regExpData": [
"/abc/g"
],
"bigIntData": [
"20"
],
"scopeData": [
{
"enclosing": "Nothing",
"kind": "global",
"firstFrameSlot": 0,
"numEnvironmentSlots": "Nothing",
"data": {
"letStart": 4,
"constStart": 4,
"trailingNames": [
{
"closedOver": false,
"isTopLevelFunction": false,
"name": "x"
},
{
"closedOver": false,
"isTopLevelFunction": false,
"name": "y"
},
{
"closedOver": false,
"isTopLevelFunction": false,
"name": "z"
},
{
"closedOver": false,
"isTopLevelFunction": true,
"name": "f"
}
]
}
}
]
}
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/c2583743d4eb Add dumpStencil shell-builtin. r=tcampbell
Comment 5•4 years ago
|
||
Backed out for bustages on ObjLiteral.cpp
backout: https://hg.mozilla.org/integration/autoland/rev/786545256e8814da7899374a2165f22509c08993
failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=312228029&repo=autoland&lineNumber=17161
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - In file included from Unified_cpp_js_src_frontend3.cpp:47:
[task 2020-08-06T06:49:48.084Z] 06:49:48 ERROR - /builds/worker/checkouts/gecko/js/src/frontend/ObjLiteral.cpp:158:24: error: out-of-line definition of 'dump' does not match any declaration in 'js::ObjLiteralWriter'
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - void ObjLiteralWriter::dump() {
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - ^~~~
[task 2020-08-06T06:49:48.084Z] 06:49:48 ERROR - /builds/worker/checkouts/gecko/js/src/frontend/ObjLiteral.cpp:164:24: error: out-of-line definition of 'dump' does not match any declaration in 'js::ObjLiteralWriter'
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - void ObjLiteralWriter::dump(js::JSONPrinter& json) {
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - ^~~~
[task 2020-08-06T06:49:48.084Z] 06:49:48 ERROR - /builds/worker/checkouts/gecko/js/src/frontend/ObjLiteral.cpp:166:3: error: use of undeclared identifier 'dumpFields'
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - dumpFields(json);
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - ^
[task 2020-08-06T06:49:48.084Z] 06:49:48 ERROR - /builds/worker/checkouts/gecko/js/src/frontend/ObjLiteral.cpp:170:24: error: out-of-line definition of 'dumpFields' does not match any declaration in 'js::ObjLiteralWriter'
[task 2020-08-06T06:49:48.084Z] 06:49:48 INFO - void ObjLiteralWriter::dumpFields(js::JSONPrinter& json) {
[task 2020-08-06T06:49:48.085Z] 06:49:48 INFO - ^~~~~~~~~~
[task 2020-08-06T06:49:48.085Z] 06:49:48 ERROR - /builds/worker/checkouts/gecko/js/src/frontend/ObjLiteral.cpp:224:30: error: out-of-line definition of 'dump' does not match any declaration in 'js::ObjLiteralCreationData'
[task 2020-08-06T06:49:48.085Z] 06:49:48 INFO - void ObjLiteralCreationData::dump() {
[task 2020-08-06T06:49:48.085Z] 06:49:48 INFO - ^~~~
[task 2020-08-06T06:49:48.085Z] 06:49:48 ERROR - /builds/worker/checkouts/gecko/js/src/frontend/ObjLiteral.cpp:230:30: error: out-of-line definition of 'dump' does not match any declaration in 'js::ObjLiteralCreationData'
[task 2020-08-06T06:49:48.085Z] 06:49:48 INFO - void ObjLiteralCreationData::dump(js::JSONPrinter& json) {
[task 2020-08-06T06:49:48.085Z] 06:49:48 INFO - ^~~~
Comment 6•4 years ago
|
||
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/af63ceb25422 Add dumpStencil shell-builtin. r=tcampbell
Assignee | ||
Updated•4 years ago
|
Comment 8•4 years ago
|
||
bugherder |
Updated•3 years ago
|
Description
•