diff options
Diffstat (limited to 'deps/v8/test')
27 files changed, 1593 insertions, 345 deletions
diff --git a/deps/v8/test/cctest/cctest.gyp b/deps/v8/test/cctest/cctest.gyp new file mode 100644 index 0000000000..aa2b355831 --- /dev/null +++ b/deps/v8/test/cctest/cctest.gyp @@ -0,0 +1,160 @@ +# Copyright 2010 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +{ + 'target_defaults': { + 'conditions': [ + ['OS!="mac"', { + # TODO(sgjesse): This is currently copied from v8.gyp, should probably + # be refactored. + 'conditions': [ + ['v8_target_arch=="arm"', { + 'defines': [ + 'V8_TARGET_ARCH_ARM', + ], + }], + ['v8_target_arch=="ia32"', { + 'defines': [ + 'V8_TARGET_ARCH_IA32', + ], + }], + ['v8_target_arch=="x64"', { + 'defines': [ + 'V8_TARGET_ARCH_X64', + ], + }], + ], + }], + ], + }, + 'targets': [ + { + 'target_name': 'cctest', + 'type': 'executable', + 'dependencies': [ + '../../tools/gyp/v8.gyp:v8', + ], + 'include_dirs': [ + '../../src', + ], + 'sources': [ + 'cctest.cc', + 'gay-fixed.cc', + 'gay-precision.cc', + 'gay-shortest.cc', + 'test-accessors.cc', + 'test-alloc.cc', + 'test-api.cc', + 'test-ast.cc', + 'test-bignum.cc', + 'test-bignum-dtoa.cc', + 'test-circular-queue.cc', + 'test-compiler.cc', + 'test-conversions.cc', + 'test-cpu-profiler.cc', + 'test-dataflow.cc', + 'test-debug.cc', + 'test-decls.cc', + 'test-deoptimization.cc', + 'test-diy-fp.cc', + 'test-double.cc', + 'test-dtoa.cc', + 'test-fast-dtoa.cc', + 'test-fixed-dtoa.cc', + 'test-flags.cc', + 'test-func-name-inference.cc', + 'test-hashmap.cc', + 'test-heap.cc', + 'test-heap-profiler.cc', + 'test-list.cc', + 'test-liveedit.cc', + 'test-lock.cc', + 'test-log.cc', + 'test-log-utils.cc', + 'test-mark-compact.cc', + 'test-parsing.cc', + 'test-profile-generator.cc', + 'test-regexp.cc', + 'test-reloc-info.cc', + 'test-serialize.cc', + 'test-sockets.cc', + 'test-spaces.cc', + 'test-strings.cc', + 'test-strtod.cc', + 'test-thread-termination.cc', + 'test-threads.cc', + 'test-type-info.cc', + 'test-unbound-queue.cc', + 'test-utils.cc', + 'test-version.cc' + ], + 'conditions': [ + ['v8_target_arch=="ia32"', { + 'sources': [ + 'test-assembler-ia32.cc', + 'test-disasm-ia32.cc', + 'test-log-stack-tracer.cc' + ], + }], + ['v8_target_arch=="x64"', { + 'sources': [ + 'test-assembler-x64.cc', + 'test-macro-assembler-x64.cc', + 'test-log-stack-tracer.cc' + ], + }], + ['v8_target_arch=="arm"', { + 'sources': [ + 'test-assembler-arm.cc', + 'test-disasm-arm.cc' + ], + }], + ['v8_target_arch=="mips"', { + 'sources': [ + 'test-assembler-mips.cc', + 'test-mips.cc', + ], + }], + [ 'OS=="linux"', { + 'sources': [ + 'test-platform-linux.cc', + ], + }], + [ 'OS=="mac"', { + 'sources': [ + 'test-platform-macos.cc', + ], + }], + [ 'OS=="win"', { + 'sources': [ + 'test-platform-win32.cc', + ], + }], + ], + }, + ], +} diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index 4f1bcdc8ad..4dfe51aac8 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -42,9 +42,6 @@ test-api/ApplyInterruption: PASS || TIMEOUT # when snapshot is on, so I am marking it PASS || FAIL test-heap-profiler/HeapSnapshotsDiff: PASS || FAIL -# BUG(3260336): Flaky test. May be timing related. -test-profile-generator/RecordStackTraceAtStartProfiling: PASS || FAIL - # These tests always fail. They are here to test test.py. If # they don't fail then test.py has failed. test-serialize/TestThatAlwaysFails: FAIL @@ -81,6 +78,17 @@ test-sockets/Socket: SKIP ############################################################################## +[ $arch == arm && $crankshaft ] + +# Tests that fail with crankshaft. +test-deoptimization/DeoptimizeBinaryOperationMOD: FAIL + +# Tests that time out with crankshaft. +test-debug/ThreadedDebugging: SKIP +test-debug/DebugBreakLoop: SKIP + + +############################################################################## [ $arch == mips ] test-accessors: SKIP test-alloc: SKIP diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index b6f551150e..9539973693 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -4344,47 +4344,167 @@ THREADED_TEST(ObjectInstantiation) { } +static int StrCmp16(uint16_t* a, uint16_t* b) { + while (true) { + if (*a == 0 && *b == 0) return 0; + if (*a != *b) return 0 + *a - *b; + a++; + b++; + } +} + + +static int StrNCmp16(uint16_t* a, uint16_t* b, int n) { + while (true) { + if (n-- == 0) return 0; + if (*a == 0 && *b == 0) return 0; + if (*a != *b) return 0 + *a - *b; + a++; + b++; + } +} + + THREADED_TEST(StringWrite) { v8::HandleScope scope; v8::Handle<String> str = v8_str("abcde"); + // abc<Icelandic eth><Unicode snowman>. + v8::Handle<String> str2 = v8_str("abc\303\260\342\230\203"); + + CHECK_EQ(5, str2->Length()); char buf[100]; + char utf8buf[100]; + uint16_t wbuf[100]; int len; + int charlen; + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen); + CHECK_EQ(len, 9); + CHECK_EQ(charlen, 5); + CHECK_EQ(strcmp(utf8buf, "abc\303\260\342\230\203"), 0); + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, 8, &charlen); + CHECK_EQ(len, 8); + CHECK_EQ(charlen, 5); + CHECK_EQ(strncmp(utf8buf, "abc\303\260\342\230\203\1", 9), 0); + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, 7, &charlen); + CHECK_EQ(len, 5); + CHECK_EQ(charlen, 4); + CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0); + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, 6, &charlen); + CHECK_EQ(len, 5); + CHECK_EQ(charlen, 4); + CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0); + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, 5, &charlen); + CHECK_EQ(len, 5); + CHECK_EQ(charlen, 4); + CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0); + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, 4, &charlen); + CHECK_EQ(len, 3); + CHECK_EQ(charlen, 3); + CHECK_EQ(strncmp(utf8buf, "abc\1", 4), 0); + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, 3, &charlen); + CHECK_EQ(len, 3); + CHECK_EQ(charlen, 3); + CHECK_EQ(strncmp(utf8buf, "abc\1", 4), 0); + + memset(utf8buf, 0x1, sizeof(utf8buf)); + len = str2->WriteUtf8(utf8buf, 2, &charlen); + CHECK_EQ(len, 2); + CHECK_EQ(charlen, 2); + CHECK_EQ(strncmp(utf8buf, "ab\1", 3), 0); memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf); CHECK_EQ(len, 5); - CHECK_EQ(strncmp("abcde\0", buf, 6), 0); + len = str->Write(wbuf); + CHECK_EQ(len, 5); + CHECK_EQ(strcmp("abcde", buf), 0); + uint16_t answer1[] = {'a', 'b', 'c', 'd', 'e', '\0'}; + CHECK_EQ(StrCmp16(answer1, wbuf), 0); memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 0, 4); CHECK_EQ(len, 4); + len = str->Write(wbuf, 0, 4); + CHECK_EQ(len, 4); CHECK_EQ(strncmp("abcd\1", buf, 5), 0); + uint16_t answer2[] = {'a', 'b', 'c', 'd', 0x101}; + CHECK_EQ(StrNCmp16(answer2, wbuf, 5), 0); memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 0, 5); CHECK_EQ(len, 5); + len = str->Write(wbuf, 0, 5); + CHECK_EQ(len, 5); CHECK_EQ(strncmp("abcde\1", buf, 6), 0); + uint16_t answer3[] = {'a', 'b', 'c', 'd', 'e', 0x101}; + CHECK_EQ(StrNCmp16(answer3, wbuf, 6), 0); memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 0, 6); CHECK_EQ(len, 5); - CHECK_EQ(strncmp("abcde\0", buf, 6), 0); + len = str->Write(wbuf, 0, 6); + CHECK_EQ(len, 5); + CHECK_EQ(strcmp("abcde", buf), 0); + uint16_t answer4[] = {'a', 'b', 'c', 'd', 'e', '\0'}; + CHECK_EQ(StrCmp16(answer4, wbuf), 0); memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 4, -1); CHECK_EQ(len, 1); - CHECK_EQ(strncmp("e\0", buf, 2), 0); + len = str->Write(wbuf, 4, -1); + CHECK_EQ(len, 1); + CHECK_EQ(strcmp("e", buf), 0); + uint16_t answer5[] = {'e', '\0'}; + CHECK_EQ(StrCmp16(answer5, wbuf), 0); memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 4, 6); CHECK_EQ(len, 1); - CHECK_EQ(strncmp("e\0", buf, 2), 0); + len = str->Write(wbuf, 4, 6); + CHECK_EQ(len, 1); + CHECK_EQ(strcmp("e", buf), 0); + CHECK_EQ(StrCmp16(answer5, wbuf), 0); memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 4, 1); CHECK_EQ(len, 1); + len = str->Write(wbuf, 4, 1); + CHECK_EQ(len, 1); CHECK_EQ(strncmp("e\1", buf, 2), 0); + uint16_t answer6[] = {'e', 0x101}; + CHECK_EQ(StrNCmp16(answer6, wbuf, 2), 0); + + memset(buf, 0x1, sizeof(buf)); + memset(wbuf, 0x1, sizeof(wbuf)); + len = str->WriteAscii(buf, 3, 1); + CHECK_EQ(len, 1); + len = str->Write(wbuf, 3, 1); + CHECK_EQ(len, 1); + CHECK_EQ(strncmp("d\1", buf, 2), 0); + uint16_t answer7[] = {'d', 0x101}; + CHECK_EQ(StrNCmp16(answer7, wbuf, 2), 0); } diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index ac4afb2517..ad242fe79c 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -1211,4 +1211,51 @@ TEST(HeapSnapshotGetNodeById) { CHECK_EQ(NULL, snapshot->GetNodeById(0x1000000UL)); } + +namespace { + +class TestActivityControl : public v8::ActivityControl { + public: + explicit TestActivityControl(int abort_count) + : done_(0), total_(0), abort_count_(abort_count) {} + ControlOption ReportProgressValue(int done, int total) { + done_ = done; + total_ = total; + return --abort_count_ != 0 ? kContinue : kAbort; + } + int done() { return done_; } + int total() { return total_; } + + private: + int done_; + int total_; + int abort_count_; +}; +} + +TEST(TakeHeapSnapshotAborting) { + v8::HandleScope scope; + LocalContext env; + + const int snapshots_count = v8::HeapProfiler::GetSnapshotsCount(); + TestActivityControl aborting_control(3); + const v8::HeapSnapshot* no_snapshot = + v8::HeapProfiler::TakeSnapshot(v8::String::New("abort"), + v8::HeapSnapshot::kFull, + &aborting_control); + CHECK_EQ(NULL, no_snapshot); + CHECK_EQ(snapshots_count, v8::HeapProfiler::GetSnapshotsCount()); + CHECK_GT(aborting_control.total(), aborting_control.done()); + + TestActivityControl control(-1); // Don't abort. + const v8::HeapSnapshot* snapshot = + v8::HeapProfiler::TakeSnapshot(v8::String::New("full"), + v8::HeapSnapshot::kFull, + &control); + CHECK_NE(NULL, snapshot); + CHECK_EQ(snapshots_count + 1, v8::HeapProfiler::GetSnapshotsCount()); + CHECK_EQ(control.total(), control.done()); + CHECK_GT(control.total(), 0); +} + #endif // ENABLE_LOGGING_AND_PROFILING diff --git a/deps/v8/test/cctest/test-log-utils.cc b/deps/v8/test/cctest/test-log-utils.cc index c99d770d42..861be12ce8 100644 --- a/deps/v8/test/cctest/test-log-utils.cc +++ b/deps/v8/test/cctest/test-log-utils.cc @@ -12,7 +12,6 @@ using v8::internal::CStrVector; using v8::internal::EmbeddedVector; using v8::internal::LogDynamicBuffer; -using v8::internal::LogRecordCompressor; using v8::internal::MutableCStrVector; using v8::internal::ScopedVector; using v8::internal::Vector; @@ -138,173 +137,4 @@ TEST(DynaBufSealing) { CHECK_EQ(0, ReadData(&dynabuf, 100 + seal_size, &buf)); } - -TEST(CompressorStore) { - LogRecordCompressor comp(2); - const Vector<const char> empty = CStrVector(""); - CHECK(comp.Store(empty)); - CHECK(!comp.Store(empty)); - CHECK(!comp.Store(empty)); - const Vector<const char> aaa = CStrVector("aaa"); - CHECK(comp.Store(aaa)); - CHECK(!comp.Store(aaa)); - CHECK(!comp.Store(aaa)); - CHECK(comp.Store(empty)); - CHECK(!comp.Store(empty)); - CHECK(!comp.Store(empty)); -} - - -void CheckCompression(LogRecordCompressor* comp, - const Vector<const char>& after) { - EmbeddedVector<char, 100> result; - CHECK(comp->RetrievePreviousCompressed(&result)); - CHECK_EQ(after, result); -} - - -void CheckCompression(LogRecordCompressor* comp, - const char* after) { - CheckCompression(comp, CStrVector(after)); -} - - -TEST(CompressorNonCompressed) { - LogRecordCompressor comp(0); - CHECK(!comp.RetrievePreviousCompressed(NULL)); - const Vector<const char> empty = CStrVector(""); - CHECK(comp.Store(empty)); - CHECK(!comp.RetrievePreviousCompressed(NULL)); - const Vector<const char> a_x_20 = CStrVector("aaaaaaaaaaaaaaaaaaaa"); - CHECK(comp.Store(a_x_20)); - CheckCompression(&comp, empty); - CheckCompression(&comp, empty); - CHECK(comp.Store(empty)); - CheckCompression(&comp, a_x_20); - CheckCompression(&comp, a_x_20); -} - - -TEST(CompressorSingleLine) { - LogRecordCompressor comp(1); - const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); - CHECK(comp.Store(string_1)); - const Vector<const char> string_2 = CStrVector("fff,ddd,ccc,bbb,aaa"); - CHECK(comp.Store(string_2)); - // string_1 hasn't been compressed. - CheckCompression(&comp, string_1); - CheckCompression(&comp, string_1); - const Vector<const char> string_3 = CStrVector("hhh,ggg,ccc,bbb,aaa"); - CHECK(comp.Store(string_3)); - // string_2 compressed using string_1. - CheckCompression(&comp, "fff#1:3"); - CheckCompression(&comp, "fff#1:3"); - CHECK(!comp.Store(string_3)); - // Expecting no changes. - CheckCompression(&comp, "fff#1:3"); - CHECK(!comp.Store(string_3)); - // Expecting no changes. - CheckCompression(&comp, "fff#1:3"); - const Vector<const char> string_4 = CStrVector("iii,hhh,ggg,ccc,bbb,aaa"); - CHECK(comp.Store(string_4)); - // string_3 compressed using string_2. - CheckCompression(&comp, "hhh,ggg#1:7"); - const Vector<const char> string_5 = CStrVector("nnn,mmm,lll,kkk,jjj"); - CHECK(comp.Store(string_5)); - // string_4 compressed using string_3. - CheckCompression(&comp, "iii,#1"); - const Vector<const char> string_6 = CStrVector("nnn,mmmmmm,lll,kkk,jjj"); - CHECK(comp.Store(string_6)); - // string_5 hasn't been compressed. - CheckCompression(&comp, string_5); - CHECK(comp.Store(string_5)); - // string_6 compressed using string_5. - CheckCompression(&comp, "nnn,mmm#1:4"); - const Vector<const char> string_7 = CStrVector("nnnnnn,mmm,lll,kkk,jjj"); - CHECK(comp.Store(string_7)); - // string_5 compressed using string_6. - CheckCompression(&comp, "nnn,#1:7"); - const Vector<const char> string_8 = CStrVector("xxn,mmm,lll,kkk,jjj"); - CHECK(comp.Store(string_8)); - // string_7 compressed using string_5. - CheckCompression(&comp, "nnn#1"); - const Vector<const char> string_9 = - CStrVector("aaaaaaaaaaaaa,bbbbbbbbbbbbbbbbb"); - CHECK(comp.Store(string_9)); - // string_8 compressed using string_7. - CheckCompression(&comp, "xx#1:5"); - const Vector<const char> string_10 = - CStrVector("aaaaaaaaaaaaa,cccccccbbbbbbbbbb"); - CHECK(comp.Store(string_10)); - // string_9 hasn't been compressed. - CheckCompression(&comp, string_9); - CHECK(comp.Store(string_1)); - // string_10 compressed using string_9. - CheckCompression(&comp, "aaaaaaaaaaaaa,ccccccc#1:21"); -} - - - -TEST(CompressorMultiLines) { - const int kWindowSize = 3; - LogRecordCompressor comp(kWindowSize); - const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); - CHECK(comp.Store(string_1)); - const Vector<const char> string_2 = CStrVector("iii,hhh,ggg,fff,aaa"); - CHECK(comp.Store(string_2)); - const Vector<const char> string_3 = CStrVector("mmm,lll,kkk,jjj,aaa"); - CHECK(comp.Store(string_3)); - const Vector<const char> string_4 = CStrVector("nnn,hhh,ggg,fff,aaa"); - CHECK(comp.Store(string_4)); - const Vector<const char> string_5 = CStrVector("ooo,lll,kkk,jjj,aaa"); - CHECK(comp.Store(string_5)); - // string_4 compressed using string_2. - CheckCompression(&comp, "nnn#2:3"); - CHECK(comp.Store(string_1)); - // string_5 compressed using string_3. - CheckCompression(&comp, "ooo#2:3"); - CHECK(comp.Store(string_4)); - // string_1 is out of buffer by now, so it shouldn't be compressed. - CHECK_GE(3, kWindowSize); - CheckCompression(&comp, string_1); - CHECK(comp.Store(string_2)); - // string_4 compressed using itself. - CheckCompression(&comp, "#3"); -} - - -TEST(CompressorBestSelection) { - LogRecordCompressor comp(3); - const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); - CHECK(comp.Store(string_1)); - const Vector<const char> string_2 = CStrVector("ddd,ccc,bbb,aaa"); - CHECK(comp.Store(string_2)); - const Vector<const char> string_3 = CStrVector("fff,eee,ddd,ccc,bbb,aaa"); - CHECK(comp.Store(string_3)); - // string_2 compressed using string_1. - CheckCompression(&comp, "#1:4"); - const Vector<const char> string_4 = CStrVector("nnn,hhh,ggg,fff,aaa"); - CHECK(comp.Store(string_4)); - // Compressing string_3 using string_1 gives a better compression than - // using string_2. - CheckCompression(&comp, "fff,#2"); -} - - -TEST(CompressorCompressibility) { - LogRecordCompressor comp(2); - const Vector<const char> string_1 = CStrVector("eee,ddd,ccc,bbb,aaa"); - CHECK(comp.Store(string_1)); - const Vector<const char> string_2 = CStrVector("ccc,bbb,aaa"); - CHECK(comp.Store(string_2)); - const Vector<const char> string_3 = CStrVector("aaa"); - CHECK(comp.Store(string_3)); - // string_2 compressed using string_1. - CheckCompression(&comp, "#1:8"); - const Vector<const char> string_4 = CStrVector("xxx"); - CHECK(comp.Store(string_4)); - // string_3 can't be compressed using string_2 --- too short. - CheckCompression(&comp, string_3); -} - #endif // ENABLE_LOGGING_AND_PROFILING diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index badbab5eeb..e642d1b622 100755 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -260,10 +260,12 @@ TEST(StandAlonePreParser) { uintptr_t stack_limit = i::StackGuard::real_climit(); for (int i = 0; programs[i]; i++) { const char* program = programs[i]; - unibrow::Utf8InputBuffer<256> stream(program, strlen(program)); + i::Utf8ToUC16CharacterStream stream( + reinterpret_cast<const i::byte*>(program), + static_cast<unsigned>(strlen(program))); i::CompleteParserRecorder log; i::V8JavaScriptScanner scanner; - scanner.Initialize(i::Handle<i::String>::null(), &stream); + scanner.Initialize(&stream); v8::preparser::PreParser::PreParseResult result = v8::preparser::PreParser::PreParseProgram(&scanner, @@ -289,9 +291,10 @@ TEST(RegressChromium62639) { // and then used the invalid currently scanned literal. This always // failed in debug mode, and sometimes crashed in release mode. - unibrow::Utf8InputBuffer<256> stream(program, strlen(program)); + i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), + static_cast<unsigned>(strlen(program))); i::ScriptDataImpl* data = - i::ParserApi::PreParse(i::Handle<i::String>::null(), &stream, NULL); + i::ParserApi::PreParse(&stream, NULL); CHECK(data->HasError()); delete data; } @@ -310,10 +313,10 @@ TEST(Regress928) { "try { } catch (e) { var foo = function () { /* first */ } }" "var bar = function () { /* second */ }"; - unibrow::Utf8InputBuffer<256> stream(program, strlen(program)); + i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), + static_cast<unsigned>(strlen(program))); i::ScriptDataImpl* data = - i::ParserApi::PartialPreParse(i::Handle<i::String>::null(), - &stream, NULL); + i::ParserApi::PartialPreParse(&stream, NULL); CHECK(!data->HasError()); data->Initialize(); @@ -347,10 +350,12 @@ TEST(PreParseOverflow) { uintptr_t stack_limit = i::StackGuard::real_climit(); - unibrow::Utf8InputBuffer<256> stream(*program, strlen(*program)); + i::Utf8ToUC16CharacterStream stream( + reinterpret_cast<const i::byte*>(*program), + static_cast<unsigned>(kProgramSize)); i::CompleteParserRecorder log; i::V8JavaScriptScanner scanner; - scanner.Initialize(i::Handle<i::String>::null(), &stream); + scanner.Initialize(&stream); v8::preparser::PreParser::PreParseResult result = @@ -360,3 +365,283 @@ TEST(PreParseOverflow) { stack_limit); CHECK_EQ(v8::preparser::PreParser::kPreParseStackOverflow, result); } + + +class TestExternalResource: public v8::String::ExternalStringResource { + public: + explicit TestExternalResource(uint16_t* data, int length) + : data_(data), length_(static_cast<size_t>(length)) { } + + ~TestExternalResource() { } + + const uint16_t* data() const { + return data_; + } + + size_t length() const { + return length_; + } + private: + uint16_t* data_; + size_t length_; +}; + + +#define CHECK_EQU(v1, v2) CHECK_EQ(static_cast<int>(v1), static_cast<int>(v2)) + +void TestCharacterStream(const char* ascii_source, + unsigned length, + unsigned start = 0, + unsigned end = 0) { + if (end == 0) end = length; + unsigned sub_length = end - start; + i::HandleScope test_scope; + i::SmartPointer<i::uc16> uc16_buffer(new i::uc16[length]); + for (unsigned i = 0; i < length; i++) { + uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]); + } + i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length)); + i::Handle<i::String> ascii_string( + i::Factory::NewStringFromAscii(ascii_vector)); + TestExternalResource resource(*uc16_buffer, length); + i::Handle<i::String> uc16_string( + i::Factory::NewExternalStringFromTwoByte(&resource)); + + i::ExternalTwoByteStringUC16CharacterStream uc16_stream( + i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end); + i::GenericStringUC16CharacterStream string_stream(ascii_string, start, end); + i::Utf8ToUC16CharacterStream utf8_stream( + reinterpret_cast<const i::byte*>(ascii_source), end); + utf8_stream.SeekForward(start); + + unsigned i = start; + while (i < end) { + // Read streams one char at a time + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + int32_t c0 = ascii_source[i]; + int32_t c1 = uc16_stream.Advance(); + int32_t c2 = string_stream.Advance(); + int32_t c3 = utf8_stream.Advance(); + i++; + CHECK_EQ(c0, c1); + CHECK_EQ(c0, c2); + CHECK_EQ(c0, c3); + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + } + while (i > start + sub_length / 4) { + // Pushback, re-read, pushback again. + int32_t c0 = ascii_source[i - 1]; + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + uc16_stream.PushBack(c0); + string_stream.PushBack(c0); + utf8_stream.PushBack(c0); + i--; + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + int32_t c1 = uc16_stream.Advance(); + int32_t c2 = string_stream.Advance(); + int32_t c3 = utf8_stream.Advance(); + i++; + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + CHECK_EQ(c0, c1); + CHECK_EQ(c0, c2); + CHECK_EQ(c0, c3); + uc16_stream.PushBack(c0); + string_stream.PushBack(c0); + utf8_stream.PushBack(c0); + i--; + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + } + unsigned halfway = start + sub_length / 2; + uc16_stream.SeekForward(halfway - i); + string_stream.SeekForward(halfway - i); + utf8_stream.SeekForward(halfway - i); + i = halfway; + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + + while (i < end) { + // Read streams one char at a time + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + int32_t c0 = ascii_source[i]; + int32_t c1 = uc16_stream.Advance(); + int32_t c2 = string_stream.Advance(); + int32_t c3 = utf8_stream.Advance(); + i++; + CHECK_EQ(c0, c1); + CHECK_EQ(c0, c2); + CHECK_EQ(c0, c3); + CHECK_EQU(i, uc16_stream.pos()); + CHECK_EQU(i, string_stream.pos()); + CHECK_EQU(i, utf8_stream.pos()); + } + + int32_t c1 = uc16_stream.Advance(); + int32_t c2 = string_stream.Advance(); + int32_t c3 = utf8_stream.Advance(); + CHECK_LT(c1, 0); + CHECK_LT(c2, 0); + CHECK_LT(c3, 0); +} + + +TEST(CharacterStreams) { + v8::HandleScope handles; + v8::Persistent<v8::Context> context = v8::Context::New(); + v8::Context::Scope context_scope(context); + + TestCharacterStream("abc\0\n\r\x7f", 7); + static const unsigned kBigStringSize = 4096; + char buffer[kBigStringSize + 1]; + for (unsigned i = 0; i < kBigStringSize; i++) { + buffer[i] = static_cast<char>(i & 0x7f); + } + TestCharacterStream(buffer, kBigStringSize); + + TestCharacterStream(buffer, kBigStringSize, 576, 3298); + + TestCharacterStream("\0", 1); + TestCharacterStream("", 0); +} + + +TEST(Utf8CharacterStream) { + static const unsigned kMaxUC16CharU = unibrow::Utf8::kMaxThreeByteChar; + static const int kMaxUC16Char = static_cast<int>(kMaxUC16CharU); + + static const int kAllUtf8CharsSize = + (unibrow::Utf8::kMaxOneByteChar + 1) + + (unibrow::Utf8::kMaxTwoByteChar - unibrow::Utf8::kMaxOneByteChar) * 2 + + (unibrow::Utf8::kMaxThreeByteChar - unibrow::Utf8::kMaxTwoByteChar) * 3; + static const unsigned kAllUtf8CharsSizeU = + static_cast<unsigned>(kAllUtf8CharsSize); + + char buffer[kAllUtf8CharsSizeU]; + unsigned cursor = 0; + for (int i = 0; i <= kMaxUC16Char; i++) { + cursor += unibrow::Utf8::Encode(buffer + cursor, i); + } + ASSERT(cursor == kAllUtf8CharsSizeU); + + i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer), + kAllUtf8CharsSizeU); + for (int i = 0; i <= kMaxUC16Char; i++) { + CHECK_EQU(i, stream.pos()); + int32_t c = stream.Advance(); + CHECK_EQ(i, c); + CHECK_EQU(i + 1, stream.pos()); + } + for (int i = kMaxUC16Char; i >= 0; i--) { + CHECK_EQU(i + 1, stream.pos()); + stream.PushBack(i); + CHECK_EQU(i, stream.pos()); + } + int i = 0; + while (stream.pos() < kMaxUC16CharU) { + CHECK_EQU(i, stream.pos()); + unsigned progress = stream.SeekForward(12); + i += progress; + int32_t c = stream.Advance(); + if (i <= kMaxUC16Char) { + CHECK_EQ(i, c); + } else { + CHECK_EQ(-1, c); + } + i += 1; + CHECK_EQU(i, stream.pos()); + } +} + +#undef CHECK_EQU + +void TestStreamScanner(i::UC16CharacterStream* stream, + i::Token::Value* expected_tokens, + int skip_pos = 0, // Zero means not skipping. + int skip_to = 0) { + i::V8JavaScriptScanner scanner; + scanner.Initialize(stream, i::JavaScriptScanner::kAllLiterals); + + int i = 0; + do { + i::Token::Value expected = expected_tokens[i]; + i::Token::Value actual = scanner.Next(); + CHECK_EQ(i::Token::String(expected), i::Token::String(actual)); + if (scanner.location().end_pos == skip_pos) { + scanner.SeekForward(skip_to); + } + i++; + } while (expected_tokens[i] != i::Token::ILLEGAL); +} + +TEST(StreamScanner) { + const char* str1 = "{ foo get for : */ <- \n\n /*foo*/ bib"; + i::Utf8ToUC16CharacterStream stream1(reinterpret_cast<const i::byte*>(str1), + static_cast<unsigned>(strlen(str1))); + i::Token::Value expectations1[] = { + i::Token::LBRACE, + i::Token::IDENTIFIER, + i::Token::IDENTIFIER, + i::Token::FOR, + i::Token::COLON, + i::Token::MUL, + i::Token::DIV, + i::Token::LT, + i::Token::SUB, + i::Token::IDENTIFIER, + i::Token::EOS, + i::Token::ILLEGAL + }; + TestStreamScanner(&stream1, expectations1, 0, 0); + + const char* str2 = "case default const {THIS\nPART\nSKIPPED} do"; + i::Utf8ToUC16CharacterStream stream2(reinterpret_cast<const i::byte*>(str2), + static_cast<unsigned>(strlen(str2))); + i::Token::Value expectations2[] = { + i::Token::CASE, + i::Token::DEFAULT, + i::Token::CONST, + i::Token::LBRACE, + // Skipped part here + i::Token::RBRACE, + i::Token::DO, + i::Token::EOS, + i::Token::ILLEGAL + }; + ASSERT_EQ('{', str2[19]); + ASSERT_EQ('}', str2[37]); + TestStreamScanner(&stream2, expectations2, 20, 37); + + const char* str3 = "{}}}}"; + i::Token::Value expectations3[] = { + i::Token::LBRACE, + i::Token::RBRACE, + i::Token::RBRACE, + i::Token::RBRACE, + i::Token::RBRACE, + i::Token::EOS, + i::Token::ILLEGAL + }; + // Skip zero-four RBRACEs. + for (int i = 0; i <= 4; i++) { + expectations3[6 - i] = i::Token::ILLEGAL; + expectations3[5 - i] = i::Token::EOS; + i::Utf8ToUC16CharacterStream stream3( + reinterpret_cast<const i::byte*>(str3), + static_cast<unsigned>(strlen(str3))); + TestStreamScanner(&stream3, expectations3, 1, 1 + i); + } +} diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index a0733ef685..f849d404ae 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -782,12 +782,16 @@ TEST(RecordStackTraceAtStartProfiling) { CpuProfiler::GetProfile(NULL, 0); const ProfileTree* topDown = profile->top_down(); const ProfileNode* current = topDown->root(); + const_cast<ProfileNode*>(current)->Print(0); // The tree should look like this: // (root) // (anonymous function) // a // b // c + // There can also be: + // startProfiling + // if the sampler managed to get a tick. current = PickChild(current, "(anonymous function)"); CHECK_NE(NULL, const_cast<ProfileNode*>(current)); current = PickChild(current, "a"); @@ -796,7 +800,12 @@ TEST(RecordStackTraceAtStartProfiling) { CHECK_NE(NULL, const_cast<ProfileNode*>(current)); current = PickChild(current, "c"); CHECK_NE(NULL, const_cast<ProfileNode*>(current)); - CHECK_EQ(0, current->children()->length()); + CHECK(current->children()->length() == 0 || + current->children()->length() == 1); + if (current->children()->length() == 1) { + current = PickChild(current, "startProfiling"); + CHECK_EQ(0, current->children()->length()); + } } diff --git a/deps/v8/test/es5conform/es5conform.status b/deps/v8/test/es5conform/es5conform.status index cc641dfe55..a51bd30200 100644 --- a/deps/v8/test/es5conform/es5conform.status +++ b/deps/v8/test/es5conform/es5conform.status @@ -88,7 +88,7 @@ chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-4-215: UNIMPLEMENTED # than those described in the spec - but according to spec they can # have additional properties. # All compareArray calls in these tests could be exchanged with a -# isSubsetOfArray call (I will upload a path to the es5conform site). +# isSubsetOfArray call (I will upload a patch to the es5conform site). # SUBSETFAIL chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-1: FAIL_OK @@ -112,12 +112,6 @@ chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-6: FAIL_OK chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-7: FAIL_OK # SUBSETFAIL -chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-8: FAIL_OK - -# SUBSETFAIL -chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-9: FAIL_OK - -# SUBSETFAIL chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-11: FAIL_OK # We do not implement all methods on RegExp. diff --git a/deps/v8/test/mjsunit/compiler/regress-intoverflow.js b/deps/v8/test/mjsunit/compiler/regress-intoverflow.js new file mode 100644 index 0000000000..d3842f1c23 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/regress-intoverflow.js @@ -0,0 +1,62 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Test overflow checks in optimized code. +function testMul(a, b) { + a *= 2; + b *= 2; + if (a < 1 && b < 1) { + return a * b; + } +} + +for (var i=0; i<1000000; i++) testMul(0,0); +assertEquals(4611686018427388000, testMul(-0x40000000, -0x40000000)); + +function testAdd(a, b) { + a *= 2; + b *= 2; + if (a < 1 && b < 1) { + return a + b; + } +} + +for (var i=0; i<1000000; i++) testAdd(0,0); +assertEquals(-4294967296, testAdd(-0x40000000, -0x40000000)); + + +function testSub(a, b) { + a *= 2; + b *= 2; + if (b == 2) {print(a); print(b);} + if (a < 1 && b < 3) { + return a - b; + } +} + +for (var i=0; i<1000000; i++) testSub(0,0); +assertEquals(-2147483650, testSub(-0x40000000, 1)); diff --git a/deps/v8/test/mjsunit/date.js b/deps/v8/test/mjsunit/date.js index 57fc5a0e8e..f13af8266d 100644 --- a/deps/v8/test/mjsunit/date.js +++ b/deps/v8/test/mjsunit/date.js @@ -167,8 +167,8 @@ assertDoesNotThrow("new Date(-0x40000001, -0x40000001, -0x40000001," + // Modified test from WebKit // LayoutTests/fast/js/script-tests/date-utc-timeclip.js: -assertEquals(Date.UTC(275760, 8, 12, 23, 59, 59, 999), 8639999999999999); -assertEquals(Date.UTC(275760, 8, 13), 8640000000000000); +assertEquals(8639999999999999, Date.UTC(275760, 8, 12, 23, 59, 59, 999)); +assertEquals(8640000000000000, Date.UTC(275760, 8, 13)); assertTrue(isNaN(Date.UTC(275760, 8, 13, 0, 0, 0, 1))); assertTrue(isNaN(Date.UTC(275760, 8, 14))); @@ -176,3 +176,14 @@ assertEquals(Date.UTC(-271821, 3, 20, 0, 0, 0, 1), -8639999999999999); assertEquals(Date.UTC(-271821, 3, 20), -8640000000000000); assertTrue(isNaN(Date.UTC(-271821, 3, 19, 23, 59, 59, 999))); assertTrue(isNaN(Date.UTC(-271821, 3, 19))); + + +// Test creation of large date values. +d = new Date(1969, 12, 1, 99999999999); +assertTrue(isNaN(d.getTime())); +d = new Date(1969, 12, 1, -99999999999); +assertTrue(isNaN(d.getTime())); +d = new Date(1969, 12, 1, Infinity); +assertTrue(isNaN(d.getTime())); +d = new Date(1969, 12, 1, -Infinity); +assertTrue(isNaN(d.getTime())); diff --git a/deps/v8/test/mjsunit/debug-evaluate-with-context.js b/deps/v8/test/mjsunit/debug-evaluate-with-context.js new file mode 100644 index 0000000000..5e1c83cf52 --- /dev/null +++ b/deps/v8/test/mjsunit/debug-evaluate-with-context.js @@ -0,0 +1,144 @@ +// Copyright 2008 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-debug-as debug +// Get the Debug object exposed from the debug context global object. +Debug = debug.Debug + +var evaluate_callback; + +function listener(event, exec_state, event_data, data) { + try { + var context = { what_is_capybara: "a fish" }; + var context2 = { what_is_capybara: "a fish", what_is_parrot: "a beard" }; + + // Try in frame's scope. + var local_expression = + "(what_is_capybara ? what_is_capybara : 'a beast') + '/' + what_is_parrot"; + var result = evaluate_callback.in_top_frame(exec_state, local_expression, context); + assertEquals('a fish/a bird', result); + + // Try in frame's scope with overrididen local variables. + var result = evaluate_callback.in_top_frame(exec_state, local_expression, context2); + assertEquals('a fish/a beard', result); + + // Try in frame's scope, without context. + var local_expression2 = "what_is_parrot"; + var result = evaluate_callback.in_top_frame(exec_state, local_expression2, void 0); + assertEquals('a bird', result); + + // Try in global additional scope. + var global_expression = "what_is_capybara ? what_is_capybara : 'a beast'"; + var result = evaluate_callback.globally(exec_state, global_expression, context); + assertEquals('a fish', result); + + // Try in global scope with overridden global variables. + var context_with_undefined = { undefined: 'kitten' }; + var global_expression2 = "'cat' + '/' + undefined"; + var result = evaluate_callback.globally(exec_state, global_expression2, context_with_undefined); + assertEquals('cat/kitten', result); + + // Try in global scope with no overridden global variables. + var result = evaluate_callback.globally(exec_state, global_expression2, void 0); + assertEquals('cat/undefined', result); + + // Try in global scope without additional context. + var global_expression3 = "'cat' + '/' + 'dog'"; + var result = evaluate_callback.globally(exec_state, global_expression3, void 0); + assertEquals('cat/dog', result); + + listenerComplete = true; + } catch (e) { + exception = e + }; +}; + + +function f() { + var what_is_parrot = "a bird"; + debugger; +}; + +function runF() { + exception = false; + listenerComplete = false; + + Debug.setListener(listener); + + // Add the debug event listener. + Debug.setListener(listener); + + f(); + + assertFalse(exception, "exception in listener") + assertTrue(listenerComplete); +} + +evaluate_callback = { + in_top_frame: function(exec_state, expression, additional_context) { + return exec_state.frame(0).evaluate(expression, void 0, additional_context).value(); + }, + globally: function(exec_state, expression, additional_context) { + return exec_state.evaluateGlobal(expression, void 0, additional_context).value(); + }, +}; + + +runF(); + +// Now try all the same, but via debug protocol. + +function evaluateViaProtocol(exec_state, expression, additional_context, frame_argument_adder) { + var dcp = exec_state.debugCommandProcessor("unspecified_running_state"); + request_json = {"seq":17,"type":"request","command":"evaluate", arguments: { "expression": expression } }; + frame_argument_adder(request_json.arguments); + if (additional_context) { + var context_json = []; + for (var key in additional_context) { + context_json.push({ name: key, handle: Debug.MakeMirror(additional_context[key]).handle() }); + } + request_json.arguments.additional_context = context_json; + } + var request = JSON.stringify(request_json); + var response_json = dcp.processDebugJSONRequest(request); + var response = JSON.parse(response_json); + + assertTrue(response.success); + var str_result = response.body.value; + return str_result; +} + +evaluate_callback = { + in_top_frame: function(exec_state, expression, additional_context) { + return evaluateViaProtocol(exec_state, expression, additional_context, function(args) { args.frame = 0; }); + }, + globally: function(exec_state, expression, additional_context) { + return evaluateViaProtocol(exec_state, expression, additional_context, function(args) { args.global = true; }); + }, +}; + +runF(); diff --git a/deps/v8/test/mjsunit/fuzz-natives.js b/deps/v8/test/mjsunit/fuzz-natives.js index 0446cd38db..020e3c0c85 100644 --- a/deps/v8/test/mjsunit/fuzz-natives.js +++ b/deps/v8/test/mjsunit/fuzz-natives.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 --noalways-opt +// Flags: --allow-natives-syntax var RUN_WITH_ALL_ARGUMENT_ENTRIES = false; var kOnManyArgumentsRemove = 5; diff --git a/deps/v8/test/mjsunit/json.js b/deps/v8/test/mjsunit/json.js index 1c55959d5f..a0be8dd133 100644 --- a/deps/v8/test/mjsunit/json.js +++ b/deps/v8/test/mjsunit/json.js @@ -25,45 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -function GenericToJSONChecks(Constructor, value, alternative) { - var n1 = new Constructor(value); - n1.valueOf = function () { return alternative; }; - assertEquals(alternative, n1.toJSON()); - var n2 = new Constructor(value); - n2.valueOf = null; - assertThrows(function () { n2.toJSON(); }, TypeError); - var n3 = new Constructor(value); - n3.valueOf = function () { return {}; }; - assertThrows(function () { n3.toJSON(); }, TypeError, 'result_not_primitive'); - var n4 = new Constructor(value); - n4.valueOf = function () { - assertEquals(0, arguments.length); - assertEquals(this, n4); - return null; - }; - assertEquals(null, n4.toJSON()); -} - -// Number toJSON -assertEquals(3, (3).toJSON()); -assertEquals(3, (3).toJSON(true)); -assertEquals(4, (new Number(4)).toJSON()); -GenericToJSONChecks(Number, 5, 6); - -// Boolean toJSON -assertEquals(true, (true).toJSON()); -assertEquals(true, (true).toJSON(false)); -assertEquals(false, (false).toJSON()); -assertEquals(true, (new Boolean(true)).toJSON()); -GenericToJSONChecks(Boolean, true, false); -GenericToJSONChecks(Boolean, false, true); - -// String toJSON -assertEquals("flot", "flot".toJSON()); -assertEquals("flot", "flot".toJSON(3)); -assertEquals("tolf", (new String("tolf")).toJSON()); -GenericToJSONChecks(String, "x", "y"); - // Date toJSON assertEquals("1970-01-01T00:00:00.000Z", new Date(0).toJSON()); assertEquals("1979-01-11T08:00:00.000Z", new Date("1979-01-11 08:00 GMT").toJSON()); @@ -74,9 +35,6 @@ assertEquals("foo", n1.toJSON()); var n2 = new Date(10001); n2.toISOString = null; assertThrows(function () { n2.toJSON(); }, TypeError); -var n3 = new Date(10002); -n3.toISOString = function () { return {}; }; -assertThrows(function () { n3.toJSON(); }, TypeError, "result_not_primitive"); var n4 = new Date(10003); n4.toISOString = function () { assertEquals(0, arguments.length); @@ -88,9 +46,47 @@ assertEquals(null, n4.toJSON()); assertTrue(Object.prototype === JSON.__proto__); assertEquals("[object JSON]", Object.prototype.toString.call(JSON)); +//Test Date.prototype.toJSON as generic function. +var d1 = {toJSON: Date.prototype.toJSON, + toISOString: function() { return 42; }}; +assertEquals(42, d1.toJSON()); + +var d2 = {toJSON: Date.prototype.toJSON, + valueOf: function() { return Infinity; }, + toISOString: function() { return 42; }}; +assertEquals(null, d2.toJSON()); + +var d3 = {toJSON: Date.prototype.toJSON, + valueOf: "not callable", + toString: function() { return Infinity; }, + toISOString: function() { return 42; }}; + +assertEquals(null, d3.toJSON()); + +var d4 = {toJSON: Date.prototype.toJSON, + valueOf: "not callable", + toString: "not callable either", + toISOString: function() { return 42; }}; +assertThrows("d4.toJSON()", TypeError); // ToPrimitive throws. + +var d5 = {toJSON: Date.prototype.toJSON, + valueOf: "not callable", + toString: function() { return "Infinity"; }, + toISOString: function() { return 42; }}; +assertEquals(42, d5.toJSON()); + +var d6 = {toJSON: Date.prototype.toJSON, + toISOString: function() { return ["not primitive"]; }}; +assertEquals(["not primitive"], d6.toJSON()); + +var d7 = {toJSON: Date.prototype.toJSON, + ISOString: "not callable"}; +assertThrows("d7.toJSON()", TypeError); + // DontEnum -for (var p in this) +for (var p in this) { assertFalse(p == "JSON"); +} // Parse assertEquals({}, JSON.parse("{}")); @@ -286,7 +282,7 @@ assertEquals('["10"]', JSON.stringify(array)); // The gap is capped at ten characters if specified as string. assertEquals('{\n "a": "b",\n "c": "d"\n}', - JSON.stringify({a:"b",c:"d"}, null, + JSON.stringify({a:"b",c:"d"}, null, " /*characters after 10th*/")); //The gap is capped at ten characters if specified as number. @@ -301,16 +297,16 @@ assertEquals('{"x":true}', JSON.stringify({x: Boolean}, newx)); assertEquals(undefined, JSON.stringify(undefined)); assertEquals(undefined, JSON.stringify(function () { })); -// Arrays with missing, undefined or function elements have those elements +// Arrays with missing, undefined or function elements have those elements // replaced by null. -assertEquals("[null,null,null]", +assertEquals("[null,null,null]", JSON.stringify([undefined,,function(){}])); // Objects with undefined or function properties (including replaced properties) // have those properties ignored. -assertEquals('{}', +assertEquals('{}', JSON.stringify({a: undefined, b: function(){}, c: 42, d: 42}, - function(k, v) { if (k == "c") return undefined; + function(k, v) { if (k == "c") return undefined; if (k == "d") return function(){}; return v; })); @@ -334,7 +330,7 @@ for (var i = 0; i < 65536; i++) { // Step 2.a expected = '\\' + string; } else if ("\b\t\n\r\f".indexOf(string) >= 0) { - // Step 2.b + // Step 2.b if (string == '\b') expected = '\\b'; else if (string == '\t') expected = '\\t'; else if (string == '\n') expected = '\\n'; @@ -349,6 +345,73 @@ for (var i = 0; i < 65536; i++) { } } else { expected = string; - } + } assertEquals('"' + expected + '"', encoded, "Codepoint " + i); -} +} + + +// Ensure that wrappers and callables are handled correctly. +var num37 = new Number(42); +num37.valueOf = function() { return 37; }; + +var numFoo = new Number(42); +numFoo.valueOf = "not callable"; +numFoo.toString = function() { return "foo"; }; + +var numTrue = new Number(42); +numTrue.valueOf = function() { return true; } + +var strFoo = new String("bar"); +strFoo.toString = function() { return "foo"; }; + +var str37 = new String("bar"); +str37.toString = "not callable"; +str37.valueOf = function() { return 37; }; + +var strTrue = new String("bar"); +strTrue.toString = function() { return true; } + +var func = function() { /* Is callable */ }; + +var funcJSON = function() { /* Is callable */ }; +funcJSON.toJSON = function() { return "has toJSON"; }; + +var re = /Is callable/; + +var reJSON = /Is callable/; +reJSON.toJSON = function() { return "has toJSON"; }; + +assertEquals( + '[37,null,1,"foo","37","true",null,"has toJSON",null,"has toJSON"]', + JSON.stringify([num37, numFoo, numTrue, + strFoo, str37, strTrue, + func, funcJSON, re, reJSON])); + + +var oddball = Object(42); +oddball.__proto__ = { __proto__: null, toString: function() { return true; } }; +assertEquals('1', JSON.stringify(oddball)); + +var getCount = 0; +var callCount = 0; +var counter = { get toJSON() { getCount++; + return function() { callCount++; + return 42; }; } }; +assertEquals('42', JSON.stringify(counter)); +assertEquals(1, getCount); +assertEquals(1, callCount); + +var oddball2 = Object(42); +var oddball3 = Object("foo"); +oddball3.__proto__ = { __proto__: null, + toString: "not callable", + valueOf: function() { return true; } }; +oddball2.__proto__ = { __proto__: null, + toJSON: function () { return oddball3; } } +assertEquals('"true"', JSON.stringify(oddball2)); + + +var falseNum = Object("37"); +falseNum.__proto__ = Number.prototype; +falseNum.toString = function() { return 42; }; +assertEquals('"42"', JSON.stringify(falseNum)); diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index 24d9603b6b..eeeb3dc112 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -34,7 +34,8 @@ bugs: FAIL ############################################################################## # Too slow in debug mode with --stress-opt compiler/regress-stacktrace-methods: PASS, SKIP if $mode == debug - +compiler/regress-funcaller: PASS, SKIP if $mode == debug +regress/regress-create-exception: PASS, SKIP if $mode == debug ############################################################################## # This one uses a built-in that's only present in debug mode. It takes @@ -106,6 +107,13 @@ regress/regress-3247124: SKIP ############################################################################## +[ $arch == arm && $crankshaft ] + +# Test that currently fail with crankshaft on ARM. +compiler/simple-osr: FAIL + + +############################################################################## [ $arch == mips ] # Skip all tests on MIPS. diff --git a/deps/v8/test/mjsunit/object-define-property.js b/deps/v8/test/mjsunit/object-define-property.js index b258aa75bf..d24a4e5a39 100644 --- a/deps/v8/test/mjsunit/object-define-property.js +++ b/deps/v8/test/mjsunit/object-define-property.js @@ -74,7 +74,7 @@ function getter3() {return val3; } // Descriptors. var emptyDesc = {}; -var accessorConfigurable = { +var accessorConfigurable = { set: setter1, get: getter1, configurable: true @@ -83,7 +83,7 @@ var accessorConfigurable = { var accessorNoConfigurable = { set: setter2, get: getter2, - configurable: false + configurable: false }; var accessorOnlySet = { @@ -234,7 +234,7 @@ assertEquals(desc.value, undefined); assertEquals(1, obj1.setOnly = 1); assertEquals(2, val3); -// The above should also work if redefining just a getter or setter on +// The above should also work if redefining just a getter or setter on // an existing property with both a getter and a setter. Object.defineProperty(obj1, "both", accessorConfigurable); @@ -384,7 +384,7 @@ assertEquals(desc.get, undefined); assertEquals(desc.set, undefined); -// Redefinition of an accessor defined using __defineGetter__ and +// Redefinition of an accessor defined using __defineGetter__ and // __defineSetter__. function get(){return this.x} function set(x){this.x=x}; @@ -462,7 +462,7 @@ try { // Test runtime calls to DefineOrRedefineDataProperty and -// DefineOrRedefineAccessorProperty - make sure we don't +// DefineOrRedefineAccessorProperty - make sure we don't // crash. try { %DefineOrRedefineAccessorProperty(0, 0, 0, 0, 0); @@ -511,7 +511,7 @@ try { // Test that all possible differences in step 6 in DefineOwnProperty are // exercised, i.e., any difference in the given property descriptor and the // existing properties should not return true, but throw an error if the -// existing configurable property is false. +// existing configurable property is false. var obj5 = {}; // Enumerable will default to false. @@ -727,7 +727,7 @@ var descElement = { value: 'foobar' }; var descElementNonConfigurable = { value: 'barfoo', configurable: false }; var descElementNonWritable = { value: 'foofoo', writable: false }; var descElementNonEnumerable = { value: 'barbar', enumerable: false }; -var descElementAllFalse = { value: 'foofalse', +var descElementAllFalse = { value: 'foofalse', configurable: false, writable: false, enumerable: false }; @@ -790,7 +790,7 @@ assertFalse(desc.configurable); // Make sure that we can't redefine using direct access. obj6[15] ='overwrite'; -assertEquals(obj6[15],'foobar'); +assertEquals(obj6[15],'foobar'); // Repeat the above tests on an array. @@ -805,7 +805,7 @@ var descElement = { value: 'foobar' }; var descElementNonConfigurable = { value: 'barfoo', configurable: false }; var descElementNonWritable = { value: 'foofoo', writable: false }; var descElementNonEnumerable = { value: 'barbar', enumerable: false }; -var descElementAllFalse = { value: 'foofalse', +var descElementAllFalse = { value: 'foofalse', configurable: false, writable: false, enumerable: false }; @@ -866,4 +866,35 @@ assertFalse(desc.writable); assertFalse(desc.enumerable); assertFalse(desc.configurable); - +// See issue 968: http://code.google.com/p/v8/issues/detail?id=968 +var o = { x : 42 }; +Object.defineProperty(o, "x", { writable: false }); +assertEquals(42, o.x); +o.x = 37; +assertEquals(42, o.x); + +o = { x : 42 }; +Object.defineProperty(o, "x", {}); +assertEquals(42, o.x); +o.x = 37; +// Writability is preserved. +assertEquals(37, o.x); + +var o = { }; +Object.defineProperty(o, "x", { writable: false }); +assertEquals(undefined, o.x); +o.x = 37; +assertEquals(undefined, o.x); + +o = { get x() { return 87; } }; +Object.defineProperty(o, "x", { writable: false }); +assertEquals(undefined, o.x); +o.x = 37; +assertEquals(undefined, o.x); + +// Ignore inherited properties. +o = { __proto__ : { x : 87 } }; +Object.defineProperty(o, "x", { writable: false }); +assertEquals(undefined, o.x); +o.x = 37; +assertEquals(undefined, o.x); diff --git a/deps/v8/test/mjsunit/object-toprimitive.js b/deps/v8/test/mjsunit/object-toprimitive.js new file mode 100644 index 0000000000..3a67ced47e --- /dev/null +++ b/deps/v8/test/mjsunit/object-toprimitive.js @@ -0,0 +1,104 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Test the ToPrimitive internal function used by ToNumber/ToString. +// Does it [[Get]] and [[Call]] the object's toString and valueOf properties +// correctly. Specifically, does it call [[Get]] only once per property. + +var o1 = { toString: function() { return 42; }, + valueOf: function() { return "37"; } }; +var n1 = Number(o1); +var s1 = String(o1); +assertTrue(typeof n1 == "number"); +assertTrue(typeof s1 == "string"); + +var trace = []; +var valueOfValue = 42; +var toStringValue = "foo"; +function traceValueOf () { + trace.push("vo"); + return valueOfValue; +}; +function traceToString() { + trace.push("ts"); + return toStringValue; +}; +var valueOfFunc = traceValueOf; +var toStringFunc = traceToString; + +var ot = { get toString() { trace.push("gts"); + return toStringFunc; }, + get valueOf() { trace.push("gvo"); + return valueOfFunc; } +}; + +var nt = Number(ot); +assertEquals(42, nt); +assertEquals(["gvo","vo"], trace); + +trace = []; +var st = String(ot); +assertEquals("foo", st); +assertEquals(["gts","ts"], trace); + +trace = []; +valueOfValue = ["not primitive"]; +var nt = Number(ot); +assertEquals(Number("foo"), nt); +assertEquals(["gvo", "vo", "gts", "ts"], trace); + +trace = []; +valueOfValue = 42; +toStringValue = ["not primitive"]; +var st = String(ot); +assertEquals(String(42), st); +assertEquals(["gts", "ts", "gvo", "vo"], trace); + +trace = []; +valueOfValue = ["not primitive"]; +assertThrows("Number(ot)", TypeError); +assertEquals(["gvo", "vo", "gts", "ts"], trace); + + +toStringFunc = "not callable"; +trace = []; +valueOfValue = 42; +var st = String(ot); +assertEquals(String(42), st); +assertEquals(["gts", "gvo", "vo"], trace); + +valueOfFunc = "not callable"; +trace = []; +assertThrows("String(ot)", TypeError); +assertEquals(["gts", "gvo"], trace); + +toStringFunc = traceToString; +toStringValue = "87"; +trace = []; +var nt = Number(ot); +assertEquals(87, nt); +assertEquals(["gvo", "gts", "ts"], trace); diff --git a/deps/v8/test/mjsunit/regress/regress-3247124.js b/deps/v8/test/mjsunit/regress/regress-3247124.js index 7fda299923..fe4ec4e3c9 100644 --- a/deps/v8/test/mjsunit/regress/regress-3247124.js +++ b/deps/v8/test/mjsunit/regress/regress-3247124.js @@ -50,4 +50,4 @@ function bar(x) { return r.toLowerCase(); } -for (var i = 0; i < 10000; i++) bar(foo); +for (var i = 0; i < 100; i++) bar(foo); diff --git a/deps/v8/test/mjsunit/regress/regress-687.js b/deps/v8/test/mjsunit/regress/regress-687.js new file mode 100644 index 0000000000..a917a447f2 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-687.js @@ -0,0 +1,75 @@ +// Copyright 2009 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. + +// This regression includes a number of cases where we did not correctly +// update a accessor property to a data property using Object.defineProperty. + +var obj = { get value() {}, set value (v) { throw "Error";} }; +assertDoesNotThrow( + Object.defineProperty(obj, "value", + { value: 5, writable:true, configurable: true })); +var desc = Object.getOwnPropertyDescriptor(obj, "value"); +assertEquals(obj.value, 5); +assertTrue(desc.configurable); +assertTrue(desc.enumerable); +assertTrue(desc.writable); +assertEquals(desc.get, undefined); +assertEquals(desc.set, undefined); + + +var proto = { + get value() {}, + set value(v) { Object.defineProperty(this, "value", {value: v}); } +}; + +var create = Object.create(proto); + +assertEquals(create.value, undefined); +assertDoesNotThrow(create.value = 4); +assertEquals(create.value, 4); + +// These tests where provided in bug 959, but are all related to the this issue. +var obj1 = {}; +Object.defineProperty(obj1, 'p', {get: undefined, set: undefined}); +assertTrue("p" in obj1); +desc = Object.getOwnPropertyDescriptor(obj1, "p"); +assertFalse(desc.configurable); +assertFalse(desc.enumerable); +assertEquals(desc.value, undefined); +assertEquals(desc.get, undefined); +assertEquals(desc.set, undefined); + + +var obj2 = { get p() {}}; +Object.defineProperty(obj2, 'p', {get: undefined}) +assertTrue("p" in obj2); +desc = Object.getOwnPropertyDescriptor(obj2, "p"); +assertTrue(desc.configurable); +assertTrue(desc.enumerable); +assertEquals(desc.value, undefined); +assertEquals(desc.get, undefined); +assertEquals(desc.set, undefined); diff --git a/deps/v8/test/mjsunit/regress/regress-962.js b/deps/v8/test/mjsunit/regress/regress-962.js new file mode 100644 index 0000000000..f9f46e18fc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-962.js @@ -0,0 +1,53 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function L(scope) { this.s = new Object(); } + +L.prototype.c = function() { return true; } + +function F() { + this.l = [new L, new L]; +} + +F.prototype.foo = function () { + var f, d = arguments, + e, b = this.l, + g; + for (e = 0; e < b.length; e++) { + g = b[e]; + f = g.c.apply(g.s, d); + if (f === false) { + break + } + } + return f +} + + +var ctx = new F; + +for (var i = 0; i < 10000; i++) ctx.foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-969.js b/deps/v8/test/mjsunit/regress/regress-969.js new file mode 100644 index 0000000000..c2ba0ac9e8 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-969.js @@ -0,0 +1,127 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Regression test for bugs when deoptimizing after assignments in effect +// contexts. + +// Bug 989 is that there was an extra value on the expression stack when +// deoptimizing after an assignment in effect context (the value of the +// assignment was lingering). This is hard to observe in the unoptimized +// code. +// +// This test uses comma expressions to put assignments in effect contexts, +// references to deleted global variables to force deoptimization, and +// function calls to observe an extra value. + +function first(x, y) { return x; } +var y = 0; +var o = {}; +o.x = 0; +o[0] = 0; + +// Assignment to global variable. +x0 = 0; +function test0() { return first((y = 1, typeof x0), 2); } +// Call the function once to compile it. +assertEquals('number', test0()); +// Delete to force deoptimization on the next call. +delete x0; +assertEquals('undefined', test0()); + +// Compound assignment to global variable. +x1 = 0; +function test1() { return first((y += 1, typeof x1), 2); } +assertEquals('number', test1(), 'test1 before'); +delete x1; +assertEquals('undefined', test1(), 'test1 after'); + +// Pre and post-increment of global variable. +x2 = 0; +function test2() { return first((++y, typeof x2), 2); } +assertEquals('number', test2(), 'test2 before'); +delete x2; +assertEquals('undefined', test2(), 'test2 after'); + +x3 = 0; +function test3() { return first((y++, typeof x3), 2); } +assertEquals('number', test3(), 'test3 before'); +delete x3; +assertEquals('undefined', test3(), 'test3 after'); + + +// Assignment, compound assignment, and pre and post-increment of named +// properties. +x4 = 0; +function test4() { return first((o.x = 1, typeof x4), 2); } +assertEquals('number', test4()); +delete x4; +assertEquals('undefined', test4()); + +x5 = 0; +function test5() { return first((o.x += 1, typeof x5), 2); } +assertEquals('number', test5()); +delete x5; +assertEquals('undefined', test5()); + +x6 = 0; +function test6() { return first((++o.x, typeof x6), 2); } +assertEquals('number', test6()); +delete x6; +assertEquals('undefined', test6()); + +x7 = 0; +function test7() { return first((o.x++, typeof x7), 2); } +assertEquals('number', test7()); +delete x7; +assertEquals('undefined', test7()); + + +// Assignment, compound assignment, and pre and post-increment of indexed +// properties. +x8 = 0; +function test8(index) { return first((o[index] = 1, typeof x8), 2); } +assertEquals('number', test8()); +delete x8; +assertEquals('undefined', test8()); + +x9 = 0; +function test9(index) { return first((o[index] += 1, typeof x9), 2); } +assertEquals('number', test9()); +delete x9; +assertEquals('undefined', test9()); + +x10 = 0; +function test10(index) { return first((++o[index], typeof x10), 2); } +assertEquals('number', test10()); +delete x10; +assertEquals('undefined', test10()); + +x11 = 0; +function test11(index) { return first((o[index]++, typeof x11), 2); } +assertEquals('number', test11()); +delete x11; +assertEquals('undefined', test11()); diff --git a/deps/v8/test/mjsunit/regress/regress-974.js b/deps/v8/test/mjsunit/regress/regress-974.js new file mode 100644 index 0000000000..d6362cd0b1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-974.js @@ -0,0 +1,32 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-gc + +// Verify that GC is safe in a finally block entered by falling off the try +// block. +eval("(function(){try { } catch(x) { } finally { gc() }})")(); diff --git a/deps/v8/test/mjsunit/regress/regress-982.js b/deps/v8/test/mjsunit/regress/regress-982.js new file mode 100644 index 0000000000..d88543a74d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-982.js @@ -0,0 +1,45 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function f(a) { + return {className: 'xxx'}; +}; + +var x = 1; + +function g(active) { + for (i = 1; i <= 20000; i++) { + if (i == active) { + x = i; + if (f("" + i) != null) { } + } else { + if (f("" + i) != null) { } + } + } +} + +g(0); diff --git a/deps/v8/test/mjsunit/regress/regress-995.js b/deps/v8/test/mjsunit/regress/regress-995.js new file mode 100644 index 0000000000..e88121a20c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-995.js @@ -0,0 +1,57 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +// A number of hydrogen instructions did not correctly compare its +// data during GVN. +// +// Flags: --allow-natives-syntax + +// HHasInstance. +function f(value) { + if (%_IsSpecObject(value)) { + if ((%_IsArray(value))) assertTrue(false); + } +} +f(new String("bar")); + +// HClassOf. +function g(value) { + if (%_ClassOf(value) === 'Date') { + if (%_ClassOf(value) === 'String') assertTrue(false); + } +} +g(new Date()); + +// HIsNull. +function h(value) { + if (value == null) { + if (value === null) assertTrue(false); + } +} +h(undefined); + diff --git a/deps/v8/test/mjsunit/regress/regress-swapelements.js b/deps/v8/test/mjsunit/regress/regress-swapelements.js new file mode 100644 index 0000000000..7c7a683623 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-swapelements.js @@ -0,0 +1,55 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Check that modifying an array while sorting it does not segfault. See +// http://code.google.com/p/chromium/issues/detail?id=66099. + +function Item(val) { + this.value = val; +} + + +var size = 23; +var array1 = new Array(size); + + +function myToString() { + array1.splice(0, 1); + return this.value.toString(); +} + + +function test() { + for (var i = 0; i < size; i++) { + array1[i] = new Item(i); + array1[i].toString = myToString; + } + array1.sort(); +} + + +test(); diff --git a/deps/v8/test/mjsunit/tools/logreader.js b/deps/v8/test/mjsunit/tools/logreader.js deleted file mode 100644 index 485990eaa1..0000000000 --- a/deps/v8/test/mjsunit/tools/logreader.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2009 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. - -// Load CSV Parser and Log Reader implementations from <project root>/tools. -// Files: tools/csvparser.js tools/logreader.js - - -(function testAddressParser() { - var reader = new devtools.profiler.LogReader({}); - var parser = reader.createAddressParser('test'); - - // Test that 0x values are parsed, and prevAddresses_ are untouched. - assertFalse('test' in reader.prevAddresses_); - assertEquals(0, parser('0x0')); - assertFalse('test' in reader.prevAddresses_); - assertEquals(0x100, parser('0x100')); - assertFalse('test' in reader.prevAddresses_); - assertEquals(0xffffffff, parser('0xffffffff')); - assertFalse('test' in reader.prevAddresses_); - - // Test that values that has no '+' or '-' prefix are parsed - // and saved to prevAddresses_. - assertEquals(0, parser('0')); - assertEquals(0, reader.prevAddresses_.test); - assertEquals(0x100, parser('100')); - assertEquals(0x100, reader.prevAddresses_.test); - assertEquals(0xffffffff, parser('ffffffff')); - assertEquals(0xffffffff, reader.prevAddresses_.test); - - // Test that values prefixed with '+' or '-' are treated as deltas, - // and prevAddresses_ is updated. - // Set base value. - assertEquals(0x100, parser('100')); - assertEquals(0x100, reader.prevAddresses_.test); - assertEquals(0x200, parser('+100')); - assertEquals(0x200, reader.prevAddresses_.test); - assertEquals(0x100, parser('-100')); - assertEquals(0x100, reader.prevAddresses_.test); -})(); - - -(function testAddressParser() { - var reader = new devtools.profiler.LogReader({}); - - assertEquals([0x10000000, 0x10001000, 0xffff000, 0x10000000], - reader.processStack(0x10000000, 0, ['overflow', - '+1000', '-2000', '+1000'])); -})(); - - -(function testExpandBackRef() { - var reader = new devtools.profiler.LogReader({}); - - assertEquals('aaaaaaaa', reader.expandBackRef_('aaaaaaaa')); - assertEquals('aaaaaaaa', reader.expandBackRef_('#1')); - assertEquals('bbbbaaaa', reader.expandBackRef_('bbbb#2:4')); - assertEquals('"#1:1"', reader.expandBackRef_('"#1:1"')); -})(); diff --git a/deps/v8/test/mozilla/mozilla.status b/deps/v8/test/mozilla/mozilla.status index 84de68550c..1f9e6eb4a7 100644 --- a/deps/v8/test/mozilla/mozilla.status +++ b/deps/v8/test/mozilla/mozilla.status @@ -53,6 +53,9 @@ def FAIL_OK = FAIL, OKAY # time to do so. js1_5/Regress/regress-271716-n: SKIP +# BUG(960): This test has an insane amount of output when it times out, +# messing up ability to see other failures on the waterfall. +js1_5/extensions/regress-342960: SKIP # This test uses a unitialized variable. A Bug has been filed: # https://bugzilla.mozilla.org/show_bug.cgi?id=575575 @@ -810,7 +813,7 @@ js1_5/Regress/regress-312588: TIMEOUT || SKIP if $FAST == yes js1_5/Regress/regress-271716-n: PASS || SKIP if $FAST == yes -[ $ARCH == arm ] +[ $arch == arm ] # Times out and print so much output that we need to skip it to not # hang the builder. @@ -833,7 +836,14 @@ js1_5/Regress/regress-451322: SKIP js1_5/extensions/regress-371636: SKIP -[ $FAST == yes && $ARCH == arm ] +[ $arch == arm && $crankshaft ] + +# Test that only fail with crankshaft. +js1_5/Regress/regress-416628: CRASH +js1_5/Regress/regress-96128-n: PASS || CRASH + + +[ $fast == yes && $arch == arm ] # In fast mode on arm we try to skip all tests that would time out, # since running the tests takes so long in the first place. diff --git a/deps/v8/test/sputnik/README b/deps/v8/test/sputnik/README index 3d39a67e43..94c689bd28 100644 --- a/deps/v8/test/sputnik/README +++ b/deps/v8/test/sputnik/README @@ -1,6 +1,6 @@ To run the sputniktests you must check out the test suite from googlecode.com. The test expectations are currently relative to version 28. To get the tests run the following command within -v8/tests/sputnik/ +v8/test/sputnik/ svn co http://sputniktests.googlecode.com/svn/trunk/ -r28 sputniktests |