diff options
author | isaacs <i@izs.me> | 2012-02-23 16:35:46 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-02-27 12:11:09 -0800 |
commit | f4641bd4de566145e99b05c47c8f3d629b0223cd (patch) | |
tree | 2d0ccb1c338bec65881b30c49707d9e688fed154 /deps/v8/test | |
parent | 82ad1f87fa99b420a97cc9bfae727fce0b1bf8a4 (diff) | |
download | node-f4641bd4de566145e99b05c47c8f3d629b0223cd.tar.gz |
Update v8 to 3.9.9
Diffstat (limited to 'deps/v8/test')
31 files changed, 1272 insertions, 304 deletions
diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 87d545375..8cd73f2a8 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -11050,14 +11050,18 @@ THREADED_TEST(TurnOnAccessCheck) { } -v8::Handle<v8::String> a; -v8::Handle<v8::String> h; +static const char* kPropertyA = "a"; +static const char* kPropertyH = "h"; static bool NamedGetAccessBlockAandH(Local<v8::Object> obj, Local<Value> name, v8::AccessType type, Local<Value> data) { - return !(name->Equals(a) || name->Equals(h)); + if (!name->IsString()) return false; + i::Handle<i::String> name_handle = + v8::Utils::OpenHandle(String::Cast(*name)); + return !name_handle->IsEqualTo(i::CStrVector(kPropertyA)) + && !name_handle->IsEqualTo(i::CStrVector(kPropertyH)); } @@ -11066,9 +11070,7 @@ THREADED_TEST(TurnOnAccessCheckAndRecompile) { // Create an environment with access check to the global object disabled by // default. When the registered access checker will block access to properties - // a and h - a = v8_str("a"); - h = v8_str("h"); + // a and h. v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); global_template->SetAccessCheckCallbacks(NamedGetAccessBlockAandH, IndexedGetAccessBlocker, @@ -12902,8 +12904,15 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, "}" "ext_array[7];"); CHECK_EQ(0, result->Int32Value()); - CHECK_EQ( - 0, static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number())); + if (array_type == v8::kExternalDoubleArray || + array_type == v8::kExternalFloatArray) { + CHECK_EQ( + static_cast<int>(0x80000000), + static_cast<int>(jsobj->GetElement(7)->ToObjectChecked()->Number())); + } else { + CHECK_EQ(0, static_cast<int>( + jsobj->GetElement(7)->ToObjectChecked()->Number())); + } result = CompileRun("for (var i = 0; i < 8; i++) {" " ext_array[6] = '2.3';" @@ -13711,58 +13720,65 @@ TEST(SourceURLInStackTrace) { THREADED_TEST(IdleNotification) { v8::HandleScope scope; LocalContext env; - CompileRun("function binom(n, m) {" - " var C = [[1]];" - " for (var i = 1; i <= n; ++i) {" - " C[i] = [1];" - " for (var j = 1; j < i; ++j) {" - " C[i][j] = C[i-1][j-1] + C[i-1][j];" - " }" - " C[i][i] = 1;" - " }" - " return C[n][m];" - "};" - "binom(1000, 500)"); - bool rv = false; - for (int i = 0; i < 100; i++) { - rv = v8::V8::IdleNotification(); - if (rv) - break; + { + // Create garbage in old-space to generate work for idle notification. + i::AlwaysAllocateScope always_allocate; + for (int i = 0; i < 100; i++) { + FACTORY->NewFixedArray(1000, i::TENURED); + } } - CHECK(rv == true); + bool finshed_idle_work = false; + for (int i = 0; i < 100 && !finshed_idle_work; i++) { + finshed_idle_work = v8::V8::IdleNotification(); + } + CHECK(finshed_idle_work); } // Test that idle notification can be handled and eventually returns true. // This just checks the contract of the IdleNotification() function, // and does not verify that it does reasonable work. -TEST(IdleNotificationWithHint) { +TEST(IdleNotificationWithSmallHint) { v8::HandleScope scope; LocalContext env; { + // Create garbage in old-space to generate work for idle notification. i::AlwaysAllocateScope always_allocate; - CompileRun("function binom(n, m) {" - " var C = [[1]];" - " for (var i = 1; i <= n; ++i) {" - " C[i] = [1];" - " for (var j = 1; j < i; ++j) {" - " C[i][j] = C[i-1][j-1] + C[i-1][j];" - " }" - " C[i][i] = 1;" - " }" - " return C[n][m];" - "};" - "binom(1000, 500)"); + for (int i = 0; i < 100; i++) { + FACTORY->NewFixedArray(1000, i::TENURED); + } } - bool rv = false; intptr_t old_size = HEAP->SizeOfObjects(); + bool finshed_idle_work = false; bool no_idle_work = v8::V8::IdleNotification(10); - for (int i = 0; i < 200; i++) { - rv = v8::V8::IdleNotification(10); - if (rv) - break; + for (int i = 0; i < 200 && !finshed_idle_work; i++) { + finshed_idle_work = v8::V8::IdleNotification(10); + } + intptr_t new_size = HEAP->SizeOfObjects(); + CHECK(finshed_idle_work); + CHECK(no_idle_work || new_size < old_size); +} + + +// This just checks the contract of the IdleNotification() function, +// and does not verify that it does reasonable work. +TEST(IdleNotificationWithLargeHint) { + v8::HandleScope scope; + LocalContext env; + { + // Create garbage in old-space to generate work for idle notification. + i::AlwaysAllocateScope always_allocate; + for (int i = 0; i < 100; i++) { + FACTORY->NewFixedArray(1000, i::TENURED); + } + } + intptr_t old_size = HEAP->SizeOfObjects(); + bool finshed_idle_work = false; + bool no_idle_work = v8::V8::IdleNotification(900); + for (int i = 0; i < 200 && !finshed_idle_work; i++) { + finshed_idle_work = v8::V8::IdleNotification(900); } - CHECK(rv == true); intptr_t new_size = HEAP->SizeOfObjects(); + CHECK(finshed_idle_work); CHECK(no_idle_work || new_size < old_size); } diff --git a/deps/v8/test/cctest/test-dataflow.cc b/deps/v8/test/cctest/test-dataflow.cc index ad48f5503..a63008d21 100644 --- a/deps/v8/test/cctest/test-dataflow.cc +++ b/deps/v8/test/cctest/test-dataflow.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2012 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: @@ -36,16 +36,17 @@ using namespace v8::internal; TEST(BitVector) { v8::internal::V8::Initialize(NULL); - ZoneScope zone(Isolate::Current(), DELETE_ON_EXIT); + ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT); + Zone* zone = ZONE; { - BitVector v(15); + BitVector v(15, zone); v.Add(1); CHECK(v.Contains(1)); v.Remove(0); CHECK(!v.Contains(0)); v.Add(0); v.Add(1); - BitVector w(15); + BitVector w(15, zone); w.Add(1); v.Intersect(w); CHECK(!v.Contains(0)); @@ -53,7 +54,7 @@ TEST(BitVector) { } { - BitVector v(64); + BitVector v(64, zone); v.Add(27); v.Add(30); v.Add(31); @@ -71,9 +72,9 @@ TEST(BitVector) { } { - BitVector v(15); + BitVector v(15, zone); v.Add(0); - BitVector w(15); + BitVector w(15, zone); w.Add(1); v.Union(w); CHECK(v.Contains(0)); @@ -81,13 +82,13 @@ TEST(BitVector) { } { - BitVector v(15); + BitVector v(15, zone); v.Add(0); - BitVector w(15); + BitVector w(15, zone); w = v; CHECK(w.Contains(0)); w.Add(1); - BitVector u(w); + BitVector u(w, zone); CHECK(u.Contains(0)); CHECK(u.Contains(1)); v.Union(w); @@ -96,9 +97,9 @@ TEST(BitVector) { } { - BitVector v(35); + BitVector v(35, zone); v.Add(0); - BitVector w(35); + BitVector w(35, zone); w.Add(33); v.Union(w); CHECK(v.Contains(0)); @@ -106,15 +107,15 @@ TEST(BitVector) { } { - BitVector v(35); + BitVector v(35, zone); v.Add(32); v.Add(33); - BitVector w(35); + BitVector w(35, zone); w.Add(33); v.Intersect(w); CHECK(!v.Contains(32)); CHECK(v.Contains(33)); - BitVector r(35); + BitVector r(35, zone); r.CopyFrom(v); CHECK(!r.Contains(32)); CHECK(r.Contains(33)); diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index d66f094df..783c36d1d 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -4222,9 +4222,9 @@ TEST(InterceptorPropertyMirror) { // Get mirrors for the three objects with interceptor. CompileRun( - "named_mirror = debug.MakeMirror(intercepted_named);" - "indexed_mirror = debug.MakeMirror(intercepted_indexed);" - "both_mirror = debug.MakeMirror(intercepted_both)"); + "var named_mirror = debug.MakeMirror(intercepted_named);" + "var indexed_mirror = debug.MakeMirror(intercepted_indexed);" + "var both_mirror = debug.MakeMirror(intercepted_both)"); CHECK(CompileRun( "named_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun( @@ -4265,7 +4265,7 @@ TEST(InterceptorPropertyMirror) { CHECK_EQ(5, CompileRun(source)->Int32Value()); // Get the interceptor properties for the object with only named interceptor. - CompileRun("named_values = named_mirror.properties()"); + CompileRun("var named_values = named_mirror.properties()"); // Check that the properties are interceptor properties. for (int i = 0; i < 3; i++) { @@ -4284,7 +4284,7 @@ TEST(InterceptorPropertyMirror) { // Get the interceptor properties for the object with only indexed // interceptor. - CompileRun("indexed_values = indexed_mirror.properties()"); + CompileRun("var indexed_values = indexed_mirror.properties()"); // Check that the properties are interceptor properties. for (int i = 0; i < 2; i++) { @@ -4296,7 +4296,7 @@ TEST(InterceptorPropertyMirror) { // Get the interceptor properties for the object with both types of // interceptors. - CompileRun("both_values = both_mirror.properties()"); + CompileRun("var both_values = both_mirror.properties()"); // Check that the properties are interceptor properties. for (int i = 0; i < 5; i++) { @@ -4352,10 +4352,10 @@ TEST(HiddenPrototypePropertyMirror) { // Get mirrors for the four objects. CompileRun( - "o0_mirror = debug.MakeMirror(o0);" - "o1_mirror = debug.MakeMirror(o1);" - "o2_mirror = debug.MakeMirror(o2);" - "o3_mirror = debug.MakeMirror(o3)"); + "var o0_mirror = debug.MakeMirror(o0);" + "var o1_mirror = debug.MakeMirror(o1);" + "var o2_mirror = debug.MakeMirror(o2);" + "var o3_mirror = debug.MakeMirror(o3)"); CHECK(CompileRun("o0_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun("o1_mirror instanceof debug.ObjectMirror")->BooleanValue()); CHECK(CompileRun("o2_mirror instanceof debug.ObjectMirror")->BooleanValue()); @@ -4441,11 +4441,11 @@ TEST(NativeGetterPropertyMirror) { CHECK_EQ(10, CompileRun("instance.x")->Int32Value()); // Get mirror for the object with property getter. - CompileRun("instance_mirror = debug.MakeMirror(instance);"); + CompileRun("var instance_mirror = debug.MakeMirror(instance);"); CHECK(CompileRun( "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); - CompileRun("named_names = instance_mirror.propertyNames();"); + CompileRun("var named_names = instance_mirror.propertyNames();"); CHECK_EQ(1, CompileRun("named_names.length")->Int32Value()); CHECK(CompileRun("named_names[0] == 'x'")->BooleanValue()); CHECK(CompileRun( @@ -4477,7 +4477,7 @@ TEST(NativeGetterThrowingErrorPropertyMirror) { env->Global()->Set(v8::String::New("instance"), named->NewInstance()); // Get mirror for the object with property getter. - CompileRun("instance_mirror = debug.MakeMirror(instance);"); + CompileRun("var instance_mirror = debug.MakeMirror(instance);"); CHECK(CompileRun( "instance_mirror instanceof debug.ObjectMirror")->BooleanValue()); CompileRun("named_names = instance_mirror.propertyNames();"); diff --git a/deps/v8/test/cctest/test-deoptimization.cc b/deps/v8/test/cctest/test-deoptimization.cc index ea34a7537..ee57d65b2 100644 --- a/deps/v8/test/cctest/test-deoptimization.cc +++ b/deps/v8/test/cctest/test-deoptimization.cc @@ -97,6 +97,14 @@ class AllowNativesSyntaxNoInlining { }; +// Abort any ongoing incremental marking to make sure that all weak global +// handle callbacks are processed. +static void NonIncrementalGC() { + // TODO(1608): This should use kAbortIncrementalMarking. + HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); +} + + static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj, const char* property_name) { v8::Local<v8::Function> fun = @@ -107,9 +115,7 @@ static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj, TEST(DeoptimizeSimple) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; // Test lazy deoptimization of a simple function. { @@ -119,9 +125,9 @@ TEST(DeoptimizeSimple) { "function h() { %DeoptimizeFunction(f); }" "function g() { count++; h(); }" "function f() { g(); };" - "f();" - "gc(); gc()"); + "f();"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -135,9 +141,9 @@ TEST(DeoptimizeSimple) { "var count = 0;" "function g() { count++; %DeoptimizeFunction(f); f(false); }" "function f(x) { if (x) { g(); } else { return } };" - "f(true);" - "gc(); gc()"); + "f(true);"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -147,9 +153,7 @@ TEST(DeoptimizeSimple) { TEST(DeoptimizeSimpleWithArguments) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; // Test lazy deoptimization of a simple function with some arguments. { @@ -159,9 +163,9 @@ TEST(DeoptimizeSimpleWithArguments) { "function h(x) { %DeoptimizeFunction(f); }" "function g(x, y) { count++; h(x); }" "function f(x, y, z) { g(1,x); y+z; };" - "f(1, \"2\", false);" - "gc(); gc()"); + "f(1, \"2\", false);"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -176,9 +180,9 @@ TEST(DeoptimizeSimpleWithArguments) { "var count = 0;" "function g(x, y) { count++; %DeoptimizeFunction(f); f(false, 1, y); }" "function f(x, y, z) { if (x) { g(x, y); } else { return y + z; } };" - "f(true, 1, \"2\");" - "gc(); gc()"); + "f(true, 1, \"2\");"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -188,9 +192,7 @@ TEST(DeoptimizeSimpleWithArguments) { TEST(DeoptimizeSimpleNested) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; // Test lazy deoptimization of a simple function. Have a nested function call // do the deoptimization. @@ -202,8 +204,8 @@ TEST(DeoptimizeSimpleNested) { "function h(x, y, z) { return x + y + z; }" "function g(z) { count++; %DeoptimizeFunction(f); return z;}" "function f(x,y,z) { return h(x, y, g(z)); };" - "result = f(1, 2, 3);" - "gc(); gc()"); + "result = f(1, 2, 3);"); + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -215,9 +217,7 @@ TEST(DeoptimizeSimpleNested) { TEST(DeoptimizeRecursive) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; { // Test lazy deoptimization of a simple function called recursively. Call @@ -228,8 +228,9 @@ TEST(DeoptimizeRecursive) { "var calls = 0;" "function g() { count++; %DeoptimizeFunction(f); }" "function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" - "f(10); gc(); gc()"); + "f(10);"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); @@ -243,9 +244,7 @@ TEST(DeoptimizeRecursive) { TEST(DeoptimizeMultiple) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; { AlwaysOptimizeAllowNativesSyntaxNoInlining options; @@ -261,9 +260,9 @@ TEST(DeoptimizeMultiple) { "function f3(x, y, z) { f4(); return x + y + z; };" "function f2(x, y) { return x + f3(y + 1, y + 1, y + 1) + y; };" "function f1(x) { return f2(x + 1, x + 1) + x; };" - "result = f1(1);" - "gc(); gc()"); + "result = f1(1);"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -273,9 +272,7 @@ TEST(DeoptimizeMultiple) { TEST(DeoptimizeConstructor) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; { AlwaysOptimizeAllowNativesSyntaxNoInlining options; @@ -284,9 +281,9 @@ TEST(DeoptimizeConstructor) { "function g() { count++;" " %DeoptimizeFunction(f); }" "function f() { g(); };" - "result = new f() instanceof f;" - "gc(); gc()"); + "result = new f() instanceof f;"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(env->Global()->Get(v8_str("result"))->IsTrue()); @@ -301,9 +298,9 @@ TEST(DeoptimizeConstructor) { " %DeoptimizeFunction(f); }" "function f(x, y) { this.x = x; g(); this.y = y; };" "result = new f(1, 2);" - "result = result.x + result.y;" - "gc(); gc()"); + "result = result.x + result.y;"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -313,9 +310,7 @@ TEST(DeoptimizeConstructor) { TEST(DeoptimizeConstructorMultiple) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; { AlwaysOptimizeAllowNativesSyntaxNoInlining options; @@ -332,9 +327,9 @@ TEST(DeoptimizeConstructorMultiple) { "function f2(x, y) {" " this.result = x + new f3(y + 1, y + 1, y + 1).result + y; };" "function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" - "result = new f1(1).result;" - "gc(); gc()"); + "result = new f1(1).result;"); } + NonIncrementalGC(); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -344,9 +339,7 @@ TEST(DeoptimizeConstructorMultiple) { TEST(DeoptimizeBinaryOperationADDString) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; const char* f_source = "function f(x, y) { return x + y; };"; @@ -376,9 +369,9 @@ TEST(DeoptimizeBinaryOperationADDString) { // Call f and force deoptimization while processing the binary operation. CompileRun("deopt = true;" - "var result = f('a+', new X());" - "gc(); gc();"); + "var result = f('a+', new X());"); } + NonIncrementalGC(); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); @@ -428,18 +421,15 @@ static void TestDeoptimizeBinaryOpHelper(LocalContext* env, // Call f and force deoptimization while processing the binary operation. CompileRun("deopt = true;" - "var result = f(7, new X());" - "gc(); gc();"); - + "var result = f(7, new X());"); + NonIncrementalGC(); CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); } TEST(DeoptimizeBinaryOperationADD) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; TestDeoptimizeBinaryOpHelper(&env, "+"); @@ -451,9 +441,7 @@ TEST(DeoptimizeBinaryOperationADD) { TEST(DeoptimizeBinaryOperationSUB) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; TestDeoptimizeBinaryOpHelper(&env, "-"); @@ -465,9 +453,7 @@ TEST(DeoptimizeBinaryOperationSUB) { TEST(DeoptimizeBinaryOperationMUL) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; TestDeoptimizeBinaryOpHelper(&env, "*"); @@ -479,9 +465,7 @@ TEST(DeoptimizeBinaryOperationMUL) { TEST(DeoptimizeBinaryOperationDIV) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; TestDeoptimizeBinaryOpHelper(&env, "/"); @@ -493,9 +477,7 @@ TEST(DeoptimizeBinaryOperationDIV) { TEST(DeoptimizeBinaryOperationMOD) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; TestDeoptimizeBinaryOpHelper(&env, "%"); @@ -507,9 +489,7 @@ TEST(DeoptimizeBinaryOperationMOD) { TEST(DeoptimizeCompare) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; const char* f_source = "function f(x, y) { return x < y; };"; @@ -539,9 +519,9 @@ TEST(DeoptimizeCompare) { // Call f and force deoptimization while processing the comparison. CompileRun("deopt = true;" - "var result = f('a', new X());" - "gc(); gc();"); + "var result = f('a', new X());"); } + NonIncrementalGC(); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); @@ -552,9 +532,7 @@ TEST(DeoptimizeCompare) { TEST(DeoptimizeLoadICStoreIC) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; // Functions to generate load/store/keyed load/keyed store IC calls. const char* f1_source = "function f1(x) { return x.y; };"; @@ -618,9 +596,9 @@ TEST(DeoptimizeLoadICStoreIC) { "var result = f1(new X());" "g1(new X());" "f2(new X(), 'z');" - "g2(new X(), 'z');" - "gc(); gc();"); + "g2(new X(), 'z');"); } + NonIncrementalGC(); CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); @@ -634,9 +612,7 @@ TEST(DeoptimizeLoadICStoreIC) { TEST(DeoptimizeLoadICStoreICNested) { v8::HandleScope scope; - const char* extension_list[] = { "v8/gc" }; - v8::ExtensionConfiguration extensions(1, extension_list); - LocalContext env(&extensions); + LocalContext env; // Functions to generate load/store/keyed load/keyed store IC calls. const char* f1_source = "function f1(x) { return x.y; };"; @@ -701,9 +677,9 @@ TEST(DeoptimizeLoadICStoreICNested) { // Call functions and force deoptimization while processing the ics. CompileRun("deopt = true;" - "var result = f1(new X());" - "gc(); gc();"); + "var result = f1(new X());"); } + NonIncrementalGC(); CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index f57477e7f..bf7e91b26 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -147,6 +147,43 @@ TEST(HeapSnapshotObjectSizes) { } +TEST(BoundFunctionInSnapshot) { + v8::HandleScope scope; + LocalContext env; + CompileRun( + "function myFunction(a, b) { this.a = a; this.b = b; }\n" + "function AAAAA() {}\n" + "boundFunction = myFunction.bind(new AAAAA(), 20, new Number(12)); \n"); + const v8::HeapSnapshot* snapshot = + v8::HeapProfiler::TakeSnapshot(v8_str("sizes")); + const v8::HeapGraphNode* global = GetGlobalObject(snapshot); + const v8::HeapGraphNode* f = + GetProperty(global, v8::HeapGraphEdge::kShortcut, "boundFunction"); + CHECK(f); + CHECK_EQ(v8::String::New("native_bind"), f->GetName()); + const v8::HeapGraphNode* bindings = + GetProperty(f, v8::HeapGraphEdge::kInternal, "bindings"); + CHECK_NE(NULL, bindings); + CHECK_EQ(v8::HeapGraphNode::kArray, bindings->GetType()); + CHECK_EQ(4, bindings->GetChildrenCount()); + + const v8::HeapGraphNode* bound_this = GetProperty( + f, v8::HeapGraphEdge::kShortcut, "bound_this"); + CHECK(bound_this); + CHECK_EQ(v8::HeapGraphNode::kObject, bound_this->GetType()); + + const v8::HeapGraphNode* bound_function = GetProperty( + f, v8::HeapGraphEdge::kShortcut, "bound_function"); + CHECK(bound_function); + CHECK_EQ(v8::HeapGraphNode::kClosure, bound_function->GetType()); + + const v8::HeapGraphNode* bound_argument = GetProperty( + f, v8::HeapGraphEdge::kShortcut, "bound_argument_1"); + CHECK(bound_argument); + CHECK_EQ(v8::HeapGraphNode::kObject, bound_argument->GetType()); +} + + TEST(HeapSnapshotEntryChildren) { v8::HandleScope scope; LocalContext env; diff --git a/deps/v8/test/cctest/test-heap.cc b/deps/v8/test/cctest/test-heap.cc index a4d4be481..a6dd83054 100644 --- a/deps/v8/test/cctest/test-heap.cc +++ b/deps/v8/test/cctest/test-heap.cc @@ -1328,35 +1328,6 @@ TEST(CollectingAllAvailableGarbageShrinksNewSpace) { CHECK(old_capacity == new_capacity); } -// This just checks the contract of the IdleNotification() function, -// and does not verify that it does reasonable work. -TEST(IdleNotificationAdvancesIncrementalMarking) { - if (!FLAG_incremental_marking || !FLAG_incremental_marking_steps) return; - InitializeVM(); - v8::HandleScope scope; - const char* source = "function binom(n, m) {" - " var C = [[1]];" - " for (var i = 1; i <= n; ++i) {" - " C[i] = [1];" - " for (var j = 1; j < i; ++j) {" - " C[i][j] = C[i-1][j-1] + C[i-1][j];" - " }" - " C[i][i] = 1;" - " }" - " return C[n][m];" - "};" - "binom(1000, 500)"; - { - AlwaysAllocateScope aa_scope; - CompileRun(source); - } - intptr_t old_size = HEAP->SizeOfObjects(); - bool no_idle_work = v8::V8::IdleNotification(900); - while (!v8::V8::IdleNotification(900)) ; - intptr_t new_size = HEAP->SizeOfObjects(); - CHECK(no_idle_work || new_size < old_size); -} - static int NumberOfGlobalObjects() { int count = 0; diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index 3070e1644..d941d0f7b 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -449,6 +449,7 @@ static bool IsWhiteSpace(uc16 c) { case 0xA0: case 0x2028: case 0x2029: + case 0xFEFF: return true; default: return unibrow::Space::Is(c); diff --git a/deps/v8/test/mjsunit/array-store-and-grow.js b/deps/v8/test/mjsunit/array-store-and-grow.js new file mode 100644 index 000000000..131d4ebc5 --- /dev/null +++ b/deps/v8/test/mjsunit/array-store-and-grow.js @@ -0,0 +1,183 @@ +// Copyright 2012 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. + +// Verifies that the KeyedStoreIC correctly handles out-of-bounds stores +// to an array that grow it by a single element. Test functions are +// called twice to make sure that the IC is used, first call is handled +// by the runtime in the miss stub. + +function array_store_1(a,b,c) { + return (a[b] = c); +} + +// Check handling of the empty array. +var a = []; +array_store_1(a, 0, 1); +a = []; +array_store_1(a, 0, 1); +assertEquals(1, a[0]); +assertEquals(1, array_store_1([], 0, 1)); + +a = []; +for (x=0;x<100000;++x) { + assertEquals(x, array_store_1(a, x, x)); +} + +for (x=0;x<100000;++x) { + assertEquals(x, array_store_1([], 0, x)); +} + +function array_store_2(a,b,c) { + return (a[b] = c); +} + +a = []; +array_store_2(a, 0, 0.5); +a = []; +array_store_2(a, 0, 0.5); +assertEquals(0.5, a[0]); +assertEquals(0.5, array_store_2([], 0, 0.5)); + +function array_store_3(a,b,c) { + return (a[b] = c); +} + +x = new Object(); +a = []; +array_store_3(a, 0, x); +a = []; +array_store_3(a, 0, x); +assertEquals(x, a[0]); +assertEquals(x, array_store_3([], 0, x)); + +// Check the handling of COW arrays +function makeCOW() { + return [1]; +} + +function array_store_4(a,b,c) { + return (a[b] = c); +} + +a = makeCOW(); +array_store_4(a, 1, 1); +a = makeCOW(); +array_store_4(a, 1, 1); +assertEquals(1, a[1]); +assertEquals(1, array_store_4([], 1, 1)); + +function array_store_5(a,b,c) { + return (a[b] = c); +} + +a = makeCOW(); +array_store_5(a, 1, 0.5); +a = makeCOW(); +array_store_5(a, 1, 0.5); +assertEquals(0.5, a[1]); +assertEquals(0.5, array_store_5([], 1, 0.5)); + +function array_store_6(a,b,c) { + return (a[b] = c); +} + +a = makeCOW(); +array_store_6(a, 1, x); +a = makeCOW(); +array_store_6(a, 1, x); +assertEquals(x, a[1]); +assertEquals(x, array_store_6([], 1, x)); + +// Check the handling of mutable arrays. +a = new Array(1,2,3); +array_store_4(a, 3, 1); +a = new Array(1,2,3); +array_store_4(a, 3, 1); +assertEquals(1, a[3]); +assertEquals(1, array_store_4([], 3, 1)); + +function array_store_5(a,b,c) { + return (a[b] = c); +} + +a = new Array(1,2,3); +array_store_5(a, 3, 0.5); +a = new Array(1,2,3); +array_store_5(a, 3, 0.5); +assertEquals(0.5, a[3]); +assertEquals(0.5, array_store_5([], 3, 0.5)); + +function array_store_6(a,b,c) { + return (a[b] = c); +} + +a = new Array(1,2,3); +array_store_6(a, 3, x); +a = new Array(1,2,3); +array_store_6(a, 3, x); +assertEquals(x, a[3]); +assertEquals(x, array_store_6([], 3, x)); + +function array_store_7(a,b,c) { + return (a[b] = c); +} + +// Check the handling of mutable arrays of doubles +var a = new Array(0.5, 1.5); +array_store_7(a, 2, .5); +a = new Array(0.5, 1.5); +array_store_7(a, 2, .5); +assertEquals(0.5, a[2]); +a = new Array(0.5, 1.5); +assertEquals(0.5, array_store_7(a, 2, 0.5)); + +for (x=0;x<100000;++x) { + a = new Array(0.5, 1.5); + assertEquals(x, array_store_7(a, 2, x)); +} + +function array_store_8(a,b,c) { + return (a[b] = c); +} + +var a = new Array(0.5, 1.5); +array_store_8(a, 2, .5); +a = new Array(0.5, 1.5); +array_store_8(a, 10, .5); +assertEquals(0.5, a[10]); + +// Grow the empty array with a double store. +function array_store_9(a,b,c) { + return (a[b] = c); +} + +var a = []; +array_store_9(a, 0, 0.5); +a = []; +array_store_1(a, 0, 0.5); +assertEquals(0.5, a[0]); +assertEquals(0.5, array_store_1([], 0, 0.5)); diff --git a/deps/v8/test/mjsunit/builtins.js b/deps/v8/test/mjsunit/builtins.js index f2ad5446a..e43b5891a 100644 --- a/deps/v8/test/mjsunit/builtins.js +++ b/deps/v8/test/mjsunit/builtins.js @@ -27,8 +27,7 @@ // Flags: --expose-natives-as=builtins -// Checks that all function properties of the builtin object are neither -// writable nor configurable. Also, theose functions that are actually +// Checks that all function properties of the builtin object that are actually // constructors (recognized by having properties on their .prototype object), // have only unconfigurable properties on the prototype, and the methods // are also non-writable. @@ -75,8 +74,6 @@ for (var i = 0; i < names.length; i++) { assertTrue(desc.hasOwnProperty("value")); var value = desc.value; if (isFunction(value)) { - assertFalse(desc.writable, name); - assertFalse(desc.configurable, name); checkConstructor(value, name); } } diff --git a/deps/v8/test/mjsunit/compiler/inline-literals.js b/deps/v8/test/mjsunit/compiler/inline-literals.js new file mode 100644 index 000000000..f78abe82d --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/inline-literals.js @@ -0,0 +1,50 @@ +// Copyright 2012 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 + +// Test that we can inline functions containing materialized literals. + +function o2(b, c) { + return { 'b':b, 'c':c, 'y':b + c }; +} + +function o1(a, b, c) { + return { 'a':a, 'x':o2(b, c) }; +} + +function TestObjectLiteral(a, b, c) { + var expected = { 'a':a, 'x':{ 'b':b, 'c':c, 'y':b + c } }; + var result = o1(a, b, c); + assertEquals(expected, result, "TestObjectLiteral"); +} + +TestObjectLiteral(1, 2, 3); +TestObjectLiteral(1, 2, 3); +%OptimizeFunctionOnNextCall(TestObjectLiteral); +TestObjectLiteral(1, 2, 3); +TestObjectLiteral('a', 'b', 'c'); diff --git a/deps/v8/test/mjsunit/compiler/literals-optimized.js b/deps/v8/test/mjsunit/compiler/literals-optimized.js new file mode 100644 index 000000000..049e21a3a --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/literals-optimized.js @@ -0,0 +1,121 @@ +// Copyright 2012 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 + +// Test optimized versions of array and object literals. + +function TestOptimizedLiteral(create, verify) { + verify(create(1, 2, 3), 1, 2, 3); + verify(create(3, 5, 7), 3, 5, 7); + %OptimizeFunctionOnNextCall(create); + verify(create(11, 23, 42), 11, 23, 42); +} + + +// Test shallow array literal. +function create_arr_shallow(a, b, c) { + return [0, a, 0, b, 0, c]; +} +function verify_arr_shallow(array, a, b, c) { + assertSame(6, array.length); + assertSame(0, array[0]); + assertSame(a, array[1]); + assertSame(0, array[2]); + assertSame(b, array[3]); + assertSame(0, array[4]); + assertSame(c, array[5]); +} +TestOptimizedLiteral(create_arr_shallow, verify_arr_shallow); + + +// Test nested array literal. +function create_arr_nested(a, b, c) { + return [[0, a], [b, c], [1, 2], 3]; +} +function verify_arr_nested(array, a, b, c) { + assertSame(4, array.length); + assertSame(2, array[0].length); + assertSame(0, array[0][0]); + assertSame(a, array[0][1]); + assertSame(2, array[1].length); + assertSame(b, array[1][0]); + assertSame(c, array[1][1]); + assertSame(2, array[2].length); + assertSame(1, array[2][0]); + assertSame(2, array[2][1]); + assertSame(3, array[3]); +} +TestOptimizedLiteral(create_arr_nested, verify_arr_nested); + + +// Test shallow object literal. +function create_obj_shallow(a, b, c) { + return { x:a, y:b, z:c, v:'foo', 9:'bar' }; +} +function verify_obj_shallow(object, a, b, c) { + assertSame(a, object.x); + assertSame(b, object.y); + assertSame(c, object.z); + assertSame('foo', object.v); + assertSame('bar', object[9]); +} +TestOptimizedLiteral(create_obj_shallow, verify_obj_shallow); + + +// Test nested object literal. +function create_obj_nested(a, b, c) { + return { x:{ v:a, w:b }, y:{ v:1, w:2 }, z:c, v:'foo', 9:'bar' }; +} +function verify_obj_nested(object, a, b, c) { + assertSame(a, object.x.v); + assertSame(b, object.x.w); + assertSame(1, object.y.v); + assertSame(2, object.y.w); + assertSame(c, object.z); + assertSame('foo', object.v); + assertSame('bar', object[9]); +} +TestOptimizedLiteral(create_obj_nested, verify_obj_nested); + + +// Test mixed array and object literal. +function create_mixed_nested(a, b, c) { + return { x:[1, 2], y:[a, b], z:c, v:{ v:'foo' }, 9:'bar' }; +} +function verify_mixed_nested(object, a, b, c) { + assertSame(2, object.x.length); + assertSame(1, object.x[0]); + assertSame(2, object.x[1]); + assertSame(2, object.y.length); + assertSame(a, object.y[0]); + assertSame(b, object.y[1]); + assertSame(c, object.z); + assertSame('foo', object.v.v); + assertSame('bar', object[9]); +} +TestOptimizedLiteral(create_mixed_nested, verify_mixed_nested); diff --git a/deps/v8/test/mjsunit/compiler/optimized-for-in.js b/deps/v8/test/mjsunit/compiler/optimized-for-in.js new file mode 100644 index 000000000..8b16101ee --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/optimized-for-in.js @@ -0,0 +1,298 @@ +// Copyright 2012 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 + +// Test for-in support in Crankshaft. For simplicity this tests assumes certain +// fixed iteration order for properties and will have to be adjusted if V8 +// stops following insertion order. + + +function a(t) { + var result = []; + for (var i in t) { + result.push(i + t[i]); + } + return result.join(''); +} + +// Check that we correctly deoptimize on map check. +function b(t) { + var result = []; + for (var i in t) { + result.push(i + t[i]); + delete t[i]; + } + return result.join(''); +} + +// Check that we correctly deoptimize during preparation step. +function c(t) { + var result = []; + for (var i in t) { + result.push(i + t[i]); + } + return result.join(''); +} + +// Check that we deoptimize to the place after side effect in the right state. +function d(t) { + var result = []; + var o; + for (var i in (o = t())) { + result.push(i + o[i]); + } + return result.join(''); +} + +// Check that we correctly deoptimize on map check inserted for fused load. +function e(t) { + var result = []; + for (var i in t) { + delete t[i]; + t[i] = i; + result.push(i + t[i]); + } + return result.join(''); +} + +// Nested for-in loops. +function f(t) { + var result = []; + for (var i in t) { + for (var j in t) { + result.push(i + j + t[i] + t[j]); + } + } + return result.join(''); +} + +// Deoptimization from the inner for-in loop. +function g(t) { + var result = []; + for (var i in t) { + for (var j in t) { + result.push(i + j + t[i] + t[j]); + var v = t[i]; + delete t[i]; + t[i] = v; + } + } + return result.join(''); +} + + +// Break from the inner for-in loop. +function h(t, deopt) { + var result = []; + for (var i in t) { + for (var j in t) { + result.push(i + j + t[i] + t[j]); + break; + } + } + deopt.deopt; + return result.join(''); +} + +// Continue in the inner loop. +function j(t, deopt) { + var result = []; + for (var i in t) { + for (var j in t) { + result.push(i + j + t[i] + t[j]); + continue; + } + } + deopt.deopt; + return result.join(''); +} + +// Continue of the outer loop. +function k(t, deopt) { + var result = []; + outer: for (var i in t) { + for (var j in t) { + result.push(i + j + t[i] + t[j]); + continue outer; + } + } + deopt.deopt; + return result.join(''); +} + +// Break of the outer loop. +function l(t, deopt) { + var result = []; + outer: for (var i in t) { + for (var j in t) { + result.push(i + j + t[i] + t[j]); + break outer; + } + } + deopt.deopt; + return result.join(''); +} + +// Test deoptimization from inlined frame (currently it is not inlined). +function m0(t, deopt) { + for (var i in t) { + for (var j in t) { + deopt.deopt; + return i + j + t[i] + t[j]; + } + } +} + +function m(t, deopt) { + return m0(t, deopt); +} + + +function tryFunction(s, mkT, f) { + var d = {deopt: false}; + assertEquals(s, f(mkT(), d)); + assertEquals(s, f(mkT(), d)); + assertEquals(s, f(mkT(), d)); + %OptimizeFunctionOnNextCall(f); + assertEquals(s, f(mkT(), d)); + assertEquals(s, f(mkT(), {})); +} + +var s = "a1b2c3d4"; +function mkTable() { return { a: "1", b: "2", c: "3", d: "4" }; } + + +tryFunction(s, mkTable, a); +tryFunction(s, mkTable, b); +tryFunction("0a1b2c3d", function () { return "abcd"; }, c); +tryFunction("0a1b2c3d", function () { + var cnt = false; + return function () { + cnt = true; + return "abcd"; + } +}, d); +tryFunction("aabbccdd", mkTable, e); + +function mkSmallTable() { return { a: "1", b: "2" }; } + +tryFunction("aa11ab12ba21bb22", mkSmallTable, f); +tryFunction("aa11ab12bb22ba21", mkSmallTable, g); +tryFunction("aa11ba21", mkSmallTable, h); +tryFunction("aa11ab12ba21bb22", mkSmallTable, j); +tryFunction("aa11ba21", mkSmallTable, h); +tryFunction("aa11ba21", mkSmallTable, k); +tryFunction("aa11", mkSmallTable, l); +tryFunction("aa11", mkSmallTable, m); + +// Test handling of null. +tryFunction("", function () { + return function () { return null; } +}, function (t) { + for (var i in t()) { return i; } + return ""; +}); + +// Test smis. +tryFunction("", function () { + return function () { return 11; } +}, function (t) { + for (var i in t()) { return i; } + return ""; +}); + +// Test LoadFieldByIndex for out of object properties. +function O() { this.a = 1; } +for (var i = 0; i < 10; i++) new O(); +tryFunction("a1b2c3d4e5f6", function () { + var o = new O(); + o.b = 2; + o.c = 3; + o.d = 4; + o.e = 5; + o.f = 6; + return o; +}, function (t) { + var r = []; + for (var i in t) r.push(i + t[i]); + return r.join(''); +}); + +// Test OSR inside for-in. +function osr_inner(t, limit) { + var r = 1; + for (var x in t) { + for (var i = 0; i < t[x].length; i++) { + r += t[x][i]; + if (i === limit) { + %OptimizeFunctionOnNextCall(osr_inner, "osr"); + } + } + r += x; + } + return r; +} + +function osr_outer(t, osr_after) { + var r = 1; + for (var x in t) { + for (var i = 0; i < t[x].length; i++) { + r += t[x][i]; + } + if (x === osr_after) { + %OptimizeFunctionOnNextCall(osr_outer, "osr"); + } + r += x; + } + return r; +} + +function osr_outer_and_deopt(t, osr_after) { + var r = 1; + for (var x in t) { + r += x; + if (x == osr_after) { + %OptimizeFunctionOnNextCall(osr_outer_and_deopt, "osr"); + } + } + return r; +} + +function test_osr() { + with ({}) {} // Disable optimizations of this function. + var arr = new Array(20); + for (var i = 0; i < arr.length; i++) { + arr[i] = i + 1; + } + arr.push(":"); // Force deopt at the end of the loop. + assertEquals("211:x", osr_inner({x: arr}, (arr.length / 2) | 0)); + assertEquals("7x456y", osr_outer({x: [1,2,3], y: [4,5,6]}, "x")); + assertEquals("101234567", osr_outer_and_deopt([1,2,3,4,5,6,7,8], "5")); +} + +test_osr(); diff --git a/deps/v8/test/mjsunit/count-based-osr.js b/deps/v8/test/mjsunit/count-based-osr.js new file mode 100644 index 000000000..125c4e26d --- /dev/null +++ b/deps/v8/test/mjsunit/count-based-osr.js @@ -0,0 +1,38 @@ +// Copyright 2012 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: --count-based-interrupts --interrupt-budget=10 --weighted-back-edges --allow-natives-syntax + +// Test that OSR works properly when using count-based interrupting/profiling. + +function osr_this() { + var a = 1; + // Trigger OSR. + while (%GetOptimizationStatus(osr_this) == 2) {} + return a; +} +assertEquals(1, osr_this()); diff --git a/deps/v8/test/mjsunit/elements-kind.js b/deps/v8/test/mjsunit/elements-kind.js index c0bc333a6..4aa79de65 100644 --- a/deps/v8/test/mjsunit/elements-kind.js +++ b/deps/v8/test/mjsunit/elements-kind.js @@ -147,6 +147,7 @@ assertKind(elements_kind.external_pixel, new PixelArray(512)); // Crankshaft support for smi-only array elements. function monomorphic(array) { + assertKind(elements_kind.fast_smi_only, array); for (var i = 0; i < 3; i++) { array[i] = i + 10; } @@ -157,6 +158,7 @@ function monomorphic(array) { } } var smi_only = new Array(1, 2, 3); +assertKind(elements_kind.fast_smi_only, smi_only); for (var i = 0; i < 3; i++) monomorphic(smi_only); %OptimizeFunctionOnNextCall(monomorphic); monomorphic(smi_only); diff --git a/deps/v8/test/mjsunit/elements-transition-hoisting.js b/deps/v8/test/mjsunit/elements-transition-hoisting.js index 53dc94091..5e78f10a0 100644 --- a/deps/v8/test/mjsunit/elements-transition-hoisting.js +++ b/deps/v8/test/mjsunit/elements-transition-hoisting.js @@ -25,7 +25,7 @@ // (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 --smi-only-arrays +// Flags: --allow-natives-syntax --smi-only-arrays --expose-gc // Ensure that ElementsKind transitions in various situations are hoisted (or // not hoisted) correctly, don't change the semantics programs and don't trigger @@ -39,6 +39,11 @@ if (support_smi_only_arrays) { print("Tests do NOT include smi-only arrays."); } +// Force existing ICs from previous stress runs to be flushed, otherwise the +// assumptions in this test about when deoptimizations get triggered are not +// valid. +gc(); + if (support_smi_only_arrays) { // Make sure that a simple elements array transitions inside a loop before // stores to an array gets hoisted in a way that doesn't generate a deopt in @@ -165,4 +170,42 @@ if (support_smi_only_arrays) { testHoistingWithSideEffect(new Array(5)); testHoistingWithSideEffect(new Array(5)); assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect)); + + function testStraightLineDupeElinination(a,b,c,d,e,f) { + var count = 3; + do { + assertTrue(true); + a[0] = b; + a[1] = c; + a[2] = d; + assertTrue(true); + a[3] = e; // TransitionElementsKind should be eliminated despite call. + a[4] = f; + } while (--count > 3); + } + + testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,0,.5); + testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,.5,0); + testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,.5,0,0); + testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,.5,0,0,0); + testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),.5,0,0,0,0); + testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,0,.5); + testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,0,.5,0); + testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,0,.5,0,0); + testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),0,.5,0,0,0); + testStraightLineDupeElinination(new Array(.1,.1,.1,.1,.1),.5,0,0,0,0); + testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); + testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); + testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); + testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); + testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); + testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); + testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); + testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); + testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); + testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); + %OptimizeFunctionOnNextCall(testStraightLineDupeElinination); + testStraightLineDupeElinination(new Array(5)); + testStraightLineDupeElinination(new Array(5)); + assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination)); } diff --git a/deps/v8/test/mjsunit/external-array.js b/deps/v8/test/mjsunit/external-array.js index 72cfd8595..32f78a72d 100644 --- a/deps/v8/test/mjsunit/external-array.js +++ b/deps/v8/test/mjsunit/external-array.js @@ -317,3 +317,37 @@ for (var t = 0; t < types.length; t++) { %DeoptimizeFunction(array_load_set_smi_check2); gc(); // Makes V8 forget about type information for array_load_set_smi_check. } + +// Check handling of undefined in 32- and 64-bit external float arrays. + +function store_float32_undefined(ext_array) { + ext_array[0] = undefined; +} + +var float32_array = new Float32Array(1); +// Make sure runtime does it right +store_float32_undefined(float32_array); +assertTrue(isNaN(float32_array[0])); +// Make sure the ICs do it right +store_float32_undefined(float32_array); +assertTrue(isNaN(float32_array[0])); +// Make sure that Cranskshft does it right. +%OptimizeFunctionOnNextCall(store_float32_undefined); +store_float32_undefined(float32_array); +assertTrue(isNaN(float32_array[0])); + +function store_float64_undefined(ext_array) { + ext_array[0] = undefined; +} + +var float64_array = new Float64Array(1); +// Make sure runtime does it right +store_float64_undefined(float64_array); +assertTrue(isNaN(float64_array[0])); +// Make sure the ICs do it right +store_float64_undefined(float64_array); +assertTrue(isNaN(float64_array[0])); +// Make sure that Cranskshft does it right. +%OptimizeFunctionOnNextCall(store_float64_undefined); +store_float64_undefined(float64_array); +assertTrue(isNaN(float64_array[0])); diff --git a/deps/v8/test/mjsunit/harmony/block-conflicts.js b/deps/v8/test/mjsunit/harmony/block-conflicts.js index ee2d9794e..8388504bc 100644 --- a/deps/v8/test/mjsunit/harmony/block-conflicts.js +++ b/deps/v8/test/mjsunit/harmony/block-conflicts.js @@ -130,5 +130,5 @@ for (var v = 0; v < varbinds.length; ++v) { // Test conflicting parameter/var bindings. for (var v = 0; v < varbinds.length; ++v) { - TestConflict('(function (x) { ' + varbinds[v] + '; })()'); + TestNoConflict('(function (x) { ' + varbinds[v] + '; })()'); } diff --git a/deps/v8/test/mjsunit/harmony/module-parsing.js b/deps/v8/test/mjsunit/harmony/module-parsing.js new file mode 100644 index 000000000..ac398636d --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/module-parsing.js @@ -0,0 +1,80 @@ +// Copyright 2011 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: --harmony-modules + +// Test basic module syntax, with and without ASI. + +module A {} + +module A1 = A +module A2 = A; +module A3 = A2 + +module B { + var x + var x, y; + var x = 0, y + let x, y + let z = 1 + const c = 9 + function f() {} + module C { + let x + module D {} + let y + } + let zz = "" +} + +module C1 = B.C; +module D1 = B.C.D +module D2 = C1.D +module D3 = D2 + +module E1 at "http://where" +module E2 at "http://where"; +module E3 = E1.F + + +// Check that ASI does not interfere. + +module +X +{ +let x +} + +module +Y += +X + +module +Z +at +"file://local" diff --git a/deps/v8/test/mjsunit/math-min-max.js b/deps/v8/test/mjsunit/math-min-max.js index 7717b3bff..e4fd31353 100644 --- a/deps/v8/test/mjsunit/math-min-max.js +++ b/deps/v8/test/mjsunit/math-min-max.js @@ -146,6 +146,14 @@ function crankshaft_test_1(arg) { // Double representation. assertEquals(v0, Math.max(v0++, v9++)); assertEquals(v9, Math.min(v0++, v9++)); + // Mixed representation. + assertEquals(v1, Math.min(v1++, v9++)); // int32, double + assertEquals(v0, Math.max(v0++, v2++)); // double, int32 + assertEquals(v1, Math.min(v1++, v6)); // int32, tagged + assertEquals(v2, Math.max(v5, v2++)); // tagged, int32 + assertEquals(v6, Math.min(v6, v9++)); // tagged, double + assertEquals(v0, Math.max(v0++, v5)); // double, tagged + // Minus zero. assertEquals(Infinity, 1/Math.max(v7, v8)); assertEquals(-Infinity, 1/Math.min(v7, v8)); diff --git a/deps/v8/test/mjsunit/object-prevent-extensions.js b/deps/v8/test/mjsunit/object-prevent-extensions.js index 322a2cb54..6b9184d88 100644 --- a/deps/v8/test/mjsunit/object-prevent-extensions.js +++ b/deps/v8/test/mjsunit/object-prevent-extensions.js @@ -114,3 +114,15 @@ Object.preventExtensions(foo); foo.x = 29; assertEquals(undefined, foo.x); + +// when Object.isExtensible(o) === false +// assignment should return right hand side value +var o = Object.preventExtensions({}); +var v = o.v = 50; +assertEquals(undefined, o.v); +assertEquals(50, v); + +// test same behavior as above, but for integer properties +var n = o[0] = 100; +assertEquals(undefined, o[0]); +assertEquals(100, n); diff --git a/deps/v8/test/mjsunit/regexp.js b/deps/v8/test/mjsunit/regexp.js index 3c4f883bd..76fa44be9 100644 --- a/deps/v8/test/mjsunit/regexp.js +++ b/deps/v8/test/mjsunit/regexp.js @@ -127,6 +127,17 @@ assertTrue(re.test("$")); assertTrue(/^[Z-\c-e]*$/.test("Z[\\cde")); +// Test that we handle \s and \S correctly on special Unicode characters. +re = /\s/; +assertTrue(re.test("\u2028")); +assertTrue(re.test("\u2029")); +assertTrue(re.test("\uFEFF")); + +re = /\S/; +assertFalse(re.test("\u2028")); +assertFalse(re.test("\u2029")); +assertFalse(re.test("\uFEFF")); + // Test that we handle \s and \S correctly inside some bizarre // character classes. re = /[\s-:]/; diff --git a/deps/v8/test/mjsunit/regress/regress-113924.js b/deps/v8/test/mjsunit/regress/regress-113924.js new file mode 100644 index 000000000..3ecdec48f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-113924.js @@ -0,0 +1,31 @@ +// Copyright 2012 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. + +var count=12000; +while(count--) { + eval("var a = new Object(10); a[2] += 7;"); +} diff --git a/deps/v8/test/mjsunit/regress/regress-1790.js b/deps/v8/test/mjsunit/regress/regress-1790.js new file mode 100644 index 000000000..8848eeaf6 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1790.js @@ -0,0 +1,58 @@ +// Copyright 2012 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. + +// Regression test checking that the sequence of element access in built-in +// array functions is specification conform (i.e. [[HasProperty]] might return +// bogus result after [[Get]] has been called). + +function CheckSequence(builtin, callback) { + var array = [1,2,3]; + var callback_count = 0; + var callback_wrapper = function() { + callback_count++; + return callback() + } + + // Define getter that will delete itself upon first invocation. + Object.defineProperty(array, '1', { + get: function () { delete array[1]; }, + configurable: true + }); + + assertTrue(array.hasOwnProperty('1')); + builtin.apply(array, [callback_wrapper, 'argument']); + assertFalse(array.hasOwnProperty('1')); + assertEquals(3, callback_count); +} + +CheckSequence(Array.prototype.every, function() { return true; }); +CheckSequence(Array.prototype.filter, function() { return true; }); +CheckSequence(Array.prototype.forEach, function() { return 0; }); +CheckSequence(Array.prototype.map, function() { return 0; }); +CheckSequence(Array.prototype.reduce, function() { return 0; }); +CheckSequence(Array.prototype.reduceRight, function() { return 0; }); +CheckSequence(Array.prototype.some, function() { return false; }); diff --git a/deps/v8/test/mjsunit/regress/regress-1878.js b/deps/v8/test/mjsunit/regress/regress-1878.js index 1b3c63aeb..a1648b121 100644 --- a/deps/v8/test/mjsunit/regress/regress-1878.js +++ b/deps/v8/test/mjsunit/regress/regress-1878.js @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2012 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: @@ -30,5 +30,15 @@ // Flags: --allow-natives-syntax --expose_natives_as=natives var a = Array(); -var ai = natives.InternalArray(); -assertFalse(%HaveSameMap(ai, a)); + +for (var i = 0; i < 1000; i++) { + var ai = natives.InternalArray(10000); + assertFalse(%HaveSameMap(ai, a)); + assertTrue(%HasFastElements(ai)); +} + +for (var i = 0; i < 1000; i++) { + var ai = new natives.InternalArray(10000); + assertFalse(%HaveSameMap(ai, a)); + assertTrue(%HasFastElements(ai)); +} diff --git a/deps/v8/test/mjsunit/regress/regress-1945.js b/deps/v8/test/mjsunit/regress/regress-1945.js new file mode 100644 index 000000000..bffc775fc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-1945.js @@ -0,0 +1,34 @@ +// Copyright 2012 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 + +var _d = new Date(); +_d.setHours(0,0,0,0); +_d.setHours(0,0,0,0); +%OptimizeFunctionOnNextCall(_d.setHours); +_d.setHours(0,0,0,0); diff --git a/deps/v8/test/mjsunit/regress/regress-inlining-function-literal-context.js b/deps/v8/test/mjsunit/regress/regress-inlining-function-literal-context.js new file mode 100644 index 000000000..9b7f7ac76 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-inlining-function-literal-context.js @@ -0,0 +1,53 @@ +// Copyright 2012 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 --expose-gc + +function mkbaz(x) { + function baz() { + return function () { + return [x]; + } + } + return baz; +} + +var baz = mkbaz(1); + +function foo() { + var f = baz(); + return f(); +} + +// Tenure. +gc(); +gc(); + +assertArrayEquals([1], foo()); +assertArrayEquals([1], foo()); +%OptimizeFunctionOnNextCall(foo); +assertArrayEquals([1], foo()); diff --git a/deps/v8/test/mjsunit/tools/tickprocessor.js b/deps/v8/test/mjsunit/tools/tickprocessor.js index 30b0ec23f..c48d9f3a5 100644 --- a/deps/v8/test/mjsunit/tools/tickprocessor.js +++ b/deps/v8/test/mjsunit/tools/tickprocessor.js @@ -376,8 +376,11 @@ function driveTickProcessorTest( } assertTrue(pathLen != -1); var testsPath = TEST_FILE_NAME.substr(0, pathLen + 1); - var tp = new TickProcessor( - new CppEntriesProviderMock(), separateIc, ignoreUnknown, stateFilter); + var tp = new TickProcessor(new CppEntriesProviderMock(), + separateIc, + TickProcessor.CALL_GRAPH_SIZE, + ignoreUnknown, + stateFilter); var pm = new PrintMonitor(testsPath + refOutput); tp.processLogFileInTest(testsPath + logInput); tp.printStatistics(); diff --git a/deps/v8/test/mozilla/mozilla.status b/deps/v8/test/mozilla/mozilla.status index bc096d5ca..cc2925d66 100644 --- a/deps/v8/test/mozilla/mozilla.status +++ b/deps/v8/test/mozilla/mozilla.status @@ -213,6 +213,10 @@ js1_5/Array/regress-101964: PASS || FAIL if $mode == debug # builtin to have undefined as the receiver. ecma/String/15.5.4.6-2: FAIL_OK +# Fail because it expects String.prototype.split to distinguish whether +# separator was undefined or not passed at all. +ecma/String/15.5.4.8-2: FAIL_OK + # Fail because of toLowerCase and toUpperCase conversion. ecma/String/15.5.4.11-2: FAIL_OK ecma/String/15.5.4.11-5: FAIL_OK diff --git a/deps/v8/test/sputnik/sputnik.status b/deps/v8/test/sputnik/sputnik.status index a587a6d4a..a4c7d57ff 100644 --- a/deps/v8/test/sputnik/sputnik.status +++ b/deps/v8/test/sputnik/sputnik.status @@ -125,6 +125,13 @@ S15.5.2_D2: PASS || FAIL_OK S15.5.4.11_D1.1_T1: PASS || FAIL_OK S15.5.4.11_D1.1_T3: PASS || FAIL_OK S12.6.4_D1: PASS || FAIL_OK +S15.5.4.14_A1_T6: FAIL_OK +S15.5.4.14_A1_T7: FAIL_OK +S15.5.4.14_A1_T8: FAIL_OK +S15.5.4.14_A1_T9: FAIL_OK +S15.5.4.14_A2_T7: FAIL_OK +S15.10.2.12_A1_T1: FAIL_OK +S15.10.2.12_A2_T1: FAIL_OK # We allow function declarations within statements S12.6.2_A13_T1: FAIL_OK @@ -189,7 +196,6 @@ S15.3.4.3_A6_T4: FAIL_OK S15.4.4.2_A2_T1: FAIL_OK S15.4.4.3_A2_T1: FAIL_OK - ##################### SKIPPED TESTS ##################### # These tests take a looong time to run in debug mode. diff --git a/deps/v8/test/test262/README b/deps/v8/test/test262/README index 094356fcf..dae18433a 100644 --- a/deps/v8/test/test262/README +++ b/deps/v8/test/test262/README @@ -4,11 +4,11 @@ tests from http://hg.ecmascript.org/tests/test262 -at revision 271 as 'data' in this directory. Using later version +at revision 309 as 'data' in this directory. Using later version may be possible but the tests are only known to pass (and indeed run) with that revision. -hg clone -r 271 http://hg.ecmascript.org/tests/test262 data +hg clone -r 309 http://hg.ecmascript.org/tests/test262 data If you do update to a newer revision you may have to change the test harness adapter code since it uses internal functionality from the diff --git a/deps/v8/test/test262/test262.status b/deps/v8/test/test262/test262.status index 1da988efc..db99c8075 100644 --- a/deps/v8/test/test262/test262.status +++ b/deps/v8/test/test262/test262.status @@ -33,9 +33,6 @@ def FAIL_OK = FAIL, OKAY # '__proto__' should be treated as a normal property in JSON. S15.12.2_A1: FAIL -# V8 Bug: http://code.google.com/p/v8/issues/detail?id=1196 -S8.7_A5_T2: FAIL - # V8 Bug: http://code.google.com/p/v8/issues/detail?id=1624 S10.4.2.1_A1: FAIL @@ -59,14 +56,6 @@ S10.4.2.1_A1: FAIL 15.2.3.7-6-a-284: FAIL 15.2.3.7-6-a-285: FAIL -# V8 Bug: http://code.google.com/p/v8/issues/detail?id=1790 -15.4.4.22-9-9: FAIL - -# Invalid test cases (recent change adding var changes semantics) -S8.3_A1_T1: FAIL -S15.3_A3_T1: FAIL -S15.3_A3_T3: FAIL - ##################### DELIBERATE INCOMPATIBILITIES ##################### # We deliberately treat arguments to parseInt() with a leading zero as @@ -80,9 +69,6 @@ S15.8.2.16_A7: PASS || FAIL_OK S15.8.2.18_A7: PASS || FAIL_OK S15.8.2.13_A23: PASS || FAIL_OK -# Sputnik tests (r97) assume RegExp.prototype is an Object, not a RegExp. -S15.10.6_A2: FAIL_OK - # We are silent in some regexp cases where the spec wants us to give # errors, for compatibility. S15.10.2.11_A1_T2: FAIL @@ -90,15 +76,9 @@ S15.10.2.11_A1_T3: FAIL # We are more lenient in which string character escapes we allow than # the spec (7.8.4 p. 19) wants us to be. This is for compatibility. -S7.8.4_A4.3_T3: FAIL_OK -S7.8.4_A4.3_T4: FAIL_OK -S7.8.4_A4.3_T5: FAIL_OK -S7.8.4_A4.3_T6: FAIL_OK S7.8.4_A6.1_T4: FAIL_OK S7.8.4_A6.2_T1: FAIL_OK S7.8.4_A6.2_T2: FAIL_OK -S7.8.4_A6.4_T1: FAIL_OK -S7.8.4_A6.4_T2: FAIL_OK S7.8.4_A7.1_T4: FAIL_OK S7.8.4_A7.2_T1: FAIL_OK S7.8.4_A7.2_T2: FAIL_OK @@ -106,102 +86,12 @@ S7.8.4_A7.2_T3: FAIL_OK S7.8.4_A7.2_T4: FAIL_OK S7.8.4_A7.2_T5: FAIL_OK S7.8.4_A7.2_T6: FAIL_OK -S7.8.4_A7.4_T1: FAIL_OK -S7.8.4_A7.4_T2: FAIL_OK - -# Sputnik expects unicode escape sequences in RegExp flags to be interpreted. -# The specification requires them to be passed uninterpreted to the RegExp -# constructor. We now implement that. -S7.8.5_A3.1_T7: FAIL_OK -S7.8.5_A3.1_T8: FAIL_OK -S7.8.5_A3.1_T9: FAIL_OK - -# We allow some keywords to be used as identifiers. -S7.5.3_A1.15: FAIL_OK -S7.5.3_A1.18: FAIL_OK -S7.5.3_A1.21: FAIL_OK -S7.5.3_A1.22: FAIL_OK -S7.5.3_A1.23: FAIL_OK -S7.5.3_A1.24: FAIL_OK -S7.5.3_A1.26: FAIL_OK - -# This checks for non-262 behavior -S7.6_D1: PASS || FAIL_OK -S7.6_D2: PASS || FAIL_OK -S8.4_D1.1: PASS || FAIL_OK -S8.4_D2.1: PASS || FAIL_OK -S8.4_D2.2: PASS || FAIL_OK -S8.4_D2.3: PASS || FAIL_OK -S8.4_D2.4: PASS || FAIL_OK -S8.4_D2.5: PASS || FAIL_OK -S8.4_D2.6: PASS || FAIL_OK -S8.4_D2.7: PASS || FAIL_OK -S11.4.3_D1.2: PASS || FAIL_OK -S12.6.4_A14_T1: PASS || FAIL_OK -S12.6.4_D1: PASS || FAIL_OK -S12.6.4_R1: PASS || FAIL_OK -S12.6.4_R2: PASS || FAIL_OK -S13.2_D1.2: PASS || FAIL_OK -S13_D1_T1: PASS || FAIL_OK -S14_D4_T3: PASS || FAIL_OK -S14_D7: PASS || FAIL_OK -S15.1.2.2_D1.2: PASS || FAIL_OK -S15.5.2_D2: PASS || FAIL_OK -S15.5.4.11_D1.1_T1: PASS || FAIL_OK -S15.5.4.11_D1.1_T2: PASS || FAIL_OK -S15.5.4.11_D1.1_T3: PASS || FAIL_OK -S15.5.4.11_D1.1_T4: PASS || FAIL_OK - -# We allow function declarations within statements -S12.6.2_A13_T1: FAIL_OK -S12.6.2_A13_T2: FAIL_OK -S12.6.4_A13_T1: FAIL_OK -S12.6.4_A13_T2: FAIL_OK -S15.3.4.2_A1_T1: FAIL_OK # Linux and Mac defaults to extended 80 bit floating point format in the FPU. # We follow the other major JS engines by keeping this default. S8.5_A2.2: PASS, FAIL if $system == linux, FAIL if $system == macos S8.5_A2.1: PASS, FAIL if $system == linux, FAIL if $system == macos -############################# ES3 TESTS ################################ -# These tests check for ES3 semantics, and differ from ES5. -# When we follow ES5 semantics, it's ok to fail the test. - -# Allow keywords as names of properties in object initialisers and -# in dot-notation property access. -S11.1.5_A4.1: FAIL_OK -S11.1.5_A4.2: FAIL_OK - -# Calls builtins without an explicit receiver which means that -# undefined is passed to the builtin. The tests expect the global -# object to be passed which was true in ES3 but not in ES5. -S11.1.1_A2: FAIL_OK -S15.5.4.4_A1_T3: FAIL_OK -S15.5.4.5_A1_T3: FAIL_OK -S15.5.4.6_A1_T3: FAIL_OK -S15.5.4.7_A1_T3: FAIL_OK -S15.5.4.8_A1_T3: FAIL_OK -S15.5.4.9_A1_T3: FAIL_OK -S15.5.4.10_A1_T3: FAIL_OK -S15.5.4.11_A1_T3: FAIL_OK -S15.5.4.12_A1_T3: FAIL_OK -S15.5.4.13_A1_T3: FAIL_OK -S15.5.4.14_A1_T3: FAIL_OK -S15.5.4.15_A1_T3: FAIL_OK - -# NaN, Infinity and undefined are read-only according to ES5. -S15.1.1.1_A2_T1: FAIL_OK # NaN -S15.1.1.1_A2_T2: FAIL_OK # NaN -S15.1.1.2_A2_T1: FAIL_OK # Infinity -# S15.1.1.2_A2_T2 would fail if it weren't bogus in r97. sputnik bug #45. -S15.1.1.3_A2_T1: FAIL_OK # undefined -S15.1.1.3_A2_T2: FAIL_OK # undefined - -# Array.prototype.to[Locale]String is generic in ES5. -S15.4.4.2_A2_T1: FAIL_OK -S15.4.4.3_A2_T1: FAIL_OK - ############################ SKIPPED TESTS ############################# # These tests take a looong time to run in debug mode. |