summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-07-03 08:36:33 +0200
committerRyan Dahl <ry@tinyclouds.org>2010-07-03 08:37:05 +0200
commit2072925f121fe8785dfd046eba24f8d18c59ae75 (patch)
tree70dcc90532a9f4da485453c6f40bc93235196071 /deps/v8/test/cctest
parent94cd83ef34176f4e451e91c92d3b2596032b8e96 (diff)
downloadnode-new-2072925f121fe8785dfd046eba24f8d18c59ae75.tar.gz
Upgrade V8 to 2.2.21
Diffstat (limited to 'deps/v8/test/cctest')
-rw-r--r--deps/v8/test/cctest/SConscript3
-rw-r--r--deps/v8/test/cctest/test-api.cc171
-rw-r--r--deps/v8/test/cctest/test-disasm-arm.cc35
-rw-r--r--deps/v8/test/cctest/test-type-info.cc56
4 files changed, 219 insertions, 46 deletions
diff --git a/deps/v8/test/cctest/SConscript b/deps/v8/test/cctest/SConscript
index 876c104bca..18388c0273 100644
--- a/deps/v8/test/cctest/SConscript
+++ b/deps/v8/test/cctest/SConscript
@@ -69,8 +69,9 @@ SOURCES = {
'test-sockets.cc',
'test-spaces.cc',
'test-strings.cc',
- 'test-threads.cc',
'test-thread-termination.cc',
+ 'test-threads.cc',
+ 'test-type-info.cc',
'test-unbound-queue.cc',
'test-utils.cc',
'test-version.cc'
diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc
index 0cf3f7ba41..be5ecba688 100644
--- a/deps/v8/test/cctest/test-api.cc
+++ b/deps/v8/test/cctest/test-api.cc
@@ -58,7 +58,7 @@ using ::v8::Function;
using ::v8::AccessorInfo;
using ::v8::Extension;
-namespace i = ::v8::internal;
+namespace i = ::i;
static void ExpectString(const char* code, const char* expected) {
@@ -381,11 +381,11 @@ THREADED_TEST(ScriptUsingStringResource) {
CHECK(source->IsExternal());
CHECK_EQ(resource,
static_cast<TestResource*>(source->GetExternalStringResource()));
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(0, TestResource::dispose_count);
}
- v8::internal::CompilationCache::Clear();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::CompilationCache::Clear();
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(1, TestResource::dispose_count);
}
@@ -402,11 +402,11 @@ THREADED_TEST(ScriptUsingAsciiStringResource) {
Local<Value> value = script->Run();
CHECK(value->IsNumber());
CHECK_EQ(7, value->Int32Value());
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(0, TestAsciiResource::dispose_count);
}
- v8::internal::CompilationCache::Clear();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::CompilationCache::Clear();
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(1, TestAsciiResource::dispose_count);
}
@@ -427,11 +427,11 @@ THREADED_TEST(ScriptMakingExternalString) {
Local<Value> value = script->Run();
CHECK(value->IsNumber());
CHECK_EQ(7, value->Int32Value());
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(0, TestResource::dispose_count);
}
- v8::internal::CompilationCache::Clear();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::CompilationCache::Clear();
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(1, TestResource::dispose_count);
}
@@ -453,11 +453,11 @@ THREADED_TEST(ScriptMakingExternalAsciiString) {
Local<Value> value = script->Run();
CHECK(value->IsNumber());
CHECK_EQ(7, value->Int32Value());
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(0, TestAsciiResource::dispose_count);
}
- v8::internal::CompilationCache::Clear();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::CompilationCache::Clear();
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(1, TestAsciiResource::dispose_count);
}
@@ -645,11 +645,11 @@ TEST(ExternalStringWithDisposeHandling) {
Local<Value> value = script->Run();
CHECK(value->IsNumber());
CHECK_EQ(7, value->Int32Value());
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(0, TestAsciiResource::dispose_count);
}
- v8::internal::CompilationCache::Clear();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::CompilationCache::Clear();
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
CHECK_EQ(0, TestAsciiResource::dispose_count);
@@ -666,11 +666,11 @@ TEST(ExternalStringWithDisposeHandling) {
Local<Value> value = script->Run();
CHECK(value->IsNumber());
CHECK_EQ(7, value->Int32Value());
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(0, TestAsciiResource::dispose_count);
}
- v8::internal::CompilationCache::Clear();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::CompilationCache::Clear();
+ i::Heap::CollectAllGarbage(false);
CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
CHECK_EQ(1, TestAsciiResource::dispose_count);
}
@@ -708,7 +708,7 @@ THREADED_TEST(StringConcat) {
CHECK(value->IsNumber());
CHECK_EQ(68, value->Int32Value());
}
- v8::internal::CompilationCache::Clear();
+ i::CompilationCache::Clear();
i::Heap::CollectAllGarbage(false);
i::Heap::CollectAllGarbage(false);
}
@@ -1881,7 +1881,7 @@ static const char* js_code_causing_out_of_memory =
// that come after them so they cannot run in parallel.
TEST(OutOfMemory) {
// It's not possible to read a snapshot into a heap with different dimensions.
- if (v8::internal::Snapshot::IsEnabled()) return;
+ if (i::Snapshot::IsEnabled()) return;
// Set heap limits.
static const int K = 1024;
v8::ResourceConstraints constraints;
@@ -1922,7 +1922,7 @@ v8::Handle<Value> ProvokeOutOfMemory(const v8::Arguments& args) {
TEST(OutOfMemoryNested) {
// It's not possible to read a snapshot into a heap with different dimensions.
- if (v8::internal::Snapshot::IsEnabled()) return;
+ if (i::Snapshot::IsEnabled()) return;
// Set heap limits.
static const int K = 1024;
v8::ResourceConstraints constraints;
@@ -1951,7 +1951,7 @@ TEST(OutOfMemoryNested) {
TEST(HugeConsStringOutOfMemory) {
// It's not possible to read a snapshot into a heap with different dimensions.
- if (v8::internal::Snapshot::IsEnabled()) return;
+ if (i::Snapshot::IsEnabled()) return;
v8::HandleScope scope;
LocalContext context;
// Set heap limits.
@@ -6811,7 +6811,7 @@ static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name,
int* call_count = reinterpret_cast<int*>(v8::External::Unwrap(info.Data()));
++(*call_count);
if ((*call_count) % 20 == 0) {
- v8::internal::Heap::CollectAllGarbage(true);
+ i::Heap::CollectAllGarbage(true);
}
return v8::Handle<Value>();
}
@@ -7620,8 +7620,8 @@ THREADED_TEST(ObjectProtoToString) {
bool ApiTestFuzzer::fuzzing_ = false;
-v8::internal::Semaphore* ApiTestFuzzer::all_tests_done_=
- v8::internal::OS::CreateSemaphore(0);
+i::Semaphore* ApiTestFuzzer::all_tests_done_=
+ i::OS::CreateSemaphore(0);
int ApiTestFuzzer::active_tests_;
int ApiTestFuzzer::tests_being_run_;
int ApiTestFuzzer::current_;
@@ -7899,7 +7899,7 @@ THREADED_TEST(LockUnlockLock) {
static int GetGlobalObjectsCount() {
int count = 0;
- v8::internal::HeapIterator it;
+ i::HeapIterator it;
for (i::HeapObject* object = it.next(); object != NULL; object = it.next())
if (object->IsJSGlobalObject()) count++;
return count;
@@ -7912,11 +7912,11 @@ static int GetSurvivingGlobalObjectsCount() {
// the first garbage collection but some of the maps have already
// been marked at that point. Therefore some of the maps are not
// collected until the second garbage collection.
- v8::internal::Heap::CollectAllGarbage(false);
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
int count = GetGlobalObjectsCount();
#ifdef DEBUG
- if (count > 0) v8::internal::Heap::TracePathToGlobal();
+ if (count > 0) i::Heap::TracePathToGlobal();
#endif
return count;
}
@@ -10021,7 +10021,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
THREADED_TEST(ExternalByteArray) {
- ExternalArrayTestHelper<v8::internal::ExternalByteArray, int8_t>(
+ ExternalArrayTestHelper<i::ExternalByteArray, int8_t>(
v8::kExternalByteArray,
-128,
127);
@@ -10029,7 +10029,7 @@ THREADED_TEST(ExternalByteArray) {
THREADED_TEST(ExternalUnsignedByteArray) {
- ExternalArrayTestHelper<v8::internal::ExternalUnsignedByteArray, uint8_t>(
+ ExternalArrayTestHelper<i::ExternalUnsignedByteArray, uint8_t>(
v8::kExternalUnsignedByteArray,
0,
255);
@@ -10037,7 +10037,7 @@ THREADED_TEST(ExternalUnsignedByteArray) {
THREADED_TEST(ExternalShortArray) {
- ExternalArrayTestHelper<v8::internal::ExternalShortArray, int16_t>(
+ ExternalArrayTestHelper<i::ExternalShortArray, int16_t>(
v8::kExternalShortArray,
-32768,
32767);
@@ -10045,7 +10045,7 @@ THREADED_TEST(ExternalShortArray) {
THREADED_TEST(ExternalUnsignedShortArray) {
- ExternalArrayTestHelper<v8::internal::ExternalUnsignedShortArray, uint16_t>(
+ ExternalArrayTestHelper<i::ExternalUnsignedShortArray, uint16_t>(
v8::kExternalUnsignedShortArray,
0,
65535);
@@ -10053,7 +10053,7 @@ THREADED_TEST(ExternalUnsignedShortArray) {
THREADED_TEST(ExternalIntArray) {
- ExternalArrayTestHelper<v8::internal::ExternalIntArray, int32_t>(
+ ExternalArrayTestHelper<i::ExternalIntArray, int32_t>(
v8::kExternalIntArray,
INT_MIN, // -2147483648
INT_MAX); // 2147483647
@@ -10061,7 +10061,7 @@ THREADED_TEST(ExternalIntArray) {
THREADED_TEST(ExternalUnsignedIntArray) {
- ExternalArrayTestHelper<v8::internal::ExternalUnsignedIntArray, uint32_t>(
+ ExternalArrayTestHelper<i::ExternalUnsignedIntArray, uint32_t>(
v8::kExternalUnsignedIntArray,
0,
UINT_MAX); // 4294967295
@@ -10069,7 +10069,7 @@ THREADED_TEST(ExternalUnsignedIntArray) {
THREADED_TEST(ExternalFloatArray) {
- ExternalArrayTestHelper<v8::internal::ExternalFloatArray, float>(
+ ExternalArrayTestHelper<i::ExternalFloatArray, float>(
v8::kExternalFloatArray,
-500,
500);
@@ -10547,7 +10547,7 @@ TEST(Regress528) {
other_context->Enter();
CompileRun(source_simple);
other_context->Exit();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
if (GetGlobalObjectsCount() == 1) break;
}
CHECK_GE(2, gc_count);
@@ -10569,7 +10569,7 @@ TEST(Regress528) {
other_context->Enter();
CompileRun(source_eval);
other_context->Exit();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
if (GetGlobalObjectsCount() == 1) break;
}
CHECK_GE(2, gc_count);
@@ -10596,7 +10596,7 @@ TEST(Regress528) {
other_context->Enter();
CompileRun(source_exception);
other_context->Exit();
- v8::internal::Heap::CollectAllGarbage(false);
+ i::Heap::CollectAllGarbage(false);
if (GetGlobalObjectsCount() == 1) break;
}
CHECK_GE(2, gc_count);
@@ -10859,7 +10859,7 @@ THREADED_TEST(AddToJSFunctionResultCache) {
" return 'Different results for ' + key1 + ': ' + r1 + ' vs. ' + r1_;"
" return 'PASSED';"
"})()";
- v8::internal::Heap::ClearJSFunctionResultCaches();
+ i::Heap::ClearJSFunctionResultCaches();
ExpectString(code, "PASSED");
}
@@ -10883,7 +10883,7 @@ THREADED_TEST(FillJSFunctionResultCache) {
" return 'FAILED: k0CacheSize is too small';"
" return 'PASSED';"
"})()";
- v8::internal::Heap::ClearJSFunctionResultCaches();
+ i::Heap::ClearJSFunctionResultCaches();
ExpectString(code, "PASSED");
}
@@ -10908,7 +10908,7 @@ THREADED_TEST(RoundRobinGetFromCache) {
" };"
" return 'PASSED';"
"})()";
- v8::internal::Heap::ClearJSFunctionResultCaches();
+ i::Heap::ClearJSFunctionResultCaches();
ExpectString(code, "PASSED");
}
@@ -10933,7 +10933,7 @@ THREADED_TEST(ReverseGetFromCache) {
" };"
" return 'PASSED';"
"})()";
- v8::internal::Heap::ClearJSFunctionResultCaches();
+ i::Heap::ClearJSFunctionResultCaches();
ExpectString(code, "PASSED");
}
@@ -10951,6 +10951,87 @@ THREADED_TEST(TestEviction) {
" };"
" return 'PASSED';"
"})()";
- v8::internal::Heap::ClearJSFunctionResultCaches();
+ i::Heap::ClearJSFunctionResultCaches();
ExpectString(code, "PASSED");
}
+
+
+THREADED_TEST(TwoByteStringInAsciiCons) {
+ // See Chromium issue 47824.
+ v8::HandleScope scope;
+
+ LocalContext context;
+ const char* init_code =
+ "var str1 = 'abelspendabel';"
+ "var str2 = str1 + str1 + str1;"
+ "str2;";
+ Local<Value> result = CompileRun(init_code);
+
+ CHECK(result->IsString());
+ i::Handle<i::String> string = v8::Utils::OpenHandle(String::Cast(*result));
+ int length = string->length();
+ CHECK(string->IsAsciiRepresentation());
+
+ FlattenString(string);
+ i::Handle<i::String> flat_string = FlattenGetString(string);
+
+ CHECK(string->IsAsciiRepresentation());
+ CHECK(flat_string->IsAsciiRepresentation());
+
+ // Create external resource.
+ uint16_t* uc16_buffer = new uint16_t[length + 1];
+
+ i::String::WriteToFlat(*flat_string, uc16_buffer, 0, length);
+ uc16_buffer[length] = 0;
+
+ TestResource resource(uc16_buffer);
+
+ flat_string->MakeExternal(&resource);
+
+ CHECK(flat_string->IsTwoByteRepresentation());
+
+ // At this point, we should have a Cons string which is flat and ASCII,
+ // with a first half that is a two-byte string (although it only contains
+ // ASCII characters). This is a valid sequence of steps, and it can happen
+ // in real pages.
+
+ CHECK(string->IsAsciiRepresentation());
+ i::ConsString* cons = i::ConsString::cast(*string);
+ CHECK_EQ(0, cons->second()->length());
+ CHECK(cons->first()->IsTwoByteRepresentation());
+
+ // Check that some string operations work.
+
+ // Atom RegExp.
+ Local<Value> reresult = CompileRun("str2.match(/abel/g).length;");
+ CHECK_EQ(6, reresult->Int32Value());
+
+ // Nonatom RegExp.
+ reresult = CompileRun("str2.match(/abe./g).length;");
+ CHECK_EQ(6, reresult->Int32Value());
+
+ reresult = CompileRun("str2.search(/bel/g);");
+ CHECK_EQ(1, reresult->Int32Value());
+
+ reresult = CompileRun("str2.search(/be./g);");
+ CHECK_EQ(1, reresult->Int32Value());
+
+ ExpectTrue("/bel/g.test(str2);");
+
+ ExpectTrue("/be./g.test(str2);");
+
+ reresult = CompileRun("/bel/g.exec(str2);");
+ CHECK(!reresult->IsNull());
+
+ reresult = CompileRun("/be./g.exec(str2);");
+ CHECK(!reresult->IsNull());
+
+ ExpectString("str2.substring(2, 10);", "elspenda");
+
+ ExpectString("str2.substring(2, 20);", "elspendabelabelspe");
+
+ ExpectString("str2.charAt(2);", "e");
+
+ reresult = CompileRun("str2.charCodeAt(2);");
+ CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value());
+}
diff --git a/deps/v8/test/cctest/test-disasm-arm.cc b/deps/v8/test/cctest/test-disasm-arm.cc
index 5903fe650b..18e641d6a3 100644
--- a/deps/v8/test/cctest/test-disasm-arm.cc
+++ b/deps/v8/test/cctest/test-disasm-arm.cc
@@ -401,3 +401,38 @@ TEST(Type3) {
VERIFY_RUN();
}
+
+
+TEST(Vfp) {
+ SETUP();
+
+ if (CpuFeatures::IsSupported(VFP3)) {
+ CpuFeatures::Scope scope(VFP3);
+ COMPARE(vadd(d0, d1, d2),
+ "ee310b02 vadd.f64 d0, d1, d2");
+ COMPARE(vadd(d3, d4, d5, mi),
+ "4e343b05 vadd.f64mi d3, d4, d5");
+
+ COMPARE(vsub(d0, d1, d2),
+ "ee310b42 vsub.f64 d0, d1, d2");
+ COMPARE(vsub(d3, d4, d5, ne),
+ "1e343b45 vsub.f64ne d3, d4, d5");
+
+ COMPARE(vmul(d2, d1, d0),
+ "ee212b00 vmul.f64 d2, d1, d0");
+ COMPARE(vmul(d6, d4, d5, cc),
+ "3e246b05 vmul.f64cc d6, d4, d5");
+
+ COMPARE(vdiv(d2, d2, d2),
+ "ee822b02 vdiv.f64 d2, d2, d2");
+ COMPARE(vdiv(d6, d7, d7, hi),
+ "8e876b07 vdiv.f64hi d6, d7, d7");
+
+ COMPARE(vsqrt(d0, d0),
+ "eeb10bc0 vsqrt.f64 d0, d0");
+ COMPARE(vsqrt(d2, d3, ne),
+ "1eb12bc3 vsqrt.f64ne d2, d3");
+ }
+
+ VERIFY_RUN();
+}
diff --git a/deps/v8/test/cctest/test-type-info.cc b/deps/v8/test/cctest/test-type-info.cc
new file mode 100644
index 0000000000..59dd83d1f7
--- /dev/null
+++ b/deps/v8/test/cctest/test-type-info.cc
@@ -0,0 +1,56 @@
+// 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.
+
+
+#include "cctest.h"
+#include "type-info.h"
+
+namespace v8 {
+namespace internal {
+
+TEST(ThreeBitRepresentation) {
+ // Numeric types and unknown should fit into the short
+ // representation.
+ CHECK(TypeInfo::ExpandedRepresentation(
+ TypeInfo::Unknown().ThreeBitRepresentation()).IsUnknown());
+ CHECK(TypeInfo::ExpandedRepresentation(
+ TypeInfo::Number().ThreeBitRepresentation()).IsNumber());
+ CHECK(TypeInfo::ExpandedRepresentation(
+ TypeInfo::Integer32().ThreeBitRepresentation()).IsInteger32());
+ CHECK(TypeInfo::ExpandedRepresentation(
+ TypeInfo::Smi().ThreeBitRepresentation()).IsSmi());
+ CHECK(TypeInfo::ExpandedRepresentation(
+ TypeInfo::Double().ThreeBitRepresentation()).IsDouble());
+
+ // Other types should map to unknown.
+ CHECK(TypeInfo::ExpandedRepresentation(
+ TypeInfo::Primitive().ThreeBitRepresentation()).IsUnknown());
+ CHECK(TypeInfo::ExpandedRepresentation(
+ TypeInfo::String().ThreeBitRepresentation()).IsUnknown());
+}
+
+} } // namespace v8::internal