diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-09-26 09:18:06 -0700 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-09-26 09:19:50 -0700 |
commit | 85898d196718ef2e2129ed98b8865ee4b2658f0b (patch) | |
tree | 5c7638115412a4229e0c25debe7caf62258a30db /deps/v8/test | |
parent | c79d5163e530892c62b08d8b814b588220c26ec8 (diff) | |
download | node-new-85898d196718ef2e2129ed98b8865ee4b2658f0b.tar.gz |
v8: upgrade to 3.20.17.13
fixes #6235
Diffstat (limited to 'deps/v8/test')
-rw-r--r-- | deps/v8/test/cctest/test-api.cc | 17 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-heap.cc | 72 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-strings.cc | 30 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/allocation-folding.js | 27 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/regress/regress-crbug-285355.js | 43 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/regress/regress-crbug-298392.js | 51 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/regress/regress-regexp-construct-result.js | 45 |
7 files changed, 283 insertions, 2 deletions
diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 3be5008145..55d376d154 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -20173,4 +20173,21 @@ TEST(AccessCheckThrows) { "other, 'x', null, null, 1)"); } + +THREADED_TEST(Regress256330) { + i::FLAG_allow_natives_syntax = true; + LocalContext context; + v8::HandleScope scope(context->GetIsolate()); + Handle<FunctionTemplate> templ = FunctionTemplate::New(); + AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter); + context->Global()->Set(v8_str("Bug"), templ->GetFunction()); + CompileRun("\"use strict\"; var o = new Bug;" + "function f(o) { o.x = 10; };" + "f(o); f(o); f(o);" + "%OptimizeFunctionOnNextCall(f);" + "f(o);"); + ExpectBoolean("%GetOptimizationStatus(f) != 2", true); +} + + #endif // WIN32 diff --git a/deps/v8/test/cctest/test-heap.cc b/deps/v8/test/cctest/test-heap.cc index df799bdd63..1813470838 100644 --- a/deps/v8/test/cctest/test-heap.cc +++ b/deps/v8/test/cctest/test-heap.cc @@ -2115,6 +2115,78 @@ TEST(OptimizedAllocationAlwaysInNewSpace) { } +TEST(OptimizedPretenuringAllocationFolding) { + i::FLAG_allow_natives_syntax = true; + CcTest::InitializeVM(); + if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; + v8::HandleScope scope(CcTest::isolate()); + HEAP->SetNewSpaceHighPromotionModeActive(true); + + v8::Local<v8::Value> res = CompileRun( + "function DataObject() {" + " this.a = 1.1;" + " this.b = [{}];" + " this.c = 1.2;" + " this.d = [{}];" + " this.e = 1.3;" + " this.f = [{}];" + "}" + "function f() {" + " return new DataObject();" + "};" + "f(); f(); f();" + "%OptimizeFunctionOnNextCall(f);" + "f();"); + + Handle<JSObject> o = + v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); + + CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(0))); + CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(1))); + CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); + CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3))); + CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4))); + CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5))); +} + + +TEST(OptimizedPretenuringAllocationFoldingBlocks) { + i::FLAG_allow_natives_syntax = true; + CcTest::InitializeVM(); + if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; + if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; + v8::HandleScope scope(CcTest::isolate()); + HEAP->SetNewSpaceHighPromotionModeActive(true); + + v8::Local<v8::Value> res = CompileRun( + "function DataObject() {" + " this.a = [{}];" + " this.b = [{}];" + " this.c = 1.1;" + " this.d = 1.2;" + " this.e = [{}];" + " this.f = 1.3;" + "}" + "function f() {" + " return new DataObject();" + "};" + "f(); f(); f();" + "%OptimizeFunctionOnNextCall(f);" + "f();"); + + Handle<JSObject> o = + v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); + + CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(0))); + CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(1))); + CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); + CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3))); + CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4))); + CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5))); +} + + TEST(OptimizedPretenuringObjectArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index 310d93c04e..726188d917 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -1017,6 +1017,36 @@ TEST(ExternalShortStringAdd) { } +TEST(JSONStringifySliceMadeExternal) { + Isolate* isolate = Isolate::Current(); + Zone zone(isolate); + CcTest::InitializeVM(); + // Create a sliced string from a one-byte string. The latter is turned + // into a two-byte external string. Check that JSON.stringify works. + v8::HandleScope handle_scope(CcTest::isolate()); + v8::Handle<v8::String> underlying = + CompileRun("var underlying = 'abcdefghijklmnopqrstuvwxyz';" + "underlying")->ToString(); + v8::Handle<v8::String> slice = + CompileRun("var slice = underlying.slice(1);" + "slice")->ToString(); + CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); + CHECK(v8::Utils::OpenHandle(*underlying)->IsSeqOneByteString()); + + int length = underlying->Length(); + uc16* two_byte = zone.NewArray<uc16>(length + 1); + underlying->Write(two_byte); + Resource* resource = + new(&zone) Resource(Vector<const uc16>(two_byte, length)); + CHECK(underlying->MakeExternal(resource)); + CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); + CHECK(v8::Utils::OpenHandle(*underlying)->IsExternalTwoByteString()); + + CHECK_EQ("\"bcdefghijklmnopqrstuvwxyz\"", + *v8::String::Utf8Value(CompileRun("JSON.stringify(slice)"))); +} + + TEST(CachedHashOverflow) { // We incorrectly allowed strings to be tagged as array indices even if their // values didn't fit in the hash field. diff --git a/deps/v8/test/mjsunit/allocation-folding.js b/deps/v8/test/mjsunit/allocation-folding.js index fe5fa6d855..ec07392f2c 100644 --- a/deps/v8/test/mjsunit/allocation-folding.js +++ b/deps/v8/test/mjsunit/allocation-folding.js @@ -56,7 +56,7 @@ function doubles() { doubles(); doubles(); doubles(); %OptimizeFunctionOnNextCall(doubles); -var result = doubles(); +result = doubles(); gc(); @@ -72,8 +72,31 @@ function doubles_int() { doubles_int(); doubles_int(); doubles_int(); %OptimizeFunctionOnNextCall(doubles_int); -var result = doubles_int(); +result = doubles_int(); gc(); assertEquals(result[1], 3.1); + +// Test allocation folding over a branch. + +function branch_int(left) { + var elem1 = [1, 2]; + var elem2; + if (left) { + elem2 = [3, 4]; + } else { + elem2 = [5, 6]; + } + return elem2; +} + +branch_int(1); branch_int(1); branch_int(1); +%OptimizeFunctionOnNextCall(branch_int); +result = branch_int(1); +var result2 = branch_int(0); + +gc(); + +assertEquals(result[1], 4); +assertEquals(result2[1], 6); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-285355.js b/deps/v8/test/mjsunit/regress/regress-crbug-285355.js new file mode 100644 index 0000000000..ebd480a710 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-285355.js @@ -0,0 +1,43 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --allow-natives-syntax + +function inverted_index() { + return ~1; +} + +%NeverOptimizeFunction(inverted_index); + +function crash(array) { + return array[~inverted_index()] = 2; +} + +assertEquals(2, crash(new Array(1))); +assertEquals(2, crash(new Array(1))); +%OptimizeFunctionOnNextCall(crash) +assertEquals(2, crash(new Array(1))); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-298392.js b/deps/v8/test/mjsunit/regress/regress-crbug-298392.js new file mode 100644 index 0000000000..8370654b6c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-298392.js @@ -0,0 +1,51 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function foo() { + return [[1,2,3], [5,6,6]]; +} + +function bar() { + return ["foo", "bar"]; +} + +function baz() { + return [foo(), bar(), foo(), bar()]; +} + +function thingy() { + var result = []; + for (var i = 0; i < 50000; ++i) { + result.push(baz()); + } + return result; +} + +var size = thingy().length; +if (size != 50000) { + throw "Error: bad size: " + size; +} diff --git a/deps/v8/test/mjsunit/regress/regress-regexp-construct-result.js b/deps/v8/test/mjsunit/regress/regress-regexp-construct-result.js new file mode 100644 index 0000000000..84bdd2004b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-regexp-construct-result.js @@ -0,0 +1,45 @@ +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Create a huge regexp with many alternative capture groups, most of +// which do not capture anything, but the corresponding capture slot +// in the result object has to exist, even though filled with undefined. +// Having a large result array helps stressing GC. + +var num_captures = 1000; +var regexp_string = "(a)"; +for (var i = 0; i < num_captures - 1; i++) { + regexp_string += "|(b)"; +} +var regexp = new RegExp(regexp_string); + +for (var i = 0; i < 10; i++) { + var matches = regexp.exec("a"); + var count = 0; + matches.forEach(function() { count++; }); + assertEquals(num_captures + 1, count); +} |