atomicDecrement() never reach 0 on Android so no deref() will be called
https://bugs.webkit.org/show_bug.cgi?id=92635

Patch by Wei James <james.wei@intel.com> on 2012-07-30
Reviewed by Adam Barth.

With Android NDK 7b and later, __atomic_dec()  is implemented by
__sync_fetch_and_sub(), which will result in that atomicDecrement()
returns the old value instead of new one.

* wtf/Atomics.h:
(WTF):
(WTF::atomicIncrement):
(WTF::atomicDecrement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@124115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
nrwt: clean up handling of 'expected' stats
https://bugs.webkit.org/show_bug.cgi?id=92527

Reviewed by Tony Chang.

This patch alters the way we compute and log the "expected"
results and how we treat skipped tests; we will now log the
number of skipped tests separately from the categories, e.g.:

Found 31607 tests; running 24464.
Expect: 23496 passes   (23496 now,    0 wontfix)
Expect:   548 failures (  543 now,    5 wontfix)
Expect:   420 flaky    (  245 now,  175 wontfix)

(so that the "expect" totals add up to the "running" totals);
in addition, the totals in the one-line-progress reflect the
number of tests we will actually run. If --iterations or
--repeat-each are specified, the number of tests we run are
multiplied as appropriate, but the "expect" numbers are
unchanged, since we don't count multiple invocations of the same
test multiple times. In addition, if we are using --run-part or
--run-chunk, the tests we don't run are treated as skipped
for consistency. We will also log the values for --iterations
and --repeat each as part of the found/running line.

Previously the code had parsed and re-parsed the
TestExpectations files several times in an attempt to come up
with some sane statistics, but this was expensive and lead to
confusing layer; treating files as skipped in the way described
above is more consistent and cleaner.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager._split_into_chunks_if_necessary):
(Manager.prepare_lists_and_print_output):
(Manager.run):
* Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
(ManagerTest.test_interrupt_if_at_failure_limits):
(ManagerTest.test_update_summary_with_result):
(ManagerTest.test_look_for_new_crash_logs):
(ResultSummaryTest.get_result_summary):
* Scripts/webkitpy/layout_tests/models/result_summary.py:
(ResultSummary.__init__):
* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectationParser.expectation_for_skipped_test):
(TestExpectations.__init__):
(TestExpectations.add_skipped_tests):
  Here we make add_skipped_tests() public, so that we can update
  the expectations for tests that we are skipping due to
  --run-part or --run-chunk; we use the wontfix flag so that
  the tests that are intentionally skipped aren't considered
  "fixable".
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
(SkippedTests.check):
* Scripts/webkitpy/layout_tests/run_webkit_tests.py:
(parse_args):
* Scripts/webkitpy/layout_tests/views/printing.py:
(Printer.print_found):
(Printer):
(Printer.print_expected):
(Printer._print_result_summary):
(Printer._print_result_summary_entry):
  Here we split out printing the number of tests found and run
  from the expected results, to be clearer and so that we don't
  have to reparse the expectations to update the stats.
* Scripts/webkitpy/layout_tests/views/printing_unittest.py:
(Testprinter.get_result_summary):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@124116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CMake] TestWebKitAPI bundle should link with WTF
https://bugs.webkit.org/show_bug.cgi?id=92616

Patch by Thiago Marcos P. Santos <thiago.santos@intel.com> on 2012-07-30
Reviewed by Antonio Gomes.

Fixes build when shared core is disabled.

* TestWebKitAPI/CMakeLists.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@124118 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add ability to load from a string to the ObjC WK API
https://bugs.webkit.org/show_bug.cgi?id=92590

Reviewed by Dan Bernstein.

Source/WebKit2:

This adds an often used method to the new Objective-C API and will
be helpful for writing API tests.

* UIProcess/API/mac/WKBrowsingContextController.h:
* UIProcess/API/mac/WKBrowsingContextController.mm:
(-[WKBrowsingContextController loadHTMLString:baseURL:]):
Implement via calling down to WKPageLoadHTMLString.

Tools:

Add tests for [WKBrowsingContextController loadHTMLString:baseURL:]. We will be able
to greatly improve these tests (to test more than just not crashing) when methods to
access page content are added (soon!).

Adds:
    Test: WKBrowsingContextLoadDelegateTest_SimpleLoadOfHTMLString
    Test: WKBrowsingContextLoadDelegateTest_SimpleLoadOfHTMLString_NilBaseURL
    Test: WKBrowsingContextLoadDelegateTest_SimpleLoadOfHTMLString_NilHTMLStringAndBaseURL

* TestWebKitAPI/Tests/WebKit2ObjC/WKBrowsingContextLoadDelegateTest.mm:
Adds tests and refactors delegates to not use global state.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@124121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Structures should be swept after all other objects
https://bugs.webkit.org/show_bug.cgi?id=92679

Reviewed by Filip Pizlo.

In order to get rid of ClassInfo from our objects, we need to be able to safely get the 
ClassInfo during the destruction of objects. We'd like to get the ClassInfo out of the 
Structure, but currently it is not safe to do so because the order of destruction of objects 
is not guaranteed to sweep objects before their corresponding Structure. We can fix this by 
sweeping Structures after everything else.

* heap/Heap.cpp:
(JSC::Heap::isSafeToSweepStructures): Add a function that checks if it is safe to sweep Structures.
If the Heap's IncrementalSweeper member is null, that means we're shutting down this VM and it is 
safe to sweep structures since we'll always do Structures last anyways due to the ordering of 
MarkedSpace::forEachBlock.
(JSC):
(JSC::Heap::didStartVMShutdown): Add this intermediate function to the Heap that ~JSGlobalData now
calls rather than calling the two HeapTimer objects individually. This allows the Heap to null out 
these pointers after it has invalidated them to prevent accidental use-after-free in the sweep() 
calls during lastChanceToFinalize().
* heap/Heap.h:
(Heap):
* heap/HeapTimer.h:
(HeapTimer):
* heap/IncrementalSweeper.cpp:
(JSC::IncrementalSweeper::structuresCanBeSwept): Determines if it is currently safe to sweep Structures.
This decision is based on whether we have gotten to the end of the vector of blocks that need sweeping
the first time.
(JSC):
(JSC::IncrementalSweeper::doSweep): We add a second pass over the vector to sweep Structures after we 
make our first pass. We now null out the slots as we sweep them so that we can quickly find the 
Structures during the second pass.
(JSC::IncrementalSweeper::startSweeping): Initialize our new Structure sweeping index.
(JSC::IncrementalSweeper::willFinishSweeping): Callback that is called by MarkedSpace::sweep to notify 
the IncrementalSweeper that we are going to sweep all of the remaining blocks in the Heap so it can 
assume that everything is taken care of in the correct order. Since MarkedSpace::forEachBlock 
iterates over the Structure blocks after all other blocks, the ordering property for sweeping Structures holds.
(JSC::IncrementalSweeper::IncrementalSweeper): Initialize Structure sweeping index.
* heap/IncrementalSweeper.h: Add declarations for new stuff.
(IncrementalSweeper):
* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::tryAllocateHelper): We now check if the current block only contains structures and 
if so and it isn't safe to sweep Structures according to the Heap, we just return early instead of doing 
the normal lazy sweep. If this proves to be too much of a waste in the future we can add an extra clause that 
will sweep some number of other blocks in place of the current block to mitigate the cost of the floating 
Structure garbage.
(JSC::MarkedAllocator::addBlock):
* heap/MarkedAllocator.h:
(JSC::MarkedAllocator::zapFreeList): When we zap the free list in the MarkedAllocator, the current block is no 
longer valid to allocate from, so we set the current block to null.
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::sweepHelper): Added a couple assertions to make sure that we weren't trying to sweep Structures
at an unsafe time.
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::sweep): Notify the IncrementalSweeper that the MarkedSpace will finish all currently remaining sweeping.
(JSC): 
* heap/MarkedSpace.h:
(JSC):
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::~JSGlobalData): Call the new Heap::didStartVMShutdown.


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