diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-10-10 17:58:30 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-10-10 17:58:30 -0700 |
commit | 3b1d656da56bdd403d1625a0c6a44d75cde36cc1 (patch) | |
tree | 80de8a68eacd596f0d120efc65dbbae3f324aea0 /deps/v8/test/cctest | |
parent | 9bbca99107652906a060679ee95bf1ad7381cbb5 (diff) | |
download | node-new-3b1d656da56bdd403d1625a0c6a44d75cde36cc1.tar.gz |
Revert "Upgrade V8 to 3.6.6"
Not stable enough.
- Windows snapshot linking broken
- Linux crash on ./node_g test/simple/test-stream-pipe-multi.js
This reverts commit 56e6952e639ba1557a5b22333788583e9e39fa29.
Diffstat (limited to 'deps/v8/test/cctest')
23 files changed, 464 insertions, 857 deletions
diff --git a/deps/v8/test/cctest/cctest.gyp b/deps/v8/test/cctest/cctest.gyp index efcbad7169..5d0cab3e98 100644 --- a/deps/v8/test/cctest/cctest.gyp +++ b/deps/v8/test/cctest/cctest.gyp @@ -91,8 +91,7 @@ 'test-threads.cc', 'test-unbound-queue.cc', 'test-utils.cc', - 'test-version.cc', - 'test-weakmaps.cc' + 'test-version.cc' ], 'conditions': [ ['v8_target_arch=="ia32"', { @@ -135,12 +134,6 @@ 'sources': [ 'test-platform-win32.cc', ], - 'msvs_settings': { - 'VCCLCompilerTool': { - # MSVS wants this for gay-{precision,shortest}.cc. - 'AdditionalOptions': ['/bigobj'], - }, - }, }], ['component=="shared_library"', { # cctest can't be built against a shared library, so we need to diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index 759f69f339..5122da5ae3 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -33,28 +33,14 @@ test-api/Bug*: FAIL # BUG(382): Weird test. Can't guarantee that it never times out. test-api/ApplyInterruption: PASS || TIMEOUT -# BUG(484): This test which we thought was originally corrected in r5236 -# is re-appearing. Disabled until bug in test is fixed. This only fails -# when snapshot is on, so I am marking it PASS || FAIL -test-heap-profiler/HeapSnapshotsDiff: 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 test-serialize/DependentTestThatAlwaysFails: FAIL -# TODO(gc): Temporarily disabled in the GC branch. -test-log/EquivalenceOfLoggingAndTraversal: PASS || FAIL - -# BUG(1261): Flakey test. -test-profile-generator/RecordStackTraceAtStartProfiling: PASS || FAIL - # We do not yet shrink weak maps after they have been emptied by the GC test-weakmaps/Shrinking: FAIL -# NewGC: BUG(1717) -test-api/OutOfMemoryNested: PASS || TIMEOUT - ############################################################################## [ $arch == arm ] diff --git a/deps/v8/test/cctest/test-accessors.cc b/deps/v8/test/cctest/test-accessors.cc index b1900f9ed3..d95536d2d5 100644 --- a/deps/v8/test/cctest/test-accessors.cc +++ b/deps/v8/test/cctest/test-accessors.cc @@ -241,7 +241,7 @@ static v8::Handle<Value> CheckAccessorArgsCorrect(Local<String> name, ApiTestFuzzer::Fuzz(); CHECK(info.This() == info.Holder()); CHECK(info.Data()->Equals(v8::String::New("data"))); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); CHECK(info.This() == info.Holder()); CHECK(info.Data()->Equals(v8::String::New("data"))); return v8::Integer::New(17); diff --git a/deps/v8/test/cctest/test-alloc.cc b/deps/v8/test/cctest/test-alloc.cc index 899c9021ff..97671923d9 100644 --- a/deps/v8/test/cctest/test-alloc.cc +++ b/deps/v8/test/cctest/test-alloc.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// 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: @@ -72,29 +72,11 @@ static MaybeObject* AllocateAfterFailures() { } CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure()); - // Old pointer space. - OldSpace* old_pointer_space = heap->old_pointer_space(); - static const int kOldPointerSpaceFillerLength = 10000; - static const int kOldPointerSpaceFillerSize = FixedArray::SizeFor( - kOldPointerSpaceFillerLength); - while (old_pointer_space->Available() > kOldPointerSpaceFillerSize) { - CHECK(!heap->AllocateFixedArray(kOldPointerSpaceFillerLength, TENURED)-> - IsFailure()); - } - CHECK(!heap->AllocateFixedArray(kOldPointerSpaceFillerLength, TENURED)-> - IsFailure()); - // Large object space. - static const int kLargeObjectSpaceFillerLength = 300000; - static const int kLargeObjectSpaceFillerSize = FixedArray::SizeFor( - kLargeObjectSpaceFillerLength); - ASSERT(kLargeObjectSpaceFillerSize > heap->MaxObjectSizeInPagedSpace()); - while (heap->OldGenerationSpaceAvailable() > kLargeObjectSpaceFillerSize) { - CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)-> - IsFailure()); + while (!heap->OldGenerationAllocationLimitReached()) { + CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); } - CHECK(!heap->AllocateFixedArray(kLargeObjectSpaceFillerLength, TENURED)-> - IsFailure()); + CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); // Map space. MapSpace* map_space = heap->map_space(); @@ -193,16 +175,16 @@ unsigned int Pseudorandom() { // Plain old data class. Represents a block of allocated memory. class Block { public: - Block(Address base_arg, int size_arg) + Block(void* base_arg, int size_arg) : base(base_arg), size(size_arg) {} - Address base; + void *base; int size; }; TEST(CodeRange) { - const int code_range_size = 32*MB; + const int code_range_size = 16*MB; OS::Setup(); Isolate::Current()->InitializeLoggingAndCounters(); CodeRange* code_range = new CodeRange(Isolate::Current()); @@ -214,13 +196,11 @@ TEST(CodeRange) { while (total_allocated < 5 * code_range_size) { if (current_allocated < code_range_size / 10) { // Allocate a block. - // Geometrically distributed sizes, greater than Page::kMaxHeapObjectSize. - // TODO(gc): instead of using 3 use some contant based on code_range_size - // kMaxHeapObjectSize. - size_t requested = (Page::kMaxHeapObjectSize << (Pseudorandom() % 3)) + + // Geometrically distributed sizes, greater than Page::kPageSize. + size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + Pseudorandom() % 5000 + 1; size_t allocated = 0; - Address base = code_range->AllocateRawMemory(requested, &allocated); + void* base = code_range->AllocateRawMemory(requested, &allocated); CHECK(base != NULL); blocks.Add(Block(base, static_cast<int>(allocated))); current_allocated += static_cast<int>(allocated); diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 167c4cd155..f9f08a6641 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -80,11 +80,6 @@ static void ExpectString(const char* code, const char* expected) { CHECK_EQ(expected, *ascii); } -static void ExpectInt32(const char* code, int expected) { - Local<Value> result = CompileRun(code); - CHECK(result->IsInt32()); - CHECK_EQ(expected, result->Int32Value()); -} static void ExpectBoolean(const char* code, bool expected) { Local<Value> result = CompileRun(code); @@ -398,11 +393,11 @@ THREADED_TEST(ScriptUsingStringResource) { CHECK(source->IsExternal()); CHECK_EQ(resource, static_cast<TestResource*>(source->GetExternalStringResource())); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, dispose_count); } v8::internal::Isolate::Current()->compilation_cache()->Clear(); - HEAP->CollectAllAvailableGarbage(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, dispose_count); } @@ -420,11 +415,11 @@ THREADED_TEST(ScriptUsingAsciiStringResource) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); - HEAP->CollectAllAvailableGarbage(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, dispose_count); } @@ -446,12 +441,11 @@ THREADED_TEST(ScriptMakingExternalString) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); - // TODO(1608): This should use kAbortIncrementalMarking. - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, dispose_count); } @@ -473,12 +467,11 @@ THREADED_TEST(ScriptMakingExternalAsciiString) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); - // TODO(1608): This should use kAbortIncrementalMarking. - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, dispose_count); } @@ -579,8 +572,8 @@ THREADED_TEST(UsingExternalString) { i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring); CHECK(isymbol->IsSymbol()); } - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -597,8 +590,8 @@ THREADED_TEST(UsingExternalAsciiString) { i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring); CHECK(isymbol->IsSymbol()); } - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -679,11 +672,11 @@ TEST(ExternalStringWithDisposeHandling) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - HEAP->CollectAllAvailableGarbage(); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); - HEAP->CollectAllAvailableGarbage(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); @@ -700,11 +693,11 @@ TEST(ExternalStringWithDisposeHandling) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - HEAP->CollectAllAvailableGarbage(); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); - HEAP->CollectAllAvailableGarbage(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); } @@ -751,8 +744,8 @@ THREADED_TEST(StringConcat) { CHECK_EQ(68, value->Int32Value()); } i::Isolate::Current()->compilation_cache()->Clear(); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -1301,197 +1294,6 @@ static v8::Handle<Value> EchoNamedProperty(Local<String> name, return name; } -// Helper functions for Interceptor/Accessor interaction tests - -Handle<Value> SimpleAccessorGetter(Local<String> name, - const AccessorInfo& info) { - Handle<Object> self = info.This(); - return self->Get(String::Concat(v8_str("accessor_"), name)); -} - -void SimpleAccessorSetter(Local<String> name, Local<Value> value, - const AccessorInfo& info) { - Handle<Object> self = info.This(); - self->Set(String::Concat(v8_str("accessor_"), name), value); -} - -Handle<Value> EmptyInterceptorGetter(Local<String> name, - const AccessorInfo& info) { - return Handle<Value>(); -} - -Handle<Value> EmptyInterceptorSetter(Local<String> name, - Local<Value> value, - const AccessorInfo& info) { - return Handle<Value>(); -} - -Handle<Value> InterceptorGetter(Local<String> name, - const AccessorInfo& info) { - // Intercept names that start with 'interceptor_'. - String::AsciiValue ascii(name); - char* name_str = *ascii; - char prefix[] = "interceptor_"; - int i; - for (i = 0; name_str[i] && prefix[i]; ++i) { - if (name_str[i] != prefix[i]) return Handle<Value>(); - } - Handle<Object> self = info.This(); - return self->GetHiddenValue(v8_str(name_str + i)); -} - -Handle<Value> InterceptorSetter(Local<String> name, - Local<Value> value, - const AccessorInfo& info) { - // Intercept accesses that set certain integer values. - if (value->IsInt32() && value->Int32Value() < 10000) { - Handle<Object> self = info.This(); - self->SetHiddenValue(name, value); - return value; - } - return Handle<Value>(); -} - -void AddAccessor(Handle<FunctionTemplate> templ, - Handle<String> name, - v8::AccessorGetter getter, - v8::AccessorSetter setter) { - templ->PrototypeTemplate()->SetAccessor(name, getter, setter); -} - -void AddInterceptor(Handle<FunctionTemplate> templ, - v8::NamedPropertyGetter getter, - v8::NamedPropertySetter setter) { - templ->InstanceTemplate()->SetNamedPropertyHandler(getter, setter); -} - -THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { - v8::HandleScope scope; - Handle<FunctionTemplate> parent = FunctionTemplate::New(); - Handle<FunctionTemplate> child = FunctionTemplate::New(); - child->Inherit(parent); - AddAccessor(parent, v8_str("age"), - SimpleAccessorGetter, SimpleAccessorSetter); - AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); - LocalContext env; - env->Global()->Set(v8_str("Child"), child->GetFunction()); - CompileRun("var child = new Child;" - "child.age = 10;"); - ExpectBoolean("child.hasOwnProperty('age')", false); - ExpectInt32("child.age", 10); - ExpectInt32("child.accessor_age", 10); -} - -THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) { - v8::HandleScope scope; - Handle<FunctionTemplate> parent = FunctionTemplate::New(); - Handle<FunctionTemplate> child = FunctionTemplate::New(); - child->Inherit(parent); - AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); - LocalContext env; - env->Global()->Set(v8_str("Child"), child->GetFunction()); - CompileRun("var child = new Child;" - "var parent = child.__proto__;" - "Object.defineProperty(parent, 'age', " - " {get: function(){ return this.accessor_age; }, " - " set: function(v){ this.accessor_age = v; }, " - " enumerable: true, configurable: true});" - "child.age = 10;"); - ExpectBoolean("child.hasOwnProperty('age')", false); - ExpectInt32("child.age", 10); - ExpectInt32("child.accessor_age", 10); -} - -THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) { - v8::HandleScope scope; - Handle<FunctionTemplate> parent = FunctionTemplate::New(); - Handle<FunctionTemplate> child = FunctionTemplate::New(); - child->Inherit(parent); - AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); - LocalContext env; - env->Global()->Set(v8_str("Child"), child->GetFunction()); - CompileRun("var child = new Child;" - "var parent = child.__proto__;" - "parent.name = 'Alice';"); - ExpectBoolean("child.hasOwnProperty('name')", false); - ExpectString("child.name", "Alice"); - CompileRun("child.name = 'Bob';"); - ExpectString("child.name", "Bob"); - ExpectBoolean("child.hasOwnProperty('name')", true); - ExpectString("parent.name", "Alice"); -} - -THREADED_TEST(SwitchFromInterceptorToAccessor) { - v8::HandleScope scope; - Handle<FunctionTemplate> parent = FunctionTemplate::New(); - Handle<FunctionTemplate> child = FunctionTemplate::New(); - child->Inherit(parent); - AddAccessor(parent, v8_str("age"), - SimpleAccessorGetter, SimpleAccessorSetter); - AddInterceptor(child, InterceptorGetter, InterceptorSetter); - LocalContext env; - env->Global()->Set(v8_str("Child"), child->GetFunction()); - CompileRun("var child = new Child;" - "function setAge(i){ child.age = i; };" - "for(var i = 0; i <= 10000; i++) setAge(i);"); - // All i < 10000 go to the interceptor. - ExpectInt32("child.interceptor_age", 9999); - // The last i goes to the accessor. - ExpectInt32("child.accessor_age", 10000); -} - -THREADED_TEST(SwitchFromAccessorToInterceptor) { - v8::HandleScope scope; - Handle<FunctionTemplate> parent = FunctionTemplate::New(); - Handle<FunctionTemplate> child = FunctionTemplate::New(); - child->Inherit(parent); - AddAccessor(parent, v8_str("age"), - SimpleAccessorGetter, SimpleAccessorSetter); - AddInterceptor(child, InterceptorGetter, InterceptorSetter); - LocalContext env; - env->Global()->Set(v8_str("Child"), child->GetFunction()); - CompileRun("var child = new Child;" - "function setAge(i){ child.age = i; };" - "for(var i = 20000; i >= 9999; i--) setAge(i);"); - // All i >= 10000 go to the accessor. - ExpectInt32("child.accessor_age", 10000); - // The last i goes to the interceptor. - ExpectInt32("child.interceptor_age", 9999); -} - -THREADED_TEST(SwitchFromInterceptorToProperty) { - v8::HandleScope scope; - Handle<FunctionTemplate> parent = FunctionTemplate::New(); - Handle<FunctionTemplate> child = FunctionTemplate::New(); - child->Inherit(parent); - AddInterceptor(child, InterceptorGetter, InterceptorSetter); - LocalContext env; - env->Global()->Set(v8_str("Child"), child->GetFunction()); - CompileRun("var child = new Child;" - "function setAge(i){ child.age = i; };" - "for(var i = 0; i <= 10000; i++) setAge(i);"); - // All i < 10000 go to the interceptor. - ExpectInt32("child.interceptor_age", 9999); - // The last i goes to child's own property. - ExpectInt32("child.age", 10000); -} - -THREADED_TEST(SwitchFromPropertyToInterceptor) { - v8::HandleScope scope; - Handle<FunctionTemplate> parent = FunctionTemplate::New(); - Handle<FunctionTemplate> child = FunctionTemplate::New(); - child->Inherit(parent); - AddInterceptor(child, InterceptorGetter, InterceptorSetter); - LocalContext env; - env->Global()->Set(v8_str("Child"), child->GetFunction()); - CompileRun("var child = new Child;" - "function setAge(i){ child.age = i; };" - "for(var i = 20000; i >= 9999; i--) setAge(i);"); - // All i >= 10000 go to child's own property. - ExpectInt32("child.age", 10000); - // The last i goes to the interceptor. - ExpectInt32("child.interceptor_age", 9999); -} THREADED_TEST(NamedPropertyHandlerGetter) { echo_named_call_count = 0; @@ -1864,12 +1666,12 @@ THREADED_TEST(InternalFieldsNativePointers) { // Check reading and writing aligned pointers. obj->SetPointerInInternalField(0, aligned); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); // Check reading and writing unaligned pointers. obj->SetPointerInInternalField(0, unaligned); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); delete[] data; @@ -1895,19 +1697,19 @@ THREADED_TEST(InternalFieldsNativePointersAndExternal) { CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); obj->SetPointerInInternalField(0, aligned); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0))); obj->SetPointerInInternalField(0, unaligned); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0))); obj->SetInternalField(0, v8::External::Wrap(aligned)); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); obj->SetInternalField(0, v8::External::Wrap(unaligned)); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); delete[] data; @@ -1920,7 +1722,7 @@ THREADED_TEST(IdentityHash) { // Ensure that the test starts with an fresh heap to test whether the hash // code is based on the address. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); Local<v8::Object> obj = v8::Object::New(); int hash = obj->GetIdentityHash(); int hash1 = obj->GetIdentityHash(); @@ -1930,7 +1732,7 @@ THREADED_TEST(IdentityHash) { // objects should not be assigned the same hash code. If the test below fails // the random number generator should be evaluated. CHECK_NE(hash, hash2); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); int hash3 = v8::Object::New()->GetIdentityHash(); // Make sure that the identity hash is not based on the initial address of // the object alone. If the test below fails the random number generator @@ -1967,7 +1769,7 @@ THREADED_TEST(HiddenProperties) { v8::Local<v8::String> empty = v8_str(""); v8::Local<v8::String> prop_name = v8_str("prop_name"); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); // Make sure delete of a non-existent hidden value works CHECK(obj->DeleteHiddenValue(key)); @@ -1977,7 +1779,7 @@ THREADED_TEST(HiddenProperties) { CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); // Make sure we do not find the hidden property. CHECK(!obj->Has(empty)); @@ -1988,7 +1790,7 @@ THREADED_TEST(HiddenProperties) { CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); CHECK_EQ(2003, obj->Get(empty)->Int32Value()); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); // Add another property and delete it afterwards to force the object in // slow case. @@ -1999,41 +1801,13 @@ THREADED_TEST(HiddenProperties) { CHECK(obj->Delete(prop_name)); CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK(obj->DeleteHiddenValue(key)); CHECK(obj->GetHiddenValue(key).IsEmpty()); } -THREADED_TEST(Regress97784) { - // Regression test for crbug.com/97784 - // Messing with the Object.prototype should not have effect on - // hidden properties. - v8::HandleScope scope; - LocalContext env; - - v8::Local<v8::Object> obj = v8::Object::New(); - v8::Local<v8::String> key = v8_str("hidden"); - - CompileRun( - "set_called = false;" - "Object.defineProperty(" - " Object.prototype," - " 'hidden'," - " {get: function() { return 45; }," - " set: function() { set_called = true; }})"); - - CHECK(obj->GetHiddenValue(key).IsEmpty()); - // Make sure that the getter and setter from Object.prototype is not invoked. - // If it did we would have full access to the hidden properties in - // the accessor. - CHECK(obj->SetHiddenValue(key, v8::Integer::New(42))); - ExpectFalse("set_called"); - CHECK_EQ(42, obj->GetHiddenValue(key)->Int32Value()); -} - - static bool interceptor_for_hidden_properties_called; static v8::Handle<Value> InterceptorForHiddenProperties( Local<String> name, const AccessorInfo& info) { @@ -2106,30 +1880,19 @@ THREADED_TEST(GlobalHandle) { } -class WeakCallCounter { - public: - explicit WeakCallCounter(int id) : id_(id), number_of_weak_calls_(0) { } - int id() { return id_; } - void increment() { number_of_weak_calls_++; } - int NumberOfWeakCalls() { return number_of_weak_calls_; } - private: - int id_; - int number_of_weak_calls_; -}; - - +static int NumberOfWeakCalls = 0; static void WeakPointerCallback(Persistent<Value> handle, void* id) { - WeakCallCounter* counter = reinterpret_cast<WeakCallCounter*>(id); - CHECK_EQ(1234, counter->id()); - counter->increment(); + CHECK_EQ(reinterpret_cast<void*>(1234), id); + NumberOfWeakCalls++; handle.Dispose(); } - THREADED_TEST(ApiObjectGroups) { HandleScope scope; LocalContext env; + NumberOfWeakCalls = 0; + Persistent<Object> g1s1; Persistent<Object> g1s2; Persistent<Object> g1c1; @@ -2137,23 +1900,21 @@ THREADED_TEST(ApiObjectGroups) { Persistent<Object> g2s2; Persistent<Object> g2c1; - WeakCallCounter counter(1234); - { HandleScope scope; g1s1 = Persistent<Object>::New(Object::New()); g1s2 = Persistent<Object>::New(Object::New()); g1c1 = Persistent<Object>::New(Object::New()); - g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + g1s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g1s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g1c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); g2s1 = Persistent<Object>::New(Object::New()); g2s2 = Persistent<Object>::New(Object::New()); g2c1 = Persistent<Object>::New(Object::New()); - g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + g2s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g2s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g2c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); } Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. @@ -2172,15 +1933,14 @@ THREADED_TEST(ApiObjectGroups) { V8::AddObjectGroup(g2_objects, 2); V8::AddImplicitReferences(g2s2, g2_children, 1); } - // Do a single full GC. Use kMakeHeapIterableMask to ensure that - // incremental garbage collection is stopped. - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + // Do a full GC + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); // All object should be alive. - CHECK_EQ(0, counter.NumberOfWeakCalls()); + CHECK_EQ(0, NumberOfWeakCalls); // Weaken the root. - root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + root.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); // But make children strong roots---all the objects (except for children) // should be collectable now. g1c1.ClearWeak(); @@ -2198,17 +1958,17 @@ THREADED_TEST(ApiObjectGroups) { V8::AddImplicitReferences(g2s2, g2_children, 1); } - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); // All objects should be gone. 5 global handles in total. - CHECK_EQ(5, counter.NumberOfWeakCalls()); + CHECK_EQ(5, NumberOfWeakCalls); // And now make children weak again and collect them. - g1c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g2c1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + g1c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g2c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); - CHECK_EQ(7, counter.NumberOfWeakCalls()); + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); + CHECK_EQ(7, NumberOfWeakCalls); } @@ -2216,7 +1976,7 @@ THREADED_TEST(ApiObjectGroupsCycle) { HandleScope scope; LocalContext env; - WeakCallCounter counter(1234); + NumberOfWeakCalls = 0; Persistent<Object> g1s1; Persistent<Object> g1s2; @@ -2229,18 +1989,18 @@ THREADED_TEST(ApiObjectGroupsCycle) { HandleScope scope; g1s1 = Persistent<Object>::New(Object::New()); g1s2 = Persistent<Object>::New(Object::New()); - g1s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g1s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + g1s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g1s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); g2s1 = Persistent<Object>::New(Object::New()); g2s2 = Persistent<Object>::New(Object::New()); - g2s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g2s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + g2s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g2s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); g3s1 = Persistent<Object>::New(Object::New()); g3s2 = Persistent<Object>::New(Object::New()); - g3s1.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); - g3s2.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + g3s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g3s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); } Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. @@ -2262,14 +2022,14 @@ THREADED_TEST(ApiObjectGroupsCycle) { V8::AddObjectGroup(g3_objects, 2); V8::AddImplicitReferences(g3s1, g3_children, 1); } - // Do a single full GC - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + // Do a full GC + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); // All object should be alive. - CHECK_EQ(0, counter.NumberOfWeakCalls()); + CHECK_EQ(0, NumberOfWeakCalls); // Weaken the root. - root.MakeWeak(reinterpret_cast<void*>(&counter), &WeakPointerCallback); + root.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); // Groups are deleted, rebuild groups. { @@ -2287,10 +2047,10 @@ THREADED_TEST(ApiObjectGroupsCycle) { V8::AddImplicitReferences(g3s1, g3_children, 1); } - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); // All objects should be gone. 7 global handles in total. - CHECK_EQ(7, counter.NumberOfWeakCalls()); + CHECK_EQ(7, NumberOfWeakCalls); } @@ -4517,47 +4277,6 @@ THREADED_TEST(SimpleExtensions) { } -static const char* kEmbeddedExtensionSource = - "function Ret54321(){return 54321;}~~@@$" - "$%% THIS IS A SERIES OF NON-NULL-TERMINATED STRINGS."; -static const int kEmbeddedExtensionSourceValidLen = 34; - - -THREADED_TEST(ExtensionMissingSourceLength) { - v8::HandleScope handle_scope; - v8::RegisterExtension(new Extension("srclentest_fail", - kEmbeddedExtensionSource)); - const char* extension_names[] = { "srclentest_fail" }; - v8::ExtensionConfiguration extensions(1, extension_names); - v8::Handle<Context> context = Context::New(&extensions); - CHECK_EQ(0, *context); -} - - -THREADED_TEST(ExtensionWithSourceLength) { - for (int source_len = kEmbeddedExtensionSourceValidLen - 1; - source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) { - v8::HandleScope handle_scope; - i::ScopedVector<char> extension_name(32); - i::OS::SNPrintF(extension_name, "ext #%d", source_len); - v8::RegisterExtension(new Extension(extension_name.start(), - kEmbeddedExtensionSource, 0, 0, - source_len)); - const char* extension_names[1] = { extension_name.start() }; - v8::ExtensionConfiguration extensions(1, extension_names); - v8::Handle<Context> context = Context::New(&extensions); - if (source_len == kEmbeddedExtensionSourceValidLen) { - Context::Scope lock(context); - v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); - CHECK_EQ(v8::Integer::New(54321), result); - } else { - // Anything but exactly the right length should fail to compile. - CHECK_EQ(0, *context); - } - } -} - - static const char* kEvalExtensionSource1 = "function UseEval1() {" " var x = 42;" @@ -5058,7 +4777,7 @@ static void InvokeScavenge() { static void InvokeMarkSweep() { - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); } @@ -5151,7 +4870,7 @@ static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) { CHECK_EQ(v8::Integer::New(3), args[2]); CHECK_EQ(v8::Undefined(), args[3]); v8::HandleScope scope; - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); return v8::Undefined(); } @@ -8136,7 +7855,7 @@ static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC( Local<String> name, const AccessorInfo& info) { ApiTestFuzzer::Fuzz(); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); return v8::Handle<Value>(); } @@ -8866,7 +8585,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) { - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); } return v8::Handle<Value>(); } @@ -10217,7 +9936,6 @@ THREADED_TEST(LockUnlockLock) { static int GetGlobalObjectsCount() { - i::Isolate::Current()->heap()->EnsureHeapIsIterable(); int count = 0; i::HeapIterator it; for (i::HeapObject* object = it.next(); object != NULL; object = it.next()) @@ -10232,8 +9950,9 @@ static void CheckSurvivingGlobalObjectsCount(int expected) { // 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. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + HEAP->global_context_map(); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); int count = GetGlobalObjectsCount(); #ifdef DEBUG if (count != expected) HEAP->TracePathToGlobal(); @@ -10302,7 +10021,7 @@ THREADED_TEST(NewPersistentHandleFromWeakCallback) { // weak callback of the first handle would be able to 'reallocate' it. handle1.MakeWeak(NULL, NewPersistentHandleCallback); handle2.Dispose(); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); } @@ -10310,7 +10029,7 @@ v8::Persistent<v8::Object> to_be_disposed; void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) { to_be_disposed.Dispose(); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); handle.Dispose(); } @@ -10326,7 +10045,7 @@ THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { } handle1.MakeWeak(NULL, DisposeAndForceGcCallback); to_be_disposed = handle2; - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); } void DisposingCallback(v8::Persistent<v8::Value> handle, void*) { @@ -10352,7 +10071,7 @@ THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { } handle2.MakeWeak(NULL, DisposingCallback); handle3.MakeWeak(NULL, HandleCreatingCallback); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); } @@ -11168,7 +10887,7 @@ class RegExpInterruptTest { { v8::Locker lock; // TODO(lrn): Perhaps create some garbage before collecting. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); gc_count_++; } i::OS::Sleep(1); @@ -11290,7 +11009,7 @@ class ApplyInterruptTest { while (gc_during_apply_ < kRequiredGCs) { { v8::Locker lock; - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); gc_count_++; } i::OS::Sleep(1); @@ -12006,15 +11725,13 @@ THREADED_TEST(PixelArray) { i::Handle<i::ExternalPixelArray> pixels = i::Handle<i::ExternalPixelArray>::cast( FACTORY->NewExternalArray(kElementCount, - v8::kExternalPixelArray, - pixel_data)); - // Force GC to trigger verification. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + v8::kExternalPixelArray, + pixel_data)); + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. for (int i = 0; i < kElementCount; i++) { pixels->set(i, i % 256); } - // Force GC to trigger verification. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. for (int i = 0; i < kElementCount; i++) { CHECK_EQ(i % 256, pixels->get_scalar(i)); CHECK_EQ(i % 256, pixel_data[i]); @@ -12490,13 +12207,11 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, i::Handle<ExternalArrayClass> array = i::Handle<ExternalArrayClass>::cast( FACTORY->NewExternalArray(kElementCount, array_type, array_data)); - // Force GC to trigger verification. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. for (int i = 0; i < kElementCount; i++) { array->set(i, static_cast<ElementType>(i)); } - // Force GC to trigger verification. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. for (int i = 0; i < kElementCount; i++) { CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array->get_scalar(i))); @@ -12614,8 +12329,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, " }" "}" "sum;"); - // Force GC to trigger verification. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. CHECK_EQ(28, result->Int32Value()); // Make sure out-of-range loads do not throw. @@ -13595,7 +13309,7 @@ TEST(Regress528) { other_context->Enter(); CompileRun(source_simple); other_context->Exit(); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); if (GetGlobalObjectsCount() == 1) break; } CHECK_GE(2, gc_count); @@ -13617,7 +13331,7 @@ TEST(Regress528) { other_context->Enter(); CompileRun(source_eval); other_context->Exit(); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); if (GetGlobalObjectsCount() == 1) break; } CHECK_GE(2, gc_count); @@ -13644,7 +13358,7 @@ TEST(Regress528) { other_context->Enter(); CompileRun(source_exception); other_context->Exit(); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); if (GetGlobalObjectsCount() == 1) break; } CHECK_GE(2, gc_count); @@ -13862,26 +13576,26 @@ TEST(GCCallbacks) { v8::V8::AddGCEpilogueCallback(EpilogueCallback); CHECK_EQ(0, prologue_call_count); CHECK_EQ(0, epilogue_call_count); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, prologue_call_count); CHECK_EQ(1, epilogue_call_count); v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, prologue_call_count); CHECK_EQ(2, epilogue_call_count); CHECK_EQ(1, prologue_call_count_second); CHECK_EQ(1, epilogue_call_count_second); v8::V8::RemoveGCPrologueCallback(PrologueCallback); v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, prologue_call_count); CHECK_EQ(2, epilogue_call_count); CHECK_EQ(2, prologue_call_count_second); CHECK_EQ(2, epilogue_call_count_second); v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, prologue_call_count); CHECK_EQ(2, epilogue_call_count); CHECK_EQ(2, prologue_call_count_second); @@ -14098,7 +13812,7 @@ THREADED_TEST(TwoByteStringInAsciiCons) { void FailedAccessCheckCallbackGC(Local<v8::Object> target, v8::AccessType type, Local<v8::Value> data) { - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); } @@ -14672,7 +14386,7 @@ TEST(DontDeleteCellLoadIC) { "})()", "ReferenceError: cell is not defined"); CompileRun("cell = \"new_second\";"); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); ExpectString("readCell()", "new_second"); ExpectString("readCell()", "new_second"); } diff --git a/deps/v8/test/cctest/test-assembler-ia32.cc b/deps/v8/test/cctest/test-assembler-ia32.cc index cdab8f7cb6..839b7f562e 100644 --- a/deps/v8/test/cctest/test-assembler-ia32.cc +++ b/deps/v8/test/cctest/test-assembler-ia32.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// Copyright 2006-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: @@ -93,15 +93,15 @@ TEST(AssemblerIa321) { Label L, C; __ mov(edx, Operand(esp, 4)); - __ xor_(eax, eax); // clear eax + __ xor_(eax, Operand(eax)); // clear eax __ jmp(&C); __ bind(&L); - __ add(eax, edx); - __ sub(edx, Immediate(1)); + __ add(eax, Operand(edx)); + __ sub(Operand(edx), Immediate(1)); __ bind(&C); - __ test(edx, edx); + __ test(edx, Operand(edx)); __ j(not_zero, &L); __ ret(0); @@ -135,11 +135,11 @@ TEST(AssemblerIa322) { __ jmp(&C); __ bind(&L); - __ imul(eax, edx); - __ sub(edx, Immediate(1)); + __ imul(eax, Operand(edx)); + __ sub(Operand(edx), Immediate(1)); __ bind(&C); - __ test(edx, edx); + __ test(edx, Operand(edx)); __ j(not_zero, &L); __ ret(0); @@ -275,10 +275,10 @@ TEST(AssemblerIa326) { __ subsd(xmm0, xmm1); __ divsd(xmm0, xmm1); // Copy xmm0 to st(0) using eight bytes of stack. - __ sub(esp, Immediate(8)); + __ sub(Operand(esp), Immediate(8)); __ movdbl(Operand(esp, 0), xmm0); __ fld_d(Operand(esp, 0)); - __ add(esp, Immediate(8)); + __ add(Operand(esp), Immediate(8)); __ ret(0); CodeDesc desc; @@ -314,12 +314,12 @@ TEST(AssemblerIa328) { v8::internal::byte buffer[256]; Assembler assm(Isolate::Current(), buffer, sizeof buffer); __ mov(eax, Operand(esp, 4)); - __ cvtsi2sd(xmm0, eax); + __ cvtsi2sd(xmm0, Operand(eax)); // Copy xmm0 to st(0) using eight bytes of stack. - __ sub(esp, Immediate(8)); + __ sub(Operand(esp), Immediate(8)); __ movdbl(Operand(esp, 0), xmm0); __ fld_d(Operand(esp, 0)); - __ add(esp, Immediate(8)); + __ add(Operand(esp), Immediate(8)); __ ret(0); CodeDesc desc; assm.GetCode(&desc); diff --git a/deps/v8/test/cctest/test-compiler.cc b/deps/v8/test/cctest/test-compiler.cc index f5c01e6162..2d9b01204a 100644 --- a/deps/v8/test/cctest/test-compiler.cc +++ b/deps/v8/test/cctest/test-compiler.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// Copyright 2006-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: @@ -305,11 +305,10 @@ TEST(C2JSFrames) { Handle<Object> fun1(fun1_object->ToObjectChecked()); CHECK(fun1->IsJSFunction()); - Handle<Object> argv[] = { FACTORY->LookupAsciiSymbol("hello") }; - Execution::Call(Handle<JSFunction>::cast(fun1), - global, - ARRAY_SIZE(argv), - argv, + Object** argv[1] = { + Handle<Object>::cast(FACTORY->LookupAsciiSymbol("hello")).location() + }; + Execution::Call(Handle<JSFunction>::cast(fun1), global, 1, argv, &has_pending_exception); CHECK(!has_pending_exception); } diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index de60d4999d..45da6dc0bd 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -425,8 +425,8 @@ void CheckDebuggerUnloaded(bool check_functions) { CHECK_EQ(NULL, Isolate::Current()->debug()->debug_info_list_); // Collect garbage to ensure weak handles are cleared. - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); // Iterate the head and check that there are no debugger related objects left. HeapIterator iterator; @@ -944,7 +944,7 @@ static void DebugEventBreakPointCollectGarbage( HEAP->CollectGarbage(v8::internal::NEW_SPACE); } else { // Mark sweep compact. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); } } } @@ -1417,7 +1417,8 @@ TEST(GCDuringBreakPointProcessing) { // Call the function three times with different garbage collections in between // and make sure that the break point survives. static void CallAndGC(v8::Local<v8::Object> recv, - v8::Local<v8::Function> f) { + v8::Local<v8::Function> f, + bool force_compaction) { break_point_hit_count = 0; for (int i = 0; i < 3; i++) { @@ -1431,15 +1432,14 @@ static void CallAndGC(v8::Local<v8::Object> recv, CHECK_EQ(2 + i * 3, break_point_hit_count); // Mark sweep (and perhaps compact) and call function. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(force_compaction); f->Call(recv, 0, NULL); CHECK_EQ(3 + i * 3, break_point_hit_count); } } -// Test that a break point can be set at a return store location. -TEST(BreakPointSurviveGC) { +static void TestBreakPointSurviveGC(bool force_compaction) { break_point_hit_count = 0; v8::HandleScope scope; DebugLocalContext env; @@ -1455,7 +1455,7 @@ TEST(BreakPointSurviveGC) { foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); SetBreakPoint(foo, 0); } - CallAndGC(env->Global(), foo); + CallAndGC(env->Global(), foo, force_compaction); // Test IC load break point with garbage collection. { @@ -1464,7 +1464,7 @@ TEST(BreakPointSurviveGC) { foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); SetBreakPoint(foo, 0); } - CallAndGC(env->Global(), foo); + CallAndGC(env->Global(), foo, force_compaction); // Test IC call break point with garbage collection. { @@ -1475,7 +1475,7 @@ TEST(BreakPointSurviveGC) { "foo"); SetBreakPoint(foo, 0); } - CallAndGC(env->Global(), foo); + CallAndGC(env->Global(), foo, force_compaction); // Test return break point with garbage collection. { @@ -1484,7 +1484,7 @@ TEST(BreakPointSurviveGC) { foo = CompileFunction(&env, "function foo(){}", "foo"); SetBreakPoint(foo, 0); } - CallAndGC(env->Global(), foo); + CallAndGC(env->Global(), foo, force_compaction); // Test non IC break point with garbage collection. { @@ -1493,7 +1493,7 @@ TEST(BreakPointSurviveGC) { foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo"); SetBreakPoint(foo, 0); } - CallAndGC(env->Global(), foo); + CallAndGC(env->Global(), foo, force_compaction); v8::Debug::SetDebugEventListener(NULL); @@ -1501,6 +1501,13 @@ TEST(BreakPointSurviveGC) { } +// Test that a break point can be set at a return store location. +TEST(BreakPointSurviveGC) { + TestBreakPointSurviveGC(false); + TestBreakPointSurviveGC(true); +} + + // Test that break points can be set using the global Debug object. TEST(BreakPointThroughJavaScript) { break_point_hit_count = 0; @@ -2252,7 +2259,7 @@ TEST(ScriptBreakPointLineTopLevel) { } f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); SetScriptBreakPointByNameFromJS("test.html", 3, -1); @@ -6465,7 +6472,7 @@ TEST(ScriptCollectedEvent) { // Do garbage collection to ensure that only the script in this test will be // collected afterwards. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); script_collected_count = 0; v8::Debug::SetDebugEventListener(DebugEventScriptCollectedEvent, @@ -6477,7 +6484,7 @@ TEST(ScriptCollectedEvent) { // Do garbage collection to collect the script above which is no longer // referenced. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, script_collected_count); @@ -6513,7 +6520,7 @@ TEST(ScriptCollectedEventContext) { // Do garbage collection to ensure that only the script in this test will be // collected afterwards. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); { @@ -6524,7 +6531,7 @@ TEST(ScriptCollectedEventContext) { // Do garbage collection to collect the script above which is no longer // referenced. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, script_collected_message_count); diff --git a/deps/v8/test/cctest/test-decls.cc b/deps/v8/test/cctest/test-decls.cc index aa733c70bc..619839185e 100644 --- a/deps/v8/test/cctest/test-decls.cc +++ b/deps/v8/test/cctest/test-decls.cc @@ -232,7 +232,7 @@ TEST(Unknown) { context.Check("const x; x", 1, // access 2, // declaration + initialization - 1, // declaration + 2, // declaration + initialization EXPECT_RESULT, Undefined()); } @@ -240,7 +240,7 @@ TEST(Unknown) { context.Check("const x = 0; x", 1, // access 2, // declaration + initialization - 1, // declaration + 2, // declaration + initialization EXPECT_RESULT, Undefined()); // SB 0 - BUG 1213579 } } @@ -285,18 +285,18 @@ TEST(Present) { { PresentPropertyContext context; context.Check("const x; x", - 1, // access - 1, // initialization + 0, + 0, 1, // (re-)declaration - EXPECT_RESULT, Undefined()); + EXPECT_EXCEPTION); // x has already been declared! } { PresentPropertyContext context; context.Check("const x = 0; x", - 1, // access - 1, // initialization + 0, + 0, 1, // (re-)declaration - EXPECT_RESULT, Number::New(0)); + EXPECT_EXCEPTION); // x has already been declared! } } @@ -341,7 +341,7 @@ TEST(Absent) { context.Check("const x; x", 1, // access 2, // declaration + initialization - 1, // declaration + 2, // declaration + initializetion EXPECT_RESULT, Undefined()); } @@ -349,7 +349,7 @@ TEST(Absent) { context.Check("const x = 0; x", 1, // access 2, // declaration + initialization - 1, // declaration + 2, // declaration + initialization EXPECT_RESULT, Undefined()); // SB 0 - BUG 1213579 } @@ -429,20 +429,18 @@ TEST(Appearing) { { AppearingPropertyContext context; context.Check("const x; x", - 1, // access - 2, // declaration + initialization + 0, 1, // declaration - EXPECT_RESULT, Undefined()); + 2, // declaration + initialization + EXPECT_EXCEPTION); // x has already been declared! } { AppearingPropertyContext context; context.Check("const x = 0; x", - 1, // access - 2, // declaration + initialization + 0, 1, // declaration - EXPECT_RESULT, Undefined()); - // Result is undefined because declaration succeeded but - // initialization to 0 failed (due to context behavior). + 2, // declaration + initialization + EXPECT_EXCEPTION); // x has already been declared! } } @@ -498,9 +496,9 @@ TEST(Reappearing) { { ReappearingPropertyContext context; context.Check("const x; var x = 0", 0, - 3, // const declaration+initialization, var initialization - 3, // 2 x declaration + var initialization - EXPECT_RESULT, Undefined()); + 2, // var declaration + const initialization + 4, // 2 x declaration + 2 x initialization + EXPECT_EXCEPTION); // x has already been declared! } } diff --git a/deps/v8/test/cctest/test-disasm-ia32.cc b/deps/v8/test/cctest/test-disasm-ia32.cc index 1e38e4ea72..9f7d0bb6e0 100644 --- a/deps/v8/test/cctest/test-disasm-ia32.cc +++ b/deps/v8/test/cctest/test-disasm-ia32.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// 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: @@ -63,9 +63,9 @@ TEST(DisasmIa320) { // Short immediate instructions __ adc(eax, 12345678); - __ add(eax, Immediate(12345678)); + __ add(Operand(eax), Immediate(12345678)); __ or_(eax, 12345678); - __ sub(eax, Immediate(12345678)); + __ sub(Operand(eax), Immediate(12345678)); __ xor_(eax, 12345678); __ and_(eax, 12345678); Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); @@ -75,7 +75,7 @@ TEST(DisasmIa320) { __ mov(ebx, Operand(esp, ecx, times_2, 0)); // [esp+ecx*4] // ---- All instructions that I can think of - __ add(edx, ebx); + __ add(edx, Operand(ebx)); __ add(edx, Operand(12, RelocInfo::NONE)); __ add(edx, Operand(ebx, 0)); __ add(edx, Operand(ebx, 16)); @@ -89,7 +89,7 @@ TEST(DisasmIa320) { __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); __ nop(); - __ add(ebx, Immediate(12)); + __ add(Operand(ebx), Immediate(12)); __ nop(); __ adc(ecx, 12); __ adc(ecx, 1000); @@ -116,16 +116,16 @@ TEST(DisasmIa320) { CpuFeatures::Scope fscope(RDTSC); __ rdtsc(); } - __ movsx_b(edx, ecx); - __ movsx_w(edx, ecx); - __ movzx_b(edx, ecx); - __ movzx_w(edx, ecx); + __ movsx_b(edx, Operand(ecx)); + __ movsx_w(edx, Operand(ecx)); + __ movzx_b(edx, Operand(ecx)); + __ movzx_w(edx, Operand(ecx)); __ nop(); - __ imul(edx, ecx); - __ shld(edx, ecx); - __ shrd(edx, ecx); - __ bts(edx, ecx); + __ imul(edx, Operand(ecx)); + __ shld(edx, Operand(ecx)); + __ shrd(edx, Operand(ecx)); + __ bts(Operand(edx), ecx); __ bts(Operand(ebx, ecx, times_4, 0), ecx); __ nop(); __ pushad(); @@ -146,9 +146,9 @@ TEST(DisasmIa320) { __ nop(); __ add(edx, Operand(esp, 16)); - __ add(edx, ecx); - __ mov_b(edx, ecx); - __ mov_b(ecx, 6); + __ add(edx, Operand(ecx)); + __ mov_b(edx, Operand(ecx)); + __ mov_b(Operand(ecx), 6); __ mov_b(Operand(ebx, ecx, times_4, 10000), 6); __ mov_b(Operand(esp, 16), edx); __ mov_w(edx, Operand(esp, 16)); @@ -216,20 +216,22 @@ TEST(DisasmIa320) { __ adc(edx, 12345); - __ add(ebx, Immediate(12)); + __ add(Operand(ebx), Immediate(12)); __ add(Operand(edx, ecx, times_4, 10000), Immediate(12)); __ and_(ebx, 12345); __ cmp(ebx, 12345); - __ cmp(ebx, Immediate(12)); + __ cmp(Operand(ebx), Immediate(12)); __ cmp(Operand(edx, ecx, times_4, 10000), Immediate(12)); - __ cmpb(eax, 100); __ or_(ebx, 12345); - __ sub(ebx, Immediate(12)); + __ sub(Operand(ebx), Immediate(12)); __ sub(Operand(edx, ecx, times_4, 10000), Immediate(12)); + __ subb(Operand(edx, ecx, times_4, 10000), 100); + __ subb(Operand(eax), 100); + __ subb(eax, Operand(edx, ecx, times_4, 10000)); __ xor_(ebx, 12345); @@ -242,7 +244,7 @@ TEST(DisasmIa320) { __ stos(); __ sub(edx, Operand(ebx, ecx, times_4, 10000)); - __ sub(edx, ebx); + __ sub(edx, Operand(ebx)); __ test(edx, Immediate(12345)); __ test(edx, Operand(ebx, ecx, times_8, 10000)); @@ -444,8 +446,8 @@ TEST(DisasmIa320) { { if (CpuFeatures::IsSupported(SSE4_1)) { CpuFeatures::Scope scope(SSE4_1); - __ pextrd(eax, xmm0, 1); - __ pinsrd(xmm1, eax, 0); + __ pextrd(Operand(eax), xmm0, 1); + __ pinsrd(xmm1, Operand(eax), 0); } } diff --git a/deps/v8/test/cctest/test-func-name-inference.cc b/deps/v8/test/cctest/test-func-name-inference.cc index 8f405b726e..bfae4d1360 100644 --- a/deps/v8/test/cctest/test-func-name-inference.cc +++ b/deps/v8/test/cctest/test-func-name-inference.cc @@ -361,42 +361,3 @@ TEST(FactoryHashmapConditional) { // Can't infer the function name statically. CheckFunctionName(script, "return 1", "obj.(anonymous function)"); } - - -TEST(GlobalAssignmentAndCall) { - InitializeVM(); - v8::HandleScope scope; - - v8::Handle<v8::Script> script = Compile( - "var Foo = function() {\n" - " return 1;\n" - "}();\n" - "var Baz = Bar = function() {\n" - " return 2;\n" - "}"); - // The inferred name is empty, because this is an assignment of a result. - CheckFunctionName(script, "return 1", ""); - // See MultipleAssignments test. - CheckFunctionName(script, "return 2", "Bar"); -} - - -TEST(AssignmentAndCall) { - InitializeVM(); - v8::HandleScope scope; - - v8::Handle<v8::Script> script = Compile( - "(function Enclosing() {\n" - " var Foo;\n" - " Foo = function() {\n" - " return 1;\n" - " }();\n" - " var Baz = Bar = function() {\n" - " return 2;\n" - " }\n" - "})();"); - // The inferred name is empty, because this is an assignment of a result. - CheckFunctionName(script, "return 1", ""); - // See MultipleAssignments test. - CheckFunctionName(script, "return 2", "Enclosing.Bar"); -} diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index d695d7438f..1769c1b7d5 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -85,7 +85,7 @@ TEST(HeapSnapshot) { "var b2_1 = new B2(a2), b2_2 = new B2(a2);\n" "var c2 = new C2(a2);"); const v8::HeapSnapshot* snapshot_env2 = - v8::HeapProfiler::TakeSnapshot(v8_str("env2")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("env2")); i::HeapSnapshot* i_snapshot_env2 = const_cast<i::HeapSnapshot*>( reinterpret_cast<const i::HeapSnapshot*>(snapshot_env2)); @@ -124,7 +124,7 @@ TEST(HeapSnapshotObjectSizes) { "x = new X(new X(), new X());\n" "(function() { x.a.a = x.b; })();"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("sizes")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("sizes")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); const v8::HeapGraphNode* x = GetProperty(global, v8::HeapGraphEdge::kShortcut, "x"); @@ -155,7 +155,7 @@ TEST(HeapSnapshotEntryChildren) { "function A() { }\n" "a = new A;"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("children")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("children")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); for (int i = 0, count = global->GetChildrenCount(); i < count; ++i) { const v8::HeapGraphEdge* prop = global->GetChild(i); @@ -181,7 +181,7 @@ TEST(HeapSnapshotCodeObjects) { "var anonymous = (function() { return function() { return 0; } })();\n" "compiled(1)"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("code")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("code")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); const v8::HeapGraphNode* compiled = @@ -243,7 +243,7 @@ TEST(HeapSnapshotHeapNumbers) { "a = 1; // a is Smi\n" "b = 2.5; // b is HeapNumber"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("numbers")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("numbers")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); CHECK_EQ(NULL, GetProperty(global, v8::HeapGraphEdge::kShortcut, "a")); const v8::HeapGraphNode* b = @@ -265,7 +265,7 @@ TEST(HeapSnapshotInternalReferences) { global->SetInternalField(0, v8_num(17)); global->SetInternalField(1, obj); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("internals")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("internals")); const v8::HeapGraphNode* global_node = GetGlobalObject(snapshot); // The first reference will not present, because it's a Smi. CHECK_EQ(NULL, GetProperty(global_node, v8::HeapGraphEdge::kInternal, "0")); @@ -292,12 +292,12 @@ TEST(HeapEntryIdsAndGC) { "var a = new A();\n" "var b = new B(a);"); const v8::HeapSnapshot* snapshot1 = - v8::HeapProfiler::TakeSnapshot(v8_str("s1")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); // Enforce compaction. const v8::HeapSnapshot* snapshot2 = - v8::HeapProfiler::TakeSnapshot(v8_str("s2")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); const v8::HeapGraphNode* global1 = GetGlobalObject(snapshot1); const v8::HeapGraphNode* global2 = GetGlobalObject(snapshot2); @@ -342,7 +342,7 @@ TEST(HeapSnapshotRootPreservedAfterSorting) { v8::HandleScope scope; LocalContext env; const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("s")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("s")); const v8::HeapGraphNode* root1 = snapshot->GetRoot(); const_cast<i::HeapSnapshot*>(reinterpret_cast<const i::HeapSnapshot*>( snapshot))->GetSortedEntriesList(); @@ -380,7 +380,7 @@ TEST(HeapEntryDominator) { "})();"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("dominators")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("dominators")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); CHECK_NE(NULL, global); @@ -463,7 +463,7 @@ TEST(HeapSnapshotJSONSerialization) { "var a = new A(" STRING_LITERAL_FOR_TEST ");\n" "var b = new B(a);"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("json")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("json")); TestJSONStream stream; snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); CHECK_GT(stream.size(), 0); @@ -474,17 +474,17 @@ TEST(HeapSnapshotJSONSerialization) { // Verify that snapshot string is valid JSON. AsciiResource json_res(json); v8::Local<v8::String> json_string = v8::String::NewExternal(&json_res); - env->Global()->Set(v8_str("json_snapshot"), json_string); + env->Global()->Set(v8::String::New("json_snapshot"), json_string); v8::Local<v8::Value> snapshot_parse_result = CompileRun( "var parsed = JSON.parse(json_snapshot); true;"); CHECK(!snapshot_parse_result.IsEmpty()); // Verify that snapshot object has required fields. v8::Local<v8::Object> parsed_snapshot = - env->Global()->Get(v8_str("parsed"))->ToObject(); - CHECK(parsed_snapshot->Has(v8_str("snapshot"))); - CHECK(parsed_snapshot->Has(v8_str("nodes"))); - CHECK(parsed_snapshot->Has(v8_str("strings"))); + env->Global()->Get(v8::String::New("parsed"))->ToObject(); + CHECK(parsed_snapshot->Has(v8::String::New("snapshot"))); + CHECK(parsed_snapshot->Has(v8::String::New("nodes"))); + CHECK(parsed_snapshot->Has(v8::String::New("strings"))); // Get node and edge "member" offsets. v8::Local<v8::Value> meta_analysis_result = CompileRun( @@ -536,12 +536,12 @@ TEST(HeapSnapshotJSONSerialization) { int string_obj_pos = static_cast<int>(string_obj_pos_val->ToNumber()->Value()); v8::Local<v8::Object> nodes_array = - parsed_snapshot->Get(v8_str("nodes"))->ToObject(); + parsed_snapshot->Get(v8::String::New("nodes"))->ToObject(); int string_index = static_cast<int>( nodes_array->Get(string_obj_pos + 1)->ToNumber()->Value()); CHECK_GT(string_index, 0); v8::Local<v8::Object> strings_array = - parsed_snapshot->Get(v8_str("strings"))->ToObject(); + parsed_snapshot->Get(v8::String::New("strings"))->ToObject(); v8::Local<v8::String> string = strings_array->Get(string_index)->ToString(); v8::Local<v8::String> ref_string = CompileRun(STRING_LITERAL_FOR_TEST)->ToString(); @@ -555,7 +555,7 @@ TEST(HeapSnapshotJSONSerializationAborting) { v8::HandleScope scope; LocalContext env; const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("abort")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("abort")); TestJSONStream stream(5); snapshot->Serialize(&stream, v8::HeapSnapshot::kJSON); CHECK_GT(stream.size(), 0); @@ -568,7 +568,7 @@ TEST(HeapSnapshotGetNodeById) { LocalContext env; const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("id")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("id")); const v8::HeapGraphNode* root = snapshot->GetRoot(); CHECK_EQ(root, snapshot->GetNodeById(root->GetId())); for (int i = 0, count = root->GetChildrenCount(); i < count; ++i) { @@ -609,7 +609,7 @@ TEST(TakeHeapSnapshotAborting) { const int snapshots_count = v8::HeapProfiler::GetSnapshotsCount(); TestActivityControl aborting_control(3); const v8::HeapSnapshot* no_snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("abort"), + v8::HeapProfiler::TakeSnapshot(v8::String::New("abort"), v8::HeapSnapshot::kFull, &aborting_control); CHECK_EQ(NULL, no_snapshot); @@ -618,7 +618,7 @@ TEST(TakeHeapSnapshotAborting) { TestActivityControl control(-1); // Don't abort. const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("full"), + v8::HeapProfiler::TakeSnapshot(v8::String::New("full"), v8::HeapSnapshot::kFull, &control); CHECK_NE(NULL, snapshot); @@ -728,7 +728,7 @@ TEST(HeapSnapshotRetainedObjectInfo) { p_CCC.SetWrapperClassId(2); CHECK_EQ(0, TestRetainedObjectInfo::instances.length()); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("retained")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("retained")); CHECK_EQ(3, TestRetainedObjectInfo::instances.length()); for (int i = 0; i < TestRetainedObjectInfo::instances.length(); ++i) { @@ -772,12 +772,12 @@ TEST(DeleteAllHeapSnapshots) { CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); v8::HeapProfiler::DeleteAllSnapshots(); CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); - CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8_str("1"))); + CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1"))); CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); v8::HeapProfiler::DeleteAllSnapshots(); CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); - CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8_str("1"))); - CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8_str("2"))); + CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("1"))); + CHECK_NE(NULL, v8::HeapProfiler::TakeSnapshot(v8::String::New("2"))); CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount()); v8::HeapProfiler::DeleteAllSnapshots(); CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); @@ -790,7 +790,7 @@ TEST(DeleteHeapSnapshot) { CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); const v8::HeapSnapshot* s1 = - v8::HeapProfiler::TakeSnapshot(v8_str("1")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("1")); CHECK_NE(NULL, s1); CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); unsigned uid1 = s1->GetUid(); @@ -800,14 +800,14 @@ TEST(DeleteHeapSnapshot) { CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid1)); const v8::HeapSnapshot* s2 = - v8::HeapProfiler::TakeSnapshot(v8_str("2")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("2")); CHECK_NE(NULL, s2); CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); unsigned uid2 = s2->GetUid(); CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); CHECK_EQ(s2, v8::HeapProfiler::FindSnapshot(uid2)); const v8::HeapSnapshot* s3 = - v8::HeapProfiler::TakeSnapshot(v8_str("3")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("3")); CHECK_NE(NULL, s3); CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount()); unsigned uid3 = s3->GetUid(); @@ -830,7 +830,7 @@ TEST(DocumentURL) { CompileRun("document = { URL:\"abcdefgh\" };"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("document")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("document")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); CHECK_NE(NULL, global); CHECK_EQ("Object / abcdefgh", @@ -846,7 +846,7 @@ TEST(DocumentWithException) { CompileRun( "this.__defineGetter__(\"document\", function() { throw new Error(); })"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("document")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("document")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); CHECK_NE(NULL, global); CHECK_EQ("Object", @@ -864,7 +864,7 @@ TEST(DocumentURLWithException) { "URLWithException.prototype = { get URL() { throw new Error(); } };\n" "document = { URL: new URLWithException() };"); const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("document")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("document")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); CHECK_NE(NULL, global); CHECK_EQ("Object", @@ -877,7 +877,7 @@ TEST(NodesIteration) { v8::HandleScope scope; LocalContext env; const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("iteration")); + v8::HeapProfiler::TakeSnapshot(v8::String::New("iteration")); const v8::HeapGraphNode* global = GetGlobalObject(snapshot); CHECK_NE(NULL, global); // Verify that we can find this object by iteration. @@ -891,62 +891,6 @@ TEST(NodesIteration) { } -TEST(GetHeapValue) { - v8::HandleScope scope; - LocalContext env; - - CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };"); - const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("value")); - const v8::HeapGraphNode* global = GetGlobalObject(snapshot); - CHECK(global->GetHeapValue()->IsObject()); - v8::Local<v8::Object> js_global = - env->Global()->GetPrototype().As<v8::Object>(); - CHECK(js_global == global->GetHeapValue()); - const v8::HeapGraphNode* obj = GetProperty( - global, v8::HeapGraphEdge::kShortcut, "a"); - CHECK(obj->GetHeapValue()->IsObject()); - v8::Local<v8::Object> js_obj = js_global->Get(v8_str("a")).As<v8::Object>(); - CHECK(js_obj == obj->GetHeapValue()); - const v8::HeapGraphNode* s_prop = - GetProperty(obj, v8::HeapGraphEdge::kProperty, "s_prop"); - v8::Local<v8::String> js_s_prop = - js_obj->Get(v8_str("s_prop")).As<v8::String>(); - CHECK(js_s_prop == s_prop->GetHeapValue()); - const v8::HeapGraphNode* n_prop = - GetProperty(obj, v8::HeapGraphEdge::kProperty, "n_prop"); - v8::Local<v8::Number> js_n_prop = - js_obj->Get(v8_str("n_prop")).As<v8::Number>(); - CHECK(js_n_prop == n_prop->GetHeapValue()); -} - - -TEST(GetHeapValueForDeletedObject) { - v8::HandleScope scope; - LocalContext env; - - // It is impossible to delete a global property, so we are about to delete a - // property of the "a" object. Also, the "p" object can't be an empty one - // because the empty object is static and isn't actually deleted. - CompileRun("a = { p: { r: {} } };"); - const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8_str("snapshot")); - const v8::HeapGraphNode* global = GetGlobalObject(snapshot); - const v8::HeapGraphNode* obj = GetProperty( - global, v8::HeapGraphEdge::kShortcut, "a"); - const v8::HeapGraphNode* prop = GetProperty( - obj, v8::HeapGraphEdge::kProperty, "p"); - { - // Perform the check inside a nested local scope to avoid creating a - // reference to the object we are deleting. - v8::HandleScope scope; - CHECK(prop->GetHeapValue()->IsObject()); - } - CompileRun("delete a.p;"); - CHECK(prop->GetHeapValue()->IsUndefined()); -} - - static int StringCmp(const char* ref, i::String* act) { i::SmartArrayPointer<char> s_act = act->ToCString(); int result = strcmp(ref, *s_act); diff --git a/deps/v8/test/cctest/test-heap.cc b/deps/v8/test/cctest/test-heap.cc index 8ed5bf7668..11b8813063 100644 --- a/deps/v8/test/cctest/test-heap.cc +++ b/deps/v8/test/cctest/test-heap.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// Copyright 2006-2008 the V8 project authors. All rights reserved. #include <stdlib.h> @@ -672,8 +672,7 @@ TEST(JSArray) { // Set array length to 0. ok = array->SetElementsLength(Smi::FromInt(0))->ToObjectChecked(); CHECK_EQ(Smi::FromInt(0), array->length()); - // Must be in fast mode. - CHECK(array->HasFastTypeElements()); + CHECK(array->HasFastElements()); // Must be in fast mode. // array[length] = name. ok = array->SetElement(0, *name, kNonStrictMode, true)->ToObjectChecked(); @@ -839,6 +838,49 @@ TEST(Iteration) { } +TEST(LargeObjectSpaceContains) { + InitializeVM(); + + HEAP->CollectGarbage(NEW_SPACE); + + Address current_top = HEAP->new_space()->top(); + Page* page = Page::FromAddress(current_top); + Address current_page = page->address(); + Address next_page = current_page + Page::kPageSize; + int bytes_to_page = static_cast<int>(next_page - current_top); + if (bytes_to_page <= FixedArray::kHeaderSize) { + // Alas, need to cross another page to be able to + // put desired value. + next_page += Page::kPageSize; + bytes_to_page = static_cast<int>(next_page - current_top); + } + CHECK(bytes_to_page > FixedArray::kHeaderSize); + + intptr_t* flags_ptr = &Page::FromAddress(next_page)->flags_; + Address flags_addr = reinterpret_cast<Address>(flags_ptr); + + int bytes_to_allocate = + static_cast<int>(flags_addr - current_top) + kPointerSize; + + int n_elements = (bytes_to_allocate - FixedArray::kHeaderSize) / + kPointerSize; + CHECK_EQ(bytes_to_allocate, FixedArray::SizeFor(n_elements)); + FixedArray* array = FixedArray::cast( + HEAP->AllocateFixedArray(n_elements)->ToObjectChecked()); + + int index = n_elements - 1; + CHECK_EQ(flags_ptr, + HeapObject::RawField(array, FixedArray::OffsetOfElementAt(index))); + array->set(index, Smi::FromInt(0)); + // This chould have turned next page into LargeObjectPage: + // CHECK(Page::FromAddress(next_page)->IsLargeObjectPage()); + + HeapObject* addr = HeapObject::FromAddress(next_page + 2 * kPointerSize); + CHECK(HEAP->new_space()->Contains(addr)); + CHECK(!HEAP->lo_space()->Contains(addr)); +} + + TEST(EmptyHandleEscapeFrom) { InitializeVM(); @@ -865,7 +907,8 @@ TEST(Regression39128) { InitializeVM(); // Increase the chance of 'bump-the-pointer' allocation in old space. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + bool force_compaction = true; + HEAP->CollectAllGarbage(force_compaction); v8::HandleScope scope; @@ -932,6 +975,12 @@ TEST(Regression39128) { return; } CHECK(HEAP->old_pointer_space()->Contains(clone->address())); + + // Step 5: verify validity of region dirty marks. + Address clone_addr = clone->address(); + Page* page = Page::FromAddress(clone_addr); + // Check that region covering inobject property 1 is marked dirty. + CHECK(page->IsRegionDirty(clone_addr + (object_size - kPointerSize))); } @@ -961,18 +1010,17 @@ TEST(TestCodeFlushing) { Handle<JSFunction> function(JSFunction::cast(func_value)); CHECK(function->shared()->is_compiled()); - // TODO(1609) Currently incremental marker does not support code flushing. - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); CHECK(function->shared()->is_compiled()); - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); - HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); // foo should no longer be in the compilation cache CHECK(!function->shared()->is_compiled() || function->IsOptimized()); @@ -1061,7 +1109,7 @@ TEST(TestInternalWeakLists) { } // Mark compact handles the weak references. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); // Get rid of f3 and f5 in the same way. @@ -1070,21 +1118,21 @@ TEST(TestInternalWeakLists) { HEAP->PerformScavenge(); CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); } - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); CompileRun("f5=null"); for (int j = 0; j < 10; j++) { HEAP->PerformScavenge(); CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); } - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i])); ctx[i]->Exit(); } // Force compilation cache cleanup. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); // Dispose the global contexts one by one. for (int i = 0; i < kNumTestContexts; i++) { @@ -1098,7 +1146,7 @@ TEST(TestInternalWeakLists) { } // Mark compact handles the weak references. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); CHECK_EQ(kNumTestContexts - i - 1, CountGlobalContexts()); } @@ -1113,7 +1161,7 @@ static int CountGlobalContextsWithGC(int n) { Handle<Object> object(HEAP->global_contexts_list()); while (!object->IsUndefined()) { count++; - if (count == n) HEAP->CollectAllGarbage(Heap::kNoGCFlags); + if (count == n) HEAP->CollectAllGarbage(true); object = Handle<Object>(Context::cast(*object)->get(Context::NEXT_CONTEXT_LINK)); } @@ -1132,7 +1180,7 @@ static int CountOptimizedUserFunctionsWithGC(v8::Handle<v8::Context> context, while (object->IsJSFunction() && !Handle<JSFunction>::cast(object)->IsBuiltin()) { count++; - if (count == n) HEAP->CollectAllGarbage(Heap::kNoGCFlags); + if (count == n) HEAP->CollectAllGarbage(true); object = Handle<Object>( Object::cast(JSFunction::cast(*object)->next_function_link())); } @@ -1192,84 +1240,90 @@ TEST(TestInternalWeakListsTraverseWithGC) { TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { InitializeVM(); - HEAP->EnsureHeapIsIterable(); intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); - HeapIterator iterator; + HeapIterator iterator(HeapIterator::kFilterFreeListNodes); intptr_t size_of_objects_2 = 0; for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { size_of_objects_2 += obj->Size(); } - // Delta must be within 5% of the larger result. - // TODO(gc): Tighten this up by distinguishing between byte - // arrays that are real and those that merely mark free space - // on the heap. + // Delta must be within 1% of the larger result. if (size_of_objects_1 > size_of_objects_2) { intptr_t delta = size_of_objects_1 - size_of_objects_2; PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " "Iterator: %" V8_PTR_PREFIX "d, " "delta: %" V8_PTR_PREFIX "d\n", size_of_objects_1, size_of_objects_2, delta); - CHECK_GT(size_of_objects_1 / 20, delta); + CHECK_GT(size_of_objects_1 / 100, delta); } else { intptr_t delta = size_of_objects_2 - size_of_objects_1; PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, " "Iterator: %" V8_PTR_PREFIX "d, " "delta: %" V8_PTR_PREFIX "d\n", size_of_objects_1, size_of_objects_2, delta); - CHECK_GT(size_of_objects_2 / 20, delta); + CHECK_GT(size_of_objects_2 / 100, delta); } } -TEST(GrowAndShrinkNewSpace) { - InitializeVM(); - NewSpace* new_space = HEAP->new_space(); - - // Explicitly growing should double the space capacity. - intptr_t old_capacity, new_capacity; - old_capacity = new_space->Capacity(); - new_space->Grow(); - new_capacity = new_space->Capacity(); - CHECK(2 * old_capacity == new_capacity); - - // Fill up new space to the point that it is completely full. Make sure - // that the scavenger does not undo the filling. - old_capacity = new_space->Capacity(); - { - v8::HandleScope scope; - AlwaysAllocateScope always_allocate; - intptr_t available = new_space->EffectiveCapacity() - new_space->Size(); - intptr_t number_of_fillers = (available / FixedArray::SizeFor(1000)) - 10; - for (intptr_t i = 0; i < number_of_fillers; i++) { - CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(1000, NOT_TENURED))); +class HeapIteratorTestHelper { + public: + HeapIteratorTestHelper(Object* a, Object* b) + : a_(a), b_(b), a_found_(false), b_found_(false) {} + bool a_found() { return a_found_; } + bool b_found() { return b_found_; } + void IterateHeap(HeapIterator::HeapObjectsFiltering mode) { + HeapIterator iterator(mode); + for (HeapObject* obj = iterator.next(); + obj != NULL; + obj = iterator.next()) { + if (obj == a_) + a_found_ = true; + else if (obj == b_) + b_found_ = true; } } - new_capacity = new_space->Capacity(); - CHECK(old_capacity == new_capacity); - - // Explicitly shrinking should not affect space capacity. - old_capacity = new_space->Capacity(); - new_space->Shrink(); - new_capacity = new_space->Capacity(); - CHECK(old_capacity == new_capacity); + private: + Object* a_; + Object* b_; + bool a_found_; + bool b_found_; +}; - // Let the scavenger empty the new space. - HEAP->CollectGarbage(NEW_SPACE); - CHECK_LE(new_space->Size(), old_capacity); - - // Explicitly shrinking should halve the space capacity. - old_capacity = new_space->Capacity(); - new_space->Shrink(); - new_capacity = new_space->Capacity(); - CHECK(old_capacity == 2 * new_capacity); - - // Consecutive shrinking should not affect space capacity. - old_capacity = new_space->Capacity(); - new_space->Shrink(); - new_space->Shrink(); - new_space->Shrink(); - new_capacity = new_space->Capacity(); - CHECK(old_capacity == new_capacity); +TEST(HeapIteratorFilterUnreachable) { + InitializeVM(); + v8::HandleScope scope; + CompileRun("a = {}; b = {};"); + v8::Handle<Object> a(ISOLATE->context()->global()->GetProperty( + *FACTORY->LookupAsciiSymbol("a"))->ToObjectChecked()); + v8::Handle<Object> b(ISOLATE->context()->global()->GetProperty( + *FACTORY->LookupAsciiSymbol("b"))->ToObjectChecked()); + CHECK_NE(*a, *b); + { + HeapIteratorTestHelper helper(*a, *b); + helper.IterateHeap(HeapIterator::kFilterUnreachable); + CHECK(helper.a_found()); + CHECK(helper.b_found()); + } + CHECK(ISOLATE->context()->global()->DeleteProperty( + *FACTORY->LookupAsciiSymbol("a"), JSObject::FORCE_DELETION)); + // We ensure that GC will not happen, so our raw pointer stays valid. + AssertNoAllocation no_alloc; + Object* a_saved = *a; + a.Clear(); + // Verify that "a" object still resides in the heap... + { + HeapIteratorTestHelper helper(a_saved, *b); + helper.IterateHeap(HeapIterator::kNoFiltering); + CHECK(helper.a_found()); + CHECK(helper.b_found()); + } + // ...but is now unreachable. + { + HeapIteratorTestHelper helper(a_saved, *b); + helper.IterateHeap(HeapIterator::kFilterUnreachable); + CHECK(!helper.a_found()); + CHECK(helper.b_found()); + } } diff --git a/deps/v8/test/cctest/test-log.cc b/deps/v8/test/cctest/test-log.cc index 6f2324dbb8..72e663c462 100644 --- a/deps/v8/test/cctest/test-log.cc +++ b/deps/v8/test/cctest/test-log.cc @@ -494,7 +494,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { " (function a(j) { return function b() { return j; } })(100);\n" "})(this);"); v8::V8::PauseProfiler(); - HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); + HEAP->CollectAllGarbage(true); LOGGER->StringEvent("test-logging-done", ""); // Iterate heap to find compiled functions, will write to log. diff --git a/deps/v8/test/cctest/test-mark-compact.cc b/deps/v8/test/cctest/test-mark-compact.cc index e99e1e5de0..dcb51a0bcb 100644 --- a/deps/v8/test/cctest/test-mark-compact.cc +++ b/deps/v8/test/cctest/test-mark-compact.cc @@ -44,21 +44,21 @@ static void InitializeVM() { } -TEST(MarkingDeque) { +TEST(MarkingStack) { int mem_size = 20 * kPointerSize; byte* mem = NewArray<byte>(20*kPointerSize); Address low = reinterpret_cast<Address>(mem); Address high = low + mem_size; - MarkingDeque s; + MarkingStack s; s.Initialize(low, high); Address address = NULL; - while (!s.IsFull()) { - s.PushBlack(HeapObject::FromAddress(address)); + while (!s.is_full()) { + s.Push(HeapObject::FromAddress(address)); address += kPointerSize; } - while (!s.IsEmpty()) { + while (!s.is_empty()) { Address value = s.Pop()->address(); address -= kPointerSize; CHECK_EQ(address, value); @@ -78,7 +78,7 @@ TEST(Promotion) { // from new space. FLAG_gc_global = true; FLAG_always_compact = true; - HEAP->ConfigureHeap(2*256*KB, 8*MB, 8*MB); + HEAP->ConfigureHeap(2*256*KB, 4*MB, 4*MB); InitializeVM(); @@ -104,7 +104,7 @@ TEST(Promotion) { TEST(NoPromotion) { - HEAP->ConfigureHeap(2*256*KB, 8*MB, 8*MB); + HEAP->ConfigureHeap(2*256*KB, 4*MB, 4*MB); // Test the situation that some objects in new space are promoted to // the old space @@ -116,12 +116,9 @@ TEST(NoPromotion) { HEAP->CollectGarbage(OLD_POINTER_SPACE); // Allocate a big Fixed array in the new space. - int max_size = - Min(HEAP->MaxObjectSizeInPagedSpace(), HEAP->MaxObjectSizeInNewSpace()); - - int length = (max_size - FixedArray::kHeaderSize) / (2*kPointerSize); - Object* obj = i::Isolate::Current()->heap()->AllocateFixedArray(length)-> - ToObjectChecked(); + int size = (HEAP->MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / + kPointerSize; + Object* obj = HEAP->AllocateFixedArray(size)->ToObjectChecked(); Handle<FixedArray> array(FixedArray::cast(obj)); @@ -231,8 +228,6 @@ TEST(MarkCompactCollector) { } -// TODO(1600): compaction of map space is temporary removed from GC. -#if 0 static Handle<Map> CreateMap() { return FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); } @@ -257,11 +252,11 @@ TEST(MapCompact) { // be able to trigger map compaction. // To give an additional chance to fail, try to force compaction which // should be impossible right now. - HEAP->CollectAllGarbage(Heap::kForceCompactionMask); + HEAP->CollectAllGarbage(true); // And now map pointers should be encodable again. CHECK(HEAP->map_space()->MapPointersEncodable()); } -#endif + static int gc_starts = 0; static int gc_ends = 0; diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index def829c297..76fd244e97 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -52,7 +52,7 @@ TEST(TokenEnumerator) { CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); } CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); - HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index b778478833..89a911274b 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -530,7 +530,7 @@ class TestConfig { typedef int Key; typedef int Value; static const int kNoKey; - static int NoValue() { return 0; } + static const int kNoValue; static inline int Compare(int a, int b) { if (a < b) return -1; @@ -543,6 +543,7 @@ class TestConfig { const int TestConfig::kNoKey = 0; +const int TestConfig::kNoValue = 0; static unsigned PseudoRandom(int i, int j) { diff --git a/deps/v8/test/cctest/test-reloc-info.cc b/deps/v8/test/cctest/test-reloc-info.cc index e638201db2..5bdc4c3e6a 100644 --- a/deps/v8/test/cctest/test-reloc-info.cc +++ b/deps/v8/test/cctest/test-reloc-info.cc @@ -34,7 +34,7 @@ namespace internal { static void WriteRinfo(RelocInfoWriter* writer, byte* pc, RelocInfo::Mode mode, intptr_t data) { - RelocInfo rinfo(pc, mode, data, NULL); + RelocInfo rinfo(pc, mode, data); writer->Write(&rinfo); } diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index cccd2eec0c..8e85444eee 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -114,6 +114,10 @@ TEST(ExternalReferenceEncoder) { ExternalReference(isolate->counters()->keyed_load_function_prototype()); CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), encoder.Encode(keyed_load_function_prototype.address())); + ExternalReference the_hole_value_location = + ExternalReference::the_hole_value_location(isolate); + CHECK_EQ(make_code(UNCLASSIFIED, 2), + encoder.Encode(the_hole_value_location.address())); ExternalReference stack_limit_address = ExternalReference::address_of_stack_limit(isolate); CHECK_EQ(make_code(UNCLASSIFIED, 4), @@ -123,7 +127,7 @@ TEST(ExternalReferenceEncoder) { CHECK_EQ(make_code(UNCLASSIFIED, 5), encoder.Encode(real_stack_limit_address.address())); #ifdef ENABLE_DEBUGGER_SUPPORT - CHECK_EQ(make_code(UNCLASSIFIED, 16), + CHECK_EQ(make_code(UNCLASSIFIED, 15), encoder.Encode(ExternalReference::debug_break(isolate).address())); #endif // ENABLE_DEBUGGER_SUPPORT CHECK_EQ(make_code(UNCLASSIFIED, 10), @@ -153,13 +157,15 @@ TEST(ExternalReferenceDecoder) { decoder.Decode( make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype))); + CHECK_EQ(ExternalReference::the_hole_value_location(isolate).address(), + decoder.Decode(make_code(UNCLASSIFIED, 2))); CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 4))); CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 5))); #ifdef ENABLE_DEBUGGER_SUPPORT CHECK_EQ(ExternalReference::debug_break(isolate).address(), - decoder.Decode(make_code(UNCLASSIFIED, 16))); + decoder.Decode(make_code(UNCLASSIFIED, 15))); #endif // ENABLE_DEBUGGER_SUPPORT CHECK_EQ(ExternalReference::new_space_start(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 10))); @@ -359,8 +365,8 @@ TEST(PartialSerialization) { Isolate::Current()->bootstrapper()->NativesSourceLookup(i); } } - HEAP->CollectAllGarbage(Heap::kNoGCFlags); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); Object* raw_foo; { @@ -484,7 +490,7 @@ TEST(ContextSerialization) { } // If we don't do this then we end up with a stray root pointing at the // context even after we have disposed of env. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + HEAP->CollectAllGarbage(true); int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; Vector<char> startup_name = Vector<char>::New(file_name_length + 1); @@ -557,19 +563,16 @@ DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { TEST(LinearAllocation) { v8::V8::Initialize(); int new_space_max = 512 * KB; - int paged_space_max = Page::kMaxHeapObjectSize; for (int size = 1000; size < 5 * MB; size += size >> 1) { - size &= ~8; // Round. int new_space_size = (size < new_space_max) ? size : new_space_max; - int paged_space_size = (size < paged_space_max) ? size : paged_space_max; HEAP->ReserveSpace( new_space_size, - paged_space_size, // Old pointer space. - paged_space_size, // Old data space. - HEAP->code_space()->RoundSizeDownToObjectAlignment(paged_space_size), - HEAP->map_space()->RoundSizeDownToObjectAlignment(paged_space_size), - HEAP->cell_space()->RoundSizeDownToObjectAlignment(paged_space_size), + size, // Old pointer space. + size, // Old data space. + size, // Code space. + size, // Map space. + size, // Cell space. size); // Large object space. LinearAllocationScope linear_allocation_scope; const int kSmallFixedArrayLength = 4; @@ -596,7 +599,7 @@ TEST(LinearAllocation) { Object* pointer_last = NULL; for (int i = 0; - i + kSmallFixedArraySize <= paged_space_size; + i + kSmallFixedArraySize <= size; i += kSmallFixedArraySize) { Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength, TENURED)->ToObjectChecked(); @@ -615,9 +618,7 @@ TEST(LinearAllocation) { } Object* data_last = NULL; - for (int i = 0; - i + kSmallStringSize <= paged_space_size; - i += kSmallStringSize) { + for (int i = 0; i + kSmallStringSize <= size; i += kSmallStringSize) { Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength, TENURED)->ToObjectChecked(); int old_page_fullness = i % Page::kPageSize; @@ -635,7 +636,7 @@ TEST(LinearAllocation) { } Object* map_last = NULL; - for (int i = 0; i + kMapSize <= paged_space_size; i += kMapSize) { + for (int i = 0; i + kMapSize <= size; i += kMapSize) { Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE, 42 * kPointerSize)->ToObjectChecked(); int old_page_fullness = i % Page::kPageSize; diff --git a/deps/v8/test/cctest/test-spaces.cc b/deps/v8/test/cctest/test-spaces.cc index ee60086ed2..0f22ce1a9b 100644 --- a/deps/v8/test/cctest/test-spaces.cc +++ b/deps/v8/test/cctest/test-spaces.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// Copyright 2006-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: @@ -32,9 +32,7 @@ using namespace v8::internal; -#if 0 static void VerifyRegionMarking(Address page_start) { -#ifdef ENABLE_CARDMARKING_WRITE_BARRIER Page* p = Page::FromAddress(page_start); p->SetRegionMarks(Page::kAllRegionsCleanMarks); @@ -56,13 +54,9 @@ static void VerifyRegionMarking(Address page_start) { addr += kPointerSize) { CHECK(Page::FromAddress(addr)->IsRegionDirty(addr)); } -#endif } -#endif -// TODO(gc) you can no longer allocate pages like this. Details are hidden. -#if 0 TEST(Page) { byte* mem = NewArray<byte>(2*Page::kPageSize); CHECK(mem != NULL); @@ -95,7 +89,6 @@ TEST(Page) { DeleteArray(mem); } -#endif namespace v8 { @@ -129,46 +122,62 @@ TEST(MemoryAllocator) { Isolate* isolate = Isolate::Current(); isolate->InitializeLoggingAndCounters(); Heap* heap = isolate->heap(); - CHECK(isolate->heap()->ConfigureHeapDefault()); - + CHECK(heap->ConfigureHeapDefault()); MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); CHECK(memory_allocator->Setup(heap->MaxReserved(), heap->MaxExecutableSize())); + TestMemoryAllocatorScope test_scope(isolate, memory_allocator); - int total_pages = 0; OldSpace faked_space(heap, heap->MaxReserved(), OLD_POINTER_SPACE, NOT_EXECUTABLE); - Page* first_page = - memory_allocator->AllocatePage(&faked_space, NOT_EXECUTABLE); - - first_page->InsertAfter(faked_space.anchor()->prev_page()); + int total_pages = 0; + int requested = MemoryAllocator::kPagesPerChunk; + int allocated; + // If we request n pages, we should get n or n - 1. + Page* first_page = memory_allocator->AllocatePages( + requested, &allocated, &faked_space); CHECK(first_page->is_valid()); - CHECK(first_page->next_page() == faked_space.anchor()); - total_pages++; + CHECK(allocated == requested || allocated == requested - 1); + total_pages += allocated; - for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { - CHECK(p->owner() == &faked_space); + Page* last_page = first_page; + for (Page* p = first_page; p->is_valid(); p = p->next_page()) { + CHECK(memory_allocator->IsPageInSpace(p, &faked_space)); + last_page = p; } // Again, we should get n or n - 1 pages. - Page* other = - memory_allocator->AllocatePage(&faked_space, NOT_EXECUTABLE); - CHECK(other->is_valid()); - total_pages++; - other->InsertAfter(first_page); + Page* others = memory_allocator->AllocatePages( + requested, &allocated, &faked_space); + CHECK(others->is_valid()); + CHECK(allocated == requested || allocated == requested - 1); + total_pages += allocated; + + memory_allocator->SetNextPage(last_page, others); int page_count = 0; - for (Page* p = first_page; p != faked_space.anchor(); p = p->next_page()) { - CHECK(p->owner() == &faked_space); + for (Page* p = first_page; p->is_valid(); p = p->next_page()) { + CHECK(memory_allocator->IsPageInSpace(p, &faked_space)); page_count++; } CHECK(total_pages == page_count); Page* second_page = first_page->next_page(); CHECK(second_page->is_valid()); - memory_allocator->Free(first_page); - memory_allocator->Free(second_page); + + // Freeing pages at the first chunk starting at or after the second page + // should free the entire second chunk. It will return the page it was passed + // (since the second page was in the first chunk). + Page* free_return = memory_allocator->FreePages(second_page); + CHECK(free_return == second_page); + memory_allocator->SetNextPage(first_page, free_return); + + // Freeing pages in the first chunk starting at the first page should free + // the first chunk and return an invalid page. + Page* invalid_page = memory_allocator->FreePages(first_page); + CHECK(!invalid_page->is_valid()); + memory_allocator->TearDown(); delete memory_allocator; } @@ -187,8 +196,12 @@ TEST(NewSpace) { NewSpace new_space(heap); - CHECK(new_space.Setup(HEAP->ReservedSemiSpaceSize(), - HEAP->ReservedSemiSpaceSize())); + void* chunk = + memory_allocator->ReserveInitialChunk(4 * heap->ReservedSemiSpaceSize()); + CHECK(chunk != NULL); + Address start = RoundUp(static_cast<Address>(chunk), + 2 * heap->ReservedSemiSpaceSize()); + CHECK(new_space.Setup(start, 2 * heap->ReservedSemiSpaceSize())); CHECK(new_space.HasBeenSetup()); while (new_space.Available() >= Page::kMaxHeapObjectSize) { @@ -220,7 +233,13 @@ TEST(OldSpace) { NOT_EXECUTABLE); CHECK(s != NULL); - CHECK(s->Setup()); + void* chunk = memory_allocator->ReserveInitialChunk( + 4 * heap->ReservedSemiSpaceSize()); + CHECK(chunk != NULL); + Address start = static_cast<Address>(chunk); + size_t size = RoundUp(start, 2 * heap->ReservedSemiSpaceSize()) - start; + + CHECK(s->Setup(start, size)); while (s->Available() > 0) { s->AllocateRaw(Page::kMaxHeapObjectSize)->ToObjectUnchecked(); @@ -239,12 +258,14 @@ TEST(LargeObjectSpace) { LargeObjectSpace* lo = HEAP->lo_space(); CHECK(lo != NULL); + Map* faked_map = reinterpret_cast<Map*>(HeapObject::FromAddress(0)); int lo_size = Page::kPageSize; - Object* obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->ToObjectUnchecked(); + Object* obj = lo->AllocateRaw(lo_size)->ToObjectUnchecked(); CHECK(obj->IsHeapObject()); HeapObject* ho = HeapObject::cast(obj); + ho->set_map(faked_map); CHECK(lo->Contains(HeapObject::cast(obj))); @@ -254,13 +275,14 @@ TEST(LargeObjectSpace) { while (true) { intptr_t available = lo->Available(); - { MaybeObject* maybe_obj = lo->AllocateRaw(lo_size, NOT_EXECUTABLE); + { MaybeObject* maybe_obj = lo->AllocateRaw(lo_size); if (!maybe_obj->ToObject(&obj)) break; } + HeapObject::cast(obj)->set_map(faked_map); CHECK(lo->Available() < available); }; CHECK(!lo->IsEmpty()); - CHECK(lo->AllocateRaw(lo_size, NOT_EXECUTABLE)->IsFailure()); + CHECK(lo->AllocateRaw(lo_size)->IsFailure()); } diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index 93f7588d36..55c21417d0 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -1,4 +1,4 @@ -// Copyright 2011 the V8 project authors. All rights reserved. +// Copyright 2006-2008 the V8 project authors. All rights reserved. // Check that we can traverse very deep stacks of ConsStrings using // StringInputBuffer. Check that Get(int) works on very deep stacks @@ -502,35 +502,6 @@ TEST(SliceFromCons) { } -class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { - public: - explicit AsciiVectorResource(i::Vector<const char> vector) - : data_(vector) {} - virtual ~AsciiVectorResource() {} - virtual size_t length() const { return data_.length(); } - virtual const char* data() const { return data_.start(); } - private: - i::Vector<const char> data_; -}; - - -TEST(SliceFromExternal) { - FLAG_string_slices = true; - InitializeVM(); - v8::HandleScope scope; - AsciiVectorResource resource( - i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26)); - Handle<String> string = FACTORY->NewExternalStringFromAscii(&resource); - CHECK(string->IsExternalString()); - Handle<String> slice = FACTORY->NewSubString(string, 1, 25); - CHECK(slice->IsSlicedString()); - CHECK(string->IsExternalString()); - CHECK_EQ(SlicedString::cast(*slice)->parent(), *string); - CHECK(SlicedString::cast(*slice)->parent()->IsExternalString()); - CHECK(slice->IsFlat()); -} - - TEST(TrivialSlice) { // This tests whether a slice that contains the entire parent string // actually creates a new string (it should not). diff --git a/deps/v8/test/cctest/test-threads.cc b/deps/v8/test/cctest/test-threads.cc index 713d1e8425..985b9e5b99 100644 --- a/deps/v8/test/cctest/test-threads.cc +++ b/deps/v8/test/cctest/test-threads.cc @@ -63,7 +63,7 @@ enum Turn { static Turn turn = FILL_CACHE; -class ThreadA : public v8::internal::Thread { +class ThreadA: public v8::internal::Thread { public: ThreadA() : Thread("ThreadA") { } void Run() { @@ -99,7 +99,7 @@ class ThreadA : public v8::internal::Thread { }; -class ThreadB : public v8::internal::Thread { +class ThreadB: public v8::internal::Thread { public: ThreadB() : Thread("ThreadB") { } void Run() { @@ -111,7 +111,7 @@ class ThreadB : public v8::internal::Thread { v8::Context::Scope context_scope(v8::Context::New()); // Clear the caches by forcing major GC. - HEAP->CollectAllGarbage(v8::internal::Heap::kNoGCFlags); + HEAP->CollectAllGarbage(false); turn = SECOND_TIME_FILL_CACHE; break; } @@ -190,19 +190,3 @@ TEST(ThreadIdValidation) { delete threads[i]; } } - - -class ThreadC : public v8::internal::Thread { - public: - ThreadC() : Thread("ThreadC") { } - void Run() { - Join(); - } -}; - - -TEST(ThreadJoinSelf) { - ThreadC thread; - thread.Start(); - thread.Join(); -} diff --git a/deps/v8/test/cctest/test-weakmaps.cc b/deps/v8/test/cctest/test-weakmaps.cc index 56d593628a..db4db25435 100644 --- a/deps/v8/test/cctest/test-weakmaps.cc +++ b/deps/v8/test/cctest/test-weakmaps.cc @@ -50,7 +50,7 @@ static void PutIntoWeakMap(Handle<JSWeakMap> weakmap, Handle<JSObject> key, int value) { Handle<ObjectHashTable> table = PutIntoObjectHashTable( - Handle<ObjectHashTable>(ObjectHashTable::cast(weakmap->table())), + Handle<ObjectHashTable>(weakmap->table()), Handle<JSObject>(JSObject::cast(*key)), Handle<Smi>(Smi::FromInt(value))); weakmap->set_table(*table); @@ -85,14 +85,13 @@ TEST(Weakness) { v8::HandleScope scope; PutIntoWeakMap(weakmap, Handle<JSObject>(JSObject::cast(*key)), 23); } - CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); + CHECK_EQ(1, weakmap->table()->NumberOfElements()); // Force a full GC. HEAP->CollectAllGarbage(false); CHECK_EQ(0, NumberOfWeakCalls); - CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); - CHECK_EQ( - 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); + CHECK_EQ(1, weakmap->table()->NumberOfElements()); + CHECK_EQ(0, weakmap->table()->NumberOfDeletedElements()); // Make the global reference to the key weak. { @@ -108,14 +107,12 @@ TEST(Weakness) { // weak references whereas the second one will also clear weak maps. HEAP->CollectAllGarbage(false); CHECK_EQ(1, NumberOfWeakCalls); - CHECK_EQ(1, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); - CHECK_EQ( - 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); + CHECK_EQ(1, weakmap->table()->NumberOfElements()); + CHECK_EQ(0, weakmap->table()->NumberOfDeletedElements()); HEAP->CollectAllGarbage(false); CHECK_EQ(1, NumberOfWeakCalls); - CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); - CHECK_EQ( - 1, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); + CHECK_EQ(0, weakmap->table()->NumberOfElements()); + CHECK_EQ(1, weakmap->table()->NumberOfDeletedElements()); } @@ -125,7 +122,7 @@ TEST(Shrinking) { Handle<JSWeakMap> weakmap = AllocateJSWeakMap(); // Check initial capacity. - CHECK_EQ(32, ObjectHashTable::cast(weakmap->table())->Capacity()); + CHECK_EQ(32, weakmap->table()->Capacity()); // Fill up weak map to trigger capacity change. { @@ -138,17 +135,15 @@ TEST(Shrinking) { } // Check increased capacity. - CHECK_EQ(128, ObjectHashTable::cast(weakmap->table())->Capacity()); + CHECK_EQ(128, weakmap->table()->Capacity()); // Force a full GC. - CHECK_EQ(32, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); - CHECK_EQ( - 0, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); + CHECK_EQ(32, weakmap->table()->NumberOfElements()); + CHECK_EQ(0, weakmap->table()->NumberOfDeletedElements()); HEAP->CollectAllGarbage(false); - CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); - CHECK_EQ( - 32, ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); + CHECK_EQ(0, weakmap->table()->NumberOfElements()); + CHECK_EQ(32, weakmap->table()->NumberOfDeletedElements()); // Check shrunk capacity. - CHECK_EQ(32, ObjectHashTable::cast(weakmap->table())->Capacity()); + CHECK_EQ(32, weakmap->table()->Capacity()); } |