summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2013-09-23 20:25:11 +0400
committerFedor Indutny <fedor.indutny@gmail.com>2013-09-23 20:26:57 +0400
commit970bdccc38fee27e10ff1a3b68f3fea3417788a1 (patch)
tree85b1d2c87da1226bcb345e9c7ee9ffd2b7bb625f /deps/v8/test/cctest
parent75ea566f5abd09882b25b9335f5ae6c53a22fcb6 (diff)
downloadnode-new-970bdccc38fee27e10ff1a3b68f3fea3417788a1.tar.gz
deps: update v8 to 3.20.17.11
fix #6235
Diffstat (limited to 'deps/v8/test/cctest')
-rw-r--r--deps/v8/test/cctest/test-api.cc17
-rw-r--r--deps/v8/test/cctest/test-heap.cc72
-rw-r--r--deps/v8/test/cctest/test-strings.cc30
3 files changed, 119 insertions, 0 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.