Web Inspector: Support for JavaScript BigInt
authorpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Aug 2019 10:41:33 +0000 (10:41 +0000)
committerpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Aug 2019 10:41:33 +0000 (10:41 +0000)
commit90e8a25e98a0a7022a0244b3db855b181411ee4f
tree719009cc5302acc669a77b614d2f1cf14b4236ac
parentdb0732dfbf76ac721a3a965f1e4ab178fa0fa000
Web Inspector: Support for JavaScript BigInt
https://bugs.webkit.org/show_bug.cgi?id=180731
<rdar://problem/36298748>

Source/JavaScriptCore:

Reviewed by Devin Rousso.

* inspector/InjectedScriptSource.js:
(toStringDescription):
(isSymbol):
(isBigInt):
(let.InjectedScript.prototype._fallbackWrapper):
(let.RemoteObject):
(let.RemoteObject.subtype):
(let.RemoteObject.describe):
(let.RemoteObject.prototype._appendPropertyPreviews):
(let.RemoteObject.set _isPreviewableObjectInternal):
(let.RemoteObject.prototype._isPreviewableObject.set add):
* inspector/protocol/Runtime.json:
New RemoteObject type and preview support.

* runtime/RuntimeType.cpp:
(JSC::runtimeTypeForValue):
(JSC::runtimeTypeAsString):
* runtime/RuntimeType.h:
* runtime/TypeSet.cpp:
(JSC::TypeSet::displayName const):
(JSC::TypeSet::inspectorTypeSet const):
New type for the type profiler.

* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::json):
* inspector/agents/InspectorHeapAgent.cpp:
(Inspector::InspectorHeapAgent::getPreview):
* runtime/JSBigInt.cpp:
(JSC::JSBigInt::toString):
(JSC::JSBigInt::tryGetString):
(JSC::JSBigInt::toStringBasePowerOfTwo):
(JSC::JSBigInt::toStringGeneric):
* runtime/JSBigInt.h:
BigInts are not tied to a GlobalObject, so provide a way to get a
String for HeapSnapshot previews that are not tied to an ExecState.

Source/WebInspectorUI:

Reviewed by Devin Rousso.

* UserInterface/External/CodeMirror/javascript.js:
(expressionAllowed):
Cherry-pick BigInt JavaScript mode support from CodeMirror:
https://github.com/codemirror/CodeMirror/pull/5411

* UserInterface/Images/TypeBigInt.svg: Added.
* UserInterface/Views/Variables.css:
(:root):
(@media (prefers-color-scheme: dark)):
* UserInterface/Views/CodeMirrorAdditions.js:
* UserInterface/Views/SyntaxHighlightingDefaultTheme.css:
(.cm-s-default .cm-number.cm-bigint,):
* UserInterface/Views/ObjectTreePropertyTreeElement.css:
(.object-tree-property.bigint > .icon):
* UserInterface/Views/HeapSnapshotInstancesContentView.css:
(.heap-snapshot .icon.bigint):
Style BigInt similiar but different from numbers but with
a [B] icon instead of [N].

* UserInterface/Views/FormattedValue.css:
(.formatted-bigint):
* UserInterface/Views/FormattedValue.js:
(WI.FormattedValue.hasSimpleDisplay):
* UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor.prototype._tokenTrackingControllerHighlightedJavaScriptExpression.populate):
(WI.SourceCodeTextEditor.prototype._tokenTrackingControllerHighlightedJavaScriptExpression):
Simple value formatting for the new type.

* UserInterface/Models/TypeSet.js:
(WI.TypeSet):
(WI.TypeSet.prototype.get primitiveTypeNames):
* UserInterface/Views/TypeTokenView.css:
(.type-token-bigint):
* UserInterface/Views/TypeTokenView.js:
(WI.TypeTokenView.prototype._displayTypeName):
(WI.TypeTokenView):
New type handling for the Type profiler.

* UserInterface/Protocol/RemoteObject.js:
(WI.RemoteObject):
(WI.RemoteObject.createBigIntFromDescriptionString):
* UserInterface/Views/HeapSnapshotClusterContentView.js:
(WI.HeapSnapshotClusterContentView.iconStyleClassNameForClassName):
* UserInterface/Views/HeapSnapshotInstanceDataGridNode.js:
(WI.HeapSnapshotInstanceDataGridNode.prototype._populatePreview):
BigInt values are not tied to a GlobalObject, so do some special casing
in the Heap output (like Strings) so we get a preview.

Source/WebKit:

Reviewed by Devin Rousso.

* WebProcess/WebPage/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::WebInspectorUI):
Enable BigInt in the Web Inspector process. It only makes use of
`globalThis.BigInt(...)` to hold the value.

LayoutTests:

Reviewed by Devin Rousso.

* inspector/model/remote-object-expected.txt:
* inspector/model/remote-object.html:
* inspector/model/resources/remote-object-utilities.js:
Include simple tests for a BigInt value and preview.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248898 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/model/remote-object-expected.txt
LayoutTests/inspector/model/remote-object.html
LayoutTests/inspector/model/resources/remote-object-utilities.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp
Source/JavaScriptCore/inspector/InjectedScriptSource.js
Source/JavaScriptCore/inspector/agents/InspectorHeapAgent.cpp
Source/JavaScriptCore/inspector/protocol/Runtime.json
Source/JavaScriptCore/runtime/JSBigInt.cpp
Source/JavaScriptCore/runtime/JSBigInt.h
Source/JavaScriptCore/runtime/RuntimeType.cpp
Source/JavaScriptCore/runtime/RuntimeType.h
Source/JavaScriptCore/runtime/TypeSet.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/External/CodeMirror/javascript.js
Source/WebInspectorUI/UserInterface/Images/TypeBigInt.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Models/TypeSet.js
Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js
Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js
Source/WebInspectorUI/UserInterface/Views/FormattedValue.css
Source/WebInspectorUI/UserInterface/Views/FormattedValue.js
Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClusterContentView.js
Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstanceDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/HeapSnapshotInstancesContentView.css
Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.css
Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
Source/WebInspectorUI/UserInterface/Views/SyntaxHighlightingDefaultTheme.css
Source/WebInspectorUI/UserInterface/Views/TypeTokenView.css
Source/WebInspectorUI/UserInterface/Views/TypeTokenView.js
Source/WebInspectorUI/UserInterface/Views/Variables.css
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp