Compilation policy management belongs in operationOptimize(), not the DFG Driver.
<https://webkit.org/b/129355>

Reviewed by Filip Pizlo.

By compilation policy, I mean the rules for determining whether to
compile, when to compile, when to attempt compilation again, etc.  The
few of these policy decisions that were previously being made in the
DFG driver are now moved to operationOptimize() where we keep the rest
of the policy logic.  Decisions that are based on the capabilities
supported by the DFG are moved to DFG capabiliityLevel().

I've run the following benchmarks:
1. the collection of jsc benchmarks on the jsc executable vs. its
   baseline.
2. Octane 2.0 in browser without the WebInspector.
3. Octane 2.0 in browser with the WebInspector open and a breakpoint
   set somewhere where it won't break.

In all of these, the results came out to be a wash as expected.

* dfg/DFGCapabilities.cpp:
(JSC::DFG::isSupported):
(JSC::DFG::mightCompileEval):
(JSC::DFG::mightCompileProgram):
(JSC::DFG::mightCompileFunctionForCall):
(JSC::DFG::mightCompileFunctionForConstruct):
(JSC::DFG::mightInlineFunctionForCall):
(JSC::DFG::mightInlineFunctionForClosureCall):
(JSC::DFG::mightInlineFunctionForConstruct):
* dfg/DFGCapabilities.h:
* dfg/DFGDriver.cpp:
(JSC::DFG::compileImpl):
* jit/JITOperations.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164734 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove unused InspectorCounters.
<https://webkit.org/b/129367>

The InspectorCounters code was only used to implement two layout test
APIs (window.internals.numberOfLive{Nodes,Documents}) yet it had hooks
in crazy places like Node construction and destruction.

Rewrote the internals APIs to iterate over all live Documents instead,
totaling up their referencing Node count. Added a process-global
Document::allDocuments() HashSet to make this whole thing possible.

Reviewed by Sam Weinig.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSEventListener.cpp:
* dom/Document.cpp:
(WebCore::Document::allDocuments):
(WebCore::Document::Document):
(WebCore::Document::~Document):
* dom/Document.h:
(WebCore::Node::Node):
* dom/Node.cpp:
(WebCore::Node::~Node):
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorCounters.cpp: Removed.
* inspector/InspectorCounters.h: Removed.
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::innerAddRecordToTimeline):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
* inspector/InspectorTimelineAgent.h:
* inspector/protocol/Timeline.json:
* platform/ThreadGlobalData.cpp:
* testing/Internals.cpp:
(WebCore::Internals::numberOfLiveNodes):
(WebCore::Internals::numberOfLiveDocuments):
* testing/Internals.h:
* testing/Internals.idl:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r164725 and r164731.
http://trac.webkit.org/changeset/164725
http://trac.webkit.org/changeset/164731
https://bugs.webkit.org/show_bug.cgi?id=129382

WebKitTestRunner build is broken on IOS (Requested by smfr on
#webkit).

* UIProcess/API/Cocoa/WKView.h:
* UIProcess/API/ios/WKViewIOS.mm: Added.
(-[WKView initWithCoder:]):
(-[WKView initWithFrame:processGroup:browsingContextGroup:]):
(-[WKView initWithFrame:processGroup:browsingContextGroup:relatedToView:]):
(-[WKView dealloc]):
(-[WKView setFrame:]):
(-[WKView setBounds:]):
(-[WKView scrollView]):
(-[WKView browsingContextController]):
(-[WKView setAllowsBackForwardNavigationGestures:]):
(-[WKView allowsBackForwardNavigationGestures]):
(-[WKView viewForZoomingInScrollView:]):
(-[WKView scrollViewWillBeginZooming:withView:]):
(-[WKView scrollViewWillBeginDragging:]):
(-[WKView _didFinishScrolling]):
(-[WKView scrollViewDidEndDragging:willDecelerate:]):
(-[WKView scrollViewDidEndDecelerating:]):
(-[WKView scrollViewDidScrollToTop:]):
(-[WKView scrollViewDidScroll:]):
(-[WKView scrollViewDidZoom:]):
(-[WKView scrollViewDidEndZooming:withView:atScale:]):
(-[WKView _commonInitializationWithContextRef:pageGroupRef:relatedToPage:]):
(-[WKView _frameOrBoundsChanged]):
(-[WKView _updateVisibleContentRects]):
(-[WKView _keyboardChangedWithInfo:adjustScrollView:]):
(-[WKView _keyboardWillChangeFrame:]):
(-[WKView _keyboardDidChangeFrame:]):
(-[WKView _keyboardWillShow:]):
(-[WKView _keyboardWillHide:]):
(-[WKView pageRef]):
(-[WKView initWithFrame:contextRef:pageGroupRef:]):
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
(-[WKView minimumLayoutSizeOverride]):
(-[WKView setMinimumLayoutSizeOverride:]):
(-[WKView _obscuredInsets]):
(-[WKView _setObscuredInsets:]):
(-[WKView _beginInteractiveObscuredInsetsChange]):
(-[WKView _endInteractiveObscuredInsetsChange]):
(-[WKView _pageExtendedBackgroundColor]):
(-[WKView _setBackgroundExtendsBeyondPage:]):
(-[WKView _backgroundExtendsBeyondPage]):
* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164736 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WebKit2] Adopt SPI for managing tabs
https://bugs.webkit.org/show_bug.cgi?id=129188
<rdar://problem/15939827>

Reviewed by Gavin Barraclough.

Call into assertions SPI to mark tabs as foreground and background.

* Configurations/WebKit2.xcconfig:
* Platform/IPC/Connection.h:
(IPC::Connection::xpcConnection): Expose the xpc_connection_t.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::viewStateDidChange):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didFinishLaunching):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::updateProcessState):
* UIProcess/ios/WebProcessProxyIOS.mm:
(WebKit::WebProcessProxy::updateProcessState): Added. This goes through the list of
WebPageProxies and sets the process state to foreground if one of them is in a window.
Otherwise, it sets it to background.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164737 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Function.prototype.apply has a bad time with the spread operator
https://bugs.webkit.org/show_bug.cgi?id=129381

Reviewed by Mark Hahnenberg.

Source/JavaScriptCore:

Make sure our apply logic handle the spread operator correctly.
To do this we simply emit the enumeration logic that we'd normally
use for other enumerations, but only store the first two results
to registers.  Then perform a varargs call.

* bytecompiler/NodesCodegen.cpp:
(JSC::ApplyFunctionCallDotNode::emitBytecode):

LayoutTests:

Add tests

* js/regress/call-spread-apply-expected.txt: Added.
* js/regress/call-spread-apply.html: Added.
* js/regress/script-tests/call-spread-apply.js: Added.
(testFunction):
(test2):
(test3):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164738 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[GTK] Reduplicate common.top_level_path in scripts
https://bugs.webkit.org/show_bug.cgi?id=129291

Reviewed by Philippe Normand.

Duplicate common.top_level_path and avoid polluting many scripts with awkward system
path manipulation and weird dependencies on the jhbuild infrastructure.

* Scripts/run-gtk-tests: Use common again.
(TestRunner._setup_testing_environment): Ditto.
* gtk/check-gdom-symbols: Ditto.
* gtk/common.py:
(top_level_path): Re-add top_level_path..
(get_build_path): Use the builtin top_level_path again.
* gtk/find-make-dist-errors: Use common again.
(get_missing_headers): Ditto.
* gtk/generate-inspector-gresource-manifest.py: Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164739 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix an issue where the Timeline filter scope bars were not applying.

Reviewed by Joseph Pecoraro.

* UserInterface/Views/TimelineDataGrid.js:
(TimelineDataGrid.prototype.treeElementMatchesActiveScopeFilters): Use .get() to access the ScopeBar.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164740 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Underlines are too thick when zoomed in
https://bugs.webkit.org/show_bug.cgi?id=129352

Reviewed by Dean Jackson.

Source/WebCore:

The input to the underline drawing code is in user-space, not device-space.
The underlines were getting scaled twice, once in InlineTextBox and the other
in GraphicsContext.

Test: fast/css3-text/css3-text-decoration/text-decoration-scaled.html

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintDecoration):

LayoutTests:

This test changes the page scale factor to a very large value, simulating
the user zooming in with a trackpad. It then positions the viewport
to a place where the underline should not be drawn. It then compares this
to a completely white page.

This explanation cannot be in the test itself because the test sets the
scale factor too high for the tester to be able to read text.

* fast/css3-text/css3-text-decoration/text-decoration-scaled-expected.html: Added.
* fast/css3-text/css3-text-decoration/text-decoration-scaled.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164741 268f45cc-cd09-0410-ab3c-d52691b4dbfc
FastMalloc should use vm_page_shift intead of PAGE_SHIFT.
https://bugs.webkit.org/show_bug.cgi?id=129370

Reviewed by Mark Rowe.

"Doesn't this lead to the page map using fewer bits than it was before?
It seems like this will cause some page addresses to no longer be
representable in the map when using 4K pages. Am I missing something?"

* wtf/FastMalloc.cpp:
    - bdash raises a valid point. This should make the TCMalloc_PageMap
      larger than absolutely necessary, rather than potentially too small.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164742 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Shapes] inset and inset-rectangle trigger assert with replaced element and large percentage dimension
https://bugs.webkit.org/show_bug.cgi?id=129060

Reviewed by Simon Fraser.

Source/WebCore:

A bounds check was omitted when computing the width and height for inset
rectangles, making it possible for the width or height to end up being
negative. This patch adds in that check for both. It seems that only
replaced elements like iframe and img trigger this problem.

Tests: fast/shapes/shape-outside-floats/shape-outside-floats-img-inset-negative-width-crash.html
       fast/shapes/shape-outside-floats/shape-outside-floats-img-inset-rectangle-negative-width-crash.html

* rendering/shapes/Shape.cpp:
(WebCore::Shape::createShape):

LayoutTests:

* fast/shapes/shape-outside-floats/shape-outside-floats-img-inset-negative-width-crash-expected.txt: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-img-inset-negative-width-crash.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-img-inset-rectangle-negative-width-crash-expected.txt: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-img-inset-rectangle-negative-width-crash.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164743 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WebGL] Protect more WebGL entry points for pending contexts
https://bugs.webkit.org/show_bug.cgi?id=129386

Reviewed by Tim Horton.

There are entry points into a WebGLRenderingContext that don't
come from the web-exposed API directly, such as drawImage with
the WebGL canvas. Protect these by returning early if we're
a pending context.

Also a bunch of drive-by 0 -> nullptr changes.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::markLayerComposited):
(WebCore::WebGLRenderingContext::paintRenderingResultsToCanvas):
(WebCore::WebGLRenderingContext::paintRenderingResultsToImageData):
(WebCore::WebGLRenderingContext::reshape):
(WebCore::WebGLRenderingContext::createBuffer):
(WebCore::WebGLRenderingContext::createFramebuffer):
(WebCore::WebGLRenderingContext::createTexture):
(WebCore::WebGLRenderingContext::createProgram):
(WebCore::WebGLRenderingContext::createRenderbuffer):
(WebCore::WebGLRenderingContext::createShader):
(WebCore::WebGLRenderingContext::getActiveAttrib):
(WebCore::WebGLRenderingContext::getActiveUniform):
(WebCore::WebGLRenderingContext::getContextAttributes):
(WebCore::WebGLRenderingContext::getError):
(WebCore::WebGLRenderingContext::getExtension):
(WebCore::WebGLRenderingContext::getShaderPrecisionFormat):
(WebCore::WebGLRenderingContext::getUniformLocation):
(WebCore::WebGLRenderingContext::drawImageIntoBuffer):
(WebCore::WebGLRenderingContext::videoFrameToImage):
(WebCore::WebGLRenderingContext::validateBufferDataParameters):
(WebCore::WebGLRenderingContext::LRUImageBufferCache::imageBuffer):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Web Replay: route through UserInputBridge when delivering user inputs to WebCore
https://bugs.webkit.org/show_bug.cgi?id=128150

Reviewed by Timothy Hatcher.

Source/WebCore:

Add an UserInputBridge instance to each Page. WebKit2 routes a page's user inputs through
the WebCore page's user input bridge so that the inputs can be selectively captured, filtered,
and replayed using instrumentation inside the UserInputBridge.

For now, the routing methods of UserInputBridge have no replay-specific code paths, and just
put the input delivery code inside WebCore rather than its external clients. Replay-specific
code paths will be added once https://bugs.webkit.org/show_bug.cgi?id=128782 is fixed. However,
once complete the code will work as follows:

- When neither capturing or replaying, behavior is unchanged.

- When capturing user inputs, each external input is saved into a replay log as it crosses
the bridge from outside WebCore.

- When replaying, the bridge closes and user inputs from WebKit2 are not accepted. Instead,
the saved inputs from the replay log are re-dispatched as if they had crossed the bridge.

* CMakeLists.txt:
* GNUmakefile.am:
* GNUmakefile.list.am:
* WebCore.exp.in: Add symbols for input routing methods.
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* page/Page.cpp:
(WebCore::Page::Page): Initialize the owned UserInputBridge in the Page constructor.
* page/Page.h:
(WebCore::Page::inputBridge): Added a by-reference getter.
* replay/UserInputBridge.cpp: Added.
(WebCore::UserInputBridge::UserInputBridge):
(WebCore::UserInputBridge::~UserInputBridge):
(WebCore::UserInputBridge::handleContextMenuEvent):
(WebCore::UserInputBridge::handleMousePressEvent):
(WebCore::UserInputBridge::handleMouseReleaseEvent):
(WebCore::UserInputBridge::handleMouseMoveEvent):
(WebCore::UserInputBridge::handleMouseMoveOnScrollbarEvent):
(WebCore::UserInputBridge::handleKeyEvent):
(WebCore::UserInputBridge::handleAccessKeyEvent):
(WebCore::UserInputBridge::handleWheelEvent):
(WebCore::UserInputBridge::focusSetActive):
(WebCore::UserInputBridge::focusSetFocused):
(WebCore::UserInputBridge::scrollRecursively):
(WebCore::UserInputBridge::logicalScrollRecursively):
(WebCore::UserInputBridge::loadRequest):
(WebCore::UserInputBridge::reloadFrame):
(WebCore::UserInputBridge::stopLoadingFrame):
(WebCore::UserInputBridge::tryClosePage):
* replay/UserInputBridge.h: Added.

Source/WebKit2:

When delivering user inputs to WebCore, route calls through the page's UserInputBridge.
This allows us to capture and replay user inputs from WebKit2 solely within WebCore.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::tryClose):
(WebKit::WebPage::loadRequest):
(WebKit::WebPage::stopLoadingFrame):
(WebKit::WebPage::stopLoading):
(WebKit::WebPage::reload):
(WebKit::WebPage::contextMenuAtPointInWindow):
(WebKit::handleContextMenuEvent):
(WebKit::handleMouseEvent):
(WebKit::handleWheelEvent):
(WebKit::handleKeyEvent):
(WebKit::WebPage::scroll):
(WebKit::WebPage::logicalScroll):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164745 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Roll out r164732 since it broke Production Mac builds.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164746 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove unused access types
https://bugs.webkit.org/show_bug.cgi?id=129385

Reviewed by Filip Pizlo.

Remove unused cruft.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::printGetByIdCacheStatus):
* bytecode/StructureStubInfo.cpp:
(JSC::StructureStubInfo::deref):
* bytecode/StructureStubInfo.h:
(JSC::isGetByIdAccess):
(JSC::isPutByIdAccess):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164747 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed. Moved myself to the list of committers.

* Scripts/webkitpy/common/config/contributors.json:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164748 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebProcessProxy::updateProcessState() is causing duplicate symbol linker errors
https://bugs.webkit.org/show_bug.cgi?id=129390

Reviewed by Tim Horton.

Caused by r164737. WebProcessProxy::updateProcessState() is defined in a header, outside of
a class, but isn't inlined.

* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::updateProcessState):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164749 268f45cc-cd09-0410-ab3c-d52691b4dbfc