diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-04-23 12:05:36 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-04-23 12:05:36 -0700 |
commit | e72b7b8002c487d32f3a651687acca13f2009b99 (patch) | |
tree | 81a6aacbf385709a83cd095c04ec7ba44bb754bc /deps/v8/test/cctest | |
parent | 7a34afba773a09c7862759872905657ec9629351 (diff) | |
download | node-new-e72b7b8002c487d32f3a651687acca13f2009b99.tar.gz |
Upgrade V8 to 2.2.4.2
Diffstat (limited to 'deps/v8/test/cctest')
-rw-r--r-- | deps/v8/test/cctest/SConscript | 1 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-cpu-profiler.cc | 6 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-debug.cc | 4 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-liveedit.cc | 174 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-profile-generator.cc | 59 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-regexp.cc | 14 |
6 files changed, 242 insertions, 16 deletions
diff --git a/deps/v8/test/cctest/SConscript b/deps/v8/test/cctest/SConscript index 9c19c2bc25..5eab892f09 100644 --- a/deps/v8/test/cctest/SConscript +++ b/deps/v8/test/cctest/SConscript @@ -55,6 +55,7 @@ SOURCES = { 'test-heap.cc', 'test-heap-profiler.cc', 'test-list.cc', + 'test-liveedit.cc', 'test-lock.cc', 'test-log.cc', 'test-log-utils.cc', diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index 81d981ec01..6133cdb2ff 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -2,7 +2,7 @@ // // Tests of profiles generator and utilities. -#ifdef ENABLE_CPP_PROFILES_PROCESSOR +#ifdef ENABLE_LOGGING_AND_PROFILING #include "v8.h" #include "cpu-profiler-inl.h" @@ -176,7 +176,7 @@ TEST(TickEvents) { processor.Stop(); processor.Join(); - CpuProfile* profile = profiles.StopProfiling(""); + CpuProfile* profile = profiles.StopProfiling("", 1); CHECK_NE(NULL, profile); // Check call trees. @@ -222,4 +222,4 @@ TEST(TickEvents) { CHECK_EQ("bbb", bottom_up_ddd_stub_children->last()->entry()->name()); } -#endif // ENABLE_CPP_PROFILES_PROCESSOR +#endif // ENABLE_LOGGING_AND_PROFILING diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index 720ab58f19..439261a732 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -5439,7 +5439,7 @@ TEST(DebugBreakInMessageHandler) { } -#ifdef V8_NATIVE_REGEXP +#ifndef V8_INTERPRETED_REGEXP // Debug event handler which gets the function on the top frame and schedules a // break a number of times. static void DebugEventDebugBreak( @@ -5506,7 +5506,7 @@ TEST(RegExpDebugBreak) { CHECK_EQ(1, break_point_hit_count); CHECK_EQ("f", last_function_hit); } -#endif // V8_NATIVE_REGEXP +#endif // V8_INTERPRETED_REGEXP // Common part of EvalContextData and NestedBreakEventContextData tests. diff --git a/deps/v8/test/cctest/test-liveedit.cc b/deps/v8/test/cctest/test-liveedit.cc new file mode 100644 index 0000000000..bf1a0660c6 --- /dev/null +++ b/deps/v8/test/cctest/test-liveedit.cc @@ -0,0 +1,174 @@ +// Copyright 2007-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. + +#include <stdlib.h> + +#include "v8.h" + +#include "liveedit.h" +#include "cctest.h" + + +using namespace v8::internal; + +// Anonymous namespace. +namespace { + +class StringCompareInput : public Compare::Input { + public: + StringCompareInput(const char* s1, const char* s2) : s1_(s1), s2_(s2) { + } + int getLength1() { + return StrLength(s1_); + } + int getLength2() { + return StrLength(s2_); + } + bool equals(int index1, int index2) { + return s1_[index1] == s2_[index2]; + } + + private: + const char* s1_; + const char* s2_; +}; + + +class DiffChunkStruct : public ZoneObject { + public: + DiffChunkStruct(int pos1_param, int pos2_param, + int len1_param, int len2_param) + : pos1(pos1_param), pos2(pos2_param), + len1(len1_param), len2(len2_param), next(NULL) {} + int pos1; + int pos2; + int len1; + int len2; + DiffChunkStruct* next; +}; + + +class ListDiffOutputWriter : public Compare::Output { + public: + explicit ListDiffOutputWriter(DiffChunkStruct** next_chunk_pointer) + : next_chunk_pointer_(next_chunk_pointer) { + (*next_chunk_pointer_) = NULL; + } + void AddChunk(int pos1, int pos2, int len1, int len2) { + current_chunk_ = new DiffChunkStruct(pos1, pos2, len1, len2); + (*next_chunk_pointer_) = current_chunk_; + next_chunk_pointer_ = ¤t_chunk_->next; + } + private: + DiffChunkStruct** next_chunk_pointer_; + DiffChunkStruct* current_chunk_; +}; + + +void CompareStringsOneWay(const char* s1, const char* s2, + int expected_diff_parameter = -1) { + StringCompareInput input(s1, s2); + + ZoneScope zone_scope(DELETE_ON_EXIT); + + DiffChunkStruct* first_chunk; + ListDiffOutputWriter writer(&first_chunk); + + Compare::CalculateDifference(&input, &writer); + + int len1 = StrLength(s1); + int len2 = StrLength(s2); + + int pos1 = 0; + int pos2 = 0; + + int diff_parameter = 0; + + for (DiffChunkStruct* chunk = first_chunk; + chunk != NULL; + chunk = chunk->next) { + int diff_pos1 = chunk->pos1; + int similar_part_length = diff_pos1 - pos1; + int diff_pos2 = pos2 + similar_part_length; + + ASSERT_EQ(diff_pos2, chunk->pos2); + + for (int j = 0; j < similar_part_length; j++) { + ASSERT(pos1 + j < len1); + ASSERT(pos2 + j < len2); + ASSERT_EQ(s1[pos1 + j], s2[pos2 + j]); + } + diff_parameter += chunk->len1 + chunk->len2; + pos1 = diff_pos1 + chunk->len1; + pos2 = diff_pos2 + chunk->len2; + } + { + // After last chunk. + int similar_part_length = len1 - pos1; + ASSERT_EQ(similar_part_length, len2 - pos2); + USE(len2); + for (int j = 0; j < similar_part_length; j++) { + ASSERT(pos1 + j < len1); + ASSERT(pos2 + j < len2); + ASSERT_EQ(s1[pos1 + j], s2[pos2 + j]); + } + } + + if (expected_diff_parameter != -1) { + ASSERT_EQ(expected_diff_parameter, diff_parameter); + } +} + + +void CompareStrings(const char* s1, const char* s2, + int expected_diff_parameter = -1) { + CompareStringsOneWay(s1, s2, expected_diff_parameter); + CompareStringsOneWay(s2, s1, expected_diff_parameter); +} + +} // Anonymous namespace. + + +// --- T h e A c t u a l T e s t s + +TEST(LiveEditDiffer) { + CompareStrings("zz1zzz12zz123zzz", "zzzzzzzzzz", 6); + CompareStrings("zz1zzz12zz123zzz", "zz0zzz0zz0zzz", 9); + CompareStrings("123456789", "987654321", 16); + CompareStrings("zzz", "yyy", 6); + CompareStrings("zzz", "zzz12", 2); + CompareStrings("zzz", "21zzz", 2); + CompareStrings("cat", "cut", 2); + CompareStrings("ct", "cut", 1); + CompareStrings("cat", "ct", 1); + CompareStrings("cat", "cat", 0); + CompareStrings("", "", 0); + CompareStrings("cat", "", 3); + CompareStrings("a cat", "a capybara", 7); + CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", + "bbbbabababbbabababbbabababababbabbababa"); +} diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index 15a5b5af72..e5850c9c61 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -2,7 +2,7 @@ // // Tests of profiles generator and utilities. -#ifdef ENABLE_CPP_PROFILES_PROCESSOR +#ifdef ENABLE_LOGGING_AND_PROFILING #include "v8.h" #include "profile-generator-inl.h" @@ -17,12 +17,13 @@ using i::CpuProfilesCollection; using i::ProfileNode; using i::ProfileTree; using i::ProfileGenerator; +using i::SampleRateCalculator; using i::TickSample; using i::Vector; TEST(ProfileNodeFindOrAddChild) { - ProfileNode node(NULL); + ProfileNode node(NULL, NULL); CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0); ProfileNode* childNode1 = node.FindOrAddChild(&entry1); CHECK_NE(NULL, childNode1); @@ -424,7 +425,7 @@ TEST(RecordTickSample) { sample3.frames_count = 2; generator.RecordTickSample(sample3); - CpuProfile* profile = profiles.StopProfiling(""); + CpuProfile* profile = profiles.StopProfiling("", 1); CHECK_NE(NULL, profile); ProfileTreeTestHelper top_down_test_helper(profile->top_down()); CHECK_EQ(NULL, top_down_test_helper.Walk(entry2)); @@ -443,4 +444,54 @@ TEST(RecordTickSample) { CHECK_EQ(entry1, node4->entry()); } -#endif // ENABLE_CPP_PROFILES_PROCESSOR + +TEST(SampleRateCalculator) { + const double kSamplingIntervalMs = i::Logger::kSamplingIntervalMs; + + // Verify that ticking exactly in query intervals results in the + // initial sampling interval. + double time = 0.0; + SampleRateCalculator calc1; + CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); + calc1.UpdateMeasurements(time); + CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); + time += SampleRateCalculator::kWallTimeQueryIntervalMs; + calc1.UpdateMeasurements(time); + CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); + time += SampleRateCalculator::kWallTimeQueryIntervalMs; + calc1.UpdateMeasurements(time); + CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); + time += SampleRateCalculator::kWallTimeQueryIntervalMs; + calc1.UpdateMeasurements(time); + CHECK_EQ(kSamplingIntervalMs, calc1.ticks_per_ms()); + + SampleRateCalculator calc2; + time = 0.0; + CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); + calc2.UpdateMeasurements(time); + CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); + time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.5; + calc2.UpdateMeasurements(time); + // (1.0 + 2.0) / 2 + CHECK_EQ(kSamplingIntervalMs * 1.5, calc2.ticks_per_ms()); + time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.75; + calc2.UpdateMeasurements(time); + // (1.0 + 2.0 + 2.0) / 3 + CHECK_EQ(kSamplingIntervalMs * 1.66666, calc2.ticks_per_ms()); + + SampleRateCalculator calc3; + time = 0.0; + CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); + calc3.UpdateMeasurements(time); + CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); + time += SampleRateCalculator::kWallTimeQueryIntervalMs * 2; + calc3.UpdateMeasurements(time); + // (1.0 + 0.5) / 2 + CHECK_EQ(kSamplingIntervalMs * 0.75, calc3.ticks_per_ms()); + time += SampleRateCalculator::kWallTimeQueryIntervalMs * 1.5; + calc3.UpdateMeasurements(time); + // (1.0 + 0.5 + 0.5) / 3 + CHECK_EQ(kSamplingIntervalMs * 0.66666, calc3.ticks_per_ms()); +} + +#endif // ENABLE_LOGGING_AND_PROFILING diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index db312da703..00abab47f8 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -38,7 +38,9 @@ #include "jsregexp.h" #include "regexp-macro-assembler.h" #include "regexp-macro-assembler-irregexp.h" -#ifdef V8_NATIVE_REGEXP +#ifdef V8_INTERPRETED_REGEXP +#include "interpreter-irregexp.h" +#else // V8_INTERPRETED_REGEXP #ifdef V8_TARGET_ARCH_ARM #include "arm/macro-assembler-arm.h" #include "arm/regexp-macro-assembler-arm.h" @@ -51,9 +53,7 @@ #include "ia32/macro-assembler-ia32.h" #include "ia32/regexp-macro-assembler-ia32.h" #endif -#else -#include "interpreter-irregexp.h" -#endif +#endif // V8_INTERPRETED_REGEXP using namespace v8::internal; @@ -645,7 +645,7 @@ TEST(ParsePossessiveRepetition) { // Tests of interpreter. -#ifdef V8_NATIVE_REGEXP +#ifndef V8_INTERPRETED_REGEXP #if V8_TARGET_ARCH_IA32 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler; @@ -1267,7 +1267,7 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { Top::clear_pending_exception(); } -#else // ! V8_REGEX_NATIVE +#else // V8_INTERPRETED_REGEXP TEST(MacroAssembler) { V8::Initialize(NULL); @@ -1332,7 +1332,7 @@ TEST(MacroAssembler) { CHECK_EQ(42, captures[0]); } -#endif // ! V8_REGEXP_NATIVE +#endif // V8_INTERPRETED_REGEXP TEST(AddInverseToTable) { |