diff options
author | isaacs <i@izs.me> | 2012-05-29 15:05:24 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-06-01 22:31:04 -0700 |
commit | cbdf3393a21690178822c2d6ce2513270d70a02e (patch) | |
tree | ebbf375e5d7aa32bf5fe988d2b3fe5fe788b404d /deps/v8/test | |
parent | 0262b6d2a563e8b96f02c3066b69fed66d956675 (diff) | |
download | node-new-cbdf3393a21690178822c2d6ce2513270d70a02e.tar.gz |
Upgrade v8 to 3.11.7
Diffstat (limited to 'deps/v8/test')
27 files changed, 676 insertions, 130 deletions
diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index af28be19d8..3cbc3bc451 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -27,6 +27,7 @@ prefix cctest +# All tests prefixed with 'Bug' are expected to fail. test-api/Bug*: FAIL ############################################################################## diff --git a/deps/v8/test/cctest/test-func-name-inference.cc b/deps/v8/test/cctest/test-func-name-inference.cc index 8f405b726e..762cc9f0fa 100644 --- a/deps/v8/test/cctest/test-func-name-inference.cc +++ b/deps/v8/test/cctest/test-func-name-inference.cc @@ -400,3 +400,41 @@ TEST(AssignmentAndCall) { // See MultipleAssignments test. CheckFunctionName(script, "return 2", "Enclosing.Bar"); } + + +TEST(MethodAssignmentInAnonymousFunctionCall) { + InitializeVM(); + v8::HandleScope scope; + + v8::Handle<v8::Script> script = Compile( + "(function () {\n" + " var EventSource = function () { };\n" + " EventSource.prototype.addListener = function () {\n" + " return 2012;\n" + " };\n" + " this.PublicEventSource = EventSource;\n" + "})();"); + CheckFunctionName(script, "return 2012", "EventSource.addListener"); +} + + +TEST(ReturnAnonymousFunction) { + InitializeVM(); + v8::HandleScope scope; + + v8::Handle<v8::Script> script = Compile( + "(function() {\n" + " function wrapCode() {\n" + " return function () {\n" + " return 2012;\n" + " };\n" + " };\n" + " var foo = 10;\n" + " function f() {\n" + " return wrapCode();\n" + " }\n" + " this.ref = f;\n" + "})()"); + script->Run(); + CheckFunctionName(script, "return 2012", ""); +} diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index cbe8d4459c..c405b334c9 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -7,6 +7,7 @@ #include "v8.h" #include "cctest.h" +#include "hashmap.h" #include "heap-profiler.h" #include "snapshot.h" #include "debug.h" @@ -27,10 +28,14 @@ class NamedEntriesDetector { if (strcmp(entry->name(), "C2") == 0) has_C2 = true; } + static bool AddressesMatch(void* key1, void* key2) { + return key1 == key2; + } + void CheckAllReachables(i::HeapEntry* root) { + i::HashMap visited(AddressesMatch); i::List<i::HeapEntry*> list(10); list.Add(root); - root->paint(); CheckEntry(root); while (!list.is_empty()) { i::HeapEntry* entry = list.RemoveLast(); @@ -38,11 +43,15 @@ class NamedEntriesDetector { for (int i = 0; i < children.length(); ++i) { if (children[i]->type() == i::HeapGraphEdge::kShortcut) continue; i::HeapEntry* child = children[i]->to(); - if (!child->painted()) { - list.Add(child); - child->paint(); - CheckEntry(child); - } + i::HashMap::Entry* entry = visited.Lookup( + reinterpret_cast<void*>(child), + static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child)), + true); + if (entry->value) + continue; + entry->value = reinterpret_cast<void*>(1); + list.Add(child); + CheckEntry(child); } } } @@ -105,9 +114,6 @@ TEST(HeapSnapshot) { "var c2 = new C2(a2);"); const v8::HeapSnapshot* snapshot_env2 = v8::HeapProfiler::TakeSnapshot(v8_str("env2")); - i::HeapSnapshot* i_snapshot_env2 = - const_cast<i::HeapSnapshot*>( - reinterpret_cast<const i::HeapSnapshot*>(snapshot_env2)); const v8::HeapGraphNode* global_env2 = GetGlobalObject(snapshot_env2); // Verify, that JS global object of env2 has '..2' properties. @@ -120,9 +126,7 @@ TEST(HeapSnapshot) { NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "b2_2")); CHECK_NE(NULL, GetProperty(global_env2, v8::HeapGraphEdge::kProperty, "c2")); - // Paint all nodes reachable from global object. NamedEntriesDetector det; - i_snapshot_env2->ClearPaint(); det.CheckAllReachables(const_cast<i::HeapEntry*>( reinterpret_cast<const i::HeapEntry*>(global_env2))); CHECK(det.has_A2); @@ -156,9 +160,9 @@ TEST(HeapSnapshotObjectSizes) { CHECK_NE(NULL, x2); // Test sizes. - CHECK_EQ(x->GetSelfSize() * 3, x->GetRetainedSize()); - CHECK_EQ(x1->GetSelfSize(), x1->GetRetainedSize()); - CHECK_EQ(x2->GetSelfSize(), x2->GetRetainedSize()); + CHECK_NE(0, x->GetSelfSize()); + CHECK_NE(0, x1->GetSelfSize()); + CHECK_NE(0, x2->GetSelfSize()); } @@ -477,66 +481,6 @@ TEST(HeapSnapshotRootPreservedAfterSorting) { } -TEST(HeapEntryDominator) { - // The graph looks like this: - // - // -> node1 - // a |^ - // -> node5 ba - // a v| - // node6 -> node2 - // b a |^ - // -> node4 ba - // b v| - // -> node3 - // - // The dominator for all nodes is node6. - - v8::HandleScope scope; - LocalContext env; - - CompileRun( - "function X(a, b) { this.a = a; this.b = b; }\n" - "node6 = new X(new X(new X()), new X(new X(),new X()));\n" - "(function(){\n" - "node6.a.a.b = node6.b.a; // node1 -> node2\n" - "node6.b.a.a = node6.a.a; // node2 -> node1\n" - "node6.b.a.b = node6.b.b; // node2 -> node3\n" - "node6.b.b.a = node6.b.a; // node3 -> node2\n" - "})();"); - - const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("dominators")); - - const v8::HeapGraphNode* global = GetGlobalObject(snapshot); - CHECK_NE(NULL, global); - const v8::HeapGraphNode* node6 = - GetProperty(global, v8::HeapGraphEdge::kProperty, "node6"); - CHECK_NE(NULL, node6); - const v8::HeapGraphNode* node5 = - GetProperty(node6, v8::HeapGraphEdge::kProperty, "a"); - CHECK_NE(NULL, node5); - const v8::HeapGraphNode* node4 = - GetProperty(node6, v8::HeapGraphEdge::kProperty, "b"); - CHECK_NE(NULL, node4); - const v8::HeapGraphNode* node3 = - GetProperty(node4, v8::HeapGraphEdge::kProperty, "b"); - CHECK_NE(NULL, node3); - const v8::HeapGraphNode* node2 = - GetProperty(node4, v8::HeapGraphEdge::kProperty, "a"); - CHECK_NE(NULL, node2); - const v8::HeapGraphNode* node1 = - GetProperty(node5, v8::HeapGraphEdge::kProperty, "a"); - CHECK_NE(NULL, node1); - - CHECK_EQ(node6, node1->GetDominatorNode()); - CHECK_EQ(node6, node2->GetDominatorNode()); - CHECK_EQ(node6, node3->GetDominatorNode()); - CHECK_EQ(node6, node4->GetDominatorNode()); - CHECK_EQ(node6, node5->GetDominatorNode()); -} - - namespace { class TestJSONStream : public v8::OutputStream { diff --git a/deps/v8/test/cctest/test-heap.cc b/deps/v8/test/cctest/test-heap.cc index 72079dc2ae..33aaed3342 100644 --- a/deps/v8/test/cctest/test-heap.cc +++ b/deps/v8/test/cctest/test-heap.cc @@ -673,7 +673,7 @@ TEST(JSArray) { array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); CHECK_EQ(Smi::FromInt(0), array->length()); // Must be in fast mode. - CHECK(array->HasFastTypeElements()); + CHECK(array->HasFastSmiOrObjectElements()); // array[length] = name. array->SetElement(0, *name, NONE, kNonStrictMode)->ToObjectChecked(); @@ -811,7 +811,9 @@ TEST(Iteration) { // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE objs[next_objs_index++] = FACTORY->NewJSArray(10); - objs[next_objs_index++] = FACTORY->NewJSArray(10, FAST_ELEMENTS, TENURED); + objs[next_objs_index++] = FACTORY->NewJSArray(10, + FAST_HOLEY_ELEMENTS, + TENURED); // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE objs[next_objs_index++] = @@ -1595,7 +1597,7 @@ TEST(PrototypeTransitionClearing) { Handle<JSObject> prototype; PagedSpace* space = HEAP->old_pointer_space(); do { - prototype = FACTORY->NewJSArray(32 * KB, FAST_ELEMENTS, TENURED); + prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); } while (space->FirstPage() == space->LastPage() || !space->LastPage()->Contains(prototype->address())); @@ -1735,3 +1737,60 @@ TEST(OptimizedAllocationAlwaysInNewSpace) { CHECK(HEAP->InNewSpace(*o)); } + + +static int CountMapTransitions(Map* map) { + int result = 0; + DescriptorArray* descs = map->instance_descriptors(); + for (int i = 0; i < descs->number_of_descriptors(); i++) { + if (descs->IsTransitionOnly(i)) { + result++; + } + } + return result; +} + + +// Test that map transitions are cleared and maps are collected with +// incremental marking as well. +TEST(Regress1465) { + i::FLAG_allow_natives_syntax = true; + i::FLAG_trace_incremental_marking = true; + InitializeVM(); + v8::HandleScope scope; + + #define TRANSITION_COUNT 256 + for (int i = 0; i < TRANSITION_COUNT; i++) { + EmbeddedVector<char, 64> buffer; + OS::SNPrintF(buffer, "var o = new Object; o.prop%d = %d;", i, i); + CompileRun(buffer.start()); + } + CompileRun("var root = new Object;"); + Handle<JSObject> root = + v8::Utils::OpenHandle( + *v8::Handle<v8::Object>::Cast( + v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); + + // Count number of live transitions before marking. + int transitions_before = CountMapTransitions(root->map()); + CompileRun("%DebugPrint(root);"); + CHECK_EQ(TRANSITION_COUNT, transitions_before); + + // Go through all incremental marking steps in one swoop. + IncrementalMarking* marking = HEAP->incremental_marking(); + CHECK(marking->IsStopped()); + marking->Start(); + CHECK(marking->IsMarking()); + while (!marking->IsComplete()) { + marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); + } + CHECK(marking->IsComplete()); + HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CHECK(marking->IsStopped()); + + // Count number of live transitions after marking. Note that one transition + // is left, because 'o' still holds an instance of one transition target. + int transitions_after = CountMapTransitions(root->map()); + CompileRun("%DebugPrint(root);"); + CHECK_EQ(1, transitions_after); +} diff --git a/deps/v8/test/cctest/test-mark-compact.cc b/deps/v8/test/cctest/test-mark-compact.cc index 700f3222ae..27123704b1 100644 --- a/deps/v8/test/cctest/test-mark-compact.cc +++ b/deps/v8/test/cctest/test-mark-compact.cc @@ -531,18 +531,18 @@ TEST(BootUpMemoryUse) { // there we just skip the test. if (initial_memory >= 0) { InitializeVM(); - intptr_t booted_memory = MemoryInUse(); + intptr_t delta = MemoryInUse() - initial_memory; if (sizeof(initial_memory) == 8) { if (v8::internal::Snapshot::IsEnabled()) { - CHECK_LE(booted_memory - initial_memory, 3600 * 1024); // 3396. + CHECK_LE(delta, 3600 * 1024); // 3396. } else { - CHECK_LE(booted_memory - initial_memory, 3600 * 1024); // 3432. + CHECK_LE(delta, 4000 * 1024); // 3948. } } else { if (v8::internal::Snapshot::IsEnabled()) { - CHECK_LE(booted_memory - initial_memory, 2800 * 1024); // 2484. + CHECK_LE(delta, 2600 * 1024); // 2484. } else { - CHECK_LE(booted_memory - initial_memory, 2950 * 1024); // 2844 + CHECK_LE(delta, 2950 * 1024); // 2844 } } } diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index e89e6cddc9..9b4f905e2c 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -1,4 +1,4 @@ -// Copyright 2008 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: @@ -506,8 +506,13 @@ static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { NewStringFromUtf8(CStrVector(input)); Handle<String> sample_subject = isolate->factory()->NewStringFromUtf8(CStrVector("")); - RegExpEngine::Compile( - &compile_data, false, multiline, pattern, sample_subject, is_ascii); + RegExpEngine::Compile(&compile_data, + false, + false, + multiline, + pattern, + sample_subject, + is_ascii); return compile_data.node; } @@ -720,6 +725,7 @@ static ArchRegExpMacroAssembler::Result Execute(Code* code, input_start, input_end, captures, + 0, Isolate::Current()); } @@ -998,11 +1004,11 @@ TEST(MacroAssemblerNativeBackReferenceUC16) { int output[4]; NativeRegExpMacroAssembler::Result result = Execute(*code, - *input, - 0, - start_adr, - start_adr + input->length() * 2, - output); + *input, + 0, + start_adr, + start_adr + input->length() * 2, + output); CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); CHECK_EQ(0, output[0]); diff --git a/deps/v8/test/mjsunit/accessor-map-sharing.js b/deps/v8/test/mjsunit/accessor-map-sharing.js index ab45afab05..8bbcb4f5dc 100644 --- a/deps/v8/test/mjsunit/accessor-map-sharing.js +++ b/deps/v8/test/mjsunit/accessor-map-sharing.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 +// Flags: --allow-natives-syntax --fast-accessor-properties // Handy abbreviations. var dp = Object.defineProperty; diff --git a/deps/v8/test/mjsunit/array-construct-transition.js b/deps/v8/test/mjsunit/array-construct-transition.js index 577e321a55..f8d7c830e5 100644 --- a/deps/v8/test/mjsunit/array-construct-transition.js +++ b/deps/v8/test/mjsunit/array-construct-transition.js @@ -27,13 +27,13 @@ // Flags: --allow-natives-syntax --smi-only-arrays -support_smi_only_arrays = %HasFastSmiOnlyElements(new Array(1,2,3,4,5,6,7,8)); +support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6)); if (support_smi_only_arrays) { var a = new Array(0, 1, 2); - assertTrue(%HasFastSmiOnlyElements(a)); + assertTrue(%HasFastSmiElements(a)); var b = new Array(0.5, 1.2, 2.3); assertTrue(%HasFastDoubleElements(b)); var c = new Array(0.5, 1.2, new Object()); - assertTrue(%HasFastElements(c)); + assertTrue(%HasFastObjectElements(c)); } diff --git a/deps/v8/test/mjsunit/array-literal-transitions.js b/deps/v8/test/mjsunit/array-literal-transitions.js index f657525eb6..a96719d448 100644 --- a/deps/v8/test/mjsunit/array-literal-transitions.js +++ b/deps/v8/test/mjsunit/array-literal-transitions.js @@ -1,4 +1,4 @@ -// Copyright 2011 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: @@ -33,7 +33,7 @@ // in this test case. Depending on whether smi-only arrays are actually // enabled, this test takes the appropriate code path to check smi-only arrays. -support_smi_only_arrays = %HasFastSmiOnlyElements([1,2,3,4,5,6,7,8,9,10]); +support_smi_only_arrays = %HasFastSmiElements([1,2,3,4,5,6,7,8,9,10]); if (support_smi_only_arrays) { print("Tests include smi-only arrays."); @@ -46,14 +46,14 @@ function get(foo) { return foo; } // Used to generate dynamic values. function array_literal_test() { var a0 = [1, 2, 3]; - assertTrue(%HasFastSmiOnlyElements(a0)); + assertTrue(%HasFastSmiElements(a0)); var a1 = [get(1), get(2), get(3)]; - assertTrue(%HasFastSmiOnlyElements(a1)); + assertTrue(%HasFastSmiElements(a1)); var b0 = [1, 2, get("three")]; - assertTrue(%HasFastElements(b0)); + assertTrue(%HasFastObjectElements(b0)); var b1 = [get(1), get(2), get("three")]; - assertTrue(%HasFastElements(b1)); + assertTrue(%HasFastObjectElements(b1)); var c0 = [1, 2, get(3.5)]; assertTrue(%HasFastDoubleElements(c0)); @@ -75,7 +75,7 @@ function array_literal_test() { var object = new Object(); var d0 = [1, 2, object]; - assertTrue(%HasFastElements(d0)); + assertTrue(%HasFastObjectElements(d0)); assertEquals(object, d0[2]); assertEquals(2, d0[1]); assertEquals(1, d0[0]); @@ -87,7 +87,7 @@ function array_literal_test() { assertEquals(1, e0[0]); var f0 = [1, 2, [1, 2]]; - assertTrue(%HasFastElements(f0)); + assertTrue(%HasFastObjectElements(f0)); assertEquals([1,2], f0[2]); assertEquals(2, f0[1]); assertEquals(1, f0[0]); @@ -115,9 +115,9 @@ if (support_smi_only_arrays) { large = [ 0, 1, 2, 3, 4, 5, d(), d(), d(), d(), d(), d(), o(), o(), o(), o() ]; assertFalse(%HasDictionaryElements(large)); - assertFalse(%HasFastSmiOnlyElements(large)); + assertFalse(%HasFastSmiElements(large)); assertFalse(%HasFastDoubleElements(large)); - assertTrue(%HasFastElements(large)); + assertTrue(%HasFastObjectElements(large)); assertEquals(large, [0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, new Object(), new Object(), new Object(), new Object()]); diff --git a/deps/v8/test/mjsunit/elements-kind.js b/deps/v8/test/mjsunit/elements-kind.js index 4aa79de659..26b3c7807b 100644 --- a/deps/v8/test/mjsunit/elements-kind.js +++ b/deps/v8/test/mjsunit/elements-kind.js @@ -34,7 +34,7 @@ // in this test case. Depending on whether smi-only arrays are actually // enabled, this test takes the appropriate code path to check smi-only arrays. -support_smi_only_arrays = %HasFastSmiOnlyElements(new Array(1,2,3,4,5,6,7,8)); +support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); if (support_smi_only_arrays) { print("Tests include smi-only arrays."); @@ -59,8 +59,8 @@ var elements_kind = { } function getKind(obj) { - if (%HasFastSmiOnlyElements(obj)) return elements_kind.fast_smi_only; - if (%HasFastElements(obj)) return elements_kind.fast; + if (%HasFastSmiElements(obj)) return elements_kind.fast_smi_only; + if (%HasFastObjectElements(obj)) return elements_kind.fast; if (%HasFastDoubleElements(obj)) return elements_kind.fast_double; if (%HasDictionaryElements(obj)) return elements_kind.dictionary; // Every external kind is also an external array. @@ -116,7 +116,7 @@ if (support_smi_only_arrays) { assertKind(elements_kind.fast_smi_only, too); } -// Make sure the element kind transitions from smionly when a non-smi is stored. +// Make sure the element kind transitions from smi when a non-smi is stored. var you = new Array(); assertKind(elements_kind.fast_smi_only, you); for (var i = 0; i < 1337; i++) { diff --git a/deps/v8/test/mjsunit/elements-transition-hoisting.js b/deps/v8/test/mjsunit/elements-transition-hoisting.js index 5e78f10a0b..50ca2a16e2 100644 --- a/deps/v8/test/mjsunit/elements-transition-hoisting.js +++ b/deps/v8/test/mjsunit/elements-transition-hoisting.js @@ -1,4 +1,4 @@ -// Copyright 2011 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: @@ -31,7 +31,7 @@ // not hoisted) correctly, don't change the semantics programs and don't trigger // deopt through hoisting in important situations. -support_smi_only_arrays = %HasFastSmiOnlyElements(new Array(1,2,3,4,5,6)); +support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6)); if (support_smi_only_arrays) { print("Tests include smi-only arrays."); diff --git a/deps/v8/test/mjsunit/elements-transition.js b/deps/v8/test/mjsunit/elements-transition.js index 60e051b3fa..0dffd3723e 100644 --- a/deps/v8/test/mjsunit/elements-transition.js +++ b/deps/v8/test/mjsunit/elements-transition.js @@ -27,7 +27,7 @@ // Flags: --allow-natives-syntax --smi-only-arrays -support_smi_only_arrays = %HasFastSmiOnlyElements(new Array(1,2,3,4,5,6,7,8)); +support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6,7,8)); if (support_smi_only_arrays) { print("Tests include smi-only arrays."); @@ -44,8 +44,8 @@ if (support_smi_only_arrays) { var array_1 = new Array(length); var array_2 = new Array(length); - assertTrue(%HasFastSmiOnlyElements(array_1)); - assertTrue(%HasFastSmiOnlyElements(array_2)); + assertTrue(%HasFastSmiElements(array_1)); + assertTrue(%HasFastSmiElements(array_2)); for (var i = 0; i < length; i++) { if (i == length - 5 && test_double) { // Trigger conversion to fast double elements at length-5. @@ -57,8 +57,8 @@ if (support_smi_only_arrays) { // Trigger conversion to fast object elements at length-3. set(array_1, i, 'object'); set(array_2, i, 'object'); - assertTrue(%HasFastElements(array_1)); - assertTrue(%HasFastElements(array_2)); + assertTrue(%HasFastObjectElements(array_1)); + assertTrue(%HasFastObjectElements(array_2)); } else if (i != length - 7) { // Set the element to an integer but leave a hole at length-7. set(array_1, i, 2*i+1); diff --git a/deps/v8/test/mjsunit/packed-elements.js b/deps/v8/test/mjsunit/packed-elements.js new file mode 100644 index 0000000000..7f333e56e5 --- /dev/null +++ b/deps/v8/test/mjsunit/packed-elements.js @@ -0,0 +1,112 @@ +// 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 --smi-only-arrays --packed-arrays + +var has_packed_elements = !%HasFastHoleyElements(Array()); + +function test1() { + var a = Array(8); + assertTrue(%HasFastSmiOrObjectElements(a)); + assertTrue(%HasFastHoleyElements(a)); +} + +function test2() { + var a = Array(); + assertTrue(%HasFastSmiOrObjectElements(a)); + assertFalse(%HasFastHoleyElements(a)); +} + +function test3() { + var a = Array(1,2,3,4,5,6,7); + assertTrue(%HasFastSmiOrObjectElements(a)); + assertFalse(%HasFastHoleyElements(a)); +} + +function test4() { + var a = [1, 2, 3, 4]; + assertTrue(%HasFastSmiElements(a)); + assertFalse(%HasFastHoleyElements(a)); + var b = [1, 2,, 4]; + assertTrue(%HasFastSmiElements(b)); + assertTrue(%HasFastHoleyElements(b)); +} + +function test5() { + var a = [1, 2, 3, 4.5]; + assertTrue(%HasFastDoubleElements(a)); + assertFalse(%HasFastHoleyElements(a)); + var b = [1,, 3.5, 4]; + assertTrue(%HasFastDoubleElements(b)); + assertTrue(%HasFastHoleyElements(b)); + var c = [1, 3.5,, 4]; + assertTrue(%HasFastDoubleElements(c)); + assertTrue(%HasFastHoleyElements(c)); +} + +function test6() { + var x = new Object(); + var a = [1, 2, 3.5, x]; + assertTrue(%HasFastObjectElements(a)); + assertFalse(%HasFastHoleyElements(a)); + assertEquals(1, a[0]); + assertEquals(2, a[1]); + assertEquals(3.5, a[2]); + assertEquals(x, a[3]); + var b = [1,, 3.5, x]; + assertTrue(%HasFastObjectElements(b)); + assertTrue(%HasFastHoleyElements(b)); + assertEquals(1, b[0]); + assertEquals(undefined, b[1]); + assertEquals(3.5, b[2]); + assertEquals(x, b[3]); + var c = [1, 3.5, x,,]; + assertTrue(%HasFastObjectElements(c)); + assertTrue(%HasFastHoleyElements(c)); + assertEquals(1, c[0]); + assertEquals(3.5, c[1]); + assertEquals(x, c[2]); + assertEquals(undefined, c[3]); +} + +function test_with_optimization(f) { + // Run tests in a loop to make sure that inlined Array() constructor runs out + // of new space memory and must fall back on runtime impl. + for (i = 0; i < 250000; ++i) f(); + %OptimizeFunctionOnNextCall(f); + for (i = 0; i < 250000; ++i) f(); // Make sure GC happens +} + +if (has_packed_elements) { + test_with_optimization(test1); + test_with_optimization(test2); + test_with_optimization(test3); + test_with_optimization(test4); + test_with_optimization(test5); + test_with_optimization(test6); +} + diff --git a/deps/v8/test/mjsunit/regexp-global.js b/deps/v8/test/mjsunit/regexp-global.js new file mode 100644 index 0000000000..12f8578596 --- /dev/null +++ b/deps/v8/test/mjsunit/regexp-global.js @@ -0,0 +1,132 @@ +// 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. + + +// Test that an optional capture is cleared between two matches. +var str = "ABX X"; +str = str.replace(/(\w)?X/g, function(match, capture) { + assertTrue(match.indexOf(capture) >= 0 || + capture === undefined); + return capture ? capture.toLowerCase() : "-"; + }); +assertEquals("Ab -", str); + +// Test zero-length matches. +str = "Als Gregor Samsa eines Morgens"; +str = str.replace(/\b/g, function(match, capture) { + return "/"; + }); +assertEquals("/Als/ /Gregor/ /Samsa/ /eines/ /Morgens/", str); + +// Test zero-length matches that have non-zero-length sub-captures. +str = "It was a pleasure to burn."; +str = str.replace(/(?=(\w+))\b/g, function(match, capture) { + return capture.length; + }); +assertEquals("2It 3was 1a 8pleasure 2to 4burn.", str); + +// Test multiple captures. +str = "Try not. Do, or do not. There is no try."; +str = str.replace(/(not?)|(do)|(try)/gi, + function(match, c1, c2, c3) { + assertTrue((c1 === undefined && c2 === undefined) || + (c2 === undefined && c3 === undefined) || + (c1 === undefined && c3 === undefined)); + if (c1) return "-"; + if (c2) return "+"; + if (c3) return "=" + }); +assertEquals("= -. +, or + -. There is - =.", str); + +// Test multiple alternate captures. +str = "FOUR LEGS GOOD, TWO LEGS BAD!"; +str = str.replace(/(FOUR|TWO) LEGS (GOOD|BAD)/g, + function(match, num_legs, likeability) { + assertTrue(num_legs !== undefined); + assertTrue(likeability !== undefined); + if (num_legs == "FOUR") assertTrue(likeability == "GOOD"); + if (num_legs == "TWO") assertTrue(likeability == "BAD"); + return match.length - 10; + }); +assertEquals("4, 2!", str); + + +// The same tests with UC16. + +//Test that an optional capture is cleared between two matches. +str = "AB\u1234 \u1234"; +str = str.replace(/(\w)?\u1234/g, + function(match, capture) { + assertTrue(match.indexOf(capture) >= 0 || + capture === undefined); + return capture ? capture.toLowerCase() : "-"; + }); +assertEquals("Ab -", str); + +// Test zero-length matches. +str = "Als \u2623\u2642 eines Morgens"; +str = str.replace(/\b/g, function(match, capture) { + return "/"; + }); +assertEquals("/Als/ \u2623\u2642 /eines/ /Morgens/", str); + +// Test zero-length matches that have non-zero-length sub-captures. +str = "It was a pleasure to \u70e7."; +str = str.replace(/(?=(\w+))\b/g, function(match, capture) { + return capture.length; + }); +assertEquals("2It 3was 1a 8pleasure 2to \u70e7.", str); + +// Test multiple captures. +str = "Try not. D\u26aa, or d\u26aa not. There is no try."; +str = str.replace(/(not?)|(d\u26aa)|(try)/gi, + function(match, c1, c2, c3) { + assertTrue((c1 === undefined && c2 === undefined) || + (c2 === undefined && c3 === undefined) || + (c1 === undefined && c3 === undefined)); + if (c1) return "-"; + if (c2) return "+"; + if (c3) return "=" + }); +assertEquals("= -. +, or + -. There is - =.", str); + +// Test multiple alternate captures. +str = "FOUR \u817f GOOD, TWO \u817f BAD!"; +str = str.replace(/(FOUR|TWO) \u817f (GOOD|BAD)/g, + function(match, num_legs, likeability) { + assertTrue(num_legs !== undefined); + assertTrue(likeability !== undefined); + if (num_legs == "FOUR") assertTrue(likeability == "GOOD"); + if (num_legs == "TWO") assertTrue(likeability == "BAD"); + return match.length - 7; + }); +assertEquals("4, 2!", str); + +// Test capture that is a real substring. +var str = "Beasts of England, beasts of Ireland"; +str = str.replace(/(.*)/g, function(match) { return '~'; }); +assertEquals("~~", str); diff --git a/deps/v8/test/mjsunit/regexp.js b/deps/v8/test/mjsunit/regexp.js index ec82c96e09..c2d92823bc 100644 --- a/deps/v8/test/mjsunit/regexp.js +++ b/deps/v8/test/mjsunit/regexp.js @@ -705,3 +705,14 @@ assertThrows("RegExp('(?!*)')"); // Test trimmed regular expression for RegExp.test(). assertTrue(/.*abc/.test("abc")); assertFalse(/.*\d+/.test("q")); + +// Test that RegExp.prototype.toString() throws TypeError for +// incompatible receivers (ES5 section 15.10.6 and 15.10.6.4). +assertThrows("RegExp.prototype.toString.call(null)", TypeError); +assertThrows("RegExp.prototype.toString.call(0)", TypeError); +assertThrows("RegExp.prototype.toString.call('')", TypeError); +assertThrows("RegExp.prototype.toString.call(false)", TypeError); +assertThrows("RegExp.prototype.toString.call(true)", TypeError); +assertThrows("RegExp.prototype.toString.call([])", TypeError); +assertThrows("RegExp.prototype.toString.call({})", TypeError); +assertThrows("RegExp.prototype.toString.call(function(){})", TypeError); diff --git a/deps/v8/test/mjsunit/regress/regress-117409.js b/deps/v8/test/mjsunit/regress/regress-117409.js index 9222191ae6..98aab5ac2d 100644 --- a/deps/v8/test/mjsunit/regress/regress-117409.js +++ b/deps/v8/test/mjsunit/regress/regress-117409.js @@ -36,7 +36,7 @@ var literal = [1.2]; KeyedStoreIC(literal); KeyedStoreIC(literal); -// Trruncate array to 0 elements, at which point backing store will be replaced +// Truncate array to 0 elements, at which point backing store will be replaced // with empty fixed array. literal.length = 0; diff --git a/deps/v8/test/mjsunit/regress/regress-128018.js b/deps/v8/test/mjsunit/regress/regress-128018.js new file mode 100644 index 0000000000..7bd15858e6 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-128018.js @@ -0,0 +1,35 @@ +// 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: --expose-gc + +function KeyedStoreIC(a) { a[(1)] = Math.E; } +var literal = [1.2]; +literal.length = 0; +literal.push('0' && 0 ); +KeyedStoreIC(literal); +gc(); diff --git a/deps/v8/test/mjsunit/regress/regress-128146.js b/deps/v8/test/mjsunit/regress/regress-128146.js new file mode 100644 index 0000000000..730dd91065 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-128146.js @@ -0,0 +1,33 @@ +// 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. + +// Define accessor properties, resulting in an AccessorPair with 2 transitions. +Object.defineProperty({},"foo",{set:function(){},configurable:false}); +Object.defineProperty({},"foo",{get:function(){},configurable:false}); + +// Define a data property under the same name. +Object.defineProperty({},"foo",{}); diff --git a/deps/v8/test/mjsunit/regress/regress-1849.js b/deps/v8/test/mjsunit/regress/regress-1849.js index 176f918b93..5b8fc50f31 100644 --- a/deps/v8/test/mjsunit/regress/regress-1849.js +++ b/deps/v8/test/mjsunit/regress/regress-1849.js @@ -1,4 +1,4 @@ -// Copyright 2011 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: @@ -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. -// See: http://code.google.com/p/v8/issues/detail?id=1878 +// See: http://code.google.com/p/v8/issues/detail?id=1849 // Flags: --allow-natives-syntax @@ -36,4 +36,4 @@ for (var i = 0; i < count; i++) { arr[i] = 0; } assertFalse(%HasFastDoubleElements(arr)); -assertTrue(%HasFastSmiOnlyElements(arr)); +assertTrue(%HasFastSmiElements(arr)); diff --git a/deps/v8/test/mjsunit/regress/regress-1878.js b/deps/v8/test/mjsunit/regress/regress-1878.js index a1648b1217..fbc47bdd14 100644 --- a/deps/v8/test/mjsunit/regress/regress-1878.js +++ b/deps/v8/test/mjsunit/regress/regress-1878.js @@ -34,11 +34,11 @@ var a = Array(); for (var i = 0; i < 1000; i++) { var ai = natives.InternalArray(10000); assertFalse(%HaveSameMap(ai, a)); - assertTrue(%HasFastElements(ai)); + assertTrue(%HasFastObjectElements(ai)); } for (var i = 0; i < 1000; i++) { var ai = new natives.InternalArray(10000); assertFalse(%HaveSameMap(ai, a)); - assertTrue(%HasFastElements(ai)); + assertTrue(%HasFastObjectElements(ai)); } diff --git a/deps/v8/test/mjsunit/regress/regress-2071.js b/deps/v8/test/mjsunit/regress/regress-2071.js new file mode 100644 index 0000000000..91ae2a7b03 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-2071.js @@ -0,0 +1,79 @@ +// 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. + +a = {}; + +a.b = 42; + +with(a) { + a.f = (function f1() { + function f2() { + return b; + }; + return f2; + })(); +} + +for(var i = 0; i < 10000; i++) { + assertEquals(42, a.f()); +} + +with(a) { + a.g = (function f1() { + function f2() { + function f3() { + return b; + } + return f3; + }; + return f2(); + })(); +} + +for(var i = 0; i < 10000; i++) { + assertEquals(42, a.g()); +} + +function outer() { + with(a) { + a.h = (function f1() { + function f2() { + function f3() { + return b; + } + return f3; + }; + return f2(); + })(); + } +}; + +outer(); + +for(var i = 0; i < 10000; i++) { + assertEquals(42, a.h()); +} diff --git a/deps/v8/test/mjsunit/regress/regress-2153.js b/deps/v8/test/mjsunit/regress/regress-2153.js new file mode 100644 index 0000000000..3170042bed --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-2153.js @@ -0,0 +1,32 @@ +// 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 o = {}; +o.__defineGetter__('foo', function () { return null; }); +var o = {}; +o.foo = 42; +assertEquals(42, o.foo); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-122271.js b/deps/v8/test/mjsunit/regress/regress-crbug-122271.js index 3a99a7fa58..8ae91e857a 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-122271.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-122271.js @@ -39,11 +39,11 @@ function foo(array) { array.foo = "bar"; } -assertTrue(%HasFastSmiOnlyElements(a)); -assertTrue(%HasFastElements(b)); +assertTrue(%HasFastSmiElements(a)); +assertTrue(%HasFastObjectElements(b)); foo(a); foo(b); -assertTrue(%HasFastSmiOnlyElements(a)); -assertTrue(%HasFastElements(b)); +assertTrue(%HasFastSmiElements(a)); +assertTrue(%HasFastObjectElements(b)); diff --git a/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js b/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js index a9a6d89b06..55ca2996ff 100644 --- a/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js +++ b/deps/v8/test/mjsunit/regress/regress-smi-only-concat.js @@ -33,5 +33,5 @@ var fast_array = ['a', 'b']; var array = fast_array.concat(fast_array); -assertTrue(%HasFastElements(fast_array)); -assertTrue(%HasFastElements(array));
\ No newline at end of file +assertTrue(%HasFastObjectElements(fast_array)); +assertTrue(%HasFastObjectElements(array)); diff --git a/deps/v8/test/mjsunit/regress/regress-transcendental.js b/deps/v8/test/mjsunit/regress/regress-transcendental.js new file mode 100644 index 0000000000..b5dbcb48af --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-transcendental.js @@ -0,0 +1,49 @@ +// 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: --expose-gc + +// Test whether the runtime implementation and generated code of +// sine and tangens return the same results. + +function test(f, x, name) { + // Reset transcendental cache. + gc(); + // Initializing cache leads to a runtime call. + var runtime_result = f(x); + // Flush transcendental cache entries and optimize f. + for (var i = 0; i < 100000; i++) f(i); + // Calculate using generated code. + var gencode_result = f(x); + print(name + " runtime function: " + runtime_result); + print(name + " generated code : " + gencode_result); + assertEquals(gencode_result, runtime_result); +} + +test(Math.tan, -1.57079632679489660000, "Math.tan"); +test(Math.sin, 6.283185307179586, "Math.sin"); + diff --git a/deps/v8/test/mjsunit/stack-traces.js b/deps/v8/test/mjsunit/stack-traces.js index 536e71bbb5..438eec979d 100644 --- a/deps/v8/test/mjsunit/stack-traces.js +++ b/deps/v8/test/mjsunit/stack-traces.js @@ -111,6 +111,18 @@ function testStrippedCustomError() { throw new CustomError("hep-hey", CustomError); } +MyObj = function() { FAIL; } + +MyObjCreator = function() {} + +MyObjCreator.prototype.Create = function() { + return new MyObj(); +} + +function testClassNames() { + (new MyObjCreator).Create(); +} + // Utility function for testing that the expected strings occur // in the stack trace produced when running the given function. function testTrace(name, fun, expected, unexpected) { @@ -254,6 +266,8 @@ testTrace("testDefaultCustomError", testDefaultCustomError, ["collectStackTrace"]); testTrace("testStrippedCustomError", testStrippedCustomError, ["hep-hey"], ["new CustomError", "collectStackTrace"]); +testTrace("testClassNames", testClassNames, + ["new MyObj", "MyObjCreator.Create"], ["as Create"]); testCallerCensorship(); testUnintendedCallerCensorship(); testErrorsDuringFormatting(); diff --git a/deps/v8/test/mjsunit/unbox-double-arrays.js b/deps/v8/test/mjsunit/unbox-double-arrays.js index fd7db28a0d..ac039930c3 100644 --- a/deps/v8/test/mjsunit/unbox-double-arrays.js +++ b/deps/v8/test/mjsunit/unbox-double-arrays.js @@ -1,4 +1,4 @@ -// Copyright 2011 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: @@ -278,7 +278,8 @@ function testOneArrayType(allocator) { expected_array_value(7)); %DeoptimizeFunction(test_various_loads6); - gc(); + %ClearFunctionTypeFeedback(test_various_stores); + %ClearFunctionTypeFeedback(test_various_loads7); // Test stores for non-NaN. var large_array = new allocator(large_array_size); @@ -376,7 +377,7 @@ delete large_array2[5]; // Convert back to fast elements and make sure the contents of the array are // unchanged. large_array2[25] = new Object(); -assertTrue(%HasFastElements(large_array2)); +assertTrue(%HasFastObjectElements(large_array2)); for (var i= 0; i < approx_dict_to_elements_threshold; i += 500 ) { if (i != 25 && i != 5) { assertEquals(expected_array_value(i), large_array2[i]); |