summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-08-27 10:21:07 +0100
committerSteve Block <steveblock@google.com>2010-08-27 10:27:17 +0100
commit791712a13f1814dd3ab5d1a5ab8ff5dbc476f6d6 (patch)
tree875cbc3272688c25996968c5165b4a957f0eeefb /test
parent756813857a4c2a4d8ad2e805969d5768d3cf43a0 (diff)
downloadandroid_external_v8-791712a13f1814dd3ab5d1a5ab8ff5dbc476f6d6.tar.gz
android_external_v8-791712a13f1814dd3ab5d1a5ab8ff5dbc476f6d6.tar.bz2
android_external_v8-791712a13f1814dd3ab5d1a5ab8ff5dbc476f6d6.zip
Update V8 to r5318 to fix crashing ARM bugs
Bug: 2947054 Change-Id: I9c7398edb1525477c75ace9d383efaf790d12c51
Diffstat (limited to 'test')
-rw-r--r--test/cctest/cctest.status3
-rw-r--r--test/cctest/test-api.cc1
-rw-r--r--test/cctest/test-heap-profiler.cc125
-rw-r--r--test/cctest/test-heap.cc4
-rw-r--r--test/mjsunit/regexp.js18
-rw-r--r--test/mjsunit/shifts.js38
6 files changed, 184 insertions, 5 deletions
diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status
index 7689371a..895e2453 100644
--- a/test/cctest/cctest.status
+++ b/test/cctest/cctest.status
@@ -42,9 +42,6 @@ test-serialize/DependentTestThatAlwaysFails: FAIL
[ $arch == arm ]
-# BUG(240): Test seems flaky on ARM.
-test-api/RegExpInterruption: SKIP
-
# We cannot assume that we can throw OutOfMemory exceptions in all situations.
# Apparently our ARM box is in such a state. Skip the test as it also runs for
# a long time.
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 8bfa51c6..adaf1027 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -9203,6 +9203,7 @@ class RegExpStringModificationTest {
morphs_ < kMaxModifications) {
int morphs_before = morphs_;
{
+ v8::HandleScope scope;
// Match 15-30 "a"'s against 14 and a "b".
const char* c_source =
"/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/"
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 92ad0a40..6dc49c0e 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -372,6 +372,7 @@ TEST(RetainerProfile) {
i::HeapIterator iterator;
for (i::HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next())
ret_profile.CollectStats(obj);
+ ret_profile.CoarseAndAggregate();
RetainerProfilePrinter printer;
ret_profile.DebugPrintStats(&printer);
const char* retainers_of_a = printer.GetRetainers("A");
@@ -650,6 +651,8 @@ TEST(HeapSnapshotCodeObjects) {
CompileAndRunScript(
"function lazy(x) { return x - 1; }\n"
"function compiled(x) { return x + 1; }\n"
+ "var inferred = function(x) { return x; }\n"
+ "var anonymous = (function() { return function() { return 0; } })();\n"
"compiled(1)");
const v8::HeapSnapshot* snapshot =
v8::HeapProfiler::TakeSnapshot(v8::String::New("code"));
@@ -663,6 +666,18 @@ TEST(HeapSnapshotCodeObjects) {
GetProperty(global, v8::HeapGraphEdge::kProperty, "lazy");
CHECK_NE(NULL, lazy);
CHECK_EQ(v8::HeapGraphNode::kClosure, lazy->GetType());
+ const v8::HeapGraphNode* inferred =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "inferred");
+ CHECK_NE(NULL, inferred);
+ CHECK_EQ(v8::HeapGraphNode::kClosure, inferred->GetType());
+ v8::String::AsciiValue inferred_name(inferred->GetName());
+ CHECK_EQ("inferred", *inferred_name);
+ const v8::HeapGraphNode* anonymous =
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "anonymous");
+ CHECK_NE(NULL, anonymous);
+ CHECK_EQ(v8::HeapGraphNode::kClosure, anonymous->GetType());
+ v8::String::AsciiValue anonymous_name(anonymous->GetName());
+ CHECK_EQ("(anonymous function)", *anonymous_name);
// Find references to code.
const v8::HeapGraphNode* compiled_code =
@@ -864,4 +879,114 @@ TEST(Issue822) {
i::HeapSnapshotTester::CalculateNetworkSize(*jsobj);
}
+
+static const v8::HeapGraphNode* GetChild(
+ const v8::HeapGraphNode* node,
+ v8::HeapGraphNode::Type type,
+ const char* name,
+ const v8::HeapGraphNode* after = NULL) {
+ bool ignore_child = after == NULL ? false : true;
+ for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) {
+ const v8::HeapGraphEdge* prop = node->GetChild(i);
+ const v8::HeapGraphNode* child = prop->GetToNode();
+ v8::String::AsciiValue child_name(child->GetName());
+ if (!ignore_child
+ && child->GetType() == type
+ && strcmp(name, *child_name) == 0)
+ return child;
+ if (after != NULL && child == after) ignore_child = false;
+ }
+ return NULL;
+}
+
+static bool IsNodeRetainedAs(const v8::HeapGraphNode* node,
+ int element) {
+ for (int i = 0, count = node->GetRetainersCount(); i < count; ++i) {
+ const v8::HeapGraphEdge* prop = node->GetRetainer(i);
+ if (prop->GetType() == v8::HeapGraphEdge::kElement
+ && element == prop->GetName()->Int32Value())
+ return true;
+ }
+ return false;
+}
+
+TEST(AggregatedHeapSnapshot) {
+ v8::HandleScope scope;
+ LocalContext env;
+
+ CompileAndRunScript(
+ "function A() {}\n"
+ "function B(x) { this.x = x; }\n"
+ "var a = new A();\n"
+ "var b = new B(a);");
+ const v8::HeapSnapshot* snapshot =
+ v8::HeapProfiler::TakeSnapshot(
+ v8::String::New("agg"), v8::HeapSnapshot::kAggregated);
+ const v8::HeapGraphNode* strings = GetChild(snapshot->GetRoot(),
+ v8::HeapGraphNode::kInternal,
+ "STRING_TYPE");
+ CHECK_NE(NULL, strings);
+ CHECK_NE(0, strings->GetSelfSize());
+ CHECK_NE(0, strings->GetInstancesCount());
+ const v8::HeapGraphNode* maps = GetChild(snapshot->GetRoot(),
+ v8::HeapGraphNode::kInternal,
+ "MAP_TYPE");
+ CHECK_NE(NULL, maps);
+ CHECK_NE(0, maps->GetSelfSize());
+ CHECK_NE(0, maps->GetInstancesCount());
+
+ const v8::HeapGraphNode* a = GetChild(snapshot->GetRoot(),
+ v8::HeapGraphNode::kObject,
+ "A");
+ CHECK_NE(NULL, a);
+ CHECK_NE(0, a->GetSelfSize());
+ CHECK_EQ(1, a->GetInstancesCount());
+
+ const v8::HeapGraphNode* b = GetChild(snapshot->GetRoot(),
+ v8::HeapGraphNode::kObject,
+ "B");
+ CHECK_NE(NULL, b);
+ CHECK_NE(0, b->GetSelfSize());
+ CHECK_EQ(1, b->GetInstancesCount());
+
+ const v8::HeapGraphNode* glob_prop = GetChild(snapshot->GetRoot(),
+ v8::HeapGraphNode::kObject,
+ "(global property)",
+ b);
+ CHECK_NE(NULL, glob_prop);
+ CHECK_EQ(0, glob_prop->GetSelfSize());
+ CHECK_EQ(0, glob_prop->GetInstancesCount());
+ CHECK_NE(0, glob_prop->GetChildrenCount());
+
+ const v8::HeapGraphNode* a_from_glob_prop = GetChild(
+ glob_prop,
+ v8::HeapGraphNode::kObject,
+ "A");
+ CHECK_NE(NULL, a_from_glob_prop);
+ CHECK_EQ(0, a_from_glob_prop->GetSelfSize());
+ CHECK_EQ(0, a_from_glob_prop->GetInstancesCount());
+ CHECK_EQ(0, a_from_glob_prop->GetChildrenCount()); // Retains nothing.
+ CHECK(IsNodeRetainedAs(a_from_glob_prop, 1)); // (global propery) has 1 ref.
+
+ const v8::HeapGraphNode* b_with_children = GetChild(
+ snapshot->GetRoot(),
+ v8::HeapGraphNode::kObject,
+ "B",
+ b);
+ CHECK_NE(NULL, b_with_children);
+ CHECK_EQ(0, b_with_children->GetSelfSize());
+ CHECK_EQ(0, b_with_children->GetInstancesCount());
+ CHECK_NE(0, b_with_children->GetChildrenCount());
+
+ const v8::HeapGraphNode* a_from_b = GetChild(
+ b_with_children,
+ v8::HeapGraphNode::kObject,
+ "A");
+ CHECK_NE(NULL, a_from_b);
+ CHECK_EQ(0, a_from_b->GetSelfSize());
+ CHECK_EQ(0, a_from_b->GetInstancesCount());
+ CHECK_EQ(0, a_from_b->GetChildrenCount()); // Retains nothing.
+ CHECK(IsNodeRetainedAs(a_from_b, 1)); // B has 1 ref to A.
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 9d5e1f19..605d8831 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -36,8 +36,8 @@ TEST(HeapMaps) {
InitializeVM();
CheckMap(Heap::meta_map(), MAP_TYPE, Map::kSize);
CheckMap(Heap::heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize);
- CheckMap(Heap::fixed_array_map(), FIXED_ARRAY_TYPE, FixedArray::kHeaderSize);
- CheckMap(Heap::string_map(), STRING_TYPE, SeqTwoByteString::kAlignedSize);
+ CheckMap(Heap::fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel);
+ CheckMap(Heap::string_map(), STRING_TYPE, kVariableSizeSentinel);
}
diff --git a/test/mjsunit/regexp.js b/test/mjsunit/regexp.js
index a8891969..db8b1338 100644
--- a/test/mjsunit/regexp.js
+++ b/test/mjsunit/regexp.js
@@ -484,3 +484,21 @@ assertRegExpTest(/[,b]\b[,b]/, ",b", true);
assertRegExpTest(/[,b]\B[,b]/, ",b", false);
assertRegExpTest(/[,b]\b[,b]/, "b,", true);
assertRegExpTest(/[,b]\B[,b]/, "b,", false);
+
+// Test that caching of result doesn't share result objects.
+// More iterations increases the chance of hitting a GC.
+for (var i = 0; i < 100; i++) {
+ var re = /x(y)z/;
+ var res = re.exec("axyzb");
+ assertTrue(!!res);
+ assertEquals(2, res.length);
+ assertEquals("xyz", res[0]);
+ assertEquals("y", res[1]);
+ assertEquals(1, res.index);
+ assertEquals("axyzb", res.input);
+ assertEquals(undefined, res.foobar);
+
+ res.foobar = "Arglebargle";
+ res[3] = "Glopglyf";
+ assertEquals("Arglebargle", res.foobar);
+}
diff --git a/test/mjsunit/shifts.js b/test/mjsunit/shifts.js
new file mode 100644
index 00000000..b91b3e8a
--- /dev/null
+++ b/test/mjsunit/shifts.js
@@ -0,0 +1,38 @@
+// Copyright 2010 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: --nofull-compiler
+
+// test a few corners cases with shifts
+
+// The result of the shift is not a Smi.
+var s1 = 0x3fffffff;
+assertEquals(0x7fffffff, (s1 << 1) + 1);
+
+// The result of the shift is not a Smi.
+var s2 = -1;
+assertEquals(0xffffffff, (s2 >>> 0));