diff options
| author | Steve Block <steveblock@google.com> | 2011-05-26 01:26:41 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2011-06-02 15:09:56 +0100 |
| commit | 44f0eee88ff00398ff7f715fab053374d808c90d (patch) | |
| tree | addd100e906cd43f843f3aaf64b445f17f46fe0f /test | |
| parent | 1b63b9ad386abd62f61af0e29246a687f5311b53 (diff) | |
| download | android_external_v8-44f0eee88ff00398ff7f715fab053374d808c90d.tar.gz android_external_v8-44f0eee88ff00398ff7f715fab053374d808c90d.tar.bz2 android_external_v8-44f0eee88ff00398ff7f715fab053374d808c90d.zip | |
Update V8 to r7427: Initial merge by git
As required by WebKit r82507
Change-Id: I7ae83ef3f689356043b4929255b7c1dd31d8c5df
Diffstat (limited to 'test')
81 files changed, 6318 insertions, 1545 deletions
diff --git a/test/benchmarks/testcfg.py b/test/benchmarks/testcfg.py new file mode 100644 index 00000000..51d85208 --- /dev/null +++ b/test/benchmarks/testcfg.py @@ -0,0 +1,100 @@ +# Copyright 2011 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +import test +import os +from os.path import join, split + +def IsNumber(string): + try: + float(string) + return True + except ValueError: + return False + + +class BenchmarkTestCase(test.TestCase): + + def __init__(self, path, context, mode): + super(BenchmarkTestCase, self).__init__(context, split(path), mode) + self.root = path + + def GetLabel(self): + return '%s benchmark %s' % (self.mode, self.GetName()) + + def IsFailureOutput(self, output): + if output.exit_code != 0: + return True + lines = output.stdout.splitlines() + for line in lines: + colon_index = line.find(':') + if colon_index >= 0: + if not IsNumber(line[colon_index+1:].strip()): + return True + return False + + def GetCommand(self): + result = self.context.GetVmCommand(self, self.mode) + result.append(join(self.root, 'run.js')) + return result + + def GetName(self): + return 'V8' + + def BeforeRun(self): + os.chdir(self.root) + + def AfterRun(self, result): + os.chdir(self.context.buildspace) + + def GetSource(self): + return open(join(self.root, 'run.js')).read() + + def GetCustomFlags(self, mode): + return [] + + +class BenchmarkTestConfiguration(test.TestConfiguration): + + def __init__(self, context, root): + super(BenchmarkTestConfiguration, self).__init__(context, root) + + def ListTests(self, current_path, path, mode, variant_flags): + path = self.context.workspace + path = join(path, 'benchmarks') + test = BenchmarkTestCase(path, self.context, mode) + return [test] + + def GetBuildRequirements(self): + return ['sample', 'sample=shell'] + + def GetTestStatus(self, sections, defs): + pass + +def GetConfiguration(context, root): + return BenchmarkTestConfiguration(context, root) diff --git a/test/cctest/SConscript b/test/cctest/SConscript index 70381377..f4cb4a9a 100644 --- a/test/cctest/SConscript +++ b/test/cctest/SConscript @@ -41,8 +41,8 @@ SOURCES = { 'test-alloc.cc', 'test-api.cc', 'test-ast.cc', - 'test-bignum.cc', 'test-bignum-dtoa.cc', + 'test-bignum.cc', 'test-circular-queue.cc', 'test-compiler.cc', 'test-conversions.cc', @@ -59,15 +59,16 @@ SOURCES = { 'test-flags.cc', 'test-func-name-inference.cc', 'test-hashmap.cc', - 'test-heap.cc', 'test-heap-profiler.cc', + 'test-heap.cc', 'test-list.cc', 'test-liveedit.cc', 'test-lock.cc', - 'test-log.cc', 'test-log-utils.cc', + 'test-log.cc', 'test-mark-compact.cc', 'test-parsing.cc', + 'test-platform-tls.cc', 'test-profile-generator.cc', 'test-regexp.cc', 'test-reloc-info.cc', @@ -95,7 +96,7 @@ SOURCES = { 'arch:x64': ['test-assembler-x64.cc', 'test-macro-assembler-x64.cc', 'test-log-stack-tracer.cc'], - 'arch:mips': ['test-assembler-mips.cc', 'test-mips.cc'], + 'arch:mips': ['test-assembler-mips.cc'], 'os:linux': ['test-platform-linux.cc'], 'os:macos': ['test-platform-macos.cc'], 'os:nullos': ['test-platform-nullos.cc'], diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h index 404b692b..277593c3 100644 --- a/test/cctest/cctest.h +++ b/test/cctest/cctest.h @@ -87,8 +87,9 @@ class CcTest { class ApiTestFuzzer: public v8::internal::Thread { public: void CallTest(); - explicit ApiTestFuzzer(int num) - : test_number_(num), + explicit ApiTestFuzzer(v8::internal::Isolate* isolate, int num) + : Thread(isolate, "ApiTestFuzzer"), + test_number_(num), gate_(v8::internal::OS::CreateSemaphore(0)), active_(true) { } diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status index e573eb29..986fb8d7 100644 --- a/test/cctest/cctest.status +++ b/test/cctest/cctest.status @@ -36,11 +36,6 @@ test-debug/DebuggerAgent: PASS, (PASS || FAIL) if $system == linux # 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 @@ -62,12 +57,6 @@ test-log/ProfLazyMode: SKIP test-debug/DebuggerAgentProtocolOverflowHeader: SKIP test-sockets/Socket: SKIP -# BUG(1075): Some deserialization tests fail om ARM -test-serialize/Deserialize: SKIP -test-serialize/DeserializeFromSecondSerializationAndRunScript2: SKIP -test-serialize/DeserializeAndRunScript2: SKIP -test-serialize/DeserializeFromSecondSerialization: SKIP - ############################################################################## [ $arch == arm && $crankshaft ] @@ -85,15 +74,21 @@ test-compiler: SKIP test-cpu-profiler: SKIP test-debug: SKIP test-decls: SKIP +test-deoptimization: SKIP test-func-name-inference: SKIP test-heap: SKIP test-heap-profiler: SKIP test-log: SKIP test-log-utils: SKIP test-mark-compact: SKIP +test-parsing: SKIP +test-profile-generator: SKIP test-regexp: SKIP test-serialize: SKIP test-sockets: SKIP test-strings: SKIP test-threads: SKIP test-thread-termination: SKIP + +############################################################################## +# Tests that time out with Isolates diff --git a/test/cctest/test-accessors.cc b/test/cctest/test-accessors.cc index 25f5c395..b74f166f 100644 --- a/test/cctest/test-accessors.cc +++ b/test/cctest/test-accessors.cc @@ -243,7 +243,7 @@ static v8::Handle<Value> CheckAccessorArgsCorrect(Local<String> name, ApiTestFuzzer::Fuzz(); CHECK(info.This() == info.Holder()); CHECK(info.Data()->Equals(v8::String::New("data"))); - i::Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); CHECK(info.This() == info.Holder()); CHECK(info.Data()->Equals(v8::String::New("data"))); return v8::Integer::New(17); @@ -397,9 +397,9 @@ static v8::Handle<Value> StackCheck(Local<String> name, for (int i = 0; !iter.done(); i++) { i::StackFrame* frame = iter.frame(); CHECK(i != 0 || (frame->type() == i::StackFrame::EXIT)); - CHECK(frame->code()->IsCode()); + i::Code* code = frame->LookupCode(i::Isolate::Current()); + CHECK(code->IsCode()); i::Address pc = frame->pc(); - i::Code* code = frame->code(); CHECK(code->contains(pc)); iter.Advance(); } diff --git a/test/cctest/test-alloc.cc b/test/cctest/test-alloc.cc index d2a28d7f..3d8157d9 100644 --- a/test/cctest/test-alloc.cc +++ b/test/cctest/test-alloc.cc @@ -27,7 +27,6 @@ #include "v8.h" #include "accessors.h" -#include "top.h" #include "cctest.h" @@ -38,13 +37,14 @@ using namespace v8::internal; static MaybeObject* AllocateAfterFailures() { static int attempts = 0; if (++attempts < 3) return Failure::RetryAfterGC(); + Heap* heap = Isolate::Current()->heap(); // New space. - NewSpace* new_space = Heap::new_space(); + NewSpace* new_space = heap->new_space(); static const int kNewSpaceFillerSize = ByteArray::SizeFor(0); while (new_space->Available() > kNewSpaceFillerSize) { int available_before = static_cast<int>(new_space->Available()); - CHECK(!Heap::AllocateByteArray(0)->IsFailure()); + CHECK(!heap->AllocateByteArray(0)->IsFailure()); if (available_before == new_space->Available()) { // It seems that we are avoiding new space allocations when // allocation is forced, so no need to fill up new space @@ -52,45 +52,46 @@ static MaybeObject* AllocateAfterFailures() { break; } } - CHECK(!Heap::AllocateByteArray(100)->IsFailure()); - CHECK(!Heap::AllocateFixedArray(100, NOT_TENURED)->IsFailure()); + CHECK(!heap->AllocateByteArray(100)->IsFailure()); + CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); // Make sure we can allocate through optimized allocation functions // for specific kinds. - CHECK(!Heap::AllocateFixedArray(100)->IsFailure()); - CHECK(!Heap::AllocateHeapNumber(0.42)->IsFailure()); - CHECK(!Heap::AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); - Object* object = - Heap::AllocateJSObject(*Top::object_function())->ToObjectChecked(); - CHECK(!Heap::CopyJSObject(JSObject::cast(object))->IsFailure()); + CHECK(!heap->AllocateFixedArray(100)->IsFailure()); + CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); + CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); + Object* object = heap->AllocateJSObject( + *Isolate::Current()->object_function())->ToObjectChecked(); + CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure()); // Old data space. - OldSpace* old_data_space = Heap::old_data_space(); + OldSpace* old_data_space = heap->old_data_space(); static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0); while (old_data_space->Available() > kOldDataSpaceFillerSize) { - CHECK(!Heap::AllocateByteArray(0, TENURED)->IsFailure()); + CHECK(!heap->AllocateByteArray(0, TENURED)->IsFailure()); } - CHECK(!Heap::AllocateRawAsciiString(100, TENURED)->IsFailure()); + CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure()); // Large object space. - while (!Heap::OldGenerationAllocationLimitReached()) { - CHECK(!Heap::AllocateFixedArray(10000, TENURED)->IsFailure()); + while (!heap->OldGenerationAllocationLimitReached()) { + CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); } - CHECK(!Heap::AllocateFixedArray(10000, TENURED)->IsFailure()); + CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); // Map space. - MapSpace* map_space = Heap::map_space(); + MapSpace* map_space = heap->map_space(); static const int kMapSpaceFillerSize = Map::kSize; InstanceType instance_type = JS_OBJECT_TYPE; int instance_size = JSObject::kHeaderSize; while (map_space->Available() > kMapSpaceFillerSize) { - CHECK(!Heap::AllocateMap(instance_type, instance_size)->IsFailure()); + CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure()); } - CHECK(!Heap::AllocateMap(instance_type, instance_size)->IsFailure()); + CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure()); // Test that we can allocate in old pointer space and code space. - CHECK(!Heap::AllocateFixedArray(100, TENURED)->IsFailure()); - CHECK(!Heap::CopyCode(Builtins::builtin(Builtins::Illegal))->IsFailure()); + CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure()); + CHECK(!heap->CopyCode(Isolate::Current()->builtins()->builtin( + Builtins::kIllegal))->IsFailure()); // Return success. return Smi::FromInt(42); @@ -98,7 +99,7 @@ static MaybeObject* AllocateAfterFailures() { static Handle<Object> Test() { - CALL_HEAP_FUNCTION(AllocateAfterFailures(), Object); + CALL_HEAP_FUNCTION(ISOLATE, AllocateAfterFailures(), Object); } @@ -129,18 +130,19 @@ TEST(StressJS) { v8::HandleScope scope; env->Enter(); Handle<JSFunction> function = - Factory::NewFunction(Factory::function_symbol(), Factory::null_value()); + FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value()); // Force the creation of an initial map and set the code to // something empty. - Factory::NewJSObject(function); - function->ReplaceCode(Builtins::builtin(Builtins::EmptyFunction)); + FACTORY->NewJSObject(function); + function->ReplaceCode(Isolate::Current()->builtins()->builtin( + Builtins::kEmptyFunction)); // Patch the map to have an accessor for "get". Handle<Map> map(function->initial_map()); Handle<DescriptorArray> instance_descriptors(map->instance_descriptors()); - Handle<Proxy> proxy = Factory::NewProxy(&kDescriptor); - instance_descriptors = Factory::CopyAppendProxyDescriptor( + Handle<Proxy> proxy = FACTORY->NewProxy(&kDescriptor); + instance_descriptors = FACTORY->CopyAppendProxyDescriptor( instance_descriptors, - Factory::NewStringFromAscii(Vector<const char>("get", 3)), + FACTORY->NewStringFromAscii(Vector<const char>("get", 3)), proxy, static_cast<PropertyAttributes>(0)); map->set_instance_descriptors(*instance_descriptors); @@ -183,7 +185,8 @@ class Block { TEST(CodeRange) { const int code_range_size = 16*MB; - CodeRange::Setup(code_range_size); + OS::Setup(); + Isolate::Current()->code_range()->Setup(code_range_size); int current_allocated = 0; int total_allocated = 0; List<Block> blocks(1000); @@ -195,14 +198,16 @@ TEST(CodeRange) { size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + Pseudorandom() % 5000 + 1; size_t allocated = 0; - void* base = CodeRange::AllocateRawMemory(requested, &allocated); + void* base = Isolate::Current()->code_range()-> + AllocateRawMemory(requested, &allocated); blocks.Add(Block(base, static_cast<int>(allocated))); current_allocated += static_cast<int>(allocated); total_allocated += static_cast<int>(allocated); } else { // Free a block. int index = Pseudorandom() % blocks.length(); - CodeRange::FreeRawMemory(blocks[index].base, blocks[index].size); + Isolate::Current()->code_range()->FreeRawMemory( + blocks[index].base, blocks[index].size); current_allocated -= blocks[index].size; if (index < blocks.length() - 1) { blocks[index] = blocks.RemoveLast(); @@ -212,5 +217,5 @@ TEST(CodeRange) { } } - CodeRange::TearDown(); + Isolate::Current()->code_range()->TearDown(); } diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index cd264127..33d505ea 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -34,7 +34,6 @@ #include "execution.h" #include "snapshot.h" #include "platform.h" -#include "top.h" #include "utils.h" #include "cctest.h" #include "parser.h" @@ -50,15 +49,19 @@ static bool IsNaN(double x) { #endif } -using ::v8::ObjectTemplate; -using ::v8::Value; +using ::v8::AccessorInfo; using ::v8::Context; +using ::v8::Extension; +using ::v8::Function; +using ::v8::HandleScope; using ::v8::Local; -using ::v8::String; +using ::v8::Object; +using ::v8::ObjectTemplate; +using ::v8::Persistent; using ::v8::Script; -using ::v8::Function; -using ::v8::AccessorInfo; -using ::v8::Extension; +using ::v8::String; +using ::v8::Value; +using ::v8::V8; namespace i = ::i; @@ -394,11 +397,11 @@ THREADED_TEST(ScriptUsingStringResource) { CHECK(source->IsExternal()); CHECK_EQ(resource, static_cast<TestResource*>(source->GetExternalStringResource())); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestResource::dispose_count); } - i::CompilationCache::Clear(); - i::Heap::CollectAllGarbage(false); + v8::internal::Isolate::Current()->compilation_cache()->Clear(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestResource::dispose_count); } @@ -415,11 +418,11 @@ THREADED_TEST(ScriptUsingAsciiStringResource) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestAsciiResource::dispose_count); } - i::CompilationCache::Clear(); - i::Heap::CollectAllGarbage(false); + i::Isolate::Current()->compilation_cache()->Clear(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResource::dispose_count); } @@ -432,19 +435,19 @@ THREADED_TEST(ScriptMakingExternalString) { LocalContext env; Local<String> source = String::New(two_byte_source); // Trigger GCs so that the newly allocated string moves to old gen. - i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now - i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now + HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now + HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now bool success = source->MakeExternal(new TestResource(two_byte_source)); CHECK(success); Local<Script> script = Script::Compile(source); Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestResource::dispose_count); } - i::CompilationCache::Clear(); - i::Heap::CollectAllGarbage(false); + i::Isolate::Current()->compilation_cache()->Clear(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestResource::dispose_count); } @@ -457,8 +460,8 @@ THREADED_TEST(ScriptMakingExternalAsciiString) { LocalContext env; Local<String> source = v8_str(c_source); // Trigger GCs so that the newly allocated string moves to old gen. - i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now - i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now + HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now + HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now bool success = source->MakeExternal( new TestAsciiResource(i::StrDup(c_source))); CHECK(success); @@ -466,11 +469,11 @@ THREADED_TEST(ScriptMakingExternalAsciiString) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestAsciiResource::dispose_count); } - i::CompilationCache::Clear(); - i::Heap::CollectAllGarbage(false); + i::Isolate::Current()->compilation_cache()->Clear(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResource::dispose_count); } @@ -480,8 +483,8 @@ TEST(MakingExternalStringConditions) { LocalContext env; // Free some space in the new space so that we can check freshness. - i::Heap::CollectGarbage(i::NEW_SPACE); - i::Heap::CollectGarbage(i::NEW_SPACE); + HEAP->CollectGarbage(i::NEW_SPACE); + HEAP->CollectGarbage(i::NEW_SPACE); uint16_t* two_byte_string = AsciiToTwoByteString("small"); Local<String> small_string = String::New(two_byte_string); @@ -490,8 +493,8 @@ TEST(MakingExternalStringConditions) { // We should refuse to externalize newly created small string. CHECK(!small_string->CanMakeExternal()); // Trigger GCs so that the newly allocated string moves to old gen. - i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now - i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now + HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now + HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now // Old space strings should be accepted. CHECK(small_string->CanMakeExternal()); @@ -526,15 +529,15 @@ TEST(MakingExternalAsciiStringConditions) { LocalContext env; // Free some space in the new space so that we can check freshness. - i::Heap::CollectGarbage(i::NEW_SPACE); - i::Heap::CollectGarbage(i::NEW_SPACE); + HEAP->CollectGarbage(i::NEW_SPACE); + HEAP->CollectGarbage(i::NEW_SPACE); Local<String> small_string = String::New("small"); // We should refuse to externalize newly created small string. CHECK(!small_string->CanMakeExternal()); // Trigger GCs so that the newly allocated string moves to old gen. - i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now - i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now + HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now + HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now // Old space strings should be accepted. CHECK(small_string->CanMakeExternal()); @@ -566,13 +569,13 @@ THREADED_TEST(UsingExternalString) { String::NewExternal(new TestResource(two_byte_string)); i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); // Trigger GCs so that the newly allocated string moves to old gen. - i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now - i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now - i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); + HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now + HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now + i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring); CHECK(isymbol->IsSymbol()); } - i::Heap::CollectAllGarbage(false); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -584,13 +587,13 @@ THREADED_TEST(UsingExternalAsciiString) { new TestAsciiResource(i::StrDup(one_byte_string))); i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); // Trigger GCs so that the newly allocated string moves to old gen. - i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now - i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now - i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); + HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now + HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now + i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring); CHECK(isymbol->IsSymbol()); } - i::Heap::CollectAllGarbage(false); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -603,12 +606,12 @@ THREADED_TEST(ScavengeExternalString) { Local<String> string = String::NewExternal(new TestResource(two_byte_string)); i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); - i::Heap::CollectGarbage(i::NEW_SPACE); - in_new_space = i::Heap::InNewSpace(*istring); - CHECK(in_new_space || i::Heap::old_data_space()->Contains(*istring)); + HEAP->CollectGarbage(i::NEW_SPACE); + in_new_space = HEAP->InNewSpace(*istring); + CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); CHECK_EQ(0, TestResource::dispose_count); } - i::Heap::CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); + HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); CHECK_EQ(1, TestResource::dispose_count); } @@ -622,12 +625,12 @@ THREADED_TEST(ScavengeExternalAsciiString) { Local<String> string = String::NewExternal( new TestAsciiResource(i::StrDup(one_byte_string))); i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); - i::Heap::CollectGarbage(i::NEW_SPACE); - in_new_space = i::Heap::InNewSpace(*istring); - CHECK(in_new_space || i::Heap::old_data_space()->Contains(*istring)); + HEAP->CollectGarbage(i::NEW_SPACE); + in_new_space = HEAP->InNewSpace(*istring); + CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); CHECK_EQ(0, TestAsciiResource::dispose_count); } - i::Heap::CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); + HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); CHECK_EQ(1, TestAsciiResource::dispose_count); } @@ -667,11 +670,11 @@ TEST(ExternalStringWithDisposeHandling) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestAsciiResource::dispose_count); } - i::CompilationCache::Clear(); - i::Heap::CollectAllGarbage(false); + i::Isolate::Current()->compilation_cache()->Clear(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); CHECK_EQ(0, TestAsciiResource::dispose_count); @@ -688,11 +691,11 @@ TEST(ExternalStringWithDisposeHandling) { Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(0, TestAsciiResource::dispose_count); } - i::CompilationCache::Clear(); - i::Heap::CollectAllGarbage(false); + i::Isolate::Current()->compilation_cache()->Clear(); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); CHECK_EQ(1, TestAsciiResource::dispose_count); } @@ -738,9 +741,9 @@ THREADED_TEST(StringConcat) { CHECK(value->IsNumber()); CHECK_EQ(68, value->Int32Value()); } - i::CompilationCache::Clear(); - i::Heap::CollectAllGarbage(false); - i::Heap::CollectAllGarbage(false); + i::Isolate::Current()->compilation_cache()->Clear(); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -1575,12 +1578,12 @@ THREADED_TEST(InternalFieldsNativePointers) { // Check reading and writing aligned pointers. obj->SetPointerInInternalField(0, aligned); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); // Check reading and writing unaligned pointers. obj->SetPointerInInternalField(0, unaligned); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); delete[] data; @@ -1606,19 +1609,19 @@ THREADED_TEST(InternalFieldsNativePointersAndExternal) { CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1)); obj->SetPointerInInternalField(0, aligned); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0))); obj->SetPointerInInternalField(0, unaligned); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0))); obj->SetInternalField(0, v8::External::Wrap(aligned)); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(aligned, obj->GetPointerFromInternalField(0)); obj->SetInternalField(0, v8::External::Wrap(unaligned)); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0)); delete[] data; @@ -1631,7 +1634,7 @@ THREADED_TEST(IdentityHash) { // Ensure that the test starts with an fresh heap to test whether the hash // code is based on the address. - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); Local<v8::Object> obj = v8::Object::New(); int hash = obj->GetIdentityHash(); int hash1 = obj->GetIdentityHash(); @@ -1641,7 +1644,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); - i::Heap::CollectAllGarbage(false); + 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 @@ -1678,7 +1681,7 @@ THREADED_TEST(HiddenProperties) { v8::Local<v8::String> empty = v8_str(""); v8::Local<v8::String> prop_name = v8_str("prop_name"); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); // Make sure delete of a non-existent hidden value works CHECK(obj->DeleteHiddenValue(key)); @@ -1688,7 +1691,7 @@ THREADED_TEST(HiddenProperties) { CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); // Make sure we do not find the hidden property. CHECK(!obj->Has(empty)); @@ -1699,7 +1702,7 @@ THREADED_TEST(HiddenProperties) { CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); CHECK_EQ(2003, obj->Get(empty)->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); // Add another property and delete it afterwards to force the object in // slow case. @@ -1710,7 +1713,7 @@ THREADED_TEST(HiddenProperties) { CHECK(obj->Delete(prop_name)); CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK(obj->DeleteHiddenValue(key)); CHECK(obj->GetHiddenValue(key).IsEmpty()); @@ -1789,6 +1792,180 @@ THREADED_TEST(GlobalHandle) { } +static int NumberOfWeakCalls = 0; +static void WeakPointerCallback(Persistent<Value> handle, void* id) { + 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; + Persistent<Object> g2s1; + Persistent<Object> g2s2; + Persistent<Object> g2c1; + + { + 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*>(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*>(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. + + // Connect group 1 and 2, make a cycle. + CHECK(g1s2->Set(0, g2s2)); + CHECK(g2s1->Set(0, g1s1)); + + { + Persistent<Value> g1_objects[] = { g1s1, g1s2 }; + Persistent<Value> g1_children[] = { g1c1 }; + Persistent<Value> g2_objects[] = { g2s1, g2s2 }; + Persistent<Value> g2_children[] = { g2c1 }; + V8::AddObjectGroup(g1_objects, 2); + V8::AddImplicitReferences(g1s1, g1_children, 1); + V8::AddObjectGroup(g2_objects, 2); + V8::AddImplicitReferences(g2s2, g2_children, 1); + } + // Do a full GC + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); + + // All object should be alive. + CHECK_EQ(0, NumberOfWeakCalls); + + // Weaken the root. + root.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + // But make children strong roots---all the objects (except for children) + // should be collectable now. + g1c1.ClearWeak(); + g2c1.ClearWeak(); + + // Groups are deleted, rebuild groups. + { + Persistent<Value> g1_objects[] = { g1s1, g1s2 }; + Persistent<Value> g1_children[] = { g1c1 }; + Persistent<Value> g2_objects[] = { g2s1, g2s2 }; + Persistent<Value> g2_children[] = { g2c1 }; + V8::AddObjectGroup(g1_objects, 2); + V8::AddImplicitReferences(g1s1, g1_children, 1); + V8::AddObjectGroup(g2_objects, 2); + V8::AddImplicitReferences(g2s2, g2_children, 1); + } + + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); + + // All objects should be gone. 5 global handles in total. + CHECK_EQ(5, NumberOfWeakCalls); + + // And now make children weak again and collect them. + g1c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + g2c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); + CHECK_EQ(7, NumberOfWeakCalls); +} + + +THREADED_TEST(ApiObjectGroupsCycle) { + HandleScope scope; + LocalContext env; + + NumberOfWeakCalls = 0; + + Persistent<Object> g1s1; + Persistent<Object> g1s2; + Persistent<Object> g2s1; + Persistent<Object> g2s2; + Persistent<Object> g3s1; + Persistent<Object> g3s2; + + { + HandleScope scope; + g1s1 = Persistent<Object>::New(Object::New()); + g1s2 = Persistent<Object>::New(Object::New()); + 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*>(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*>(1234), &WeakPointerCallback); + g3s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + } + + Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root. + + // Connect groups. We're building the following cycle: + // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other + // groups. + { + Persistent<Value> g1_objects[] = { g1s1, g1s2 }; + Persistent<Value> g1_children[] = { g2s1 }; + Persistent<Value> g2_objects[] = { g2s1, g2s2 }; + Persistent<Value> g2_children[] = { g3s1 }; + Persistent<Value> g3_objects[] = { g3s1, g3s2 }; + Persistent<Value> g3_children[] = { g1s1 }; + V8::AddObjectGroup(g1_objects, 2); + V8::AddImplicitReferences(g1s1, g1_children, 1); + V8::AddObjectGroup(g2_objects, 2); + V8::AddImplicitReferences(g2s1, g2_children, 1); + V8::AddObjectGroup(g3_objects, 2); + V8::AddImplicitReferences(g3s1, g3_children, 1); + } + // Do a full GC + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); + + // All object should be alive. + CHECK_EQ(0, NumberOfWeakCalls); + + // Weaken the root. + root.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback); + + // Groups are deleted, rebuild groups. + { + Persistent<Value> g1_objects[] = { g1s1, g1s2 }; + Persistent<Value> g1_children[] = { g2s1 }; + Persistent<Value> g2_objects[] = { g2s1, g2s2 }; + Persistent<Value> g2_children[] = { g3s1 }; + Persistent<Value> g3_objects[] = { g3s1, g3s2 }; + Persistent<Value> g3_children[] = { g1s1 }; + V8::AddObjectGroup(g1_objects, 2); + V8::AddImplicitReferences(g1s1, g1_children, 1); + V8::AddObjectGroup(g2_objects, 2); + V8::AddImplicitReferences(g2s1, g2_children, 1); + V8::AddObjectGroup(g3_objects, 2); + V8::AddImplicitReferences(g3s1, g3_children, 1); + } + + HEAP->CollectGarbage(i::OLD_POINTER_SPACE); + + // All objects should be gone. 7 global handles in total. + CHECK_EQ(7, NumberOfWeakCalls); +} + + THREADED_TEST(ScriptException) { v8::HandleScope scope; LocalContext env; @@ -1900,6 +2077,10 @@ THREADED_TEST(Array) { CHECK_EQ(1, arr->Get(0)->Int32Value()); CHECK_EQ(2, arr->Get(1)->Int32Value()); CHECK_EQ(3, arr->Get(2)->Int32Value()); + array = v8::Array::New(27); + CHECK_EQ(27, array->Length()); + array = v8::Array::New(-27); + CHECK_EQ(0, array->Length()); } @@ -2082,8 +2263,6 @@ TEST(OutOfMemoryNested) { TEST(HugeConsStringOutOfMemory) { // It's not possible to read a snapshot into a heap with different dimensions. if (i::Snapshot::IsEnabled()) return; - v8::HandleScope scope; - LocalContext context; // Set heap limits. static const int K = 1024; v8::ResourceConstraints constraints; @@ -2094,6 +2273,9 @@ TEST(HugeConsStringOutOfMemory) { // Execute a script that causes out of memory. v8::V8::IgnoreOutOfMemoryException(); + v8::HandleScope scope; + LocalContext context; + // Build huge string. This should fail with out of memory exception. Local<Value> result = CompileRun( "var str = Array.prototype.join.call({length: 513}, \"A\").toUpperCase();" @@ -2513,7 +2695,7 @@ v8::Handle<Value> CThrowCountDown(const v8::Arguments& args) { if (try_catch.HasCaught()) { CHECK_EQ(expected, count); CHECK(result.IsEmpty()); - CHECK(!i::Top::has_scheduled_exception()); + CHECK(!i::Isolate::Current()->has_scheduled_exception()); } else { CHECK_NE(expected, count); } @@ -3688,10 +3870,8 @@ THREADED_TEST(ExtensibleOnUndetectable) { source = v8_str("undetectable.y = 2000;"); script = Script::Compile(source); - v8::TryCatch try_catch; Local<Value> result = script->Run(); - CHECK(result.IsEmpty()); - CHECK(try_catch.HasCaught()); + ExpectBoolean("undetectable.y == undefined", true); } @@ -4205,7 +4385,7 @@ static void ForceScavenge(v8::Persistent<v8::Value> obj, void* data) { obj.Dispose(); obj.Clear(); in_scavenge = true; - i::Heap::PerformScavenge(); + HEAP->PerformScavenge(); in_scavenge = false; *(reinterpret_cast<bool*>(data)) = true; } @@ -4242,7 +4422,7 @@ THREADED_TEST(NoWeakRefCallbacksInScavenge) { object_b.MakeWeak(&released_in_scavenge, &CheckIsNotInvokedInScavenge); while (!object_a_disposed) { - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } CHECK(!released_in_scavenge); } @@ -4260,7 +4440,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; - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); return v8::Undefined(); } @@ -4562,130 +4742,130 @@ THREADED_TEST(StringWrite) { memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen); - CHECK_EQ(len, 9); - CHECK_EQ(charlen, 5); - CHECK_EQ(strcmp(utf8buf, "abc\303\260\342\230\203"), 0); + CHECK_EQ(9, len); + CHECK_EQ(5, charlen); + CHECK_EQ(0, strcmp(utf8buf, "abc\303\260\342\230\203")); memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, 8, &charlen); - CHECK_EQ(len, 8); - CHECK_EQ(charlen, 5); - CHECK_EQ(strncmp(utf8buf, "abc\303\260\342\230\203\1", 9), 0); + CHECK_EQ(8, len); + CHECK_EQ(5, charlen); + CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\342\230\203\1", 9)); memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, 7, &charlen); - CHECK_EQ(len, 5); - CHECK_EQ(charlen, 4); - CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0); + CHECK_EQ(5, len); + CHECK_EQ(4, charlen); + CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5)); memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, 6, &charlen); - CHECK_EQ(len, 5); - CHECK_EQ(charlen, 4); - CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0); + CHECK_EQ(5, len); + CHECK_EQ(4, charlen); + CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5)); memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, 5, &charlen); - CHECK_EQ(len, 5); - CHECK_EQ(charlen, 4); - CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0); + CHECK_EQ(5, len); + CHECK_EQ(4, charlen); + CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5)); memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, 4, &charlen); - CHECK_EQ(len, 3); - CHECK_EQ(charlen, 3); - CHECK_EQ(strncmp(utf8buf, "abc\1", 4), 0); + CHECK_EQ(3, len); + CHECK_EQ(3, charlen); + CHECK_EQ(0, strncmp(utf8buf, "abc\1", 4)); memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, 3, &charlen); - CHECK_EQ(len, 3); - CHECK_EQ(charlen, 3); - CHECK_EQ(strncmp(utf8buf, "abc\1", 4), 0); + CHECK_EQ(3, len); + CHECK_EQ(3, charlen); + CHECK_EQ(0, strncmp(utf8buf, "abc\1", 4)); memset(utf8buf, 0x1, sizeof(utf8buf)); len = str2->WriteUtf8(utf8buf, 2, &charlen); - CHECK_EQ(len, 2); - CHECK_EQ(charlen, 2); - CHECK_EQ(strncmp(utf8buf, "ab\1", 3), 0); + CHECK_EQ(2, len); + CHECK_EQ(2, charlen); + CHECK_EQ(0, strncmp(utf8buf, "ab\1", 3)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf); - CHECK_EQ(len, 5); + CHECK_EQ(5, len); len = str->Write(wbuf); - CHECK_EQ(len, 5); - CHECK_EQ(strcmp("abcde", buf), 0); + CHECK_EQ(5, len); + CHECK_EQ(0, strcmp("abcde", buf)); uint16_t answer1[] = {'a', 'b', 'c', 'd', 'e', '\0'}; - CHECK_EQ(StrCmp16(answer1, wbuf), 0); + CHECK_EQ(0, StrCmp16(answer1, wbuf)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 0, 4); - CHECK_EQ(len, 4); + CHECK_EQ(4, len); len = str->Write(wbuf, 0, 4); - CHECK_EQ(len, 4); - CHECK_EQ(strncmp("abcd\1", buf, 5), 0); + CHECK_EQ(4, len); + CHECK_EQ(0, strncmp("abcd\1", buf, 5)); uint16_t answer2[] = {'a', 'b', 'c', 'd', 0x101}; - CHECK_EQ(StrNCmp16(answer2, wbuf, 5), 0); + CHECK_EQ(0, StrNCmp16(answer2, wbuf, 5)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 0, 5); - CHECK_EQ(len, 5); + CHECK_EQ(5, len); len = str->Write(wbuf, 0, 5); - CHECK_EQ(len, 5); - CHECK_EQ(strncmp("abcde\1", buf, 6), 0); + CHECK_EQ(5, len); + CHECK_EQ(0, strncmp("abcde\1", buf, 6)); uint16_t answer3[] = {'a', 'b', 'c', 'd', 'e', 0x101}; - CHECK_EQ(StrNCmp16(answer3, wbuf, 6), 0); + CHECK_EQ(0, StrNCmp16(answer3, wbuf, 6)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 0, 6); - CHECK_EQ(len, 5); + CHECK_EQ(5, len); len = str->Write(wbuf, 0, 6); - CHECK_EQ(len, 5); - CHECK_EQ(strcmp("abcde", buf), 0); + CHECK_EQ(5, len); + CHECK_EQ(0, strcmp("abcde", buf)); uint16_t answer4[] = {'a', 'b', 'c', 'd', 'e', '\0'}; - CHECK_EQ(StrCmp16(answer4, wbuf), 0); + CHECK_EQ(0, StrCmp16(answer4, wbuf)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 4, -1); - CHECK_EQ(len, 1); + CHECK_EQ(1, len); len = str->Write(wbuf, 4, -1); - CHECK_EQ(len, 1); - CHECK_EQ(strcmp("e", buf), 0); + CHECK_EQ(1, len); + CHECK_EQ(0, strcmp("e", buf)); uint16_t answer5[] = {'e', '\0'}; - CHECK_EQ(StrCmp16(answer5, wbuf), 0); + CHECK_EQ(0, StrCmp16(answer5, wbuf)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 4, 6); - CHECK_EQ(len, 1); + CHECK_EQ(1, len); len = str->Write(wbuf, 4, 6); - CHECK_EQ(len, 1); - CHECK_EQ(strcmp("e", buf), 0); - CHECK_EQ(StrCmp16(answer5, wbuf), 0); + CHECK_EQ(1, len); + CHECK_EQ(0, strcmp("e", buf)); + CHECK_EQ(0, StrCmp16(answer5, wbuf)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 4, 1); - CHECK_EQ(len, 1); + CHECK_EQ(1, len); len = str->Write(wbuf, 4, 1); - CHECK_EQ(len, 1); - CHECK_EQ(strncmp("e\1", buf, 2), 0); + CHECK_EQ(1, len); + CHECK_EQ(0, strncmp("e\1", buf, 2)); uint16_t answer6[] = {'e', 0x101}; - CHECK_EQ(StrNCmp16(answer6, wbuf, 2), 0); + CHECK_EQ(0, StrNCmp16(answer6, wbuf, 2)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); len = str->WriteAscii(buf, 3, 1); - CHECK_EQ(len, 1); + CHECK_EQ(1, len); len = str->Write(wbuf, 3, 1); - CHECK_EQ(len, 1); - CHECK_EQ(strncmp("d\1", buf, 2), 0); + CHECK_EQ(1, len); + CHECK_EQ(0, strncmp("d\1", buf, 2)); uint16_t answer7[] = {'d', 0x101}; - CHECK_EQ(StrNCmp16(answer7, wbuf, 2), 0); + CHECK_EQ(0, StrNCmp16(answer7, wbuf, 2)); } @@ -5659,6 +5839,14 @@ TEST(AccessControlES5) { global_template->SetAccessCheckCallbacks(NamedAccessBlocker, IndexedAccessBlocker); + // Add accessible accessor. + global_template->SetAccessor( + v8_str("accessible_prop"), + EchoGetter, EchoSetter, + v8::Handle<Value>(), + v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE)); + + // Add an accessor that is not accessible by cross-domain JS code. global_template->SetAccessor(v8_str("blocked_prop"), UnreachableGetter, UnreachableSetter, @@ -5699,6 +5887,18 @@ TEST(AccessControlES5) { CompileRun("Object.seal(other)"); ExpectTrue("Object.isExtensible(other)"); + + // Regression test for issue 1250. + // Make sure that we can set the accessible accessors value using normal + // assignment. + CompileRun("other.accessible_prop = 42"); + CHECK_EQ(42, g_echo_value); + + v8::Handle<Value> value; + // We follow Safari in ignoring assignments to host object accessors. + CompileRun("Object.defineProperty(other, 'accessible_prop', {value: -1})"); + value = CompileRun("other.accessible_prop == 42"); + CHECK(value->IsTrue()); } @@ -6481,7 +6681,7 @@ THREADED_TEST(SetPrototypeThrows) { v8::TryCatch try_catch; CHECK(!o1->SetPrototype(o0)); CHECK(!try_catch.HasCaught()); - ASSERT(!i::Top::has_pending_exception()); + ASSERT(!i::Isolate::Current()->has_pending_exception()); CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value()); } @@ -6863,7 +7063,7 @@ static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC( Local<String> name, const AccessorInfo& info) { ApiTestFuzzer::Fuzz(); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); return v8::Handle<Value>(); } @@ -7593,7 +7793,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) { - i::Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); } return v8::Handle<Value>(); } @@ -7631,7 +7831,7 @@ static void GenerateSomeGarbage() { v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) { static int count = 0; if (count++ % 3 == 0) { - i::Heap::CollectAllGarbage(true); // This should move the stub + HEAP-> CollectAllGarbage(true); // This should move the stub GenerateSomeGarbage(); // This should ensure the old stub memory is flushed } return v8::Handle<v8::Value>(); @@ -7686,7 +7886,7 @@ THREADED_TEST(CallICFastApi_DirectCall_Throw) { v8::Handle<v8::Value> DirectGetterCallback(Local<String> name, const v8::AccessorInfo& info) { if (++p_getter_count % 3 == 0) { - i::Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); GenerateSomeGarbage(); } return v8::Handle<v8::Value>(); @@ -8601,7 +8801,8 @@ void ApiTestFuzzer::Setup(PartOfTest part) { : RegisterThreadedTest::count(); active_tests_ = tests_being_run_ = end - start; for (int i = 0; i < tests_being_run_; i++) { - RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(i + start); + RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer( + i::Isolate::Current(), i + start); } for (int i = 0; i < active_tests_; i++) { RegisterThreadedTest::nth(i)->fuzzer_->Start(); @@ -8823,11 +9024,11 @@ 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. - i::Heap::CollectAllGarbage(false); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); int count = GetGlobalObjectsCount(); #ifdef DEBUG - if (count != expected) i::Heap::TracePathToGlobal(); + if (count != expected) HEAP->TracePathToGlobal(); #endif CHECK_EQ(expected, count); } @@ -8893,7 +9094,7 @@ THREADED_TEST(NewPersistentHandleFromWeakCallback) { // weak callback of the first handle would be able to 'reallocate' it. handle1.MakeWeak(NULL, NewPersistentHandleCallback); handle2.Dispose(); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -8901,7 +9102,7 @@ v8::Persistent<v8::Object> to_be_disposed; void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) { to_be_disposed.Dispose(); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); handle.Dispose(); } @@ -8917,7 +9118,7 @@ THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { } handle1.MakeWeak(NULL, DisposeAndForceGcCallback); to_be_disposed = handle2; - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } void DisposingCallback(v8::Persistent<v8::Value> handle, void*) { @@ -8943,7 +9144,7 @@ THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) { } handle2.MakeWeak(NULL, DisposingCallback); handle3.MakeWeak(NULL, HandleCreatingCallback); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); } @@ -9189,6 +9390,31 @@ THREADED_TEST(PropertyEnumeration) { CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3); } +THREADED_TEST(PropertyEnumeration2) { + v8::HandleScope scope; + LocalContext context; + v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New( + "var result = [];" + "result[0] = {};" + "result[1] = {a: 1, b: 2};" + "result[2] = [1, 2, 3];" + "var proto = {x: 1, y: 2, z: 3};" + "var x = { __proto__: proto, w: 0, z: 1 };" + "result[3] = x;" + "result;"))->Run(); + v8::Handle<v8::Array> elms = obj.As<v8::Array>(); + CHECK_EQ(4, elms->Length()); + int elmc0 = 0; + const char** elmv0 = NULL; + CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0); + + v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(0)); + v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames(); + CHECK_EQ(0, props->Length()); + for (uint32_t i = 0; i < props->Length(); i++) { + printf("p[%d]\n", i); + } +} static bool NamedSetAccessBlocker(Local<v8::Object> obj, Local<Value> name, @@ -9681,7 +9907,7 @@ class RegExpInterruptTest { gc_during_regexp_ = 0; regexp_success_ = false; gc_success_ = false; - GCThread gc_thread(this); + GCThread gc_thread(i::Isolate::Current(), this); gc_thread.Start(); v8::Locker::StartPreemption(1); @@ -9700,8 +9926,8 @@ class RegExpInterruptTest { class GCThread : public i::Thread { public: - explicit GCThread(RegExpInterruptTest* test) - : test_(test) {} + explicit GCThread(i::Isolate* isolate, RegExpInterruptTest* test) + : Thread(isolate, "GCThread"), test_(test) {} virtual void Run() { test_->CollectGarbage(); } @@ -9715,7 +9941,7 @@ class RegExpInterruptTest { { v8::Locker lock; // TODO(lrn): Perhaps create some garbage before collecting. - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); gc_count_++; } i::OS::Sleep(1); @@ -9803,7 +10029,7 @@ class ApplyInterruptTest { gc_during_apply_ = 0; apply_success_ = false; gc_success_ = false; - GCThread gc_thread(this); + GCThread gc_thread(i::Isolate::Current(), this); gc_thread.Start(); v8::Locker::StartPreemption(1); @@ -9822,8 +10048,8 @@ class ApplyInterruptTest { class GCThread : public i::Thread { public: - explicit GCThread(ApplyInterruptTest* test) - : test_(test) {} + explicit GCThread(i::Isolate* isolate, ApplyInterruptTest* test) + : Thread(isolate, "GCThread"), test_(test) {} virtual void Run() { test_->CollectGarbage(); } @@ -9836,7 +10062,7 @@ class ApplyInterruptTest { while (gc_during_apply_ < kRequiredGCs) { { v8::Locker lock; - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); gc_count_++; } i::OS::Sleep(1); @@ -9965,17 +10191,17 @@ static void MorphAString(i::String* string, CHECK(i::StringShape(string).IsExternal()); if (string->IsAsciiRepresentation()) { // Check old map is not symbol or long. - CHECK(string->map() == i::Heap::external_ascii_string_map()); + CHECK(string->map() == HEAP->external_ascii_string_map()); // Morph external string to be TwoByte string. - string->set_map(i::Heap::external_string_map()); + string->set_map(HEAP->external_string_map()); i::ExternalTwoByteString* morphed = i::ExternalTwoByteString::cast(string); morphed->set_resource(uc16_resource); } else { // Check old map is not symbol or long. - CHECK(string->map() == i::Heap::external_string_map()); + CHECK(string->map() == HEAP->external_string_map()); // Morph external string to be ASCII string. - string->set_map(i::Heap::external_ascii_string_map()); + string->set_map(HEAP->external_ascii_string_map()); i::ExternalAsciiString* morphed = i::ExternalAsciiString::cast(string); morphed->set_resource(ascii_resource); @@ -9999,9 +10225,9 @@ THREADED_TEST(MorphCompositeStringTest) { i::StrLength(c_string))); Local<String> lhs(v8::Utils::ToLocal( - i::Factory::NewExternalStringFromAscii(&ascii_resource))); + FACTORY->NewExternalStringFromAscii(&ascii_resource))); Local<String> rhs(v8::Utils::ToLocal( - i::Factory::NewExternalStringFromAscii(&ascii_resource))); + FACTORY->NewExternalStringFromAscii(&ascii_resource))); env->Global()->Set(v8_str("lhs"), lhs); env->Global()->Set(v8_str("rhs"), rhs); @@ -10086,18 +10312,18 @@ class RegExpStringModificationTest { // Create the input string for the regexp - the one we are going to change // properties of. - input_ = i::Factory::NewExternalStringFromAscii(&ascii_resource_); + input_ = FACTORY->NewExternalStringFromAscii(&ascii_resource_); // Inject the input as a global variable. i::Handle<i::String> input_name = - i::Factory::NewStringFromAscii(i::Vector<const char>("input", 5)); - i::Top::global_context()->global()->SetProperty( + FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5)); + i::Isolate::Current()->global_context()->global()->SetProperty( *input_name, *input_, NONE, i::kNonStrictMode)->ToObjectChecked(); - MorphThread morph_thread(this); + MorphThread morph_thread(i::Isolate::Current(), this); morph_thread.Start(); v8::Locker::StartPreemption(1); LongRunningRegExp(); @@ -10117,8 +10343,9 @@ class RegExpStringModificationTest { class MorphThread : public i::Thread { public: - explicit MorphThread(RegExpStringModificationTest* test) - : test_(test) {} + explicit MorphThread(i::Isolate* isolate, + RegExpStringModificationTest* test) + : Thread(isolate, "MorphThread"), test_(test) {} virtual void Run() { test_->MorphString(); } @@ -10549,13 +10776,16 @@ THREADED_TEST(PixelArray) { LocalContext context; const int kElementCount = 260; uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); - i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount, - pixel_data); - i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. + i::Handle<i::ExternalPixelArray> pixels = + i::Handle<i::ExternalPixelArray>::cast( + FACTORY->NewExternalArray(kElementCount, + v8::kExternalPixelArray, + pixel_data)); + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. for (int i = 0; i < kElementCount; i++) { pixels->set(i, i % 256); } - i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. for (int i = 0; i < kElementCount; i++) { CHECK_EQ(i % 256, pixels->get(i)); CHECK_EQ(i % 256, pixel_data[i]); @@ -10890,7 +11120,7 @@ THREADED_TEST(PixelArray) { " return sum; " "}" "for (var i = 0; i < 256; ++i) { pixels[i] = i; }" - "for (var i = 0; i < 10000; ++i) {" + "for (var i = 0; i < 5000; ++i) {" " result = pa_load(pixels);" "}" "result"); @@ -10907,7 +11137,7 @@ THREADED_TEST(PixelArray) { " }" " return sum; " "}" - "for (var i = 0; i < 100000; ++i) {" + "for (var i = 0; i < 5000; ++i) {" " pa_init(pixels);" "}" "result = pa_load(pixels);" @@ -10955,8 +11185,11 @@ THREADED_TEST(PixelArrayWithInterceptor) { LocalContext context; const int kElementCount = 260; uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); - i::Handle<i::PixelArray> pixels = - i::Factory::NewPixelArray(kElementCount, pixel_data); + i::Handle<i::ExternalPixelArray> pixels = + i::Handle<i::ExternalPixelArray>::cast( + FACTORY->NewExternalArray(kElementCount, + v8::kExternalPixelArray, + pixel_data)); for (int i = 0; i < kElementCount; i++) { pixels->set(i, i % 256); } @@ -10984,6 +11217,7 @@ static int ExternalArrayElementSize(v8::ExternalArrayType array_type) { switch (array_type) { case v8::kExternalByteArray: case v8::kExternalUnsignedByteArray: + case v8::kExternalPixelArray: return 1; break; case v8::kExternalShortArray: @@ -11016,12 +11250,12 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, static_cast<ElementType*>(malloc(kElementCount * element_size)); i::Handle<ExternalArrayClass> array = i::Handle<ExternalArrayClass>::cast( - i::Factory::NewExternalArray(kElementCount, array_type, array_data)); - i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. + FACTORY->NewExternalArray(kElementCount, array_type, array_data)); + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. for (int i = 0; i < kElementCount; i++) { array->set(i, static_cast<ElementType>(i)); } - i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. + 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(i))); CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); @@ -11138,7 +11372,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, " }" "}" "sum;"); - i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. + HEAP->CollectAllGarbage(false); // Force GC to trigger verification. CHECK_EQ(28, result->Int32Value()); // Make sure out-of-range loads do not throw. @@ -11205,8 +11439,10 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, " ext_array[i] = Infinity;" "}" "ext_array[5];"); - CHECK_EQ(0, result->Int32Value()); - CHECK_EQ(0, + int expected_value = + (array_type == v8::kExternalPixelArray) ? 255 : 0; + CHECK_EQ(expected_value, result->Int32Value()); + CHECK_EQ(expected_value, i::Smi::cast(jsobj->GetElement(5)->ToObjectChecked())->value()); result = CompileRun("for (var i = 0; i < 8; i++) {" @@ -11227,10 +11463,14 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, const char* signed_data = "var source_data = [0.6, 10.6, -0.6, -10.6];" "var expected_results = [0, 10, 0, -10];"; + const char* pixel_data = + "var source_data = [0.6, 10.6];" + "var expected_results = [1, 11];"; bool is_unsigned = (array_type == v8::kExternalUnsignedByteArray || array_type == v8::kExternalUnsignedShortArray || array_type == v8::kExternalUnsignedIntArray); + bool is_pixel_data = array_type == v8::kExternalPixelArray; i::OS::SNPrintF(test_buf, "%s" @@ -11243,11 +11483,42 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, " (ext_array[5] == expected_results[i]);" "}" "all_passed;", - (is_unsigned ? unsigned_data : signed_data)); + (is_unsigned ? + unsigned_data : + (is_pixel_data ? pixel_data : signed_data))); result = CompileRun(test_buf.start()); CHECK_EQ(true, result->BooleanValue()); } + // Test crankshaft external array loads + for (int i = 0; i < kElementCount; i++) { + array->set(i, static_cast<ElementType>(i)); + } + result = CompileRun("function ee_load_test_func(sum) {" + " for (var i=0;i<40;++i)" + " sum += ext_array[i];" + " return sum;" + "}" + "sum=0;" + "for (var i=0;i<10000;++i) {" + " sum=ee_load_test_func(sum);" + "}" + "sum;"); + CHECK_EQ(7800000, result->Int32Value()); + + // Test crankshaft external array stores + result = CompileRun("function ee_store_test_func(sum) {" + " for (var i=0;i<40;++i)" + " sum += ext_array[i] = i;" + " return sum;" + "}" + "sum=0;" + "for (var i=0;i<10000;++i) {" + " sum=ee_store_test_func(sum);" + "}" + "sum;"); + CHECK_EQ(7800000, result->Int32Value()); + result = CompileRun("ext_array[3] = 33;" "delete ext_array[3];" "ext_array[3];"); @@ -11287,7 +11558,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, static_cast<ElementType*>(malloc(kLargeElementCount * element_size)); i::Handle<ExternalArrayClass> large_array = i::Handle<ExternalArrayClass>::cast( - i::Factory::NewExternalArray(kLargeElementCount, + FACTORY->NewExternalArray(kLargeElementCount, array_type, array_data)); v8::Handle<v8::Object> large_obj = v8::Object::New(); @@ -11354,6 +11625,95 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, free(large_array_data); } + // The "" property descriptor is overloaded to store information about + // the external array. Ensure that setting and accessing the "" property + // works (it should overwrite the information cached about the external + // array in the DescriptorArray) in various situations. + result = CompileRun("ext_array[''] = 23; ext_array['']"); + CHECK_EQ(23, result->Int32Value()); + + // Property "" set after the external array is associated with the object. + { + v8::Handle<v8::Object> obj2 = v8::Object::New(); + obj2->Set(v8_str("ee_test_field"), v8::Int32::New(256)); + obj2->Set(v8_str(""), v8::Int32::New(1503)); + // Set the elements to be the external array. + obj2->SetIndexedPropertiesToExternalArrayData(array_data, + array_type, + kElementCount); + context->Global()->Set(v8_str("ext_array"), obj2); + result = CompileRun("ext_array['']"); + CHECK_EQ(1503, result->Int32Value()); + } + + // Property "" set after the external array is associated with the object. + { + v8::Handle<v8::Object> obj2 = v8::Object::New(); + obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); + // Set the elements to be the external array. + obj2->SetIndexedPropertiesToExternalArrayData(array_data, + array_type, + kElementCount); + obj2->Set(v8_str(""), v8::Int32::New(1503)); + context->Global()->Set(v8_str("ext_array"), obj2); + result = CompileRun("ext_array['']"); + CHECK_EQ(1503, result->Int32Value()); + } + + // Should reuse the map from previous test. + { + v8::Handle<v8::Object> obj2 = v8::Object::New(); + obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256)); + // Set the elements to be the external array. Should re-use the map + // from previous test. + obj2->SetIndexedPropertiesToExternalArrayData(array_data, + array_type, + kElementCount); + context->Global()->Set(v8_str("ext_array"), obj2); + result = CompileRun("ext_array['']"); + } + + // Property "" is a constant function that shouldn't not be interfered with + // when an external array is set. + { + v8::Handle<v8::Object> obj2 = v8::Object::New(); + // Start + obj2->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); + + // Add a constant function to an object. + context->Global()->Set(v8_str("ext_array"), obj2); + result = CompileRun("ext_array[''] = function() {return 1503;};" + "ext_array['']();"); + + // Add an external array transition to the same map that + // has the constant transition. + v8::Handle<v8::Object> obj3 = v8::Object::New(); + obj3->Set(v8_str("ee_test_field3"), v8::Int32::New(256)); + obj3->SetIndexedPropertiesToExternalArrayData(array_data, + array_type, + kElementCount); + context->Global()->Set(v8_str("ext_array"), obj3); + } + + // If a external array transition is in the map, it should get clobbered + // by a constant function. + { + // Add an external array transition. + v8::Handle<v8::Object> obj3 = v8::Object::New(); + obj3->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); + obj3->SetIndexedPropertiesToExternalArrayData(array_data, + array_type, + kElementCount); + + // Add a constant function to the same map that just got an external array + // transition. + v8::Handle<v8::Object> obj2 = v8::Object::New(); + obj2->Set(v8_str("ee_test_field4"), v8::Int32::New(256)); + context->Global()->Set(v8_str("ext_array"), obj2); + result = CompileRun("ext_array[''] = function() {return 1503;};" + "ext_array['']();"); + } + free(array_data); } @@ -11374,6 +11734,14 @@ THREADED_TEST(ExternalUnsignedByteArray) { } +THREADED_TEST(ExternalPixelArray) { + ExternalArrayTestHelper<i::ExternalPixelArray, uint8_t>( + v8::kExternalPixelArray, + 0, + 255); +} + + THREADED_TEST(ExternalShortArray) { ExternalArrayTestHelper<i::ExternalShortArray, int16_t>( v8::kExternalShortArray, @@ -11451,6 +11819,7 @@ THREADED_TEST(ExternalArrayInfo) { ExternalArrayInfoTestHelper(v8::kExternalIntArray); ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); ExternalArrayInfoTestHelper(v8::kExternalFloatArray); + ExternalArrayInfoTestHelper(v8::kExternalPixelArray); } @@ -11714,7 +12083,8 @@ THREADED_TEST(IdleNotification) { static uint32_t* stack_limit; static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) { - stack_limit = reinterpret_cast<uint32_t*>(i::StackGuard::real_climit()); + stack_limit = reinterpret_cast<uint32_t*>( + i::Isolate::Current()->stack_guard()->real_climit()); return v8::Undefined(); } @@ -11980,7 +12350,7 @@ TEST(Regress528) { other_context->Enter(); CompileRun(source_simple); other_context->Exit(); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); if (GetGlobalObjectsCount() == 1) break; } CHECK_GE(2, gc_count); @@ -12002,7 +12372,7 @@ TEST(Regress528) { other_context->Enter(); CompileRun(source_eval); other_context->Exit(); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); if (GetGlobalObjectsCount() == 1) break; } CHECK_GE(2, gc_count); @@ -12029,7 +12399,7 @@ TEST(Regress528) { other_context->Enter(); CompileRun(source_exception); other_context->Exit(); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); if (GetGlobalObjectsCount() == 1) break; } CHECK_GE(2, gc_count); @@ -12247,26 +12617,26 @@ TEST(GCCallbacks) { v8::V8::AddGCEpilogueCallback(EpilogueCallback); CHECK_EQ(0, prologue_call_count); CHECK_EQ(0, epilogue_call_count); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(1, prologue_call_count); CHECK_EQ(1, epilogue_call_count); v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); - i::Heap::CollectAllGarbage(false); + 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); - i::Heap::CollectAllGarbage(false); + 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); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, prologue_call_count); CHECK_EQ(2, epilogue_call_count); CHECK_EQ(2, prologue_call_count_second); @@ -12294,7 +12664,7 @@ THREADED_TEST(AddToJSFunctionResultCache) { " return 'Different results for ' + key1 + ': ' + r1 + ' vs. ' + r1_;" " return 'PASSED';" "})()"; - i::Heap::ClearJSFunctionResultCaches(); + HEAP->ClearJSFunctionResultCaches(); ExpectString(code, "PASSED"); } @@ -12318,7 +12688,7 @@ THREADED_TEST(FillJSFunctionResultCache) { " return 'FAILED: k0CacheSize is too small';" " return 'PASSED';" "})()"; - i::Heap::ClearJSFunctionResultCaches(); + HEAP->ClearJSFunctionResultCaches(); ExpectString(code, "PASSED"); } @@ -12343,7 +12713,7 @@ THREADED_TEST(RoundRobinGetFromCache) { " };" " return 'PASSED';" "})()"; - i::Heap::ClearJSFunctionResultCaches(); + HEAP->ClearJSFunctionResultCaches(); ExpectString(code, "PASSED"); } @@ -12368,7 +12738,7 @@ THREADED_TEST(ReverseGetFromCache) { " };" " return 'PASSED';" "})()"; - i::Heap::ClearJSFunctionResultCaches(); + HEAP->ClearJSFunctionResultCaches(); ExpectString(code, "PASSED"); } @@ -12386,7 +12756,7 @@ THREADED_TEST(TestEviction) { " };" " return 'PASSED';" "})()"; - i::Heap::ClearJSFunctionResultCaches(); + HEAP->ClearJSFunctionResultCaches(); ExpectString(code, "PASSED"); } @@ -12476,7 +12846,7 @@ THREADED_TEST(TwoByteStringInAsciiCons) { void FailedAccessCheckCallbackGC(Local<v8::Object> target, v8::AccessType type, Local<v8::Value> data) { - i::Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); } @@ -12557,6 +12927,374 @@ TEST(GCInFailedAccessCheckCallback) { v8::V8::SetFailedAccessCheckCallbackFunction(NULL); } +TEST(DefaultIsolateGetCurrent) { + CHECK(v8::Isolate::GetCurrent() != NULL); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + CHECK(reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate()); + printf("*** %s\n", "DefaultIsolateGetCurrent success"); +} + +TEST(IsolateNewDispose) { + v8::Isolate* current_isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = v8::Isolate::New(); + CHECK(isolate != NULL); + CHECK(!reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate()); + CHECK(current_isolate != isolate); + CHECK(current_isolate == v8::Isolate::GetCurrent()); + + v8::V8::SetFatalErrorHandler(StoringErrorCallback); + last_location = last_message = NULL; + isolate->Dispose(); + CHECK_EQ(last_location, NULL); + CHECK_EQ(last_message, NULL); +} + +TEST(IsolateEnterExitDefault) { + v8::HandleScope scope; + LocalContext context; + v8::Isolate* current_isolate = v8::Isolate::GetCurrent(); + CHECK(current_isolate != NULL); // Default isolate. + ExpectString("'hello'", "hello"); + current_isolate->Enter(); + ExpectString("'still working'", "still working"); + current_isolate->Exit(); + ExpectString("'still working 2'", "still working 2"); + current_isolate->Exit(); + // Default isolate is always, well, 'default current'. + CHECK_EQ(v8::Isolate::GetCurrent(), current_isolate); + // Still working since default isolate is auto-entering any thread + // that has no isolate and attempts to execute V8 APIs. + ExpectString("'still working 3'", "still working 3"); +} + +TEST(DisposeDefaultIsolate) { + v8::V8::SetFatalErrorHandler(StoringErrorCallback); + + // Run some V8 code to trigger default isolate to become 'current'. + v8::HandleScope scope; + LocalContext context; + ExpectString("'run some V8'", "run some V8"); + + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + CHECK(reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate()); + last_location = last_message = NULL; + isolate->Dispose(); + // It is not possible to dispose default isolate via Isolate API. + CHECK_NE(last_location, NULL); + CHECK_NE(last_message, NULL); +} + +TEST(RunDefaultAndAnotherIsolate) { + v8::HandleScope scope; + LocalContext context; + + // Enter new isolate. + v8::Isolate* isolate = v8::Isolate::New(); + CHECK(isolate); + isolate->Enter(); + { // Need this block because subsequent Exit() will deallocate Heap, + // so we need all scope objects to be deconstructed when it happens. + v8::HandleScope scope_new; + LocalContext context_new; + + // Run something in new isolate. + CompileRun("var foo = 153;"); + ExpectTrue("function f() { return foo == 153; }; f()"); + } + isolate->Exit(); + + // This runs automatically in default isolate. + // Variables in another isolate should be not available. + ExpectTrue("function f() {" + " try {" + " foo;" + " return false;" + " } catch(e) {" + " return true;" + " }" + "};" + "var bar = 371;" + "f()"); + + v8::V8::SetFatalErrorHandler(StoringErrorCallback); + last_location = last_message = NULL; + isolate->Dispose(); + CHECK_EQ(last_location, NULL); + CHECK_EQ(last_message, NULL); + + // Check that default isolate still runs. + ExpectTrue("function f() { return bar == 371; }; f()"); +} + +TEST(DisposeIsolateWhenInUse) { + v8::Isolate* isolate = v8::Isolate::New(); + CHECK(isolate); + isolate->Enter(); + v8::HandleScope scope; + LocalContext context; + // Run something in this isolate. + ExpectTrue("true"); + v8::V8::SetFatalErrorHandler(StoringErrorCallback); + last_location = last_message = NULL; + // Still entered, should fail. + isolate->Dispose(); + CHECK_NE(last_location, NULL); + CHECK_NE(last_message, NULL); +} + +TEST(RunTwoIsolatesOnSingleThread) { + // Run isolate 1. + v8::Isolate* isolate1 = v8::Isolate::New(); + isolate1->Enter(); + v8::Persistent<v8::Context> context1 = v8::Context::New(); + + { + v8::Context::Scope cscope(context1); + v8::HandleScope scope; + // Run something in new isolate. + CompileRun("var foo = 'isolate 1';"); + ExpectString("function f() { return foo; }; f()", "isolate 1"); + } + + // Run isolate 2. + v8::Isolate* isolate2 = v8::Isolate::New(); + v8::Persistent<v8::Context> context2; + + { + v8::Isolate::Scope iscope(isolate2); + context2 = v8::Context::New(); + v8::Context::Scope cscope(context2); + v8::HandleScope scope; + + // Run something in new isolate. + CompileRun("var foo = 'isolate 2';"); + ExpectString("function f() { return foo; }; f()", "isolate 2"); + } + + { + v8::Context::Scope cscope(context1); + v8::HandleScope scope; + // Now again in isolate 1 + ExpectString("function f() { return foo; }; f()", "isolate 1"); + } + + isolate1->Exit(); + + // Run some stuff in default isolate. + v8::Persistent<v8::Context> context_default = v8::Context::New(); + + { + v8::Context::Scope cscope(context_default); + v8::HandleScope scope; + // Variables in other isolates should be not available, verify there + // is an exception. + ExpectTrue("function f() {" + " try {" + " foo;" + " return false;" + " } catch(e) {" + " return true;" + " }" + "};" + "var isDefaultIsolate = true;" + "f()"); + } + + isolate1->Enter(); + + { + v8::Isolate::Scope iscope(isolate2); + v8::Context::Scope cscope(context2); + v8::HandleScope scope; + ExpectString("function f() { return foo; }; f()", "isolate 2"); + } + + { + v8::Context::Scope cscope(context1); + v8::HandleScope scope; + ExpectString("function f() { return foo; }; f()", "isolate 1"); + } + + { + v8::Isolate::Scope iscope(isolate2); + context2.Dispose(); + } + + context1.Dispose(); + isolate1->Exit(); + + v8::V8::SetFatalErrorHandler(StoringErrorCallback); + last_location = last_message = NULL; + + isolate1->Dispose(); + CHECK_EQ(last_location, NULL); + CHECK_EQ(last_message, NULL); + + isolate2->Dispose(); + CHECK_EQ(last_location, NULL); + CHECK_EQ(last_message, NULL); + + // Check that default isolate still runs. + { + v8::Context::Scope cscope(context_default); + v8::HandleScope scope; + ExpectTrue("function f() { return isDefaultIsolate; }; f()"); + } +} + +static int CalcFibonacci(v8::Isolate* isolate, int limit) { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope scope; + LocalContext context; + i::ScopedVector<char> code(1024); + i::OS::SNPrintF(code, "function fib(n) {" + " if (n <= 2) return 1;" + " return fib(n-1) + fib(n-2);" + "}" + "fib(%d)", limit); + Local<Value> value = CompileRun(code.start()); + CHECK(value->IsNumber()); + return static_cast<int>(value->NumberValue()); +} + +class IsolateThread : public v8::internal::Thread { + public: + explicit IsolateThread(v8::Isolate* isolate, int fib_limit) + : Thread(NULL, "IsolateThread"), + isolate_(isolate), + fib_limit_(fib_limit), + result_(0) { } + + void Run() { + result_ = CalcFibonacci(isolate_, fib_limit_); + } + + int result() { return result_; } + + private: + v8::Isolate* isolate_; + int fib_limit_; + int result_; +}; + +TEST(MultipleIsolatesOnIndividualThreads) { + v8::Isolate* isolate1 = v8::Isolate::New(); + v8::Isolate* isolate2 = v8::Isolate::New(); + + IsolateThread thread1(isolate1, 21); + IsolateThread thread2(isolate2, 12); + + // Compute some fibonacci numbers on 3 threads in 3 isolates. + thread1.Start(); + thread2.Start(); + + int result1 = CalcFibonacci(v8::Isolate::GetCurrent(), 21); + int result2 = CalcFibonacci(v8::Isolate::GetCurrent(), 12); + + thread1.Join(); + thread2.Join(); + + // Compare results. The actual fibonacci numbers for 12 and 21 are taken + // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number + CHECK_EQ(result1, 10946); + CHECK_EQ(result2, 144); + CHECK_EQ(result1, thread1.result()); + CHECK_EQ(result2, thread2.result()); + + isolate1->Dispose(); + isolate2->Dispose(); +} + + +class InitDefaultIsolateThread : public v8::internal::Thread { + public: + enum TestCase { + IgnoreOOM, + SetResourceConstraints, + SetFatalHandler, + SetCounterFunction, + SetCreateHistogramFunction, + SetAddHistogramSampleFunction + }; + + explicit InitDefaultIsolateThread(TestCase testCase) + : Thread(NULL, "InitDefaultIsolateThread"), + testCase_(testCase), + result_(false) { } + + void Run() { + switch (testCase_) { + case IgnoreOOM: + v8::V8::IgnoreOutOfMemoryException(); + break; + + case SetResourceConstraints: { + static const int K = 1024; + v8::ResourceConstraints constraints; + constraints.set_max_young_space_size(256 * K); + constraints.set_max_old_space_size(4 * K * K); + v8::SetResourceConstraints(&constraints); + break; + } + + case SetFatalHandler: + v8::V8::SetFatalErrorHandler(NULL); + break; + + case SetCounterFunction: + v8::V8::SetCounterFunction(NULL); + break; + + case SetCreateHistogramFunction: + v8::V8::SetCreateHistogramFunction(NULL); + break; + + case SetAddHistogramSampleFunction: + v8::V8::SetAddHistogramSampleFunction(NULL); + break; + } + result_ = true; + } + + bool result() { return result_; } + + private: + TestCase testCase_; + bool result_; +}; + + +static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) { + InitDefaultIsolateThread thread(testCase); + thread.Start(); + thread.Join(); + CHECK_EQ(thread.result(), true); +} + +TEST(InitializeDefaultIsolateOnSecondaryThread1) { + InitializeTestHelper(InitDefaultIsolateThread::IgnoreOOM); +} + +TEST(InitializeDefaultIsolateOnSecondaryThread2) { + InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints); +} + +TEST(InitializeDefaultIsolateOnSecondaryThread3) { + InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler); +} + +TEST(InitializeDefaultIsolateOnSecondaryThread4) { + InitializeTestHelper(InitDefaultIsolateThread::SetCounterFunction); +} + +TEST(InitializeDefaultIsolateOnSecondaryThread5) { + InitializeTestHelper(InitDefaultIsolateThread::SetCreateHistogramFunction); +} + +TEST(InitializeDefaultIsolateOnSecondaryThread6) { + InitializeTestHelper(InitDefaultIsolateThread::SetAddHistogramSampleFunction); +} + TEST(StringCheckMultipleContexts) { const char* code = @@ -12660,7 +13398,7 @@ TEST(DontDeleteCellLoadIC) { "})()", "ReferenceError: cell is not defined"); CompileRun("cell = \"new_second\";"); - i::Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); ExpectString("readCell()", "new_second"); ExpectString("readCell()", "new_second"); } diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc index 43cf580a..a91886e7 100644 --- a/test/cctest/test-assembler-arm.cc +++ b/test/cctest/test-assembler-arm.cc @@ -65,10 +65,10 @@ TEST(0) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); @@ -102,10 +102,10 @@ TEST(1) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); @@ -139,7 +139,7 @@ TEST(2) { // some relocated stuff here, not executed __ RecordComment("dead code, just testing relocations"); - __ mov(r0, Operand(Factory::true_value())); + __ mov(r0, Operand(FACTORY->true_value())); __ RecordComment("dead code, just testing immediate operands"); __ mov(r0, Operand(-1)); __ mov(r0, Operand(0xFF000000)); @@ -148,10 +148,10 @@ TEST(2) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); @@ -196,10 +196,10 @@ TEST(3) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); @@ -232,6 +232,8 @@ TEST(4) { double g; double h; int i; + double m; + double n; float x; float y; } T; @@ -243,7 +245,7 @@ TEST(4) { Label L, C; - if (CpuFeatures::IsSupported(VFP3)) { + if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { CpuFeatures::Scope scope(VFP3); __ mov(ip, Operand(sp)); @@ -297,14 +299,22 @@ TEST(4) { __ vabs(d0, d2); __ vstr(d0, r4, OFFSET_OF(T, h)); + // Test vneg. + __ vldr(d1, r4, OFFSET_OF(T, m)); + __ vneg(d0, d1); + __ vstr(d0, r4, OFFSET_OF(T, m)); + __ vldr(d1, r4, OFFSET_OF(T, n)); + __ vneg(d0, d1); + __ vstr(d0, r4, OFFSET_OF(T, n)); + __ ldm(ia_w, sp, r4.bit() | fp.bit() | pc.bit()); CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); @@ -319,12 +329,16 @@ TEST(4) { t.g = -2718.2818; t.h = 31415926.5; t.i = 0; + t.m = -2718.2818; + t.n = 123.456; t.x = 4.5; t.y = 9.0; Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); USE(dummy); CHECK_EQ(4.5, t.y); CHECK_EQ(9.0, t.x); + CHECK_EQ(-123.456, t.n); + CHECK_EQ(2718.2818, t.m); CHECK_EQ(2, t.i); CHECK_EQ(2718.2818, t.g); CHECK_EQ(31415926.5, t.h); @@ -345,7 +359,7 @@ TEST(5) { Assembler assm(NULL, 0); - if (CpuFeatures::IsSupported(ARMv7)) { + if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { CpuFeatures::Scope scope(ARMv7); // On entry, r0 = 0xAAAAAAAA = 0b10..10101010. __ ubfx(r0, r0, 1, 12); // 0b00..010101010101 = 0x555 @@ -357,10 +371,10 @@ TEST(5) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); @@ -381,7 +395,7 @@ TEST(6) { Assembler assm(NULL, 0); - if (CpuFeatures::IsSupported(ARMv7)) { + if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { CpuFeatures::Scope scope(ARMv7); __ usat(r1, 8, Operand(r0)); // Sat 0xFFFF to 0-255 = 0xFF. __ usat(r2, 12, Operand(r0, ASR, 9)); // Sat (0xFFFF>>9) to 0-4095 = 0x7F. @@ -392,10 +406,10 @@ TEST(6) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); @@ -424,7 +438,7 @@ static void TestRoundingMode(VCVTTypes types, Assembler assm(NULL, 0); - if (CpuFeatures::IsSupported(VFP3)) { + if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { CpuFeatures::Scope scope(VFP3); Label wrong_exception; @@ -468,10 +482,10 @@ static void TestRoundingMode(VCVTTypes types, CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef DEBUG Code::cast(code)->Print(); diff --git a/test/cctest/test-assembler-ia32.cc b/test/cctest/test-assembler-ia32.cc index 14692ff1..694bd57b 100644 --- a/test/cctest/test-assembler-ia32.cc +++ b/test/cctest/test-assembler-ia32.cc @@ -69,10 +69,10 @@ TEST(AssemblerIa320) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode(desc, - Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))-> - ToObjectChecked(); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef OBJECT_PRINT Code::cast(code)->Print(); @@ -107,10 +107,10 @@ TEST(AssemblerIa321) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode(desc, - Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))-> - ToObjectChecked(); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef OBJECT_PRINT Code::cast(code)->Print(); @@ -144,16 +144,15 @@ TEST(AssemblerIa322) { __ ret(0); // some relocated stuff here, not executed - __ mov(eax, Factory::true_value()); + __ mov(eax, FACTORY->true_value()); __ jmp(NULL, RelocInfo::RUNTIME_ENTRY); CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); - + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef OBJECT_PRINT Code::cast(code)->Print(); @@ -168,7 +167,7 @@ TEST(AssemblerIa322) { typedef int (*F3)(float x); TEST(AssemblerIa323) { - if (!CpuFeatures::IsSupported(SSE2)) return; + if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return; InitializeVM(); v8::HandleScope scope; @@ -176,7 +175,7 @@ TEST(AssemblerIa323) { v8::internal::byte buffer[256]; Assembler assm(buffer, sizeof buffer); - CHECK(CpuFeatures::IsSupported(SSE2)); + CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2)); { CpuFeatures::Scope fscope(SSE2); __ cvttss2si(eax, Operand(esp, 4)); __ ret(0); @@ -184,10 +183,10 @@ TEST(AssemblerIa323) { CodeDesc desc; assm.GetCode(&desc); - Code* code = Code::cast(Heap::CreateCode( + Code* code = Code::cast(HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); // don't print the code - our disassembler can't handle cvttss2si // instead print bytes Disassembler::Dump(stdout, @@ -203,7 +202,7 @@ TEST(AssemblerIa323) { typedef int (*F4)(double x); TEST(AssemblerIa324) { - if (!CpuFeatures::IsSupported(SSE2)) return; + if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return; InitializeVM(); v8::HandleScope scope; @@ -211,17 +210,17 @@ TEST(AssemblerIa324) { v8::internal::byte buffer[256]; Assembler assm(buffer, sizeof buffer); - CHECK(CpuFeatures::IsSupported(SSE2)); + CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2)); CpuFeatures::Scope fscope(SSE2); __ cvttsd2si(eax, Operand(esp, 4)); __ ret(0); CodeDesc desc; assm.GetCode(&desc); - Code* code = Code::cast(Heap::CreateCode( + Code* code = Code::cast(HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); // don't print the code - our disassembler can't handle cvttsd2si // instead print bytes Disassembler::Dump(stdout, @@ -247,10 +246,10 @@ TEST(AssemblerIa325) { CodeDesc desc; assm.GetCode(&desc); - Code* code = Code::cast(Heap::CreateCode( + Code* code = Code::cast(HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); F0 f = FUNCTION_CAST<F0>(code->entry()); int res = f(); CHECK_EQ(42, res); @@ -260,11 +259,11 @@ TEST(AssemblerIa325) { typedef double (*F5)(double x, double y); TEST(AssemblerIa326) { - if (!CpuFeatures::IsSupported(SSE2)) return; + if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return; InitializeVM(); v8::HandleScope scope; - CHECK(CpuFeatures::IsSupported(SSE2)); + CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2)); CpuFeatures::Scope fscope(SSE2); v8::internal::byte buffer[256]; Assembler assm(buffer, sizeof buffer); @@ -284,10 +283,10 @@ TEST(AssemblerIa326) { CodeDesc desc; assm.GetCode(&desc); - Code* code = Code::cast(Heap::CreateCode( + Code* code = Code::cast(HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); #ifdef DEBUG ::printf("\n---\n"); // don't print the code - our disassembler can't handle SSE instructions @@ -306,11 +305,11 @@ TEST(AssemblerIa326) { typedef double (*F6)(int x); TEST(AssemblerIa328) { - if (!CpuFeatures::IsSupported(SSE2)) return; + if (!Isolate::Current()->cpu_features()->IsSupported(SSE2)) return; InitializeVM(); v8::HandleScope scope; - CHECK(CpuFeatures::IsSupported(SSE2)); + CHECK(Isolate::Current()->cpu_features()->IsSupported(SSE2)); CpuFeatures::Scope fscope(SSE2); v8::internal::byte buffer[256]; Assembler assm(buffer, sizeof buffer); @@ -324,10 +323,10 @@ TEST(AssemblerIa328) { __ ret(0); CodeDesc desc; assm.GetCode(&desc); - Code* code = Code::cast(Heap::CreateCode( + Code* code = Code::cast(HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); CHECK(code->IsCode()); #ifdef OBJECT_PRINT Code::cast(code)->Print(); @@ -379,10 +378,10 @@ TEST(AssemblerIa329) { CodeDesc desc; assm.GetCode(&desc); - Code* code = Code::cast(Heap::CreateCode( + Code* code = Code::cast(HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked()); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked()); CHECK(code->IsCode()); #ifdef OBJECT_PRINT Code::cast(code)->Print(); diff --git a/test/cctest/test-assembler-mips.cc b/test/cctest/test-assembler-mips.cc index ecb42e2f..8cd56f76 100644 --- a/test/cctest/test-assembler-mips.cc +++ b/test/cctest/test-assembler-mips.cc @@ -59,6 +59,7 @@ static void InitializeVM() { #define __ assm. + TEST(MIPS0) { InitializeVM(); v8::HandleScope scope; @@ -72,14 +73,11 @@ TEST(MIPS0) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode(desc, - NULL, - Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value())); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); -#ifdef DEBUG - Code::cast(code)->Print(); -#endif F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 0xab0, 0xc, 0, 0, 0)); ::printf("f() = %d\n", res); @@ -100,12 +98,12 @@ TEST(MIPS1) { __ nop(); __ bind(&L); - __ add(v0, v0, a1); + __ addu(v0, v0, a1); __ addiu(a1, a1, -1); __ bind(&C); __ xori(v1, a1, 0); - __ Branch(ne, &L, v1, Operand(0, RelocInfo::NONE)); + __ Branch(&L, ne, v1, Operand(0)); __ nop(); __ jr(ra); @@ -113,14 +111,11 @@ TEST(MIPS1) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode(desc, - NULL, - Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value())); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); -#ifdef DEBUG - Code::cast(code)->Print(); -#endif F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 50, 0, 0, 0, 0)); ::printf("f() = %d\n", res); @@ -166,62 +161,81 @@ TEST(MIPS2) { __ srav(v0, v0, t0); // 0xff234560 __ sllv(v0, v0, t0); // 0xf2345600 __ srlv(v0, v0, t0); // 0x0f234560 - __ Branch(ne, &error, v0, Operand(0x0f234560)); + __ Branch(&error, ne, v0, Operand(0x0f234560)); __ nop(); - __ add(v0, t0, t1); // 0x00001238 - __ sub(v0, v0, t0); // 0x00001234 - __ Branch(ne, &error, v0, Operand(0x00001234)); + __ addu(v0, t0, t1); // 0x00001238 + __ subu(v0, v0, t0); // 0x00001234 + __ Branch(&error, ne, v0, Operand(0x00001234)); __ nop(); __ addu(v1, t3, t0); - __ Branch(ne, &error, v1, Operand(0x80000003)); + __ Branch(&error, ne, v1, Operand(0x80000003)); __ nop(); __ subu(v1, t7, t0); // 0x7ffffffc - __ Branch(ne, &error, v1, Operand(0x7ffffffc)); + __ Branch(&error, ne, v1, Operand(0x7ffffffc)); __ nop(); __ and_(v0, t1, t2); // 0x00001230 __ or_(v0, v0, t1); // 0x00001234 __ xor_(v0, v0, t2); // 0x1234444c __ nor(v0, v0, t2); // 0xedcba987 - __ Branch(ne, &error, v0, Operand(0xedcba983)); + __ Branch(&error, ne, v0, Operand(0xedcba983)); __ nop(); __ slt(v0, t7, t3); - __ Branch(ne, &error, v0, Operand(0x1)); + __ Branch(&error, ne, v0, Operand(0x1)); __ nop(); __ sltu(v0, t7, t3); - __ Branch(ne, &error, v0, Operand(0x0)); + __ Branch(&error, ne, v0, Operand(0x0)); __ nop(); // End of SPECIAL class. - __ addi(v0, zero_reg, 0x7421); // 0x00007421 - __ addi(v0, v0, -0x1); // 0x00007420 + __ addiu(v0, zero_reg, 0x7421); // 0x00007421 + __ addiu(v0, v0, -0x1); // 0x00007420 __ addiu(v0, v0, -0x20); // 0x00007400 - __ Branch(ne, &error, v0, Operand(0x00007400)); + __ Branch(&error, ne, v0, Operand(0x00007400)); __ nop(); __ addiu(v1, t3, 0x1); // 0x80000000 - __ Branch(ne, &error, v1, Operand(0x80000000)); + __ Branch(&error, ne, v1, Operand(0x80000000)); __ nop(); __ slti(v0, t1, 0x00002000); // 0x1 __ slti(v0, v0, 0xffff8000); // 0x0 - __ Branch(ne, &error, v0, Operand(0x0)); + __ Branch(&error, ne, v0, Operand(0x0)); __ nop(); __ sltiu(v0, t1, 0x00002000); // 0x1 __ sltiu(v0, v0, 0x00008000); // 0x1 - __ Branch(ne, &error, v0, Operand(0x1)); + __ Branch(&error, ne, v0, Operand(0x1)); __ nop(); __ andi(v0, t1, 0xf0f0); // 0x00001030 __ ori(v0, v0, 0x8a00); // 0x00009a30 __ xori(v0, v0, 0x83cc); // 0x000019fc - __ Branch(ne, &error, v0, Operand(0x000019fc)); + __ Branch(&error, ne, v0, Operand(0x000019fc)); __ nop(); __ lui(v1, 0x8123); // 0x81230000 - __ Branch(ne, &error, v1, Operand(0x81230000)); + __ Branch(&error, ne, v1, Operand(0x81230000)); __ nop(); + // Bit twiddling instructions & conditional moves. + // Uses t0-t7 as set above. + __ clz(v0, t0); // 29 + __ clz(v1, t1); // 19 + __ addu(v0, v0, v1); // 48 + __ clz(v1, t2); // 3 + __ addu(v0, v0, v1); // 51 + __ clz(v1, t7); // 0 + __ addu(v0, v0, v1); // 51 + __ Branch(&error, ne, v0, Operand(51)); + __ movn(a0, t3, t0); // Move a0<-t3 (t0 is NOT 0). + __ Ins(a0, t1, 12, 8); // 0x7ff34fff + __ Branch(&error, ne, a0, Operand(0x7ff34fff)); + __ movz(a0, t6, t7); // a0 not updated (t7 is NOT 0). + __ Ext(a1, a0, 8, 12); // 0x34f + __ Branch(&error, ne, a1, Operand(0x34f)); + __ movz(a0, t6, v1); // a0<-t6, v0 is 0, from 8 instr back. + __ Branch(&error, ne, a0, Operand(t6)); + // Everything was correctly executed. Load the expected result. __ li(v0, 0x31415926); __ b(&exit); @@ -229,6 +243,7 @@ TEST(MIPS2) { __ bind(&error); // Got an error. Return a wrong result. + __ li(v0, 666); __ bind(&exit); __ jr(ra); @@ -236,18 +251,1061 @@ TEST(MIPS2) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode(desc, - NULL, - Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value())); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); -#ifdef DEBUG - Code::cast(code)->Print(); -#endif F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 0xab0, 0xc, 0, 0, 0)); ::printf("f() = %d\n", res); CHECK_EQ(0x31415926, res); } + +TEST(MIPS3) { + // Test floating point instructions. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + double a; + double b; + double c; + double d; + double e; + double f; + double g; + } T; + T t; + + // Create a function that accepts &t, and loads, manipulates, and stores + // the doubles t.a ... t.f. + MacroAssembler assm(NULL, 0); + Label L, C; + + if (Isolate::Current()->cpu_features()->IsSupported(FPU)) { + CpuFeatures::Scope scope(FPU); + + __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); + __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); + __ add_d(f8, f4, f6); + __ sdc1(f8, MemOperand(a0, OFFSET_OF(T, c)) ); // c = a + b. + + __ mov_d(f10, f8); // c + __ neg_d(f12, f6); // -b + __ sub_d(f10, f10, f12); + __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, d)) ); // d = c - (-b). + + __ sdc1(f4, MemOperand(a0, OFFSET_OF(T, b)) ); // b = a. + + __ li(t0, 120); + __ mtc1(t0, f14); + __ cvt_d_w(f14, f14); // f14 = 120.0. + __ mul_d(f10, f10, f14); + __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, e)) ); // e = d * 120 = 1.8066e16. + + __ div_d(f12, f10, f4); + __ sdc1(f12, MemOperand(a0, OFFSET_OF(T, f)) ); // f = e / a = 120.44. + + __ sqrt_d(f14, f12); + __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, g)) ); + // g = sqrt(f) = 10.97451593465515908537 + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.a = 1.5e14; + t.b = 2.75e11; + t.c = 0.0; + t.d = 0.0; + t.e = 0.0; + t.f = 0.0; + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + CHECK_EQ(1.5e14, t.a); + CHECK_EQ(1.5e14, t.b); + CHECK_EQ(1.50275e14, t.c); + CHECK_EQ(1.50550e14, t.d); + CHECK_EQ(1.8066e16, t.e); + CHECK_EQ(120.44, t.f); + CHECK_EQ(10.97451593465515908537, t.g); + } +} + + +TEST(MIPS4) { + // Test moves between floating point and integer registers. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + double a; + double b; + double c; + } T; + T t; + + Assembler assm(NULL, 0); + Label L, C; + + if (Isolate::Current()->cpu_features()->IsSupported(FPU)) { + CpuFeatures::Scope scope(FPU); + + __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); + __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); + + // Swap f4 and f6, by using four integer registers, t0-t3. + __ mfc1(t0, f4); + __ mfc1(t1, f5); + __ mfc1(t2, f6); + __ mfc1(t3, f7); + + __ mtc1(t0, f6); + __ mtc1(t1, f7); + __ mtc1(t2, f4); + __ mtc1(t3, f5); + + // Store the swapped f4 and f5 back to memory. + __ sdc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); + __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, c)) ); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.a = 1.5e22; + t.b = 2.75e11; + t.c = 17.17; + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(2.75e11, t.a); + CHECK_EQ(2.75e11, t.b); + CHECK_EQ(1.5e22, t.c); + } +} + + +TEST(MIPS5) { + // Test conversions between doubles and integers. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + double a; + double b; + int i; + int j; + } T; + T t; + + Assembler assm(NULL, 0); + Label L, C; + + if (Isolate::Current()->cpu_features()->IsSupported(FPU)) { + CpuFeatures::Scope scope(FPU); + + // Load all structure elements to registers. + __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); + __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); + __ lw(t0, MemOperand(a0, OFFSET_OF(T, i)) ); + __ lw(t1, MemOperand(a0, OFFSET_OF(T, j)) ); + + // Convert double in f4 to int in element i. + __ cvt_w_d(f8, f4); + __ mfc1(t2, f8); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, i)) ); + + // Convert double in f6 to int in element j. + __ cvt_w_d(f10, f6); + __ mfc1(t3, f10); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, j)) ); + + // Convert int in original i (t0) to double in a. + __ mtc1(t0, f12); + __ cvt_d_w(f0, f12); + __ sdc1(f0, MemOperand(a0, OFFSET_OF(T, a)) ); + + // Convert int in original j (t1) to double in b. + __ mtc1(t1, f14); + __ cvt_d_w(f2, f14); + __ sdc1(f2, MemOperand(a0, OFFSET_OF(T, b)) ); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.a = 1.5e4; + t.b = 2.75e8; + t.i = 12345678; + t.j = -100000; + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(12345678.0, t.a); + CHECK_EQ(-100000.0, t.b); + CHECK_EQ(15000, t.i); + CHECK_EQ(275000000, t.j); + } +} + + +TEST(MIPS6) { + // Test simple memory loads and stores. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + uint32_t ui; + int32_t si; + int32_t r1; + int32_t r2; + int32_t r3; + int32_t r4; + int32_t r5; + int32_t r6; + } T; + T t; + + Assembler assm(NULL, 0); + Label L, C; + + // Basic word load/store. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, ui)) ); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, r1)) ); + + // lh with positive data. + __ lh(t1, MemOperand(a0, OFFSET_OF(T, ui)) ); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, r2)) ); + + // lh with negative data. + __ lh(t2, MemOperand(a0, OFFSET_OF(T, si)) ); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, r3)) ); + + // lhu with negative data. + __ lhu(t3, MemOperand(a0, OFFSET_OF(T, si)) ); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, r4)) ); + + // lb with negative data. + __ lb(t4, MemOperand(a0, OFFSET_OF(T, si)) ); + __ sw(t4, MemOperand(a0, OFFSET_OF(T, r5)) ); + + // sh writes only 1/2 of word. + __ lui(t5, 0x3333); + __ ori(t5, t5, 0x3333); + __ sw(t5, MemOperand(a0, OFFSET_OF(T, r6)) ); + __ lhu(t5, MemOperand(a0, OFFSET_OF(T, si)) ); + __ sh(t5, MemOperand(a0, OFFSET_OF(T, r6)) ); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.ui = 0x11223344; + t.si = 0x99aabbcc; + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(0x11223344, t.r1); + CHECK_EQ(0x3344, t.r2); + CHECK_EQ(0xffffbbcc, t.r3); + CHECK_EQ(0x0000bbcc, t.r4); + CHECK_EQ(0xffffffcc, t.r5); + CHECK_EQ(0x3333bbcc, t.r6); +} + + +TEST(MIPS7) { + // Test floating point compare and branch instructions. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + double a; + double b; + double c; + double d; + double e; + double f; + int32_t result; + } T; + T t; + + // Create a function that accepts &t, and loads, manipulates, and stores + // the doubles t.a ... t.f. + MacroAssembler assm(NULL, 0); + Label neither_is_nan, less_than, outa_here; + + if (Isolate::Current()->cpu_features()->IsSupported(FPU)) { + CpuFeatures::Scope scope(FPU); + + __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); + __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); + __ c(UN, D, f4, f6); + __ bc1f(&neither_is_nan); + __ nop(); + __ sw(zero_reg, MemOperand(a0, OFFSET_OF(T, result)) ); + __ Branch(&outa_here); + + __ bind(&neither_is_nan); + + __ c(OLT, D, f6, f4, 2); + __ bc1t(&less_than, 2); + __ nop(); + __ sw(zero_reg, MemOperand(a0, OFFSET_OF(T, result)) ); + __ Branch(&outa_here); + + __ bind(&less_than); + __ Addu(t0, zero_reg, Operand(1)); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, result)) ); // Set true. + + + // This test-case should have additional tests. + + __ bind(&outa_here); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.a = 1.5e14; + t.b = 2.75e11; + t.c = 2.0; + t.d = -4.0; + t.e = 0.0; + t.f = 0.0; + t.result = 0; + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + CHECK_EQ(1.5e14, t.a); + CHECK_EQ(2.75e11, t.b); + CHECK_EQ(1, t.result); + } +} + + +TEST(MIPS8) { + // Test ROTR and ROTRV instructions. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + int32_t input; + int32_t result_rotr_4; + int32_t result_rotr_8; + int32_t result_rotr_12; + int32_t result_rotr_16; + int32_t result_rotr_20; + int32_t result_rotr_24; + int32_t result_rotr_28; + int32_t result_rotrv_4; + int32_t result_rotrv_8; + int32_t result_rotrv_12; + int32_t result_rotrv_16; + int32_t result_rotrv_20; + int32_t result_rotrv_24; + int32_t result_rotrv_28; + } T; + T t; + + MacroAssembler assm(NULL, 0); + + // Basic word load. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, input)) ); + + // ROTR instruction (called through the Ror macro). + __ Ror(t1, t0, 0x0004); + __ Ror(t2, t0, 0x0008); + __ Ror(t3, t0, 0x000c); + __ Ror(t4, t0, 0x0010); + __ Ror(t5, t0, 0x0014); + __ Ror(t6, t0, 0x0018); + __ Ror(t7, t0, 0x001c); + + // Basic word store. + __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotr_4)) ); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotr_8)) ); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotr_12)) ); + __ sw(t4, MemOperand(a0, OFFSET_OF(T, result_rotr_16)) ); + __ sw(t5, MemOperand(a0, OFFSET_OF(T, result_rotr_20)) ); + __ sw(t6, MemOperand(a0, OFFSET_OF(T, result_rotr_24)) ); + __ sw(t7, MemOperand(a0, OFFSET_OF(T, result_rotr_28)) ); + + // ROTRV instruction (called through the Ror macro). + __ li(t7, 0x0004); + __ Ror(t1, t0, t7); + __ li(t7, 0x0008); + __ Ror(t2, t0, t7); + __ li(t7, 0x000C); + __ Ror(t3, t0, t7); + __ li(t7, 0x0010); + __ Ror(t4, t0, t7); + __ li(t7, 0x0014); + __ Ror(t5, t0, t7); + __ li(t7, 0x0018); + __ Ror(t6, t0, t7); + __ li(t7, 0x001C); + __ Ror(t7, t0, t7); + + // Basic word store. + __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotrv_4)) ); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotrv_8)) ); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotrv_12)) ); + __ sw(t4, MemOperand(a0, OFFSET_OF(T, result_rotrv_16)) ); + __ sw(t5, MemOperand(a0, OFFSET_OF(T, result_rotrv_20)) ); + __ sw(t6, MemOperand(a0, OFFSET_OF(T, result_rotrv_24)) ); + __ sw(t7, MemOperand(a0, OFFSET_OF(T, result_rotrv_28)) ); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.input = 0x12345678; + Object* dummy = CALL_GENERATED_CODE(f, &t, 0x0, 0, 0, 0); + USE(dummy); + CHECK_EQ(0x81234567, t.result_rotr_4); + CHECK_EQ(0x78123456, t.result_rotr_8); + CHECK_EQ(0x67812345, t.result_rotr_12); + CHECK_EQ(0x56781234, t.result_rotr_16); + CHECK_EQ(0x45678123, t.result_rotr_20); + CHECK_EQ(0x34567812, t.result_rotr_24); + CHECK_EQ(0x23456781, t.result_rotr_28); + + CHECK_EQ(0x81234567, t.result_rotrv_4); + CHECK_EQ(0x78123456, t.result_rotrv_8); + CHECK_EQ(0x67812345, t.result_rotrv_12); + CHECK_EQ(0x56781234, t.result_rotrv_16); + CHECK_EQ(0x45678123, t.result_rotrv_20); + CHECK_EQ(0x34567812, t.result_rotrv_24); + CHECK_EQ(0x23456781, t.result_rotrv_28); +} + + +TEST(MIPS9) { + // Test BRANCH improvements. + InitializeVM(); + v8::HandleScope scope; + + MacroAssembler assm(NULL, 0); + Label exit, exit2, exit3; + + __ Branch(&exit, ge, a0, Operand(0x00000000)); + __ Branch(&exit2, ge, a0, Operand(0x00001FFF)); + __ Branch(&exit3, ge, a0, Operand(0x0001FFFF)); + + __ bind(&exit); + __ bind(&exit2); + __ bind(&exit3); + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); +} + + +TEST(MIPS10) { + // Test conversions between doubles and long integers. + // Test hos the long ints map to FP regs pairs. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + double a; + double b; + int32_t dbl_mant; + int32_t dbl_exp; + int32_t long_hi; + int32_t long_lo; + int32_t b_long_hi; + int32_t b_long_lo; + } T; + T t; + + Assembler assm(NULL, 0); + Label L, C; + + if (Isolate::Current()->cpu_features()->IsSupported(FPU)) { + CpuFeatures::Scope scope(FPU); + + // Load all structure elements to registers. + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, a))); + + // Save the raw bits of the double. + __ mfc1(t0, f0); + __ mfc1(t1, f1); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, dbl_mant))); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, dbl_exp))); + + // Convert double in f0 to long, save hi/lo parts. + __ cvt_l_d(f0, f0); + __ mfc1(t0, f0); // f0 has LS 32 bits of long. + __ mfc1(t1, f1); // f1 has MS 32 bits of long. + __ sw(t0, MemOperand(a0, OFFSET_OF(T, long_lo))); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, long_hi))); + + // Convert the b long integers to double b. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, b_long_lo))); + __ lw(t1, MemOperand(a0, OFFSET_OF(T, b_long_hi))); + __ mtc1(t0, f8); // f8 has LS 32-bits. + __ mtc1(t1, f9); // f9 has MS 32-bits. + __ cvt_d_l(f10, f8); + __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, b))); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.a = 2.147483647e9; // 0x7fffffff -> 0x41DFFFFFFFC00000 as double. + t.b_long_hi = 0x000000ff; // 0xFF00FF00FF -> 0x426FE01FE01FE000 as double. + t.b_long_lo = 0x00ff00ff; + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(0x41DFFFFF, t.dbl_exp); + CHECK_EQ(0xFFC00000, t.dbl_mant); + CHECK_EQ(0, t.long_hi); + CHECK_EQ(0x7fffffff, t.long_lo); + // 0xFF00FF00FF -> 1.095233372415e12. + CHECK_EQ(1.095233372415e12, t.b); + } +} + + +TEST(MIPS11) { + // Test LWL, LWR, SWL and SWR instructions. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + int32_t reg_init; + int32_t mem_init; + int32_t lwl_0; + int32_t lwl_1; + int32_t lwl_2; + int32_t lwl_3; + int32_t lwr_0; + int32_t lwr_1; + int32_t lwr_2; + int32_t lwr_3; + int32_t swl_0; + int32_t swl_1; + int32_t swl_2; + int32_t swl_3; + int32_t swr_0; + int32_t swr_1; + int32_t swr_2; + int32_t swr_3; + } T; + T t; + + Assembler assm(NULL, 0); + + // Test all combinations of LWL and vAddr. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwl(t0, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, lwl_0)) ); + + __ lw(t1, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwl(t1, MemOperand(a0, OFFSET_OF(T, mem_init) + 1) ); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, lwl_1)) ); + + __ lw(t2, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwl(t2, MemOperand(a0, OFFSET_OF(T, mem_init) + 2) ); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, lwl_2)) ); + + __ lw(t3, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwl(t3, MemOperand(a0, OFFSET_OF(T, mem_init) + 3) ); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, lwl_3)) ); + + // Test all combinations of LWR and vAddr. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwr(t0, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, lwr_0)) ); + + __ lw(t1, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwr(t1, MemOperand(a0, OFFSET_OF(T, mem_init) + 1) ); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, lwr_1)) ); + + __ lw(t2, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwr(t2, MemOperand(a0, OFFSET_OF(T, mem_init) + 2) ); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, lwr_2)) ); + + __ lw(t3, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ lwr(t3, MemOperand(a0, OFFSET_OF(T, mem_init) + 3) ); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, lwr_3)) ); + + // Test all combinations of SWL and vAddr. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, swl_0)) ); + __ lw(t0, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swl(t0, MemOperand(a0, OFFSET_OF(T, swl_0)) ); + + __ lw(t1, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, swl_1)) ); + __ lw(t1, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swl(t1, MemOperand(a0, OFFSET_OF(T, swl_1) + 1) ); + + __ lw(t2, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, swl_2)) ); + __ lw(t2, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swl(t2, MemOperand(a0, OFFSET_OF(T, swl_2) + 2) ); + + __ lw(t3, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, swl_3)) ); + __ lw(t3, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swl(t3, MemOperand(a0, OFFSET_OF(T, swl_3) + 3) ); + + // Test all combinations of SWR and vAddr. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, swr_0)) ); + __ lw(t0, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swr(t0, MemOperand(a0, OFFSET_OF(T, swr_0)) ); + + __ lw(t1, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, swr_1)) ); + __ lw(t1, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swr(t1, MemOperand(a0, OFFSET_OF(T, swr_1) + 1) ); + + __ lw(t2, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t2, MemOperand(a0, OFFSET_OF(T, swr_2)) ); + __ lw(t2, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swr(t2, MemOperand(a0, OFFSET_OF(T, swr_2) + 2) ); + + __ lw(t3, MemOperand(a0, OFFSET_OF(T, mem_init)) ); + __ sw(t3, MemOperand(a0, OFFSET_OF(T, swr_3)) ); + __ lw(t3, MemOperand(a0, OFFSET_OF(T, reg_init)) ); + __ swr(t3, MemOperand(a0, OFFSET_OF(T, swr_3) + 3) ); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.reg_init = 0xaabbccdd; + t.mem_init = 0x11223344; + + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(0x44bbccdd, t.lwl_0); + CHECK_EQ(0x3344ccdd, t.lwl_1); + CHECK_EQ(0x223344dd, t.lwl_2); + CHECK_EQ(0x11223344, t.lwl_3); + + CHECK_EQ(0x11223344, t.lwr_0); + CHECK_EQ(0xaa112233, t.lwr_1); + CHECK_EQ(0xaabb1122, t.lwr_2); + CHECK_EQ(0xaabbcc11, t.lwr_3); + + CHECK_EQ(0x112233aa, t.swl_0); + CHECK_EQ(0x1122aabb, t.swl_1); + CHECK_EQ(0x11aabbcc, t.swl_2); + CHECK_EQ(0xaabbccdd, t.swl_3); + + CHECK_EQ(0xaabbccdd, t.swr_0); + CHECK_EQ(0xbbccdd44, t.swr_1); + CHECK_EQ(0xccdd3344, t.swr_2); + CHECK_EQ(0xdd223344, t.swr_3); +} + + +TEST(MIPS12) { + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + int32_t x; + int32_t y; + int32_t y1; + int32_t y2; + int32_t y3; + int32_t y4; + } T; + T t; + + MacroAssembler assm(NULL, 0); + + __ mov(t6, fp); // Save frame pointer. + __ mov(fp, a0); // Access struct T by fp. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, y)) ); + __ lw(t3, MemOperand(a0, OFFSET_OF(T, y4)) ); + + __ addu(t1, t0, t3); + __ subu(t4, t0, t3); + __ nop(); + __ Push(t0); // These instructions disappear after opt. + __ Pop(); + __ addu(t0, t0, t0); + __ nop(); + __ Pop(); // These instructions disappear after opt. + __ Push(t3); + __ nop(); + __ Push(t3); // These instructions disappear after opt. + __ Pop(t3); + __ nop(); + __ Push(t3); + __ Pop(t4); + __ nop(); + __ sw(t0, MemOperand(fp, OFFSET_OF(T, y)) ); + __ lw(t0, MemOperand(fp, OFFSET_OF(T, y)) ); + __ nop(); + __ sw(t0, MemOperand(fp, OFFSET_OF(T, y)) ); + __ lw(t1, MemOperand(fp, OFFSET_OF(T, y)) ); + __ nop(); + __ Push(t1); + __ lw(t1, MemOperand(fp, OFFSET_OF(T, y)) ); + __ Pop(t1); + __ nop(); + __ Push(t1); + __ lw(t2, MemOperand(fp, OFFSET_OF(T, y)) ); + __ Pop(t1); + __ nop(); + __ Push(t1); + __ lw(t2, MemOperand(fp, OFFSET_OF(T, y)) ); + __ Pop(t2); + __ nop(); + __ Push(t2); + __ lw(t2, MemOperand(fp, OFFSET_OF(T, y)) ); + __ Pop(t1); + __ nop(); + __ Push(t1); + __ lw(t2, MemOperand(fp, OFFSET_OF(T, y)) ); + __ Pop(t3); + __ nop(); + + __ mov(fp, t6); + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + t.x = 1; + t.y = 2; + t.y1 = 3; + t.y2 = 4; + t.y3 = 0XBABA; + t.y4 = 0xDEDA; + + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(3, t.y1); +} + + +TEST(MIPS13) { + // Test Cvt_d_uw and Trunc_uw_d macros. + InitializeVM(); + v8::HandleScope scope; + + typedef struct { + double cvt_big_out; + double cvt_small_out; + uint32_t trunc_big_out; + uint32_t trunc_small_out; + uint32_t cvt_big_in; + uint32_t cvt_small_in; + } T; + T t; + + MacroAssembler assm(NULL, 0); + + if (Isolate::Current()->cpu_features()->IsSupported(FPU)) { + CpuFeatures::Scope scope(FPU); + + __ sw(t0, MemOperand(a0, OFFSET_OF(T, cvt_small_in))); + __ Cvt_d_uw(f10, t0); + __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, cvt_small_out))); + + __ Trunc_uw_d(f10, f10); + __ swc1(f10, MemOperand(a0, OFFSET_OF(T, trunc_small_out))); + + __ sw(t0, MemOperand(a0, OFFSET_OF(T, cvt_big_in))); + __ Cvt_d_uw(f8, t0); + __ sdc1(f8, MemOperand(a0, OFFSET_OF(T, cvt_big_out))); + + __ Trunc_uw_d(f8, f8); + __ swc1(f8, MemOperand(a0, OFFSET_OF(T, trunc_big_out))); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + + t.cvt_big_in = 0xFFFFFFFF; + t.cvt_small_in = 333; + + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(t.cvt_big_out, static_cast<double>(t.cvt_big_in)); + CHECK_EQ(t.cvt_small_out, static_cast<double>(t.cvt_small_in)); + + CHECK_EQ(static_cast<int>(t.trunc_big_out), static_cast<int>(t.cvt_big_in)); + CHECK_EQ(static_cast<int>(t.trunc_small_out), + static_cast<int>(t.cvt_small_in)); + } +} + + +TEST(MIPS14) { + // Test round, floor, ceil, trunc, cvt. + InitializeVM(); + v8::HandleScope scope; + +#define ROUND_STRUCT_ELEMENT(x) \ + int32_t x##_up_out; \ + int32_t x##_down_out; \ + int32_t neg_##x##_up_out; \ + int32_t neg_##x##_down_out; \ + int32_t x##_err1_out; \ + int32_t x##_err2_out; \ + int32_t x##_err3_out; \ + int32_t x##_err4_out; \ + int32_t x##_invalid_result; + + typedef struct { + double round_up_in; + double round_down_in; + double neg_round_up_in; + double neg_round_down_in; + double err1_in; + double err2_in; + double err3_in; + double err4_in; + + ROUND_STRUCT_ELEMENT(round) + ROUND_STRUCT_ELEMENT(floor) + ROUND_STRUCT_ELEMENT(ceil) + ROUND_STRUCT_ELEMENT(trunc) + ROUND_STRUCT_ELEMENT(cvt) + } T; + T t; + +#undef ROUND_STRUCT_ELEMENT + + MacroAssembler assm(NULL, 0); + + if (Isolate::Current()->cpu_features()->IsSupported(FPU)) { + CpuFeatures::Scope scope(FPU); + + // Save FCSR. + __ cfc1(a1, FCSR); + // Disable FPU exceptions. + __ ctc1(zero_reg, FCSR); +#define RUN_ROUND_TEST(x) \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, round_up_in))); \ + __ x##_w_d(f0, f0); \ + __ swc1(f0, MemOperand(a0, OFFSET_OF(T, x##_up_out))); \ + \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, round_down_in))); \ + __ x##_w_d(f0, f0); \ + __ swc1(f0, MemOperand(a0, OFFSET_OF(T, x##_down_out))); \ + \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, neg_round_up_in))); \ + __ x##_w_d(f0, f0); \ + __ swc1(f0, MemOperand(a0, OFFSET_OF(T, neg_##x##_up_out))); \ + \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, neg_round_down_in))); \ + __ x##_w_d(f0, f0); \ + __ swc1(f0, MemOperand(a0, OFFSET_OF(T, neg_##x##_down_out))); \ + \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, err1_in))); \ + __ ctc1(zero_reg, FCSR); \ + __ x##_w_d(f0, f0); \ + __ cfc1(a2, FCSR); \ + __ sw(a2, MemOperand(a0, OFFSET_OF(T, x##_err1_out))); \ + \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, err2_in))); \ + __ ctc1(zero_reg, FCSR); \ + __ x##_w_d(f0, f0); \ + __ cfc1(a2, FCSR); \ + __ sw(a2, MemOperand(a0, OFFSET_OF(T, x##_err2_out))); \ + \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, err3_in))); \ + __ ctc1(zero_reg, FCSR); \ + __ x##_w_d(f0, f0); \ + __ cfc1(a2, FCSR); \ + __ sw(a2, MemOperand(a0, OFFSET_OF(T, x##_err3_out))); \ + \ + __ ldc1(f0, MemOperand(a0, OFFSET_OF(T, err4_in))); \ + __ ctc1(zero_reg, FCSR); \ + __ x##_w_d(f0, f0); \ + __ cfc1(a2, FCSR); \ + __ sw(a2, MemOperand(a0, OFFSET_OF(T, x##_err4_out))); \ + __ swc1(f0, MemOperand(a0, OFFSET_OF(T, x##_invalid_result))); + + RUN_ROUND_TEST(round) + RUN_ROUND_TEST(floor) + RUN_ROUND_TEST(ceil) + RUN_ROUND_TEST(trunc) + RUN_ROUND_TEST(cvt) + + // Restore FCSR. + __ ctc1(a1, FCSR); + +#undef RUN_ROUND_TEST + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Object* code = HEAP->CreateCode( + desc, + Code::ComputeFlags(Code::STUB), + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); + CHECK(code->IsCode()); + F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); + + t.round_up_in = 123.51; + t.round_down_in = 123.49; + t.neg_round_up_in = -123.5; + t.neg_round_down_in = -123.49; + t.err1_in = 123.51; + t.err2_in = 1; + t.err3_in = static_cast<double>(1) + 0xFFFFFFFF; + t.err4_in = NAN; + + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + +#define GET_FPU_ERR(x) ((x >> 2) & (32 - 1)) + + CHECK_EQ(124, t.round_up_out); + CHECK_EQ(123, t.round_down_out); + CHECK_EQ(-124, t.neg_round_up_out); + CHECK_EQ(-123, t.neg_round_down_out); + + // Inaccurate. + CHECK_EQ(1, GET_FPU_ERR(t.round_err1_out)); + // No error. + CHECK_EQ(0, GET_FPU_ERR(t.round_err2_out)); + // Invalid operation. + CHECK_EQ(16, GET_FPU_ERR(t.round_err3_out)); + CHECK_EQ(16, GET_FPU_ERR(t.round_err4_out)); + CHECK_EQ(kFPUInvalidResult, t.round_invalid_result); + + CHECK_EQ(123, t.floor_up_out); + CHECK_EQ(123, t.floor_down_out); + CHECK_EQ(-124, t.neg_floor_up_out); + CHECK_EQ(-124, t.neg_floor_down_out); + + // Inaccurate. + CHECK_EQ(1, GET_FPU_ERR(t.floor_err1_out)); + // No error. + CHECK_EQ(0, GET_FPU_ERR(t.floor_err2_out)); + // Invalid operation. + CHECK_EQ(16, GET_FPU_ERR(t.floor_err3_out)); + CHECK_EQ(16, GET_FPU_ERR(t.floor_err4_out)); + CHECK_EQ(kFPUInvalidResult, t.floor_invalid_result); + + CHECK_EQ(124, t.ceil_up_out); + CHECK_EQ(124, t.ceil_down_out); + CHECK_EQ(-123, t.neg_ceil_up_out); + CHECK_EQ(-123, t.neg_ceil_down_out); + + // Inaccurate. + CHECK_EQ(1, GET_FPU_ERR(t.ceil_err1_out)); + // No error. + CHECK_EQ(0, GET_FPU_ERR(t.ceil_err2_out)); + // Invalid operation. + CHECK_EQ(16, GET_FPU_ERR(t.ceil_err3_out)); + CHECK_EQ(16, GET_FPU_ERR(t.ceil_err4_out)); + CHECK_EQ(kFPUInvalidResult, t.ceil_invalid_result); + + // In rounding mode 0 cvt should behave like round. + CHECK_EQ(t.round_up_out, t.cvt_up_out); + CHECK_EQ(t.round_down_out, t.cvt_down_out); + CHECK_EQ(t.neg_round_up_out, t.neg_cvt_up_out); + CHECK_EQ(t.neg_round_down_out, t.neg_cvt_down_out); + + // Inaccurate. + CHECK_EQ(1, GET_FPU_ERR(t.cvt_err1_out)); + // No error. + CHECK_EQ(0, GET_FPU_ERR(t.cvt_err2_out)); + // Invalid operation. + CHECK_EQ(16, GET_FPU_ERR(t.cvt_err3_out)); + CHECK_EQ(16, GET_FPU_ERR(t.cvt_err4_out)); + CHECK_EQ(kFPUInvalidResult, t.cvt_invalid_result); + } +} + + #undef __ diff --git a/test/cctest/test-assembler-x64.cc b/test/cctest/test-assembler-x64.cc index 5d292df0..7e2115a1 100644 --- a/test/cctest/test-assembler-x64.cc +++ b/test/cctest/test-assembler-x64.cc @@ -50,8 +50,8 @@ using v8::internal::rbp; using v8::internal::rsp; using v8::internal::r8; using v8::internal::r9; -using v8::internal::r12; using v8::internal::r13; +using v8::internal::r15; using v8::internal::times_1; using v8::internal::FUNCTION_CAST; @@ -86,6 +86,7 @@ static const v8::internal::Register arg2 = rsi; TEST(AssemblerX64ReturnOperation) { + OS::Setup(); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -107,6 +108,7 @@ TEST(AssemblerX64ReturnOperation) { } TEST(AssemblerX64StackOperations) { + OS::Setup(); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -138,6 +140,7 @@ TEST(AssemblerX64StackOperations) { } TEST(AssemblerX64ArithmeticOperations) { + OS::Setup(); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -159,6 +162,7 @@ TEST(AssemblerX64ArithmeticOperations) { } TEST(AssemblerX64ImulOperation) { + OS::Setup(); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -186,6 +190,7 @@ TEST(AssemblerX64ImulOperation) { } TEST(AssemblerX64MemoryOperands) { + OS::Setup(); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -219,6 +224,7 @@ TEST(AssemblerX64MemoryOperands) { } TEST(AssemblerX64ControlFlow) { + OS::Setup(); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -247,6 +253,7 @@ TEST(AssemblerX64ControlFlow) { } TEST(AssemblerX64LoopImmediates) { + OS::Setup(); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -317,7 +324,7 @@ TEST(OperandRegisterDependency) { CHECK(Operand(rsp, offset).AddressUsesRegister(rsp)); CHECK(!Operand(rsp, offset).AddressUsesRegister(rax)); - CHECK(!Operand(rsp, offset).AddressUsesRegister(r12)); + CHECK(!Operand(rsp, offset).AddressUsesRegister(r15)); CHECK(Operand(rbp, offset).AddressUsesRegister(rbp)); CHECK(!Operand(rbp, offset).AddressUsesRegister(rax)); @@ -333,7 +340,7 @@ TEST(OperandRegisterDependency) { CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rsp)); CHECK(Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rbp)); CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(rax)); - CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r12)); + CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r15)); CHECK(!Operand(rsp, rbp, times_1, offset).AddressUsesRegister(r13)); } } diff --git a/test/cctest/test-ast.cc b/test/cctest/test-ast.cc index 9c292bcf..6183357b 100644 --- a/test/cctest/test-ast.cc +++ b/test/cctest/test-ast.cc @@ -35,6 +35,7 @@ using namespace v8::internal; TEST(List) { + v8::internal::V8::Initialize(NULL); List<AstNode*>* list = new List<AstNode*>(0); CHECK_EQ(0, list->length()); diff --git a/test/cctest/test-circular-queue.cc b/test/cctest/test-circular-queue.cc index ce9a42e8..9dd4981c 100644 --- a/test/cctest/test-circular-queue.cc +++ b/test/cctest/test-circular-queue.cc @@ -84,11 +84,13 @@ class ProducerThread: public i::Thread { public: typedef SamplingCircularQueue::Cell Record; - ProducerThread(SamplingCircularQueue* scq, + ProducerThread(i::Isolate* isolate, + SamplingCircularQueue* scq, int records_per_chunk, Record value, i::Semaphore* finished) - : scq_(scq), + : Thread(isolate, "producer"), + scq_(scq), records_per_chunk_(records_per_chunk), value_(value), finished_(finished) { } @@ -131,9 +133,10 @@ TEST(SamplingCircularQueueMultithreading) { // Check that we are using non-reserved values. CHECK_NE(SamplingCircularQueue::kClear, 1); CHECK_NE(SamplingCircularQueue::kEnd, 1); - ProducerThread producer1(&scq, kRecordsPerChunk, 1, semaphore); - ProducerThread producer2(&scq, kRecordsPerChunk, 10, semaphore); - ProducerThread producer3(&scq, kRecordsPerChunk, 20, semaphore); + i::Isolate* isolate = i::Isolate::Current(); + ProducerThread producer1(isolate, &scq, kRecordsPerChunk, 1, semaphore); + ProducerThread producer2(isolate, &scq, kRecordsPerChunk, 10, semaphore); + ProducerThread producer3(isolate, &scq, kRecordsPerChunk, 20, semaphore); CHECK_EQ(NULL, scq.StartDequeue()); producer1.Start(); diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index 9f21b78d..d3dd9c6f 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -34,7 +34,6 @@ #include "execution.h" #include "factory.h" #include "platform.h" -#include "top.h" #include "cctest.h" using namespace v8::internal; @@ -99,21 +98,21 @@ static void InitializeVM() { static MaybeObject* GetGlobalProperty(const char* name) { - Handle<String> symbol = Factory::LookupAsciiSymbol(name); - return Top::context()->global()->GetProperty(*symbol); + Handle<String> symbol = FACTORY->LookupAsciiSymbol(name); + return Isolate::Current()->context()->global()->GetProperty(*symbol); } static void SetGlobalProperty(const char* name, Object* value) { Handle<Object> object(value); - Handle<String> symbol = Factory::LookupAsciiSymbol(name); - Handle<JSObject> global(Top::context()->global()); + Handle<String> symbol = FACTORY->LookupAsciiSymbol(name); + Handle<JSObject> global(Isolate::Current()->context()->global()); SetProperty(global, symbol, object, NONE, kNonStrictMode); } static Handle<JSFunction> Compile(const char* source) { - Handle<String> source_code(Factory::NewStringFromUtf8(CStrVector(source))); + Handle<String> source_code(FACTORY->NewStringFromUtf8(CStrVector(source))); Handle<SharedFunctionInfo> shared_function = Compiler::Compile(source_code, Handle<String>(), @@ -123,8 +122,8 @@ static Handle<JSFunction> Compile(const char* source) { NULL, Handle<String>::null(), NOT_NATIVES_CODE); - return Factory::NewFunctionFromSharedFunctionInfo(shared_function, - Top::global_context()); + return FACTORY->NewFunctionFromSharedFunctionInfo(shared_function, + Isolate::Current()->global_context()); } @@ -137,7 +136,7 @@ static double Inc(int x) { if (fun.is_null()) return -1; bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Execution::Call(fun, global, 0, NULL, &has_pending_exception); CHECK(!has_pending_exception); return GetGlobalProperty("result")->ToObjectChecked()->Number(); @@ -158,7 +157,7 @@ static double Add(int x, int y) { SetGlobalProperty("x", Smi::FromInt(x)); SetGlobalProperty("y", Smi::FromInt(y)); bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Execution::Call(fun, global, 0, NULL, &has_pending_exception); CHECK(!has_pending_exception); return GetGlobalProperty("result")->ToObjectChecked()->Number(); @@ -178,7 +177,7 @@ static double Abs(int x) { SetGlobalProperty("x", Smi::FromInt(x)); bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Execution::Call(fun, global, 0, NULL, &has_pending_exception); CHECK(!has_pending_exception); return GetGlobalProperty("result")->ToObjectChecked()->Number(); @@ -199,7 +198,7 @@ static double Sum(int n) { SetGlobalProperty("n", Smi::FromInt(n)); bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Execution::Call(fun, global, 0, NULL, &has_pending_exception); CHECK(!has_pending_exception); return GetGlobalProperty("result")->ToObjectChecked()->Number(); @@ -220,7 +219,7 @@ TEST(Print) { Handle<JSFunction> fun = Compile(source); if (fun.is_null()) return; bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Execution::Call(fun, global, 0, NULL, &has_pending_exception); CHECK(!has_pending_exception); } @@ -253,7 +252,7 @@ TEST(Stuff) { Handle<JSFunction> fun = Compile(source); CHECK(!fun.is_null()); bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Execution::Call(fun, global, 0, NULL, &has_pending_exception); CHECK(!has_pending_exception); CHECK_EQ(511.0, GetGlobalProperty("r")->ToObjectChecked()->Number()); @@ -268,11 +267,12 @@ TEST(UncaughtThrow) { Handle<JSFunction> fun = Compile(source); CHECK(!fun.is_null()); bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Handle<Object> result = Execution::Call(fun, global, 0, NULL, &has_pending_exception); CHECK(has_pending_exception); - CHECK_EQ(42.0, Top::pending_exception()->ToObjectChecked()->Number()); + CHECK_EQ(42.0, Isolate::Current()->pending_exception()-> + ToObjectChecked()->Number()); } @@ -293,18 +293,18 @@ TEST(C2JSFrames) { // Run the generated code to populate the global object with 'foo'. bool has_pending_exception; - Handle<JSObject> global(Top::context()->global()); + Handle<JSObject> global(Isolate::Current()->context()->global()); Execution::Call(fun0, global, 0, NULL, &has_pending_exception); CHECK(!has_pending_exception); - Object* foo_symbol = Factory::LookupAsciiSymbol("foo")->ToObjectChecked(); - MaybeObject* fun1_object = - Top::context()->global()->GetProperty(String::cast(foo_symbol)); + Object* foo_symbol = FACTORY->LookupAsciiSymbol("foo")->ToObjectChecked(); + MaybeObject* fun1_object = Isolate::Current()->context()->global()-> + GetProperty(String::cast(foo_symbol)); Handle<Object> fun1(fun1_object->ToObjectChecked()); CHECK(fun1->IsJSFunction()); Object** argv[1] = { - Handle<Object>::cast(Factory::LookupAsciiSymbol("hello")).location() + Handle<Object>::cast(FACTORY->LookupAsciiSymbol("hello")).location() }; Execution::Call(Handle<JSFunction>::cast(fun1), global, 1, argv, &has_pending_exception); @@ -318,8 +318,8 @@ TEST(Regression236) { InitializeVM(); v8::HandleScope scope; - Handle<Script> script = Factory::NewScript(Factory::empty_string()); - script->set_source(Heap::undefined_value()); + Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string()); + script->set_source(HEAP->undefined_value()); CHECK_EQ(-1, GetScriptLineNumber(script, 0)); CHECK_EQ(-1, GetScriptLineNumber(script, 100)); CHECK_EQ(-1, GetScriptLineNumber(script, -1)); diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 7f06bc34..749ac154 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -7,6 +7,7 @@ #include "v8.h" #include "cpu-profiler-inl.h" #include "cctest.h" +#include "../include/v8-profiler.h" namespace i = v8::internal; @@ -23,7 +24,7 @@ using i::TokenEnumerator; TEST(StartStop) { CpuProfilesCollection profiles; ProfileGenerator generator(&profiles); - ProfilerEventsProcessor processor(&generator); + ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); processor.Start(); while (!processor.running()) { i::Thread::YieldCPU(); @@ -87,7 +88,7 @@ TEST(CodeEvents) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1); ProfileGenerator generator(&profiles); - ProfilerEventsProcessor processor(&generator); + ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); processor.Start(); while (!processor.running()) { i::Thread::YieldCPU(); @@ -96,11 +97,11 @@ TEST(CodeEvents) { // Enqueue code creation events. i::HandleScope scope; const char* aaa_str = "aaa"; - i::Handle<i::String> aaa_name = i::Factory::NewStringFromAscii( + i::Handle<i::String> aaa_name = FACTORY->NewStringFromAscii( i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); processor.CodeCreateEvent(i::Logger::FUNCTION_TAG, *aaa_name, - i::Heap::empty_string(), + HEAP->empty_string(), 0, ToAddress(0x1000), 0x100, @@ -151,7 +152,7 @@ TEST(TickEvents) { CpuProfilesCollection profiles; profiles.StartProfiling("", 1); ProfileGenerator generator(&profiles); - ProfilerEventsProcessor processor(&generator); + ProfilerEventsProcessor processor(i::Isolate::Current(), &generator); processor.Start(); while (!processor.running()) { i::Thread::YieldCPU(); @@ -236,4 +237,138 @@ TEST(CrashIfStoppingLastNonExistentProfile) { CpuProfiler::TearDown(); } + +TEST(DeleteAllCpuProfiles) { + InitializeVM(); + TestSetup test_setup; + CpuProfiler::Setup(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + CpuProfiler::DeleteAllProfiles(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + + CpuProfiler::StartProfiling("1"); + CpuProfiler::StopProfiling("1"); + CHECK_EQ(1, CpuProfiler::GetProfilesCount()); + CpuProfiler::DeleteAllProfiles(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + CpuProfiler::StartProfiling("1"); + CpuProfiler::StartProfiling("2"); + CpuProfiler::StopProfiling("2"); + CpuProfiler::StopProfiling("1"); + CHECK_EQ(2, CpuProfiler::GetProfilesCount()); + CpuProfiler::DeleteAllProfiles(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + + // Test profiling cancellation by the 'delete' command. + CpuProfiler::StartProfiling("1"); + CpuProfiler::StartProfiling("2"); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + CpuProfiler::DeleteAllProfiles(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + + CpuProfiler::TearDown(); +} + + +TEST(DeleteCpuProfile) { + v8::HandleScope scope; + LocalContext env; + + CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); + v8::Local<v8::String> name1 = v8::String::New("1"); + v8::CpuProfiler::StartProfiling(name1); + const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); + CHECK_NE(NULL, p1); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + unsigned uid1 = p1->GetUid(); + CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); + const_cast<v8::CpuProfile*>(p1)->Delete(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); + + v8::Local<v8::String> name2 = v8::String::New("2"); + v8::CpuProfiler::StartProfiling(name2); + const v8::CpuProfile* p2 = v8::CpuProfiler::StopProfiling(name2); + CHECK_NE(NULL, p2); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + unsigned uid2 = p2->GetUid(); + CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); + CHECK_EQ(p2, v8::CpuProfiler::FindProfile(uid2)); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); + v8::Local<v8::String> name3 = v8::String::New("3"); + v8::CpuProfiler::StartProfiling(name3); + const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3); + CHECK_NE(NULL, p3); + CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount()); + unsigned uid3 = p3->GetUid(); + CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); + CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); + const_cast<v8::CpuProfile*>(p2)->Delete(); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); + CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); + const_cast<v8::CpuProfile*>(p3)->Delete(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); +} + + +TEST(DeleteCpuProfileDifferentTokens) { + v8::HandleScope scope; + LocalContext env; + + CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount()); + v8::Local<v8::String> name1 = v8::String::New("1"); + v8::CpuProfiler::StartProfiling(name1); + const v8::CpuProfile* p1 = v8::CpuProfiler::StopProfiling(name1); + CHECK_NE(NULL, p1); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + unsigned uid1 = p1->GetUid(); + CHECK_EQ(p1, v8::CpuProfiler::FindProfile(uid1)); + v8::Local<v8::String> token1 = v8::String::New("token1"); + const v8::CpuProfile* p1_t1 = v8::CpuProfiler::FindProfile(uid1, token1); + CHECK_NE(NULL, p1_t1); + CHECK_NE(p1, p1_t1); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + const_cast<v8::CpuProfile*>(p1)->Delete(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1)); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid1, token1)); + const_cast<v8::CpuProfile*>(p1_t1)->Delete(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + + v8::Local<v8::String> name2 = v8::String::New("2"); + v8::CpuProfiler::StartProfiling(name2); + v8::Local<v8::String> token2 = v8::String::New("token2"); + const v8::CpuProfile* p2_t2 = v8::CpuProfiler::StopProfiling(name2, token2); + CHECK_NE(NULL, p2_t2); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + unsigned uid2 = p2_t2->GetUid(); + CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); + const v8::CpuProfile* p2 = v8::CpuProfiler::FindProfile(uid2); + CHECK_NE(p2_t2, p2); + v8::Local<v8::String> name3 = v8::String::New("3"); + v8::CpuProfiler::StartProfiling(name3); + const v8::CpuProfile* p3 = v8::CpuProfiler::StopProfiling(name3); + CHECK_NE(NULL, p3); + CHECK_EQ(2, v8::CpuProfiler::GetProfilesCount()); + unsigned uid3 = p3->GetUid(); + CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); + CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); + const_cast<v8::CpuProfile*>(p2_t2)->Delete(); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); + CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); + const_cast<v8::CpuProfile*>(p2)->Delete(); + CHECK_EQ(1, v8::CpuProfiler::GetProfilesCount()); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid2)); + CHECK_EQ(p3, v8::CpuProfiler::FindProfile(uid3)); + const_cast<v8::CpuProfile*>(p3)->Delete(); + CHECK_EQ(0, CpuProfiler::GetProfilesCount()); + CHECK_EQ(NULL, v8::CpuProfiler::FindProfile(uid3)); +} + #endif // ENABLE_LOGGING_AND_PROFILING diff --git a/test/cctest/test-dataflow.cc b/test/cctest/test-dataflow.cc index 5894de2a..feae0b06 100644 --- a/test/cctest/test-dataflow.cc +++ b/test/cctest/test-dataflow.cc @@ -35,6 +35,7 @@ using namespace v8::internal; TEST(BitVector) { + v8::internal::V8::Initialize(NULL); ZoneScope zone(DELETE_ON_EXIT); { BitVector v(15); diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index 7245e54b..b81129e6 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -143,17 +143,18 @@ class DebugLocalContext { inline v8::Context* operator*() { return *context_; } inline bool IsReady() { return !context_.IsEmpty(); } void ExposeDebug() { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // Expose the debug context global object in the global object for testing. - Debug::Load(); - Debug::debug_context()->set_security_token( + debug->Load(); + debug->debug_context()->set_security_token( v8::Utils::OpenHandle(*context_)->security_token()); Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast( v8::Utils::OpenHandle(*context_->Global()))); Handle<v8::internal::String> debug_string = - v8::internal::Factory::LookupAsciiSymbol("debug"); + FACTORY->LookupAsciiSymbol("debug"); SetProperty(global, debug_string, - Handle<Object>(Debug::debug_context()->global_proxy()), DONT_ENUM, + Handle<Object>(debug->debug_context()->global_proxy()), DONT_ENUM, ::v8::internal::kNonStrictMode); } private: @@ -196,7 +197,8 @@ static bool HasDebugInfo(v8::Handle<v8::Function> fun) { static int SetBreakPoint(Handle<v8::internal::JSFunction> fun, int position) { static int break_point = 0; Handle<v8::internal::SharedFunctionInfo> shared(fun->shared()); - Debug::SetBreakPoint( + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); + debug->SetBreakPoint( shared, Handle<Object>(v8::internal::Smi::FromInt(++break_point)), &position); @@ -279,7 +281,8 @@ static int SetScriptBreakPointByNameFromJS(const char* script_name, // Clear a break point. static void ClearBreakPoint(int break_point) { - Debug::ClearBreakPoint( + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); + debug->ClearBreakPoint( Handle<Object>(v8::internal::Smi::FromInt(break_point))); } @@ -339,8 +342,9 @@ static void ChangeScriptBreakPointIgnoreCountFromJS(int break_point_number, // Change break on exception. static void ChangeBreakOnException(bool caught, bool uncaught) { - Debug::ChangeBreakOnException(v8::internal::BreakException, caught); - Debug::ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); + debug->ChangeBreakOnException(v8::internal::BreakException, caught); + debug->ChangeBreakOnException(v8::internal::BreakUncaughtException, uncaught); } @@ -365,7 +369,8 @@ static void ChangeBreakOnExceptionFromJS(bool caught, bool uncaught) { // Prepare to step to next break location. static void PrepareStep(StepAction step_action) { - Debug::PrepareStep(step_action, 1); + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); + debug->PrepareStep(step_action, 1); } @@ -376,7 +381,9 @@ namespace internal { // Collect the currently debugged functions. Handle<FixedArray> GetDebuggedFunctions() { - v8::internal::DebugInfoListNode* node = Debug::debug_info_list_; + Debug* debug = Isolate::Current()->debug(); + + v8::internal::DebugInfoListNode* node = debug->debug_info_list_; // Find the number of debugged functions. int count = 0; @@ -387,7 +394,7 @@ Handle<FixedArray> GetDebuggedFunctions() { // Allocate array for the debugged functions Handle<FixedArray> debugged_functions = - v8::internal::Factory::NewFixedArray(count); + FACTORY->NewFixedArray(count); // Run through the debug info objects and collect all functions. count = 0; @@ -402,7 +409,9 @@ Handle<FixedArray> GetDebuggedFunctions() { static Handle<Code> ComputeCallDebugBreak(int argc) { CALL_HEAP_FUNCTION( - v8::internal::StubCache::ComputeCallDebugBreak(argc, Code::CALL_IC), + v8::internal::Isolate::Current(), + v8::internal::Isolate::Current()->stub_cache()->ComputeCallDebugBreak( + argc, Code::CALL_IC), Code); } @@ -411,12 +420,12 @@ static Handle<Code> ComputeCallDebugBreak(int argc) { void CheckDebuggerUnloaded(bool check_functions) { // Check that the debugger context is cleared and that there is no debug // information stored for the debugger. - CHECK(Debug::debug_context().is_null()); - CHECK_EQ(NULL, Debug::debug_info_list_); + CHECK(Isolate::Current()->debug()->debug_context().is_null()); + CHECK_EQ(NULL, Isolate::Current()->debug()->debug_info_list_); // Collect garbage to ensure weak handles are cleared. - Heap::CollectAllGarbage(false); - Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); // Iterate the head and check that there are no debugger related objects left. HeapIterator iterator; @@ -444,8 +453,8 @@ void CheckDebuggerUnloaded(bool check_functions) { void ForceUnloadDebugger() { - Debugger::never_unload_debugger_ = false; - Debugger::UnloadDebugger(); + Isolate::Current()->debugger()->never_unload_debugger_ = false; + Isolate::Current()->debugger()->UnloadDebugger(); } @@ -480,6 +489,8 @@ void CheckDebugBreakFunction(DebugLocalContext* env, const char* source, const char* name, int position, v8::internal::RelocInfo::Mode mode, Code* debug_break) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); + // Create function and set the break point. Handle<v8::internal::JSFunction> fun = v8::Utils::OpenHandle( *CompileFunction(env, source, name)); @@ -501,8 +512,8 @@ void CheckDebugBreakFunction(DebugLocalContext* env, // Clear the break point and check that the debug break function is no longer // there ClearBreakPoint(bp); - CHECK(!Debug::HasDebugInfo(shared)); - CHECK(Debug::EnsureDebugInfo(shared)); + CHECK(!debug->HasDebugInfo(shared)); + CHECK(debug->EnsureDebugInfo(shared)); TestBreakLocationIterator it2(Debug::GetDebugInfo(shared)); it2.FindBreakLocationFromPosition(position); CHECK_EQ(mode, it2.it()->rinfo()->rmode()); @@ -634,8 +645,9 @@ static void DebugEventBreakPointHitCount(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); // Count the number of breaks. if (event == v8::Break) { @@ -738,8 +750,10 @@ static void DebugEventCounter(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); + // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); // Count the number of breaks. if (event == v8::Break) { @@ -796,8 +810,9 @@ static void DebugEventEvaluate(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); if (event == v8::Break) { for (int i = 0; checks[i].expr != NULL; i++) { @@ -822,8 +837,9 @@ static void DebugEventRemoveBreakPoint(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); if (event == v8::Break) { break_point_hit_count++; @@ -840,8 +856,9 @@ static void DebugEventStep(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); if (event == v8::Break) { break_point_hit_count++; @@ -866,8 +883,9 @@ static void DebugEventStepSequence(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); if (event == v8::Break || event == v8::Exception) { // Check that the current function is the expected. @@ -896,8 +914,9 @@ static void DebugEventBreakPointCollectGarbage( v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); // Perform a garbage collection when break point is hit and continue. Based // on the number of break points hit either scavenge or mark compact @@ -906,10 +925,10 @@ static void DebugEventBreakPointCollectGarbage( break_point_hit_count++; if (break_point_hit_count % 2 == 0) { // Scavenge. - Heap::CollectGarbage(v8::internal::NEW_SPACE); + HEAP->CollectGarbage(v8::internal::NEW_SPACE); } else { // Mark sweep compact. - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); } } } @@ -921,8 +940,9 @@ static void DebugEventBreak(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); if (event == v8::Break) { // Count the number of breaks. @@ -930,7 +950,7 @@ static void DebugEventBreak(v8::DebugEvent event, // Run the garbage collector to enforce heap verification if option // --verify-heap is set. - Heap::CollectGarbage(v8::internal::NEW_SPACE); + HEAP->CollectGarbage(v8::internal::NEW_SPACE); // Set the break flag again to come back here as soon as possible. v8::Debug::DebugBreak(); @@ -946,8 +966,9 @@ static void DebugEventBreakMax(v8::DebugEvent event, v8::Handle<v8::Object> exec_state, v8::Handle<v8::Object> event_data, v8::Handle<v8::Value> data) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // When hitting a debug event listener there must be a break set. - CHECK_NE(v8::internal::Debug::break_id(), 0); + CHECK_NE(debug->break_id(), 0); if (event == v8::Break) { if (break_point_hit_count < max_break_point_hit_count) { @@ -987,6 +1008,7 @@ static void MessageCallbackCount(v8::Handle<v8::Message> message, // of break locations. TEST(DebugStub) { using ::v8::internal::Builtins; + using ::v8::internal::Isolate; v8::HandleScope scope; DebugLocalContext env; @@ -999,12 +1021,14 @@ TEST(DebugStub) { "function f2(){x=1;}", "f2", 0, v8::internal::RelocInfo::CODE_TARGET_CONTEXT, - Builtins::builtin(Builtins::StoreIC_DebugBreak)); + Isolate::Current()->builtins()->builtin( + Builtins::kStoreIC_DebugBreak)); CheckDebugBreakFunction(&env, "function f3(){var a=x;}", "f3", 0, v8::internal::RelocInfo::CODE_TARGET_CONTEXT, - Builtins::builtin(Builtins::LoadIC_DebugBreak)); + Isolate::Current()->builtins()->builtin( + Builtins::kLoadIC_DebugBreak)); // TODO(1240753): Make the test architecture independent or split // parts of the debugger into architecture dependent files. This @@ -1017,14 +1041,16 @@ TEST(DebugStub) { "f4", 0, v8::internal::RelocInfo::CODE_TARGET, - Builtins::builtin(Builtins::KeyedStoreIC_DebugBreak)); + Isolate::Current()->builtins()->builtin( + Builtins::kKeyedStoreIC_DebugBreak)); CheckDebugBreakFunction( &env, "function f5(){var index='propertyName'; var a={}; return a[index];}", "f5", 0, v8::internal::RelocInfo::CODE_TARGET, - Builtins::builtin(Builtins::KeyedLoadIC_DebugBreak)); + Isolate::Current()->builtins()->builtin( + Builtins::kKeyedLoadIC_DebugBreak)); #endif // Check the debug break code stubs for call ICs with different number of @@ -1139,7 +1165,7 @@ TEST(BreakPointICLoad) { foo->Call(env->Global(), 0, NULL); CHECK_EQ(0, break_point_hit_count); - // Run with breakpoint + // Run with breakpoint. int bp = SetBreakPoint(foo, 0); foo->Call(env->Global(), 0, NULL); CHECK_EQ(1, break_point_hit_count); @@ -1172,7 +1198,7 @@ TEST(BreakPointICCall) { foo->Call(env->Global(), 0, NULL); CHECK_EQ(0, break_point_hit_count); - // Run with breakpoint. + // Run with breakpoint int bp = SetBreakPoint(foo, 0); foo->Call(env->Global(), 0, NULL); CHECK_EQ(1, break_point_hit_count); @@ -1367,12 +1393,12 @@ static void CallAndGC(v8::Local<v8::Object> recv, CHECK_EQ(1 + i * 3, break_point_hit_count); // Scavenge and call function. - Heap::CollectGarbage(v8::internal::NEW_SPACE); + HEAP->CollectGarbage(v8::internal::NEW_SPACE); f->Call(recv, 0, NULL); CHECK_EQ(2 + i * 3, break_point_hit_count); // Mark sweep (and perhaps compact) and call function. - Heap::CollectAllGarbage(force_compaction); + HEAP->CollectAllGarbage(force_compaction); f->Call(recv, 0, NULL); CHECK_EQ(3 + i * 3, break_point_hit_count); } @@ -2199,7 +2225,7 @@ TEST(ScriptBreakPointLineTopLevel) { } f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); - Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); SetScriptBreakPointByNameFromJS("test.html", 3, -1); @@ -3698,7 +3724,7 @@ TEST(BreakOnException) { DebugLocalContext env; env.ExposeDebug(); - v8::internal::Top::TraceException(false); + v8::internal::Isolate::Current()->TraceException(false); // Create functions for testing break on exception. v8::Local<v8::Function> throws = @@ -3845,7 +3871,7 @@ TEST(BreakOnCompileException) { // For this test, we want to break on uncaught exceptions: ChangeBreakOnException(false, true); - v8::internal::Top::TraceException(false); + v8::internal::Isolate::Current()->TraceException(false); // Create a function for checking the function when hitting a break point. frame_count = CompileFunction(&env, frame_count_source, "frame_count"); @@ -4694,6 +4720,8 @@ Barriers message_queue_barriers; // placing JSON debugger commands in the queue. class MessageQueueDebuggerThread : public v8::internal::Thread { public: + explicit MessageQueueDebuggerThread(v8::internal::Isolate* isolate) + : Thread(isolate, "MessageQueueDebuggerThread") { } void Run(); }; @@ -4793,10 +4821,12 @@ void MessageQueueDebuggerThread::Run() { // Main thread continues running source_3 to end, waits for this thread. } -MessageQueueDebuggerThread message_queue_debugger_thread; // This thread runs the v8 engine. TEST(MessageQueues) { + MessageQueueDebuggerThread message_queue_debugger_thread( + i::Isolate::Current()); + // Create a V8 environment v8::HandleScope scope; DebugLocalContext env; @@ -4942,11 +4972,15 @@ Barriers threaded_debugging_barriers; class V8Thread : public v8::internal::Thread { public: + explicit V8Thread(v8::internal::Isolate* isolate) + : Thread(isolate, "V8Thread") { } void Run(); }; class DebuggerThread : public v8::internal::Thread { public: + explicit DebuggerThread(v8::internal::Isolate* isolate) + : Thread(isolate, "DebuggerThread") { } void Run(); }; @@ -5021,10 +5055,11 @@ void DebuggerThread::Run() { v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer)); } -DebuggerThread debugger_thread; -V8Thread v8_thread; TEST(ThreadedDebugging) { + DebuggerThread debugger_thread(i::Isolate::Current()); + V8Thread v8_thread(i::Isolate::Current()); + // Create a V8 environment threaded_debugging_barriers.Initialize(); @@ -5044,13 +5079,17 @@ TEST(ThreadedDebugging) { class BreakpointsV8Thread : public v8::internal::Thread { public: + explicit BreakpointsV8Thread(v8::internal::Isolate* isolate) + : Thread(isolate, "BreakpointsV8Thread") { } void Run(); }; class BreakpointsDebuggerThread : public v8::internal::Thread { public: - explicit BreakpointsDebuggerThread(bool global_evaluate) - : global_evaluate_(global_evaluate) {} + explicit BreakpointsDebuggerThread(v8::internal::Isolate* isolate, + bool global_evaluate) + : Thread(isolate, "BreakpointsDebuggerThread"), + global_evaluate_(global_evaluate) {} void Run(); private: @@ -5226,8 +5265,9 @@ void BreakpointsDebuggerThread::Run() { void TestRecursiveBreakpointsGeneric(bool global_evaluate) { i::FLAG_debugger_auto_break = true; - BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate); - BreakpointsV8Thread breakpoints_v8_thread; + BreakpointsDebuggerThread breakpoints_debugger_thread(i::Isolate::Current(), + global_evaluate); + BreakpointsV8Thread breakpoints_v8_thread(i::Isolate::Current()); // Create a V8 environment Barriers stack_allocated_breakpoints_barriers; @@ -5609,11 +5649,15 @@ TEST(DebuggerClearMessageHandlerWhileActive) { class HostDispatchV8Thread : public v8::internal::Thread { public: + explicit HostDispatchV8Thread(v8::internal::Isolate* isolate) + : Thread(isolate, "HostDispatchV8Thread") { } void Run(); }; class HostDispatchDebuggerThread : public v8::internal::Thread { public: + explicit HostDispatchDebuggerThread(v8::internal::Isolate* isolate) + : Thread(isolate, "HostDispatchDebuggerThread") { } void Run(); }; @@ -5683,11 +5727,11 @@ void HostDispatchDebuggerThread::Run() { v8::Debug::SendCommand(buffer, AsciiToUtf16(command_2, buffer)); } -HostDispatchDebuggerThread host_dispatch_debugger_thread; -HostDispatchV8Thread host_dispatch_v8_thread; - TEST(DebuggerHostDispatch) { + HostDispatchDebuggerThread host_dispatch_debugger_thread( + i::Isolate::Current()); + HostDispatchV8Thread host_dispatch_v8_thread(i::Isolate::Current()); i::FLAG_debugger_auto_break = true; // Create a V8 environment @@ -5711,11 +5755,15 @@ TEST(DebuggerHostDispatch) { class DebugMessageDispatchV8Thread : public v8::internal::Thread { public: + explicit DebugMessageDispatchV8Thread(v8::internal::Isolate* isolate) + : Thread(isolate, "DebugMessageDispatchV8Thread") { } void Run(); }; class DebugMessageDispatchDebuggerThread : public v8::internal::Thread { public: + explicit DebugMessageDispatchDebuggerThread(v8::internal::Isolate* isolate) + : Thread(isolate, "DebugMessageDispatchDebuggerThread") { } void Run(); }; @@ -5747,11 +5795,13 @@ void DebugMessageDispatchDebuggerThread::Run() { debug_message_dispatch_barriers->barrier_2.Wait(); } -DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread; -DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread; - TEST(DebuggerDebugMessageDispatch) { + DebugMessageDispatchDebuggerThread debug_message_dispatch_debugger_thread( + i::Isolate::Current()); + DebugMessageDispatchV8Thread debug_message_dispatch_v8_thread( + i::Isolate::Current()); + i::FLAG_debugger_auto_break = true; // Create a V8 environment @@ -5769,6 +5819,7 @@ TEST(DebuggerDebugMessageDispatch) { TEST(DebuggerAgent) { + i::Debugger* debugger = i::Isolate::Current()->debugger(); // Make sure these ports is not used by other tests to allow tests to run in // parallel. const int kPort1 = 5858; @@ -5786,18 +5837,18 @@ TEST(DebuggerAgent) { i::Socket::Setup(); // Test starting and stopping the agent without any client connection. - i::Debugger::StartAgent("test", kPort1); - i::Debugger::StopAgent(); + debugger->StartAgent("test", kPort1); + debugger->StopAgent(); // Test starting the agent, connecting a client and shutting down the agent // with the client connected. - ok = i::Debugger::StartAgent("test", kPort2); + ok = debugger->StartAgent("test", kPort2); CHECK(ok); - i::Debugger::WaitForAgent(); + debugger->WaitForAgent(); i::Socket* client = i::OS::CreateSocket(); ok = client->Connect("localhost", port2_str); CHECK(ok); - i::Debugger::StopAgent(); + debugger->StopAgent(); delete client; // Test starting and stopping the agent with the required port already @@ -5805,8 +5856,8 @@ TEST(DebuggerAgent) { i::Socket* server = i::OS::CreateSocket(); server->Bind(kPort3); - i::Debugger::StartAgent("test", kPort3); - i::Debugger::StopAgent(); + debugger->StartAgent("test", kPort3); + debugger->StopAgent(); delete server; } @@ -5814,8 +5865,11 @@ TEST(DebuggerAgent) { class DebuggerAgentProtocolServerThread : public i::Thread { public: - explicit DebuggerAgentProtocolServerThread(int port) - : port_(port), server_(NULL), client_(NULL), + explicit DebuggerAgentProtocolServerThread(i::Isolate* isolate, int port) + : Thread(isolate, "DebuggerAgentProtocolServerThread"), + port_(port), + server_(NULL), + client_(NULL), listening_(OS::CreateSemaphore(0)) { } ~DebuggerAgentProtocolServerThread() { @@ -5877,7 +5931,7 @@ TEST(DebuggerAgentProtocolOverflowHeader) { // Create a socket server to receive a debugger agent message. DebuggerAgentProtocolServerThread* server = - new DebuggerAgentProtocolServerThread(kPort); + new DebuggerAgentProtocolServerThread(i::Isolate::Current(), kPort); server->Start(); server->WaitForListening(); @@ -6376,17 +6430,18 @@ static void DebugEventScriptCollectedEvent(v8::DebugEvent event, // Test that scripts collected are reported through the debug event listener. TEST(ScriptCollectedEvent) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); break_point_hit_count = 0; script_collected_count = 0; v8::HandleScope scope; DebugLocalContext env; // Request the loaded scripts to initialize the debugger script cache. - Debug::GetLoadedScripts(); + debug->GetLoadedScripts(); // Do garbage collection to ensure that only the script in this test will be // collected afterwards. - Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); script_collected_count = 0; v8::Debug::SetDebugEventListener(DebugEventScriptCollectedEvent, @@ -6398,7 +6453,7 @@ TEST(ScriptCollectedEvent) { // Do garbage collection to collect the script above which is no longer // referenced. - Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, script_collected_count); @@ -6422,6 +6477,7 @@ static void ScriptCollectedMessageHandler(const v8::Debug::Message& message) { // Test that GetEventContext doesn't fail and return empty handle for // ScriptCollected events. TEST(ScriptCollectedEventContext) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); script_collected_message_count = 0; v8::HandleScope scope; @@ -6429,11 +6485,11 @@ TEST(ScriptCollectedEventContext) { DebugLocalContext env; // Request the loaded scripts to initialize the debugger script cache. - Debug::GetLoadedScripts(); + debug->GetLoadedScripts(); // Do garbage collection to ensure that only the script in this test will be // collected afterwards. - Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); { @@ -6444,7 +6500,7 @@ TEST(ScriptCollectedEventContext) { // Do garbage collection to collect the script above which is no longer // referenced. - Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); CHECK_EQ(2, script_collected_message_count); @@ -6592,6 +6648,7 @@ TEST(ProvisionalBreakpointOnLineOutOfRange) { static void BreakMessageHandler(const v8::Debug::Message& message) { + i::Isolate* isolate = i::Isolate::Current(); if (message.IsEvent() && message.GetEvent() == v8::Break) { // Count the number of breaks. break_point_hit_count++; @@ -6603,18 +6660,18 @@ static void BreakMessageHandler(const v8::Debug::Message& message) { } else if (message.IsEvent() && message.GetEvent() == v8::AfterCompile) { v8::HandleScope scope; - bool is_debug_break = i::StackGuard::IsDebugBreak(); + bool is_debug_break = isolate->stack_guard()->IsDebugBreak(); // Force DebugBreak flag while serializer is working. - i::StackGuard::DebugBreak(); + isolate->stack_guard()->DebugBreak(); // Force serialization to trigger some internal JS execution. v8::Handle<v8::String> json = message.GetJSON(); // Restore previous state. if (is_debug_break) { - i::StackGuard::DebugBreak(); + isolate->stack_guard()->DebugBreak(); } else { - i::StackGuard::Continue(i::DEBUGBREAK); + isolate->stack_guard()->Continue(i::DEBUGBREAK); } } } @@ -6843,6 +6900,7 @@ static void DebugEventGetAtgumentPropertyValue( TEST(CallingContextIsNotDebugContext) { + v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug(); // Create and enter a debugee context. v8::HandleScope scope; DebugLocalContext env; @@ -6851,7 +6909,7 @@ TEST(CallingContextIsNotDebugContext) { // Save handles to the debugger and debugee contexts to be used in // NamedGetterWithCallingContextCheck. debugee_context = v8::Local<v8::Context>(*env); - debugger_context = v8::Utils::ToLocal(Debug::debug_context()); + debugger_context = v8::Utils::ToLocal(debug->debug_context()); // Create object with 'a' property accessor. v8::Handle<v8::ObjectTemplate> named = v8::ObjectTemplate::New(); diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc index 6ea4c849..61983918 100644 --- a/test/cctest/test-decls.cc +++ b/test/cctest/test-decls.cc @@ -130,7 +130,7 @@ void DeclarationContext::Check(const char* source, InitializeIfNeeded(); // A retry after a GC may pollute the counts, so perform gc now // to avoid that. - v8::internal::Heap::CollectGarbage(v8::internal::NEW_SPACE); + HEAP->CollectGarbage(v8::internal::NEW_SPACE); HandleScope scope; TryCatch catcher; catcher.SetVerbose(true); diff --git a/test/cctest/test-deoptimization.cc b/test/cctest/test-deoptimization.cc index 17453552..5ab84f96 100644 --- a/test/cctest/test-deoptimization.cc +++ b/test/cctest/test-deoptimization.cc @@ -30,20 +30,21 @@ #include "v8.h" #include "api.h" +#include "cctest.h" #include "compilation-cache.h" #include "debug.h" #include "deoptimizer.h" +#include "isolate.h" #include "platform.h" #include "stub-cache.h" -#include "cctest.h" - -using ::v8::internal::Handle; -using ::v8::internal::Object; -using ::v8::internal::JSFunction; using ::v8::internal::Deoptimizer; using ::v8::internal::EmbeddedVector; +using ::v8::internal::Handle; +using ::v8::internal::Isolate; +using ::v8::internal::JSFunction; using ::v8::internal::OS; +using ::v8::internal::Object; // Size of temp buffer for formatting small strings. #define SMALL_STRING_BUFFER_SIZE 80 @@ -124,7 +125,7 @@ TEST(DeoptimizeSimple) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); // Test lazy deoptimization of a simple function. Call the function after the // deoptimization while it is still activated further down the stack. @@ -140,7 +141,7 @@ TEST(DeoptimizeSimple) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -164,7 +165,7 @@ TEST(DeoptimizeSimpleWithArguments) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); // Test lazy deoptimization of a simple function with some arguments. Call the // function after the deoptimization while it is still activated further down @@ -181,7 +182,7 @@ TEST(DeoptimizeSimpleWithArguments) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -207,7 +208,7 @@ TEST(DeoptimizeSimpleNested) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } } @@ -232,7 +233,7 @@ TEST(DeoptimizeRecursive) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); v8::Local<v8::Function> fun = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); @@ -266,7 +267,7 @@ TEST(DeoptimizeMultiple) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -289,7 +290,7 @@ TEST(DeoptimizeConstructor) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(env->Global()->Get(v8_str("result"))->IsTrue()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); { AlwaysOptimizeAllowNativesSyntaxNoInlining options; @@ -306,7 +307,7 @@ TEST(DeoptimizeConstructor) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -337,7 +338,7 @@ TEST(DeoptimizeConstructorMultiple) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -385,7 +386,7 @@ TEST(DeoptimizeBinaryOperationADDString) { CHECK(result->IsString()); v8::String::AsciiValue ascii(result); CHECK_EQ("a+an X", *ascii); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -444,7 +445,7 @@ TEST(DeoptimizeBinaryOperationADD) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -458,7 +459,7 @@ TEST(DeoptimizeBinaryOperationSUB) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -472,7 +473,7 @@ TEST(DeoptimizeBinaryOperationMUL) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -486,7 +487,7 @@ TEST(DeoptimizeBinaryOperationDIV) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -500,7 +501,7 @@ TEST(DeoptimizeBinaryOperationMOD) { CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -545,7 +546,7 @@ TEST(DeoptimizeCompare) { CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -627,7 +628,7 @@ TEST(DeoptimizeLoadICStoreIC) { CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } @@ -710,5 +711,5 @@ TEST(DeoptimizeLoadICStoreICNested) { CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount()); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); } diff --git a/test/cctest/test-disasm-arm.cc b/test/cctest/test-disasm-arm.cc index dea0db92..32216147 100644 --- a/test/cctest/test-disasm-arm.cc +++ b/test/cctest/test-disasm-arm.cc @@ -270,7 +270,7 @@ TEST(Type0) { "13a06000 movne r6, #0"); // mov -> movw. - if (CpuFeatures::IsSupported(ARMv7)) { + if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { COMPARE(mov(r5, Operand(0x01234), LeaveCC, ne), "13015234 movwne r5, #4660"); // We only disassemble one instruction so the eor instruction is not here. @@ -360,7 +360,7 @@ TEST(Type1) { TEST(Type3) { SETUP(); - if (CpuFeatures::IsSupported(ARMv7)) { + if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { COMPARE(ubfx(r0, r1, 5, 10), "e7e902d1 ubfx r0, r1, #5, #10"); COMPARE(ubfx(r1, r0, 5, 10), @@ -415,7 +415,7 @@ TEST(Type3) { TEST(Vfp) { SETUP(); - if (CpuFeatures::IsSupported(VFP3)) { + if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { CpuFeatures::Scope scope(VFP3); COMPARE(vmov(d0, d1), "eeb00b41 vmov.f64 d0, d1"); @@ -440,6 +440,11 @@ TEST(Vfp) { COMPARE(vabs(d3, d4, mi), "4eb03bc4 vabsmi d3, d4"); + COMPARE(vneg(d0, d1), + "eeb10b41 vneg d0, d1"); + COMPARE(vneg(d3, d4, mi), + "4eb13b44 vnegmi d3, d4"); + COMPARE(vadd(d0, d1, d2), "ee310b02 vadd.f64 d0, d1, d2"); COMPARE(vadd(d3, d4, d5, mi), diff --git a/test/cctest/test-disasm-ia32.cc b/test/cctest/test-disasm-ia32.cc index c995aa8e..26da5c9c 100644 --- a/test/cctest/test-disasm-ia32.cc +++ b/test/cctest/test-disasm-ia32.cc @@ -68,7 +68,7 @@ TEST(DisasmIa320) { __ sub(Operand(eax), Immediate(12345678)); __ xor_(eax, 12345678); __ and_(eax, 12345678); - Handle<FixedArray> foo = Factory::NewFixedArray(10, TENURED); + Handle<FixedArray> foo = FACTORY->NewFixedArray(10, TENURED); __ cmp(eax, foo); // ---- This one caused crash @@ -99,7 +99,7 @@ TEST(DisasmIa320) { __ cmp(edx, 3); __ cmp(edx, Operand(esp, 4)); __ cmp(Operand(ebp, ecx, times_4, 0), Immediate(1000)); - Handle<FixedArray> foo2 = Factory::NewFixedArray(10, TENURED); + Handle<FixedArray> foo2 = FACTORY->NewFixedArray(10, TENURED); __ cmp(ebx, foo2); __ cmpb(ebx, Operand(ebp, ecx, times_2, 0)); __ cmpb(Operand(ebp, ecx, times_2, 0), ebx); @@ -107,12 +107,12 @@ TEST(DisasmIa320) { __ xor_(edx, 3); __ nop(); { - CHECK(CpuFeatures::IsSupported(CPUID)); + CHECK(Isolate::Current()->cpu_features()->IsSupported(CPUID)); CpuFeatures::Scope fscope(CPUID); __ cpuid(); } { - CHECK(CpuFeatures::IsSupported(RDTSC)); + CHECK(Isolate::Current()->cpu_features()->IsSupported(RDTSC)); CpuFeatures::Scope fscope(RDTSC); __ rdtsc(); } @@ -272,7 +272,8 @@ TEST(DisasmIa320) { __ bind(&L2); __ call(Operand(ebx, ecx, times_4, 10000)); __ nop(); - Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); + Handle<Code> ic(Isolate::Current()->builtins()->builtin( + Builtins::kLoadIC_Initialize)); __ call(ic, RelocInfo::CODE_TARGET); __ nop(); __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY); @@ -282,7 +283,8 @@ TEST(DisasmIa320) { __ jmp(Operand(ebx, ecx, times_4, 10000)); #ifdef ENABLE_DEBUGGER_SUPPORT ExternalReference after_break_target = - ExternalReference(Debug_Address::AfterBreakTarget()); + ExternalReference(Debug_Address::AfterBreakTarget(), + assm.isolate()); __ jmp(Operand::StaticVariable(after_break_target)); #endif // ENABLE_DEBUGGER_SUPPORT __ jmp(ic, RelocInfo::CODE_TARGET); @@ -332,7 +334,7 @@ TEST(DisasmIa320) { __ j(zero, &Ljcc, taken); __ j(zero, &Ljcc, not_taken); - // __ mov(Operand::StaticVariable(Top::handler_address()), eax); + // __ mov(Operand::StaticVariable(Isolate::handler_address()), eax); // 0xD9 instructions __ nop(); @@ -373,7 +375,7 @@ TEST(DisasmIa320) { __ fwait(); __ nop(); { - if (CpuFeatures::IsSupported(SSE2)) { + if (Isolate::Current()->cpu_features()->IsSupported(SSE2)) { CpuFeatures::Scope fscope(SSE2); __ cvttss2si(edx, Operand(ebx, ecx, times_4, 10000)); __ cvtsi2sd(xmm1, Operand(ebx, ecx, times_4, 10000)); @@ -395,7 +397,7 @@ TEST(DisasmIa320) { // cmov. { - if (CpuFeatures::IsSupported(CMOV)) { + if (Isolate::Current()->cpu_features()->IsSupported(CMOV)) { CpuFeatures::Scope use_cmov(CMOV); __ cmov(overflow, eax, Operand(eax, 0)); __ cmov(no_overflow, eax, Operand(eax, 1)); @@ -418,7 +420,7 @@ TEST(DisasmIa320) { // andpd, cmpltsd, movaps, psllq, psrlq, por. { - if (CpuFeatures::IsSupported(SSE2)) { + if (Isolate::Current()->cpu_features()->IsSupported(SSE2)) { CpuFeatures::Scope fscope(SSE2); __ andpd(xmm0, xmm1); __ andpd(xmm1, xmm2); @@ -447,7 +449,7 @@ TEST(DisasmIa320) { } { - if (CpuFeatures::IsSupported(SSE4_1)) { + if (Isolate::Current()->cpu_features()->IsSupported(SSE4_1)) { CpuFeatures::Scope scope(SSE4_1); __ pextrd(Operand(eax), xmm0, 1); __ pinsrd(xmm1, Operand(eax), 0); @@ -458,10 +460,10 @@ TEST(DisasmIa320) { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); #ifdef OBJECT_PRINT Code::cast(code)->Print(); diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc index 563cc4bf..dea5c477 100644 --- a/test/cctest/test-func-name-inference.cc +++ b/test/cctest/test-func-name-inference.cc @@ -36,6 +36,7 @@ using ::v8::internal::CStrVector; using ::v8::internal::Factory; using ::v8::internal::Handle; using ::v8::internal::Heap; +using ::v8::internal::Isolate; using ::v8::internal::JSFunction; using ::v8::internal::Object; using ::v8::internal::Runtime; @@ -77,15 +78,20 @@ static void CheckFunctionName(v8::Handle<v8::Script> script, // Find the position of a given func source substring in the source. Handle<String> func_pos_str = - Factory::NewStringFromAscii(CStrVector(func_pos_src)); - int func_pos = Runtime::StringMatch(script_src, func_pos_str, 0); + FACTORY->NewStringFromAscii(CStrVector(func_pos_src)); + int func_pos = Runtime::StringMatch(Isolate::Current(), + script_src, + func_pos_str, + 0); CHECK_NE(0, func_pos); #ifdef ENABLE_DEBUGGER_SUPPORT // Obtain SharedFunctionInfo for the function. Object* shared_func_info_ptr = - Runtime::FindSharedFunctionInfoInScript(i_script, func_pos); - CHECK(shared_func_info_ptr != Heap::undefined_value()); + Runtime::FindSharedFunctionInfoInScript(Isolate::Current(), + i_script, + func_pos); + CHECK(shared_func_info_ptr != HEAP->undefined_value()); Handle<SharedFunctionInfo> shared_func_info( SharedFunctionInfo::cast(shared_func_info_ptr)); diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index ad242fe7..141b42f7 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -26,7 +26,7 @@ class ConstructorHeapProfileTestHelper : public i::ConstructorHeapProfile { public: ConstructorHeapProfileTestHelper() : i::ConstructorHeapProfile(), - f_name_(i::Factory::NewStringFromAscii(i::CStrVector("F"))), + f_name_(FACTORY->NewStringFromAscii(i::CStrVector("F"))), f_count_(0) { } @@ -143,25 +143,25 @@ TEST(ClustersCoarserSimple) { i::ZoneScope zn_scope(i::DELETE_ON_EXIT); JSObjectsRetainerTree tree; - JSObjectsCluster function(i::Heap::function_class_symbol()); - JSObjectsCluster a(*i::Factory::NewStringFromAscii(i::CStrVector("A"))); - JSObjectsCluster b(*i::Factory::NewStringFromAscii(i::CStrVector("B"))); + JSObjectsCluster function(HEAP->function_class_symbol()); + JSObjectsCluster a(*FACTORY->NewStringFromAscii(i::CStrVector("A"))); + JSObjectsCluster b(*FACTORY->NewStringFromAscii(i::CStrVector("B"))); // o1 <- Function JSObjectsCluster o1 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100, &function); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function); // o2 <- Function JSObjectsCluster o2 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x200, &function); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x200, &function); // o3 <- A, B JSObjectsCluster o3 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x300, &a, &b); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x300, &a, &b); // o4 <- B, A JSObjectsCluster o4 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x400, &b, &a); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x400, &b, &a); // o5 <- A, B, Function JSObjectsCluster o5 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x500, + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x500, &a, &b, &function); ClustersCoarser coarser; @@ -181,20 +181,20 @@ TEST(ClustersCoarserMultipleConstructors) { i::ZoneScope zn_scope(i::DELETE_ON_EXIT); JSObjectsRetainerTree tree; - JSObjectsCluster function(i::Heap::function_class_symbol()); + JSObjectsCluster function(HEAP->function_class_symbol()); // o1 <- Function JSObjectsCluster o1 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100, &function); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100, &function); // a1 <- Function JSObjectsCluster a1 = - AddHeapObjectToTree(&tree, i::Heap::Array_symbol(), 0x1000, &function); + AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x1000, &function); // o2 <- Function JSObjectsCluster o2 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x200, &function); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x200, &function); // a2 <- Function JSObjectsCluster a2 = - AddHeapObjectToTree(&tree, i::Heap::Array_symbol(), 0x2000, &function); + AddHeapObjectToTree(&tree, HEAP->Array_symbol(), 0x2000, &function); ClustersCoarser coarser; coarser.Process(&tree); @@ -224,21 +224,21 @@ TEST(ClustersCoarserPathsTraversal) { // o21 ~ o22, and o11 ~ o12. JSObjectsCluster o = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100); JSObjectsCluster o11 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x110, &o); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x110, &o); JSObjectsCluster o12 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x120, &o); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x120, &o); JSObjectsCluster o21 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x210, &o11); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x210, &o11); JSObjectsCluster o22 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x220, &o12); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x220, &o12); JSObjectsCluster p = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x300, &o21); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x300, &o21); JSObjectsCluster q = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x310, &o21, &o22); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x310, &o21, &o22); JSObjectsCluster r = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x320, &o22); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x320, &o22); ClustersCoarser coarser; coarser.Process(&tree); @@ -275,19 +275,19 @@ TEST(ClustersCoarserSelf) { // we expect that coarser will deduce equivalences: p ~ q ~ r, o1 ~ o2; JSObjectsCluster o = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x100); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x100); JSObjectsCluster o1 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x110, &o); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x110, &o); JSObjectsCluster o2 = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x120, &o); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x120, &o); JSObjectsCluster p = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x300, &o1); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x300, &o1); AddSelfReferenceToTree(&tree, &p); JSObjectsCluster q = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x310, &o1, &o2); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x310, &o1, &o2); AddSelfReferenceToTree(&tree, &q); JSObjectsCluster r = - AddHeapObjectToTree(&tree, i::Heap::Object_symbol(), 0x320, &o2); + AddHeapObjectToTree(&tree, HEAP->Object_symbol(), 0x320, &o2); AddSelfReferenceToTree(&tree, &r); ClustersCoarser coarser; @@ -433,19 +433,6 @@ static const v8::HeapGraphNode* GetProperty(const v8::HeapGraphNode* node, } -static bool IsNodeRetainedAs(const v8::HeapGraphNode* node, - v8::HeapGraphEdge::Type type, - const char* name) { - for (int i = 0, count = node->GetRetainersCount(); i < count; ++i) { - const v8::HeapGraphEdge* prop = node->GetRetainer(i); - v8::String::AsciiValue prop_name(prop->GetName()); - if (prop->GetType() == type && strcmp(name, *prop_name) == 0) - return true; - } - return false; -} - - static bool HasString(const v8::HeapGraphNode* node, const char* contents) { for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { const v8::HeapGraphEdge* prop = node->GetChild(i); @@ -496,56 +483,6 @@ TEST(HeapSnapshot) { CHECK(det.has_A2); CHECK(det.has_B2); CHECK(det.has_C2); - - /* - // Currently disabled. Too many retaining paths emerge, need to - // reduce the amount. - - // Verify 'a2' object retainers. They are: - // - (global object).a2 - // - c2.x1, c2.x2, c2[1] - // - b2_1 and b2_2 closures: via 'x' variable - CHECK_EQ(6, a2_node->GetRetainingPathsCount()); - bool has_global_obj_a2_ref = false; - bool has_c2_x1_ref = false, has_c2_x2_ref = false, has_c2_1_ref = false; - bool has_b2_1_x_ref = false, has_b2_2_x_ref = false; - for (int i = 0; i < a2_node->GetRetainingPathsCount(); ++i) { - const v8::HeapGraphPath* path = a2_node->GetRetainingPath(i); - const int edges_count = path->GetEdgesCount(); - CHECK_GT(edges_count, 0); - const v8::HeapGraphEdge* last_edge = path->GetEdge(edges_count - 1); - v8::String::AsciiValue last_edge_name(last_edge->GetName()); - if (strcmp("a2", *last_edge_name) == 0 - && last_edge->GetType() == v8::HeapGraphEdge::kProperty) { - has_global_obj_a2_ref = true; - continue; - } - CHECK_GT(edges_count, 1); - const v8::HeapGraphEdge* prev_edge = path->GetEdge(edges_count - 2); - v8::String::AsciiValue prev_edge_name(prev_edge->GetName()); - if (strcmp("x1", *last_edge_name) == 0 - && last_edge->GetType() == v8::HeapGraphEdge::kProperty - && strcmp("c2", *prev_edge_name) == 0) has_c2_x1_ref = true; - if (strcmp("x2", *last_edge_name) == 0 - && last_edge->GetType() == v8::HeapGraphEdge::kProperty - && strcmp("c2", *prev_edge_name) == 0) has_c2_x2_ref = true; - if (strcmp("1", *last_edge_name) == 0 - && last_edge->GetType() == v8::HeapGraphEdge::kElement - && strcmp("c2", *prev_edge_name) == 0) has_c2_1_ref = true; - if (strcmp("x", *last_edge_name) == 0 - && last_edge->GetType() == v8::HeapGraphEdge::kContextVariable - && strcmp("b2_1", *prev_edge_name) == 0) has_b2_1_x_ref = true; - if (strcmp("x", *last_edge_name) == 0 - && last_edge->GetType() == v8::HeapGraphEdge::kContextVariable - && strcmp("b2_2", *prev_edge_name) == 0) has_b2_2_x_ref = true; - } - CHECK(has_global_obj_a2_ref); - CHECK(has_c2_x1_ref); - CHECK(has_c2_x2_ref); - CHECK(has_c2_1_ref); - CHECK(has_b2_1_x_ref); - CHECK(has_b2_2_x_ref); - */ } @@ -730,7 +667,7 @@ TEST(HeapEntryIdsAndGC) { const v8::HeapSnapshot* snapshot1 = v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); - i::Heap::CollectAllGarbage(true); // Enforce compaction. + HEAP->CollectAllGarbage(true); // Enforce compaction. const v8::HeapSnapshot* snapshot2 = v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); @@ -774,76 +711,6 @@ TEST(HeapEntryIdsAndGC) { } -TEST(HeapSnapshotsDiff) { - v8::HandleScope scope; - LocalContext env; - - CompileRun( - "function A() {}\n" - "function B(x) { this.x = x; }\n" - "function A2(a) { for (var i = 0; i < a; ++i) this[i] = i; }\n" - "var a = new A();\n" - "var b = new B(a);"); - const v8::HeapSnapshot* snapshot1 = - v8::HeapProfiler::TakeSnapshot(v8::String::New("s1")); - - CompileRun( - "delete a;\n" - "b.x = null;\n" - "var a = new A2(20);\n" - "var b2 = new B(a);"); - const v8::HeapSnapshot* snapshot2 = - v8::HeapProfiler::TakeSnapshot(v8::String::New("s2")); - - const v8::HeapSnapshotsDiff* diff = snapshot1->CompareWith(snapshot2); - - // Verify additions: ensure that addition of A and B was detected. - const v8::HeapGraphNode* additions_root = diff->GetAdditionsRoot(); - bool found_A = false, found_B = false; - uint64_t s1_A_id = 0; - for (int i = 0, count = additions_root->GetChildrenCount(); i < count; ++i) { - const v8::HeapGraphEdge* prop = additions_root->GetChild(i); - const v8::HeapGraphNode* node = prop->GetToNode(); - if (node->GetType() == v8::HeapGraphNode::kObject) { - v8::String::AsciiValue node_name(node->GetName()); - if (strcmp(*node_name, "A2") == 0) { - CHECK(IsNodeRetainedAs(node, v8::HeapGraphEdge::kShortcut, "a")); - CHECK(!found_A); - found_A = true; - s1_A_id = node->GetId(); - } else if (strcmp(*node_name, "B") == 0) { - CHECK(IsNodeRetainedAs(node, v8::HeapGraphEdge::kShortcut, "b2")); - CHECK(!found_B); - found_B = true; - } - } - } - CHECK(found_A); - CHECK(found_B); - - // Verify deletions: ensure that deletion of A was detected. - const v8::HeapGraphNode* deletions_root = diff->GetDeletionsRoot(); - bool found_A_del = false; - uint64_t s2_A_id = 0; - for (int i = 0, count = deletions_root->GetChildrenCount(); i < count; ++i) { - const v8::HeapGraphEdge* prop = deletions_root->GetChild(i); - const v8::HeapGraphNode* node = prop->GetToNode(); - if (node->GetType() == v8::HeapGraphNode::kObject) { - v8::String::AsciiValue node_name(node->GetName()); - if (strcmp(*node_name, "A") == 0) { - CHECK(IsNodeRetainedAs(node, v8::HeapGraphEdge::kShortcut, "a")); - CHECK(!found_A_del); - found_A_del = true; - s2_A_id = node->GetId(); - } - } - } - CHECK(found_A_del); - CHECK_NE_UINT64_T(0, s1_A_id); - CHECK(s1_A_id != s2_A_id); -} - - TEST(HeapSnapshotRootPreservedAfterSorting) { v8::HandleScope scope; LocalContext env; @@ -1258,4 +1125,199 @@ TEST(TakeHeapSnapshotAborting) { CHECK_GT(control.total(), 0); } + +namespace { + +class TestRetainedObjectInfo : public v8::RetainedObjectInfo { + public: + TestRetainedObjectInfo(int hash, + const char* label, + intptr_t element_count = -1, + intptr_t size = -1) + : disposed_(false), + hash_(hash), + label_(label), + element_count_(element_count), + size_(size) { + instances.Add(this); + } + virtual ~TestRetainedObjectInfo() {} + virtual void Dispose() { + CHECK(!disposed_); + disposed_ = true; + } + virtual bool IsEquivalent(RetainedObjectInfo* other) { + return GetHash() == other->GetHash(); + } + virtual intptr_t GetHash() { return hash_; } + virtual const char* GetLabel() { return label_; } + virtual intptr_t GetElementCount() { return element_count_; } + virtual intptr_t GetSizeInBytes() { return size_; } + bool disposed() { return disposed_; } + + static v8::RetainedObjectInfo* WrapperInfoCallback( + uint16_t class_id, v8::Handle<v8::Value> wrapper) { + if (class_id == 1) { + if (wrapper->IsString()) { + v8::String::AsciiValue ascii(wrapper); + if (strcmp(*ascii, "AAA") == 0) + return new TestRetainedObjectInfo(1, "aaa", 100); + else if (strcmp(*ascii, "BBB") == 0) + return new TestRetainedObjectInfo(1, "aaa", 100); + } + } else if (class_id == 2) { + if (wrapper->IsString()) { + v8::String::AsciiValue ascii(wrapper); + if (strcmp(*ascii, "CCC") == 0) + return new TestRetainedObjectInfo(2, "ccc"); + } + } + CHECK(false); + return NULL; + } + + static i::List<TestRetainedObjectInfo*> instances; + + private: + bool disposed_; + int category_; + int hash_; + const char* label_; + intptr_t element_count_; + intptr_t size_; +}; + + +i::List<TestRetainedObjectInfo*> TestRetainedObjectInfo::instances; +} + + +static const v8::HeapGraphNode* GetNode(const v8::HeapGraphNode* parent, + v8::HeapGraphNode::Type type, + const char* name) { + for (int i = 0, count = parent->GetChildrenCount(); i < count; ++i) { + const v8::HeapGraphNode* node = parent->GetChild(i)->GetToNode(); + if (node->GetType() == type && strcmp(name, + const_cast<i::HeapEntry*>( + reinterpret_cast<const i::HeapEntry*>(node))->name()) == 0) { + return node; + } + } + return NULL; +} + + +TEST(HeapSnapshotRetainedObjectInfo) { + v8::HandleScope scope; + LocalContext env; + + v8::HeapProfiler::DefineWrapperClass( + 1, TestRetainedObjectInfo::WrapperInfoCallback); + v8::HeapProfiler::DefineWrapperClass( + 2, TestRetainedObjectInfo::WrapperInfoCallback); + v8::Persistent<v8::String> p_AAA = + v8::Persistent<v8::String>::New(v8_str("AAA")); + p_AAA.SetWrapperClassId(1); + v8::Persistent<v8::String> p_BBB = + v8::Persistent<v8::String>::New(v8_str("BBB")); + p_BBB.SetWrapperClassId(1); + v8::Persistent<v8::String> p_CCC = + v8::Persistent<v8::String>::New(v8_str("CCC")); + p_CCC.SetWrapperClassId(2); + CHECK_EQ(0, TestRetainedObjectInfo::instances.length()); + const v8::HeapSnapshot* snapshot = + v8::HeapProfiler::TakeSnapshot(v8::String::New("retained")); + + CHECK_EQ(3, TestRetainedObjectInfo::instances.length()); + for (int i = 0; i < TestRetainedObjectInfo::instances.length(); ++i) { + CHECK(TestRetainedObjectInfo::instances[i]->disposed()); + delete TestRetainedObjectInfo::instances[i]; + } + + const v8::HeapGraphNode* natives = GetNode( + snapshot->GetRoot(), v8::HeapGraphNode::kObject, "(Native objects)"); + CHECK_NE(NULL, natives); + CHECK_EQ(2, natives->GetChildrenCount()); + const v8::HeapGraphNode* aaa = GetNode( + natives, v8::HeapGraphNode::kNative, "aaa / 100 entries"); + CHECK_NE(NULL, aaa); + const v8::HeapGraphNode* ccc = GetNode( + natives, v8::HeapGraphNode::kNative, "ccc"); + CHECK_NE(NULL, ccc); + + CHECK_EQ(2, aaa->GetChildrenCount()); + const v8::HeapGraphNode* n_AAA = GetNode( + aaa, v8::HeapGraphNode::kString, "AAA"); + CHECK_NE(NULL, n_AAA); + const v8::HeapGraphNode* n_BBB = GetNode( + aaa, v8::HeapGraphNode::kString, "BBB"); + CHECK_NE(NULL, n_BBB); + CHECK_EQ(1, ccc->GetChildrenCount()); + const v8::HeapGraphNode* n_CCC = GetNode( + ccc, v8::HeapGraphNode::kString, "CCC"); + CHECK_NE(NULL, n_CCC); + + CHECK_EQ(aaa, GetProperty(n_AAA, v8::HeapGraphEdge::kInternal, "Native")); + CHECK_EQ(aaa, GetProperty(n_BBB, v8::HeapGraphEdge::kInternal, "Native")); + CHECK_EQ(ccc, GetProperty(n_CCC, v8::HeapGraphEdge::kInternal, "Native")); +} + + +TEST(DeleteAllHeapSnapshots) { + v8::HandleScope scope; + LocalContext env; + + CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); + v8::HeapProfiler::DeleteAllSnapshots(); + CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); + 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::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()); +} + + +TEST(DeleteHeapSnapshot) { + v8::HandleScope scope; + LocalContext env; + + CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); + const v8::HeapSnapshot* s1 = + v8::HeapProfiler::TakeSnapshot(v8::String::New("1")); + CHECK_NE(NULL, s1); + CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); + unsigned uid1 = s1->GetUid(); + CHECK_EQ(s1, v8::HeapProfiler::FindSnapshot(uid1)); + const_cast<v8::HeapSnapshot*>(s1)->Delete(); + CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); + CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid1)); + + const v8::HeapSnapshot* s2 = + 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::String::New("3")); + CHECK_NE(NULL, s3); + CHECK_EQ(2, v8::HeapProfiler::GetSnapshotsCount()); + unsigned uid3 = s3->GetUid(); + CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); + CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); + const_cast<v8::HeapSnapshot*>(s2)->Delete(); + CHECK_EQ(1, v8::HeapProfiler::GetSnapshotsCount()); + CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid2)); + CHECK_EQ(s3, v8::HeapProfiler::FindSnapshot(uid3)); + const_cast<v8::HeapSnapshot*>(s3)->Delete(); + CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount()); + CHECK_EQ(NULL, v8::HeapProfiler::FindSnapshot(uid3)); +} + #endif // ENABLE_LOGGING_AND_PROFILING diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc index 4cc7f8ba..86860ce0 100644 --- a/test/cctest/test-heap.cc +++ b/test/cctest/test-heap.cc @@ -24,9 +24,9 @@ static void InitializeVM() { static void CheckMap(Map* map, int type, int instance_size) { CHECK(map->IsHeapObject()); #ifdef DEBUG - CHECK(Heap::Contains(map)); + CHECK(HEAP->Contains(map)); #endif - CHECK_EQ(Heap::meta_map(), map->map()); + CHECK_EQ(HEAP->meta_map(), map->map()); CHECK_EQ(type, map->instance_type()); CHECK_EQ(instance_size, map->instance_size()); } @@ -34,10 +34,10 @@ static void CheckMap(Map* map, int type, int instance_size) { TEST(HeapMaps) { InitializeVM(); - CheckMap(Heap::meta_map(), MAP_TYPE, Map::kSize); - CheckMap(Heap::heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); - CheckMap(Heap::fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); - CheckMap(Heap::string_map(), STRING_TYPE, kVariableSizeSentinel); + CheckMap(HEAP->meta_map(), MAP_TYPE, Map::kSize); + CheckMap(HEAP->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); + CheckMap(HEAP->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); + CheckMap(HEAP->string_map(), STRING_TYPE, kVariableSizeSentinel); } @@ -58,7 +58,7 @@ static void CheckSmi(int value, const char* string) { static void CheckNumber(double value, const char* string) { - Object* obj = Heap::NumberFromDouble(value)->ToObjectChecked(); + Object* obj = HEAP->NumberFromDouble(value)->ToObjectChecked(); CHECK(obj->IsNumber()); bool exc; Object* print_string = *Execution::ToString(Handle<Object>(obj), &exc); @@ -76,27 +76,27 @@ static void CheckFindCodeObject() { CodeDesc desc; assm.GetCode(&desc); - Object* code = Heap::CreateCode( + Object* code = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(code->IsCode()); HeapObject* obj = HeapObject::cast(code); Address obj_addr = obj->address(); for (int i = 0; i < obj->Size(); i += kPointerSize) { - Object* found = Heap::FindCodeObject(obj_addr + i); + Object* found = HEAP->FindCodeObject(obj_addr + i); CHECK_EQ(code, found); } - Object* copy = Heap::CreateCode( + Object* copy = HEAP->CreateCode( desc, Code::ComputeFlags(Code::STUB), - Handle<Object>(Heap::undefined_value()))->ToObjectChecked(); + Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); CHECK(copy->IsCode()); HeapObject* obj_copy = HeapObject::cast(copy); - Object* not_right = Heap::FindCodeObject(obj_copy->address() + + Object* not_right = HEAP->FindCodeObject(obj_copy->address() + obj_copy->Size() / 2); CHECK(not_right != code); } @@ -106,41 +106,41 @@ TEST(HeapObjects) { InitializeVM(); v8::HandleScope sc; - Object* value = Heap::NumberFromDouble(1.000123)->ToObjectChecked(); + Object* value = HEAP->NumberFromDouble(1.000123)->ToObjectChecked(); CHECK(value->IsHeapNumber()); CHECK(value->IsNumber()); CHECK_EQ(1.000123, value->Number()); - value = Heap::NumberFromDouble(1.0)->ToObjectChecked(); + value = HEAP->NumberFromDouble(1.0)->ToObjectChecked(); CHECK(value->IsSmi()); CHECK(value->IsNumber()); CHECK_EQ(1.0, value->Number()); - value = Heap::NumberFromInt32(1024)->ToObjectChecked(); + value = HEAP->NumberFromInt32(1024)->ToObjectChecked(); CHECK(value->IsSmi()); CHECK(value->IsNumber()); CHECK_EQ(1024.0, value->Number()); - value = Heap::NumberFromInt32(Smi::kMinValue)->ToObjectChecked(); + value = HEAP->NumberFromInt32(Smi::kMinValue)->ToObjectChecked(); CHECK(value->IsSmi()); CHECK(value->IsNumber()); CHECK_EQ(Smi::kMinValue, Smi::cast(value)->value()); - value = Heap::NumberFromInt32(Smi::kMaxValue)->ToObjectChecked(); + value = HEAP->NumberFromInt32(Smi::kMaxValue)->ToObjectChecked(); CHECK(value->IsSmi()); CHECK(value->IsNumber()); CHECK_EQ(Smi::kMaxValue, Smi::cast(value)->value()); #ifndef V8_TARGET_ARCH_X64 // TODO(lrn): We need a NumberFromIntptr function in order to test this. - value = Heap::NumberFromInt32(Smi::kMinValue - 1)->ToObjectChecked(); + value = HEAP->NumberFromInt32(Smi::kMinValue - 1)->ToObjectChecked(); CHECK(value->IsHeapNumber()); CHECK(value->IsNumber()); CHECK_EQ(static_cast<double>(Smi::kMinValue - 1), value->Number()); #endif MaybeObject* maybe_value = - Heap::NumberFromUint32(static_cast<uint32_t>(Smi::kMaxValue) + 1); + HEAP->NumberFromUint32(static_cast<uint32_t>(Smi::kMaxValue) + 1); value = maybe_value->ToObjectChecked(); CHECK(value->IsHeapNumber()); CHECK(value->IsNumber()); @@ -148,21 +148,22 @@ TEST(HeapObjects) { value->Number()); // nan oddball checks - CHECK(Heap::nan_value()->IsNumber()); - CHECK(isnan(Heap::nan_value()->Number())); + CHECK(HEAP->nan_value()->IsNumber()); + CHECK(isnan(HEAP->nan_value()->Number())); - Handle<String> s = Factory::NewStringFromAscii(CStrVector("fisk hest ")); + Handle<String> s = FACTORY->NewStringFromAscii(CStrVector("fisk hest ")); CHECK(s->IsString()); CHECK_EQ(10, s->length()); - String* object_symbol = String::cast(Heap::Object_symbol()); - CHECK(Top::context()->global()->HasLocalProperty(object_symbol)); + String* object_symbol = String::cast(HEAP->Object_symbol()); + CHECK( + Isolate::Current()->context()->global()->HasLocalProperty(object_symbol)); // Check ToString for oddballs - CheckOddball(Heap::true_value(), "true"); - CheckOddball(Heap::false_value(), "false"); - CheckOddball(Heap::null_value(), "null"); - CheckOddball(Heap::undefined_value(), "undefined"); + CheckOddball(HEAP->true_value(), "true"); + CheckOddball(HEAP->false_value(), "false"); + CheckOddball(HEAP->null_value(), "null"); + CheckOddball(HEAP->undefined_value(), "undefined"); // Check ToString for Smis CheckSmi(0, "0"); @@ -197,25 +198,25 @@ TEST(GarbageCollection) { v8::HandleScope sc; // Check GC. - Heap::CollectGarbage(NEW_SPACE); + HEAP->CollectGarbage(NEW_SPACE); - Handle<String> name = Factory::LookupAsciiSymbol("theFunction"); - Handle<String> prop_name = Factory::LookupAsciiSymbol("theSlot"); - Handle<String> prop_namex = Factory::LookupAsciiSymbol("theSlotx"); - Handle<String> obj_name = Factory::LookupAsciiSymbol("theObject"); + Handle<String> name = FACTORY->LookupAsciiSymbol("theFunction"); + Handle<String> prop_name = FACTORY->LookupAsciiSymbol("theSlot"); + Handle<String> prop_namex = FACTORY->LookupAsciiSymbol("theSlotx"); + Handle<String> obj_name = FACTORY->LookupAsciiSymbol("theObject"); { v8::HandleScope inner_scope; // Allocate a function and keep it in global object's property. Handle<JSFunction> function = - Factory::NewFunction(name, Factory::undefined_value()); + FACTORY->NewFunction(name, FACTORY->undefined_value()); Handle<Map> initial_map = - Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); + FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); function->set_initial_map(*initial_map); - Top::context()->global()->SetProperty( + Isolate::Current()->context()->global()->SetProperty( *name, *function, NONE, kNonStrictMode)->ToObjectChecked(); // Allocate an object. Unrooted after leaving the scope. - Handle<JSObject> obj = Factory::NewJSObject(function); + Handle<JSObject> obj = FACTORY->NewJSObject(function); obj->SetProperty( *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); obj->SetProperty( @@ -225,34 +226,34 @@ TEST(GarbageCollection) { CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); } - Heap::CollectGarbage(NEW_SPACE); + HEAP->CollectGarbage(NEW_SPACE); // Function should be alive. - CHECK(Top::context()->global()->HasLocalProperty(*name)); + CHECK(Isolate::Current()->context()->global()->HasLocalProperty(*name)); // Check function is retained. - Object* func_value = - Top::context()->global()->GetProperty(*name)->ToObjectChecked(); + Object* func_value = Isolate::Current()->context()->global()-> + GetProperty(*name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); Handle<JSFunction> function(JSFunction::cast(func_value)); { HandleScope inner_scope; // Allocate another object, make it reachable from global. - Handle<JSObject> obj = Factory::NewJSObject(function); - Top::context()->global()->SetProperty( + Handle<JSObject> obj = FACTORY->NewJSObject(function); + Isolate::Current()->context()->global()->SetProperty( *obj_name, *obj, NONE, kNonStrictMode)->ToObjectChecked(); obj->SetProperty( *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); } // After gc, it should survive. - Heap::CollectGarbage(NEW_SPACE); + HEAP->CollectGarbage(NEW_SPACE); - CHECK(Top::context()->global()->HasLocalProperty(*obj_name)); - CHECK(Top::context()->global()->GetProperty(*obj_name)->ToObjectChecked()-> - IsJSObject()); - Object* obj = - Top::context()->global()->GetProperty(*obj_name)->ToObjectChecked(); + CHECK(Isolate::Current()->context()->global()->HasLocalProperty(*obj_name)); + CHECK(Isolate::Current()->context()->global()-> + GetProperty(*obj_name)->ToObjectChecked()->IsJSObject()); + Object* obj = Isolate::Current()->context()->global()-> + GetProperty(*obj_name)->ToObjectChecked(); JSObject* js_obj = JSObject::cast(obj); CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name)); } @@ -260,7 +261,7 @@ TEST(GarbageCollection) { static void VerifyStringAllocation(const char* string) { v8::HandleScope scope; - Handle<String> s = Factory::NewStringFromUtf8(CStrVector(string)); + Handle<String> s = FACTORY->NewStringFromUtf8(CStrVector(string)); CHECK_EQ(StrLength(string), s->length()); for (int index = 0; index < s->length(); index++) { CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index)); @@ -284,12 +285,13 @@ TEST(LocalHandles) { v8::HandleScope scope; const char* name = "Kasper the spunky"; - Handle<String> string = Factory::NewStringFromAscii(CStrVector(name)); + Handle<String> string = FACTORY->NewStringFromAscii(CStrVector(name)); CHECK_EQ(StrLength(name), string->length()); } TEST(GlobalHandles) { + GlobalHandles* global_handles = Isolate::Current()->global_handles(); InitializeVM(); Handle<Object> h1; @@ -300,17 +302,17 @@ TEST(GlobalHandles) { { HandleScope scope; - Handle<Object> i = Factory::NewStringFromAscii(CStrVector("fisk")); - Handle<Object> u = Factory::NewNumber(1.12344); + Handle<Object> i = FACTORY->NewStringFromAscii(CStrVector("fisk")); + Handle<Object> u = FACTORY->NewNumber(1.12344); - h1 = GlobalHandles::Create(*i); - h2 = GlobalHandles::Create(*u); - h3 = GlobalHandles::Create(*i); - h4 = GlobalHandles::Create(*u); + h1 = global_handles->Create(*i); + h2 = global_handles->Create(*u); + h3 = global_handles->Create(*i); + h4 = global_handles->Create(*u); } // after gc, it should survive - Heap::CollectGarbage(NEW_SPACE); + HEAP->CollectGarbage(NEW_SPACE); CHECK((*h1)->IsString()); CHECK((*h2)->IsHeapNumber()); @@ -318,12 +320,12 @@ TEST(GlobalHandles) { CHECK((*h4)->IsHeapNumber()); CHECK_EQ(*h3, *h1); - GlobalHandles::Destroy(h1.location()); - GlobalHandles::Destroy(h3.location()); + global_handles->Destroy(h1.location()); + global_handles->Destroy(h3.location()); CHECK_EQ(*h4, *h2); - GlobalHandles::Destroy(h2.location()); - GlobalHandles::Destroy(h4.location()); + global_handles->Destroy(h2.location()); + global_handles->Destroy(h4.location()); } @@ -337,6 +339,7 @@ static void TestWeakGlobalHandleCallback(v8::Persistent<v8::Value> handle, TEST(WeakGlobalHandlesScavenge) { + GlobalHandles* global_handles = Isolate::Current()->global_handles(); InitializeVM(); WeakPointerCleared = false; @@ -347,33 +350,34 @@ TEST(WeakGlobalHandlesScavenge) { { HandleScope scope; - Handle<Object> i = Factory::NewStringFromAscii(CStrVector("fisk")); - Handle<Object> u = Factory::NewNumber(1.12344); + Handle<Object> i = FACTORY->NewStringFromAscii(CStrVector("fisk")); + Handle<Object> u = FACTORY->NewNumber(1.12344); - h1 = GlobalHandles::Create(*i); - h2 = GlobalHandles::Create(*u); + h1 = global_handles->Create(*i); + h2 = global_handles->Create(*u); } - GlobalHandles::MakeWeak(h2.location(), - reinterpret_cast<void*>(1234), - &TestWeakGlobalHandleCallback); + global_handles->MakeWeak(h2.location(), + reinterpret_cast<void*>(1234), + &TestWeakGlobalHandleCallback); // Scavenge treats weak pointers as normal roots. - Heap::PerformScavenge(); + HEAP->PerformScavenge(); CHECK((*h1)->IsString()); CHECK((*h2)->IsHeapNumber()); CHECK(!WeakPointerCleared); - CHECK(!GlobalHandles::IsNearDeath(h2.location())); - CHECK(!GlobalHandles::IsNearDeath(h1.location())); + CHECK(!global_handles->IsNearDeath(h2.location())); + CHECK(!global_handles->IsNearDeath(h1.location())); - GlobalHandles::Destroy(h1.location()); - GlobalHandles::Destroy(h2.location()); + global_handles->Destroy(h1.location()); + global_handles->Destroy(h2.location()); } TEST(WeakGlobalHandlesMark) { + GlobalHandles* global_handles = Isolate::Current()->global_handles(); InitializeVM(); WeakPointerCleared = false; @@ -384,34 +388,35 @@ TEST(WeakGlobalHandlesMark) { { HandleScope scope; - Handle<Object> i = Factory::NewStringFromAscii(CStrVector("fisk")); - Handle<Object> u = Factory::NewNumber(1.12344); + Handle<Object> i = FACTORY->NewStringFromAscii(CStrVector("fisk")); + Handle<Object> u = FACTORY->NewNumber(1.12344); - h1 = GlobalHandles::Create(*i); - h2 = GlobalHandles::Create(*u); + h1 = global_handles->Create(*i); + h2 = global_handles->Create(*u); } - Heap::CollectGarbage(OLD_POINTER_SPACE); - Heap::CollectGarbage(NEW_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(NEW_SPACE); // Make sure the object is promoted. - GlobalHandles::MakeWeak(h2.location(), - reinterpret_cast<void*>(1234), - &TestWeakGlobalHandleCallback); + global_handles->MakeWeak(h2.location(), + reinterpret_cast<void*>(1234), + &TestWeakGlobalHandleCallback); CHECK(!GlobalHandles::IsNearDeath(h1.location())); CHECK(!GlobalHandles::IsNearDeath(h2.location())); - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); CHECK((*h1)->IsString()); CHECK(WeakPointerCleared); CHECK(!GlobalHandles::IsNearDeath(h1.location())); - GlobalHandles::Destroy(h1.location()); + global_handles->Destroy(h1.location()); } TEST(DeleteWeakGlobalHandle) { + GlobalHandles* global_handles = Isolate::Current()->global_handles(); InitializeVM(); WeakPointerCleared = false; @@ -421,21 +426,21 @@ TEST(DeleteWeakGlobalHandle) { { HandleScope scope; - Handle<Object> i = Factory::NewStringFromAscii(CStrVector("fisk")); - h = GlobalHandles::Create(*i); + Handle<Object> i = FACTORY->NewStringFromAscii(CStrVector("fisk")); + h = global_handles->Create(*i); } - GlobalHandles::MakeWeak(h.location(), - reinterpret_cast<void*>(1234), - &TestWeakGlobalHandleCallback); + global_handles->MakeWeak(h.location(), + reinterpret_cast<void*>(1234), + &TestWeakGlobalHandleCallback); // Scanvenge does not recognize weak reference. - Heap::PerformScavenge(); + HEAP->PerformScavenge(); CHECK(!WeakPointerCleared); // Mark-compact treats weak reference properly. - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); CHECK(WeakPointerCleared); } @@ -507,12 +512,12 @@ static const char* not_so_random_string_table[] = { static void CheckSymbols(const char** strings) { for (const char* string = *strings; *strings != 0; string = *strings++) { Object* a; - MaybeObject* maybe_a = Heap::LookupAsciiSymbol(string); + MaybeObject* maybe_a = HEAP->LookupAsciiSymbol(string); // LookupAsciiSymbol may return a failure if a GC is needed. if (!maybe_a->ToObject(&a)) continue; CHECK(a->IsSymbol()); Object* b; - MaybeObject *maybe_b = Heap::LookupAsciiSymbol(string); + MaybeObject* maybe_b = HEAP->LookupAsciiSymbol(string); if (!maybe_b->ToObject(&b)) continue; CHECK_EQ(b, a); CHECK(String::cast(b)->IsEqualTo(CStrVector(string))); @@ -532,15 +537,15 @@ TEST(FunctionAllocation) { InitializeVM(); v8::HandleScope sc; - Handle<String> name = Factory::LookupAsciiSymbol("theFunction"); + Handle<String> name = FACTORY->LookupAsciiSymbol("theFunction"); Handle<JSFunction> function = - Factory::NewFunction(name, Factory::undefined_value()); + FACTORY->NewFunction(name, FACTORY->undefined_value()); Handle<Map> initial_map = - Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); + FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); function->set_initial_map(*initial_map); - Handle<String> prop_name = Factory::LookupAsciiSymbol("theSlot"); - Handle<JSObject> obj = Factory::NewJSObject(function); + Handle<String> prop_name = FACTORY->LookupAsciiSymbol("theSlot"); + Handle<JSObject> obj = FACTORY->NewJSObject(function); obj->SetProperty( *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); @@ -555,14 +560,14 @@ TEST(ObjectProperties) { InitializeVM(); v8::HandleScope sc; - String* object_symbol = String::cast(Heap::Object_symbol()); - Object* raw_object = - Top::context()->global()->GetProperty(object_symbol)->ToObjectChecked(); + String* object_symbol = String::cast(HEAP->Object_symbol()); + Object* raw_object = Isolate::Current()->context()->global()-> + GetProperty(object_symbol)->ToObjectChecked(); JSFunction* object_function = JSFunction::cast(raw_object); Handle<JSFunction> constructor(object_function); - Handle<JSObject> obj = Factory::NewJSObject(constructor); - Handle<String> first = Factory::LookupAsciiSymbol("first"); - Handle<String> second = Factory::LookupAsciiSymbol("second"); + Handle<JSObject> obj = FACTORY->NewJSObject(constructor); + Handle<String> first = FACTORY->LookupAsciiSymbol("first"); + Handle<String> second = FACTORY->LookupAsciiSymbol("second"); // check for empty CHECK(!obj->HasLocalProperty(*first)); @@ -608,18 +613,18 @@ TEST(ObjectProperties) { // check string and symbol match static const char* string1 = "fisk"; - Handle<String> s1 = Factory::NewStringFromAscii(CStrVector(string1)); + Handle<String> s1 = FACTORY->NewStringFromAscii(CStrVector(string1)); obj->SetProperty( *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); - Handle<String> s1_symbol = Factory::LookupAsciiSymbol(string1); + Handle<String> s1_symbol = FACTORY->LookupAsciiSymbol(string1); CHECK(obj->HasLocalProperty(*s1_symbol)); // check symbol and string match static const char* string2 = "fugl"; - Handle<String> s2_symbol = Factory::LookupAsciiSymbol(string2); + Handle<String> s2_symbol = FACTORY->LookupAsciiSymbol(string2); obj->SetProperty( *s2_symbol, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); - Handle<String> s2 = Factory::NewStringFromAscii(CStrVector(string2)); + Handle<String> s2 = FACTORY->NewStringFromAscii(CStrVector(string2)); CHECK(obj->HasLocalProperty(*s2)); } @@ -628,15 +633,15 @@ TEST(JSObjectMaps) { InitializeVM(); v8::HandleScope sc; - Handle<String> name = Factory::LookupAsciiSymbol("theFunction"); + Handle<String> name = FACTORY->LookupAsciiSymbol("theFunction"); Handle<JSFunction> function = - Factory::NewFunction(name, Factory::undefined_value()); + FACTORY->NewFunction(name, FACTORY->undefined_value()); Handle<Map> initial_map = - Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); + FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); function->set_initial_map(*initial_map); - Handle<String> prop_name = Factory::LookupAsciiSymbol("theSlot"); - Handle<JSObject> obj = Factory::NewJSObject(function); + Handle<String> prop_name = FACTORY->LookupAsciiSymbol("theSlot"); + Handle<JSObject> obj = FACTORY->NewJSObject(function); // Set a propery obj->SetProperty( @@ -652,14 +657,14 @@ TEST(JSArray) { InitializeVM(); v8::HandleScope sc; - Handle<String> name = Factory::LookupAsciiSymbol("Array"); - Object* raw_object = - Top::context()->global()->GetProperty(*name)->ToObjectChecked(); + Handle<String> name = FACTORY->LookupAsciiSymbol("Array"); + Object* raw_object = Isolate::Current()->context()->global()-> + GetProperty(*name)->ToObjectChecked(); Handle<JSFunction> function = Handle<JSFunction>( JSFunction::cast(raw_object)); // Allocate the object. - Handle<JSObject> object = Factory::NewJSObject(function); + Handle<JSObject> object = FACTORY->NewJSObject(function); Handle<JSArray> array = Handle<JSArray>::cast(object); // We just initialized the VM, no heap allocation failure yet. Object* ok = array->Initialize(0)->ToObjectChecked(); @@ -676,7 +681,7 @@ TEST(JSArray) { // Set array length with larger than smi value. Handle<Object> length = - Factory::NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); + FACTORY->NewNumberFromUint(static_cast<uint32_t>(Smi::kMaxValue) + 1); ok = array->SetElementsLength(*length)->ToObjectChecked(); uint32_t int_length = 0; @@ -698,14 +703,14 @@ TEST(JSObjectCopy) { InitializeVM(); v8::HandleScope sc; - String* object_symbol = String::cast(Heap::Object_symbol()); - Object* raw_object = - Top::context()->global()->GetProperty(object_symbol)->ToObjectChecked(); + String* object_symbol = String::cast(HEAP->Object_symbol()); + Object* raw_object = Isolate::Current()->context()->global()-> + GetProperty(object_symbol)->ToObjectChecked(); JSFunction* object_function = JSFunction::cast(raw_object); Handle<JSFunction> constructor(object_function); - Handle<JSObject> obj = Factory::NewJSObject(constructor); - Handle<String> first = Factory::LookupAsciiSymbol("first"); - Handle<String> second = Factory::LookupAsciiSymbol("second"); + Handle<JSObject> obj = FACTORY->NewJSObject(constructor); + Handle<String> first = FACTORY->LookupAsciiSymbol("first"); + Handle<String> second = FACTORY->LookupAsciiSymbol("second"); obj->SetProperty( *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); @@ -761,17 +766,17 @@ TEST(StringAllocation) { non_ascii[3 * i + 2] = chars[2]; } Handle<String> non_ascii_sym = - Factory::LookupSymbol(Vector<const char>(non_ascii, 3 * length)); + FACTORY->LookupSymbol(Vector<const char>(non_ascii, 3 * length)); CHECK_EQ(length, non_ascii_sym->length()); Handle<String> ascii_sym = - Factory::LookupSymbol(Vector<const char>(ascii, length)); + FACTORY->LookupSymbol(Vector<const char>(ascii, length)); CHECK_EQ(length, ascii_sym->length()); Handle<String> non_ascii_str = - Factory::NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length)); + FACTORY->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length)); non_ascii_str->Hash(); CHECK_EQ(length, non_ascii_str->length()); Handle<String> ascii_str = - Factory::NewStringFromUtf8(Vector<const char>(ascii, length)); + FACTORY->NewStringFromUtf8(Vector<const char>(ascii, length)); ascii_str->Hash(); CHECK_EQ(length, ascii_str->length()); DeleteArray(non_ascii); @@ -805,22 +810,22 @@ TEST(Iteration) { int next_objs_index = 0; // Allocate a JS array to OLD_POINTER_SPACE and NEW_SPACE - objs[next_objs_index++] = Factory::NewJSArray(10); - objs[next_objs_index++] = Factory::NewJSArray(10, TENURED); + objs[next_objs_index++] = FACTORY->NewJSArray(10); + objs[next_objs_index++] = FACTORY->NewJSArray(10, TENURED); // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE objs[next_objs_index++] = - Factory::NewStringFromAscii(CStrVector("abcdefghij")); + FACTORY->NewStringFromAscii(CStrVector("abcdefghij")); objs[next_objs_index++] = - Factory::NewStringFromAscii(CStrVector("abcdefghij"), TENURED); + FACTORY->NewStringFromAscii(CStrVector("abcdefghij"), TENURED); // Allocate a large string (for large object space). - int large_size = Heap::MaxObjectSizeInPagedSpace() + 1; + int large_size = HEAP->MaxObjectSizeInPagedSpace() + 1; char* str = new char[large_size]; for (int i = 0; i < large_size - 1; ++i) str[i] = 'a'; str[large_size - 1] = '\0'; objs[next_objs_index++] = - Factory::NewStringFromAscii(CStrVector(str), TENURED); + FACTORY->NewStringFromAscii(CStrVector(str), TENURED); delete[] str; // Add a Map object to look for. @@ -834,9 +839,9 @@ TEST(Iteration) { TEST(LargeObjectSpaceContains) { InitializeVM(); - Heap::CollectGarbage(NEW_SPACE); + HEAP->CollectGarbage(NEW_SPACE); - Address current_top = Heap::new_space()->top(); + 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; @@ -859,7 +864,7 @@ TEST(LargeObjectSpaceContains) { kPointerSize; CHECK_EQ(bytes_to_allocate, FixedArray::SizeFor(n_elements)); FixedArray* array = FixedArray::cast( - Heap::AllocateFixedArray(n_elements)->ToObjectChecked()); + HEAP->AllocateFixedArray(n_elements)->ToObjectChecked()); int index = n_elements - 1; CHECK_EQ(flags_ptr, @@ -869,8 +874,8 @@ TEST(LargeObjectSpaceContains) { // 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)); + CHECK(HEAP->new_space()->Contains(addr)); + CHECK(!HEAP->lo_space()->Contains(addr)); } @@ -901,7 +906,7 @@ TEST(Regression39128) { // Increase the chance of 'bump-the-pointer' allocation in old space. bool force_compaction = true; - Heap::CollectAllGarbage(force_compaction); + HEAP->CollectAllGarbage(force_compaction); v8::HandleScope scope; @@ -910,11 +915,12 @@ TEST(Regression39128) { // that region dirty marks are updated correctly. // Step 1: prepare a map for the object. We add 1 inobject property to it. - Handle<JSFunction> object_ctor(Top::global_context()->object_function()); + Handle<JSFunction> object_ctor( + Isolate::Current()->global_context()->object_function()); CHECK(object_ctor->has_initial_map()); Handle<Map> object_map(object_ctor->initial_map()); // Create a map with single inobject property. - Handle<Map> my_map = Factory::CopyMap(object_map, 1); + Handle<Map> my_map = FACTORY->CopyMap(object_map, 1); int n_properties = my_map->inobject_properties(); CHECK_GT(n_properties, 0); @@ -924,15 +930,15 @@ TEST(Regression39128) { // just enough room to allocate JSObject and thus fill the newspace. int allocation_amount = Min(FixedArray::kMaxSize, - Heap::MaxObjectSizeInNewSpace()); + HEAP->MaxObjectSizeInNewSpace()); int allocation_len = LenFromSize(allocation_amount); - NewSpace* new_space = Heap::new_space(); + NewSpace* new_space = HEAP->new_space(); Address* top_addr = new_space->allocation_top_address(); Address* limit_addr = new_space->allocation_limit_address(); while ((*limit_addr - *top_addr) > allocation_amount) { - CHECK(!Heap::always_allocate()); - Object* array = - Heap::AllocateFixedArray(allocation_len)->ToObjectChecked(); + CHECK(!HEAP->always_allocate()); + Object* array = HEAP->AllocateFixedArray(allocation_len)->ToObjectChecked(); + CHECK(!array->IsFailure()); CHECK(new_space->Contains(array)); } @@ -941,12 +947,12 @@ TEST(Regression39128) { int fixed_array_len = LenFromSize(to_fill); CHECK(fixed_array_len < FixedArray::kMaxLength); - CHECK(!Heap::always_allocate()); - Object* array = - Heap::AllocateFixedArray(fixed_array_len)->ToObjectChecked(); + CHECK(!HEAP->always_allocate()); + Object* array = HEAP->AllocateFixedArray(fixed_array_len)->ToObjectChecked(); + CHECK(!array->IsFailure()); CHECK(new_space->Contains(array)); - Object* object = Heap::AllocateJSObjectFromMap(*my_map)->ToObjectChecked(); + Object* object = HEAP->AllocateJSObjectFromMap(*my_map)->ToObjectChecked(); CHECK(new_space->Contains(object)); JSObject* jsobject = JSObject::cast(object); CHECK_EQ(0, FixedArray::cast(jsobject->elements())->length()); @@ -958,15 +964,15 @@ TEST(Regression39128) { // Step 4: clone jsobject, but force always allocate first to create a clone // in old pointer space. - Address old_pointer_space_top = Heap::old_pointer_space()->top(); + Address old_pointer_space_top = HEAP->old_pointer_space()->top(); AlwaysAllocateScope aa_scope; - Object* clone_obj = Heap::CopyJSObject(jsobject)->ToObjectChecked(); + Object* clone_obj = HEAP->CopyJSObject(jsobject)->ToObjectChecked(); JSObject* clone = JSObject::cast(clone_obj); if (clone->address() != old_pointer_space_top) { // Alas, got allocated from free list, we cannot do checks. return; } - CHECK(Heap::old_pointer_space()->Contains(clone->address())); + CHECK(HEAP->old_pointer_space()->Contains(clone->address())); // Step 5: verify validity of region dirty marks. Address clone_addr = clone->address(); @@ -988,7 +994,7 @@ TEST(TestCodeFlushing) { " var z = x + y;" "};" "foo()"; - Handle<String> foo_name = Factory::LookupAsciiSymbol("foo"); + Handle<String> foo_name = FACTORY->LookupAsciiSymbol("foo"); // This compile will add the code to the compilation cache. { v8::HandleScope scope; @@ -996,23 +1002,23 @@ TEST(TestCodeFlushing) { } // Check function is compiled. - Object* func_value = - Top::context()->global()->GetProperty(*foo_name)->ToObjectChecked(); + Object* func_value = Isolate::Current()->context()->global()-> + GetProperty(*foo_name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); Handle<JSFunction> function(JSFunction::cast(func_value)); CHECK(function->shared()->is_compiled()); - Heap::CollectAllGarbage(true); - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); CHECK(function->shared()->is_compiled()); - Heap::CollectAllGarbage(true); - Heap::CollectAllGarbage(true); - Heap::CollectAllGarbage(true); - Heap::CollectAllGarbage(true); - Heap::CollectAllGarbage(true); - Heap::CollectAllGarbage(true); + 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()); @@ -1027,7 +1033,7 @@ TEST(TestCodeFlushing) { // Count the number of global contexts in the weak list of global contexts. static int CountGlobalContexts() { int count = 0; - Object* object = Heap::global_contexts_list(); + Object* object = HEAP->global_contexts_list(); while (!object->IsUndefined()) { count++; object = Context::cast(object)->get(Context::NEXT_CONTEXT_LINK); @@ -1051,6 +1057,8 @@ static int CountOptimizedUserFunctions(v8::Handle<v8::Context> context) { TEST(TestInternalWeakLists) { + v8::V8::Initialize(); + static const int kNumTestContexts = 10; v8::HandleScope scope; @@ -1094,35 +1102,35 @@ TEST(TestInternalWeakLists) { // Scavenge treats these references as strong. for (int j = 0; j < 10; j++) { - Heap::PerformScavenge(); + HEAP->PerformScavenge(); CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); } // Mark compact handles the weak references. - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); // Get rid of f3 and f5 in the same way. CompileRun("f3=null"); for (int j = 0; j < 10; j++) { - Heap::PerformScavenge(); + HEAP->PerformScavenge(); CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); } - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); CompileRun("f5=null"); for (int j = 0; j < 10; j++) { - Heap::PerformScavenge(); + HEAP->PerformScavenge(); CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); } - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i])); ctx[i]->Exit(); } // Force compilation cache cleanup. - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); // Dispose the global contexts one by one. for (int i = 0; i < kNumTestContexts; i++) { @@ -1131,12 +1139,12 @@ TEST(TestInternalWeakLists) { // Scavenge treats these references as strong. for (int j = 0; j < 10; j++) { - Heap::PerformScavenge(); + HEAP->PerformScavenge(); CHECK_EQ(kNumTestContexts - i, CountGlobalContexts()); } // Mark compact handles the weak references. - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); CHECK_EQ(kNumTestContexts - i - 1, CountGlobalContexts()); } @@ -1148,10 +1156,10 @@ TEST(TestInternalWeakLists) { // causing a GC after the specified number of elements. static int CountGlobalContextsWithGC(int n) { int count = 0; - Handle<Object> object(Heap::global_contexts_list()); + Handle<Object> object(HEAP->global_contexts_list()); while (!object->IsUndefined()) { count++; - if (count == n) Heap::CollectAllGarbage(true); + if (count == n) HEAP->CollectAllGarbage(true); object = Handle<Object>(Context::cast(*object)->get(Context::NEXT_CONTEXT_LINK)); } @@ -1170,7 +1178,7 @@ static int CountOptimizedUserFunctionsWithGC(v8::Handle<v8::Context> context, while (object->IsJSFunction() && !Handle<JSFunction>::cast(object)->IsBuiltin()) { count++; - if (count == n) Heap::CollectAllGarbage(true); + if (count == n) HEAP->CollectAllGarbage(true); object = Handle<Object>( Object::cast(JSFunction::cast(*object)->next_function_link())); } @@ -1179,6 +1187,8 @@ static int CountOptimizedUserFunctionsWithGC(v8::Handle<v8::Context> context, TEST(TestInternalWeakListsTraverseWithGC) { + v8::V8::Initialize(); + static const int kNumTestContexts = 10; v8::HandleScope scope; @@ -1228,7 +1238,7 @@ TEST(TestInternalWeakListsTraverseWithGC) { TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { InitializeVM(); - intptr_t size_of_objects_1 = Heap::SizeOfObjects(); + intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); HeapIterator iterator(HeapIterator::kFilterFreeListNodes); intptr_t size_of_objects_2 = 0; for (HeapObject* obj = iterator.next(); @@ -1283,10 +1293,10 @@ TEST(HeapIteratorFilterUnreachable) { InitializeVM(); v8::HandleScope scope; CompileRun("a = {}; b = {};"); - v8::Handle<Object> a(Top::context()->global()->GetProperty( - *Factory::LookupAsciiSymbol("a"))->ToObjectChecked()); - v8::Handle<Object> b(Top::context()->global()->GetProperty( - *Factory::LookupAsciiSymbol("b"))->ToObjectChecked()); + 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); @@ -1294,8 +1304,8 @@ TEST(HeapIteratorFilterUnreachable) { CHECK(helper.a_found()); CHECK(helper.b_found()); } - CHECK(Top::context()->global()->DeleteProperty( - *Factory::LookupAsciiSymbol("a"), JSObject::FORCE_DELETION)); + 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; diff --git a/test/cctest/test-liveedit.cc b/test/cctest/test-liveedit.cc index 244980a1..92323544 100644 --- a/test/cctest/test-liveedit.cc +++ b/test/cctest/test-liveedit.cc @@ -158,6 +158,7 @@ void CompareStrings(const char* s1, const char* s2, // --- T h e A c t u a l T e s t s TEST(LiveEditDiffer) { + v8::internal::V8::Initialize(NULL); CompareStrings("zz1zzz12zz123zzz", "zzzzzzzzzz", 6); CompareStrings("zz1zzz12zz123zzz", "zz0zzz0zz0zzz", 9); CompareStrings("123456789", "987654321", 16); diff --git a/test/cctest/test-log-stack-tracer.cc b/test/cctest/test-log-stack-tracer.cc index bf72184f..df0806f8 100644 --- a/test/cctest/test-log-stack-tracer.cc +++ b/test/cctest/test-log-stack-tracer.cc @@ -36,7 +36,7 @@ #include "api.h" #include "codegen.h" #include "log.h" -#include "top.h" +#include "isolate.h" #include "cctest.h" #include "disassembler.h" #include "register-allocator-inl.h" @@ -52,10 +52,10 @@ using v8::Value; using v8::internal::byte; using v8::internal::Address; using v8::internal::Handle; +using v8::internal::Isolate; using v8::internal::JSFunction; using v8::internal::StackTracer; using v8::internal::TickSample; -using v8::internal::Top; namespace i = v8::internal; @@ -78,18 +78,19 @@ static void DoTrace(Address fp) { // sp is only used to define stack high bound trace_env.sample->sp = reinterpret_cast<Address>(trace_env.sample) - 10240; - StackTracer::Trace(trace_env.sample); + StackTracer::Trace(Isolate::Current(), trace_env.sample); } // Hide c_entry_fp to emulate situation when sampling is done while // pure JS code is being executed static void DoTraceHideCEntryFPAddress(Address fp) { - v8::internal::Address saved_c_frame_fp = *(Top::c_entry_fp_address()); + v8::internal::Address saved_c_frame_fp = + *(Isolate::Current()->c_entry_fp_address()); CHECK(saved_c_frame_fp); - *(Top::c_entry_fp_address()) = 0; + *(Isolate::Current()->c_entry_fp_address()) = 0; DoTrace(fp); - *(Top::c_entry_fp_address()) = saved_c_frame_fp; + *(Isolate::Current()->c_entry_fp_address()) = saved_c_frame_fp; } @@ -163,8 +164,8 @@ v8::Handle<v8::Value> TraceExtension::JSTrace(const v8::Arguments& args) { static Address GetJsEntrySp() { - CHECK_NE(NULL, Top::GetCurrentThread()); - return Top::js_entry_sp(Top::GetCurrentThread()); + CHECK_NE(NULL, i::Isolate::Current()->thread_local_top()); + return Isolate::js_entry_sp(i::Isolate::Current()->thread_local_top()); } @@ -276,7 +277,7 @@ static void CreateTraceCallerFunction(const char* func_name, // This test verifies that stack tracing works when called during // execution of a native function called from JS code. In this case, -// StackTracer uses Top::c_entry_fp as a starting point for stack +// StackTracer uses Isolate::c_entry_fp as a starting point for stack // walking. TEST(CFromJSStackTrace) { TickSample sample; @@ -302,13 +303,11 @@ TEST(CFromJSStackTrace) { // DoTrace(EBP) [native] // StackTracer::Trace - // The VM state tracking keeps track of external callbacks and puts - // them at the top of the sample stack. - int base = 0; - CHECK(sample.stack[0] == FUNCTION_ADDR(TraceExtension::Trace)); - base++; + CHECK(sample.has_external_callback); + CHECK_EQ(FUNCTION_ADDR(TraceExtension::Trace), sample.external_callback); // Stack tracing will start from the first JS function, i.e. "JSFuncDoTrace" + int base = 0; CHECK_GT(sample.frames_count, base + 1); CHECK(IsAddressWithinFuncCode("JSFuncDoTrace", sample.stack[base + 0])); CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 1])); @@ -318,7 +317,7 @@ TEST(CFromJSStackTrace) { // This test verifies that stack tracing works when called during // execution of JS code. However, as calling StackTracer requires // entering native code, we can only emulate pure JS by erasing -// Top::c_entry_fp value. In this case, StackTracer uses passed frame +// Isolate::c_entry_fp value. In this case, StackTracer uses passed frame // pointer value as a starting point for stack walking. TEST(PureJSStackTrace) { // This test does not pass with inlining enabled since inlined functions @@ -353,13 +352,11 @@ TEST(PureJSStackTrace) { // StackTracer::Trace // - // The VM state tracking keeps track of external callbacks and puts - // them at the top of the sample stack. - int base = 0; - CHECK(sample.stack[0] == FUNCTION_ADDR(TraceExtension::JSTrace)); - base++; + CHECK(sample.has_external_callback); + CHECK_EQ(FUNCTION_ADDR(TraceExtension::JSTrace), sample.external_callback); // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" + int base = 0; CHECK_GT(sample.frames_count, base + 1); CHECK(IsAddressWithinFuncCode("JSTrace", sample.stack[base + 0])); CHECK(IsAddressWithinFuncCode("OuterJSTrace", sample.stack[base + 1])); @@ -397,6 +394,7 @@ static int CFunc(int depth) { TEST(PureCStackTrace) { TickSample sample; InitTraceEnv(&sample); + InitializeVM(); // Check that sampler doesn't crash CHECK_EQ(10, CFunc(10)); } diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc index 30b8a48d..17c73874 100644 --- a/test/cctest/test-log.cc +++ b/test/cctest/test-log.cc @@ -29,61 +29,61 @@ static void SetUp() { // Log to memory buffer. i::FLAG_logfile = "*"; i::FLAG_log = true; - Logger::Setup(); + LOGGER->Setup(); } static void TearDown() { - Logger::TearDown(); + LOGGER->TearDown(); } TEST(EmptyLog) { SetUp(); - CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0)); - CHECK_EQ(0, Logger::GetLogLines(100, NULL, 0)); - CHECK_EQ(0, Logger::GetLogLines(0, NULL, 100)); - CHECK_EQ(0, Logger::GetLogLines(100, NULL, 100)); + CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0)); + CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 0)); + CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 100)); + CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 100)); TearDown(); } TEST(GetMessages) { SetUp(); - Logger::StringEvent("aaa", "bbb"); - Logger::StringEvent("cccc", "dddd"); - CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0)); + LOGGER->StringEvent("aaa", "bbb"); + LOGGER->StringEvent("cccc", "dddd"); + CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0)); char log_lines[100]; memset(log_lines, 0, sizeof(log_lines)); // See Logger::StringEvent. const char* line_1 = "aaa,\"bbb\"\n"; const int line_1_len = StrLength(line_1); // The exact size. - CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len)); + CHECK_EQ(line_1_len, LOGGER->GetLogLines(0, log_lines, line_1_len)); CHECK_EQ(line_1, log_lines); memset(log_lines, 0, sizeof(log_lines)); // A bit more than the first line length. - CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len + 3)); + CHECK_EQ(line_1_len, LOGGER->GetLogLines(0, log_lines, line_1_len + 3)); log_lines[line_1_len] = '\0'; CHECK_EQ(line_1, log_lines); memset(log_lines, 0, sizeof(log_lines)); const char* line_2 = "cccc,\"dddd\"\n"; const int line_2_len = StrLength(line_2); // Now start with line_2 beginning. - CHECK_EQ(0, Logger::GetLogLines(line_1_len, log_lines, 0)); - CHECK_EQ(line_2_len, Logger::GetLogLines(line_1_len, log_lines, line_2_len)); + CHECK_EQ(0, LOGGER->GetLogLines(line_1_len, log_lines, 0)); + CHECK_EQ(line_2_len, LOGGER->GetLogLines(line_1_len, log_lines, line_2_len)); CHECK_EQ(line_2, log_lines); memset(log_lines, 0, sizeof(log_lines)); CHECK_EQ(line_2_len, - Logger::GetLogLines(line_1_len, log_lines, line_2_len + 3)); + LOGGER->GetLogLines(line_1_len, log_lines, line_2_len + 3)); CHECK_EQ(line_2, log_lines); memset(log_lines, 0, sizeof(log_lines)); // Now get entire buffer contents. const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n"; const int all_lines_len = StrLength(all_lines); - CHECK_EQ(all_lines_len, Logger::GetLogLines(0, log_lines, all_lines_len)); + CHECK_EQ(all_lines_len, LOGGER->GetLogLines(0, log_lines, all_lines_len)); CHECK_EQ(all_lines, log_lines); memset(log_lines, 0, sizeof(log_lines)); - CHECK_EQ(all_lines_len, Logger::GetLogLines(0, log_lines, all_lines_len + 3)); + CHECK_EQ(all_lines_len, LOGGER->GetLogLines(0, log_lines, all_lines_len + 3)); CHECK_EQ(all_lines, log_lines); memset(log_lines, 0, sizeof(log_lines)); TearDown(); @@ -91,26 +91,26 @@ TEST(GetMessages) { static int GetLogLines(int start_pos, i::Vector<char>* buffer) { - return Logger::GetLogLines(start_pos, buffer->start(), buffer->length()); + return LOGGER->GetLogLines(start_pos, buffer->start(), buffer->length()); } TEST(BeyondWritePosition) { SetUp(); - Logger::StringEvent("aaa", "bbb"); - Logger::StringEvent("cccc", "dddd"); + LOGGER->StringEvent("aaa", "bbb"); + LOGGER->StringEvent("cccc", "dddd"); // See Logger::StringEvent. const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n"; const int all_lines_len = StrLength(all_lines); EmbeddedVector<char, 100> buffer; const int beyond_write_pos = all_lines_len; - CHECK_EQ(0, Logger::GetLogLines(beyond_write_pos, buffer.start(), 1)); + CHECK_EQ(0, LOGGER->GetLogLines(beyond_write_pos, buffer.start(), 1)); CHECK_EQ(0, GetLogLines(beyond_write_pos, &buffer)); - CHECK_EQ(0, Logger::GetLogLines(beyond_write_pos + 1, buffer.start(), 1)); + CHECK_EQ(0, LOGGER->GetLogLines(beyond_write_pos + 1, buffer.start(), 1)); CHECK_EQ(0, GetLogLines(beyond_write_pos + 1, &buffer)); - CHECK_EQ(0, Logger::GetLogLines(beyond_write_pos + 100, buffer.start(), 1)); + CHECK_EQ(0, LOGGER->GetLogLines(beyond_write_pos + 100, buffer.start(), 1)); CHECK_EQ(0, GetLogLines(beyond_write_pos + 100, &buffer)); - CHECK_EQ(0, Logger::GetLogLines(10 * 1024 * 1024, buffer.start(), 1)); + CHECK_EQ(0, LOGGER->GetLogLines(10 * 1024 * 1024, buffer.start(), 1)); CHECK_EQ(0, GetLogLines(10 * 1024 * 1024, &buffer)); TearDown(); } @@ -120,12 +120,12 @@ TEST(MemoryLoggingTurnedOff) { // Log to stdout i::FLAG_logfile = "-"; i::FLAG_log = true; - Logger::Setup(); - CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0)); - CHECK_EQ(0, Logger::GetLogLines(100, NULL, 0)); - CHECK_EQ(0, Logger::GetLogLines(0, NULL, 100)); - CHECK_EQ(0, Logger::GetLogLines(100, NULL, 100)); - Logger::TearDown(); + LOGGER->Setup(); + CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0)); + CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 0)); + CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 100)); + CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 100)); + LOGGER->TearDown(); } @@ -139,12 +139,12 @@ namespace internal { class LoggerTestHelper : public AllStatic { public: - static bool IsSamplerActive() { return Logger::IsProfilerSamplerActive(); } + static bool IsSamplerActive() { return LOGGER->IsProfilerSamplerActive(); } static void ResetSamplesTaken() { - reinterpret_cast<Sampler*>(Logger::ticker_)->ResetSamplesTaken(); + reinterpret_cast<Sampler*>(LOGGER->ticker_)->ResetSamplesTaken(); } static bool has_samples_taken() { - return reinterpret_cast<Sampler*>(Logger::ticker_)->samples_taken() > 0; + return reinterpret_cast<Sampler*>(LOGGER->ticker_)->samples_taken() > 0; } }; @@ -166,13 +166,13 @@ class ScopedLoggerInitializer { need_to_set_up_logger_(i::V8::IsRunning()), scope_(), env_(v8::Context::New()) { - if (need_to_set_up_logger_) Logger::Setup(); + if (need_to_set_up_logger_) LOGGER->Setup(); env_->Enter(); } ~ScopedLoggerInitializer() { env_->Exit(); - Logger::TearDown(); + LOGGER->TearDown(); i::FLAG_prof_lazy = saved_prof_lazy_; i::FLAG_prof = saved_prof_; i::FLAG_prof_auto = saved_prof_auto_; @@ -251,7 +251,7 @@ static void CheckThatProfilerWorks(LogBufferMatcher* matcher) { !LoggerTestHelper::IsSamplerActive()); LoggerTestHelper::ResetSamplesTaken(); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 0); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 0); CHECK(LoggerTestHelper::IsSamplerActive()); // Verify that the current map of compiled functions has been logged. @@ -273,7 +273,7 @@ static void CheckThatProfilerWorks(LogBufferMatcher* matcher) { i::OS::Sleep(1); } - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 0); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 0); CHECK(i::RuntimeProfiler::IsEnabled() || !LoggerTestHelper::IsSamplerActive()); @@ -329,8 +329,8 @@ namespace { class LoopingThread : public v8::internal::Thread { public: - LoopingThread() - : v8::internal::Thread(), + explicit LoopingThread(v8::internal::Isolate* isolate) + : v8::internal::Thread(isolate), semaphore_(v8::internal::OS::CreateSemaphore(0)), run_(true) { } @@ -369,9 +369,12 @@ class LoopingThread : public v8::internal::Thread { class LoopingJsThread : public LoopingThread { public: + explicit LoopingJsThread(v8::internal::Isolate* isolate) + : LoopingThread(isolate) { } void RunLoop() { v8::Locker locker; - CHECK(v8::internal::ThreadManager::HasId()); + CHECK(i::Isolate::Current() != NULL); + CHECK_GT(i::Isolate::Current()->thread_manager()->CurrentId(), 0); SetV8ThreadId(); while (IsRunning()) { v8::HandleScope scope; @@ -392,11 +395,14 @@ class LoopingJsThread : public LoopingThread { class LoopingNonJsThread : public LoopingThread { public: + explicit LoopingNonJsThread(v8::internal::Isolate* isolate) + : LoopingThread(isolate) { } void RunLoop() { v8::Locker locker; v8::Unlocker unlocker; // Now thread has V8's id, but will not run VM code. - CHECK(v8::internal::ThreadManager::HasId()); + CHECK(i::Isolate::Current() != NULL); + CHECK_GT(i::Isolate::Current()->thread_manager()->CurrentId(), 0); double i = 10; SignalRunning(); while (IsRunning()) { @@ -409,8 +415,8 @@ class LoopingNonJsThread : public LoopingThread { class TestSampler : public v8::internal::Sampler { public: - TestSampler() - : Sampler(0, true, true), + explicit TestSampler(v8::internal::Isolate* isolate) + : Sampler(isolate, 0, true, true), semaphore_(v8::internal::OS::CreateSemaphore(0)), was_sample_stack_called_(false) { } @@ -441,14 +447,14 @@ TEST(ProfMultipleThreads) { TestSampler* sampler = NULL; { v8::Locker locker; - sampler = new TestSampler(); + sampler = new TestSampler(v8::internal::Isolate::Current()); sampler->Start(); CHECK(sampler->IsActive()); } - LoopingJsThread jsThread; + LoopingJsThread jsThread(v8::internal::Isolate::Current()); jsThread.Start(); - LoopingNonJsThread nonJsThread; + LoopingNonJsThread nonJsThread(v8::internal::Isolate::Current()); nonJsThread.Start(); CHECK(!sampler->WasSampleStackCalled()); @@ -515,7 +521,7 @@ TEST(Issue23768) { i_source->set_resource(NULL); // Must not crash. - i::Logger::LogCompiledFunctions(); + LOGGER->LogCompiledFunctions(); } @@ -541,7 +547,7 @@ TEST(LogCallbacks) { initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction()); CompileAndRunScript("Obj.prototype.method1.toString();"); - i::Logger::LogCompiledFunctions(); + LOGGER->LogCompiledFunctions(); CHECK_GT(matcher.GetNextChunk(), 0); const char* callback_rec = "code-creation,Callback,"; @@ -584,7 +590,7 @@ TEST(LogAccessorCallbacks) { inst->SetAccessor(v8::String::New("prop1"), Prop1Getter, Prop1Setter); inst->SetAccessor(v8::String::New("prop2"), Prop2Getter); - i::Logger::LogAccessorCallbacks(); + LOGGER->LogAccessorCallbacks(); CHECK_GT(matcher.GetNextChunk(), 0); matcher.PrintBuffer(); @@ -616,11 +622,11 @@ TEST(LogTags) { const char* close_tag = "close-tag,"; // Check compatibility with the old style behavior. - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 0); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 0); - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 0); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 0); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); CHECK_EQ(NULL, matcher.Find(open_tag)); CHECK_EQ(NULL, matcher.Find(close_tag)); @@ -628,11 +634,11 @@ TEST(LogTags) { const char* close_tag1 = "close-tag,1\n"; // Check non-nested tag case. - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); CHECK_GT(matcher.GetNextChunk(), 0); CHECK(matcher.IsInSequence(open_tag1, close_tag1)); @@ -640,15 +646,15 @@ TEST(LogTags) { const char* close_tag2 = "close-tag,2\n"; // Check nested tags case. - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 2); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 2); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); CHECK_GT(matcher.GetNextChunk(), 0); // open_tag1 < open_tag2 < close_tag2 < close_tag1 CHECK(matcher.IsInSequence(open_tag1, open_tag2)); @@ -656,15 +662,15 @@ TEST(LogTags) { CHECK(matcher.IsInSequence(close_tag2, close_tag1)); // Check overlapped tags case. - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 2); - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 2); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); CHECK_GT(matcher.GetNextChunk(), 0); // open_tag1 < open_tag2 < close_tag1 < close_tag2 CHECK(matcher.IsInSequence(open_tag1, open_tag2)); @@ -675,19 +681,19 @@ TEST(LogTags) { const char* close_tag3 = "close-tag,3\n"; // Check pausing overflow case. - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 2); - CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 3); - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 3); - CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 2); + CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 3); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 3); + CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules()); // Must be no tags, because logging must be disabled. CHECK_EQ(NULL, matcher.Find(open_tag3)); CHECK_EQ(NULL, matcher.Find(close_tag3)); @@ -697,29 +703,29 @@ TEST(LogTags) { TEST(IsLoggingPreserved) { ScopedLoggerInitializer initialize_logger(false); - CHECK(Logger::is_logging()); - Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK(Logger::is_logging()); - Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); - CHECK(Logger::is_logging()); + CHECK(LOGGER->is_logging()); + LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK(LOGGER->is_logging()); + LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1); + CHECK(LOGGER->is_logging()); - CHECK(Logger::is_logging()); - Logger::ResumeProfiler( + CHECK(LOGGER->is_logging()); + LOGGER->ResumeProfiler( v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); - CHECK(Logger::is_logging()); - Logger::PauseProfiler( + CHECK(LOGGER->is_logging()); + LOGGER->PauseProfiler( v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); - CHECK(Logger::is_logging()); + CHECK(LOGGER->is_logging()); - CHECK(Logger::is_logging()); - Logger::ResumeProfiler( + CHECK(LOGGER->is_logging()); + LOGGER->ResumeProfiler( v8::PROFILER_MODULE_CPU | v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); - CHECK(Logger::is_logging()); - Logger::PauseProfiler( + CHECK(LOGGER->is_logging()); + LOGGER->PauseProfiler( v8::PROFILER_MODULE_CPU | v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); - CHECK(Logger::is_logging()); + CHECK(LOGGER->is_logging()); } @@ -1128,7 +1134,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { " obj.test =\n" " (function a(j) { return function b() { return j; } })(100);\n" "})(this);"); - i::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); EmbeddedVector<char, 204800> buffer; int log_size; @@ -1148,9 +1154,9 @@ TEST(EquivalenceOfLoggingAndTraversal) { } // Iterate heap to find compiled functions, will write to log. - i::Logger::LogCompiledFunctions(); + LOGGER->LogCompiledFunctions(); char* new_log_start = buffer.start() + log_size; - const int new_log_size = Logger::GetLogLines( + const int new_log_size = LOGGER->GetLogLines( log_size, new_log_start, buffer.length() - log_size); CHECK_GT(new_log_size, 0); CHECK_GT(buffer.length(), log_size + new_log_size); @@ -1184,7 +1190,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { CHECK(results_equal); env->Exit(); - Logger::TearDown(); + LOGGER->TearDown(); i::FLAG_always_compact = saved_always_compact; } diff --git a/test/cctest/test-macro-assembler-x64.cc b/test/cctest/test-macro-assembler-x64.cc index 9b1fc46e..c7c67b05 100755 --- a/test/cctest/test-macro-assembler-x64.cc +++ b/test/cctest/test-macro-assembler-x64.cc @@ -57,9 +57,9 @@ using v8::internal::rsp; using v8::internal::r8; using v8::internal::r9; using v8::internal::r11; -using v8::internal::r12; using v8::internal::r13; using v8::internal::r14; +using v8::internal::r15; using v8::internal::times_pointer_size; using v8::internal::FUNCTION_CAST; using v8::internal::CodeDesc; @@ -95,7 +95,9 @@ typedef int (*F0)(); static void EntryCode(MacroAssembler* masm) { // Smi constant register is callee save. __ push(v8::internal::kSmiConstantRegister); + __ push(v8::internal::kRootRegister); __ InitializeSmiConstantRegister(); + __ InitializeRootRegister(); } @@ -105,6 +107,7 @@ static void ExitCode(MacroAssembler* masm) { __ cmpq(rdx, v8::internal::kSmiConstantRegister); __ movq(rdx, Immediate(-1)); __ cmovq(not_equal, rax, rdx); + __ pop(v8::internal::kRootRegister); __ pop(v8::internal::kSmiConstantRegister); } @@ -146,6 +149,7 @@ static void TestMoveSmi(MacroAssembler* masm, Label* exit, int id, Smi* value) { // Test that we can move a Smi value literally into a register. TEST(SmiMove) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -220,7 +224,7 @@ void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ j(less_equal, exit); } } else { - __ SmiCompare(rcx, rcx); + __ cmpq(rcx, rcx); __ movl(rax, Immediate(id + 11)); __ j(not_equal, exit); __ incq(rax); @@ -232,10 +236,11 @@ void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) { // Test that we can compare smis for equality (and more). TEST(SmiCompare) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = - static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, + static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, &actual_size, true)); CHECK(buffer); @@ -282,6 +287,7 @@ TEST(SmiCompare) { TEST(Integer32ToSmi) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -300,35 +306,35 @@ TEST(Integer32ToSmi) { __ movl(rcx, Immediate(0)); __ Integer32ToSmi(rcx, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); - __ SmiCompare(rcx, rdx); + __ cmpq(rcx, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(2)); // Test number. __ movl(rcx, Immediate(1024)); __ Integer32ToSmi(rcx, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); - __ SmiCompare(rcx, rdx); + __ cmpq(rcx, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(3)); // Test number. __ movl(rcx, Immediate(-1)); __ Integer32ToSmi(rcx, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); - __ SmiCompare(rcx, rdx); + __ cmpq(rcx, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(4)); // Test number. __ movl(rcx, Immediate(Smi::kMaxValue)); __ Integer32ToSmi(rcx, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); - __ SmiCompare(rcx, rdx); + __ cmpq(rcx, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(5)); // Test number. __ movl(rcx, Immediate(Smi::kMinValue)); __ Integer32ToSmi(rcx, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); - __ SmiCompare(rcx, rdx); + __ cmpq(rcx, rdx); __ j(not_equal, &exit); // Different target register. @@ -337,35 +343,35 @@ TEST(Integer32ToSmi) { __ movl(rcx, Immediate(0)); __ Integer32ToSmi(r8, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(0))); - __ SmiCompare(r8, rdx); + __ cmpq(r8, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(7)); // Test number. __ movl(rcx, Immediate(1024)); __ Integer32ToSmi(r8, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(1024))); - __ SmiCompare(r8, rdx); + __ cmpq(r8, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(8)); // Test number. __ movl(rcx, Immediate(-1)); __ Integer32ToSmi(r8, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(-1))); - __ SmiCompare(r8, rdx); + __ cmpq(r8, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(9)); // Test number. __ movl(rcx, Immediate(Smi::kMaxValue)); __ Integer32ToSmi(r8, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMaxValue))); - __ SmiCompare(r8, rdx); + __ cmpq(r8, rdx); __ j(not_equal, &exit); __ movq(rax, Immediate(10)); // Test number. __ movl(rcx, Immediate(Smi::kMinValue)); __ Integer32ToSmi(r8, rcx); __ Set(rdx, reinterpret_cast<intptr_t>(Smi::FromInt(Smi::kMinValue))); - __ SmiCompare(r8, rdx); + __ cmpq(r8, rdx); __ j(not_equal, &exit); @@ -394,21 +400,22 @@ void TestI64PlusConstantToSmi(MacroAssembler* masm, __ movq(rcx, x, RelocInfo::NONE); __ movq(r11, rcx); __ Integer64PlusConstantToSmi(rdx, rcx, y); - __ SmiCompare(rdx, r8); + __ cmpq(rdx, r8); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ Integer64PlusConstantToSmi(rcx, rcx, y); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); } TEST(Integer64PlusConstantToSmi) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -452,6 +459,7 @@ TEST(Integer64PlusConstantToSmi) { TEST(SmiCheck) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -660,14 +668,14 @@ void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) { __ SmiNeg(r9, rcx, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiNeg(rcx, rcx, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); } else { Label smi_ok, smi_ok2; @@ -679,11 +687,11 @@ void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) { __ jmp(exit); __ bind(&smi_ok); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); @@ -691,13 +699,14 @@ void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) { __ jmp(exit); __ bind(&smi_ok2); __ incq(rax); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); } } TEST(SmiNeg) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -751,12 +760,12 @@ static void SmiAddTest(MacroAssembler* masm, __ movl(rax, Immediate(id)); // Test number. __ SmiAdd(r9, rcx, rdx, exit); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); __ SmiAdd(rcx, rcx, rdx, exit); \ - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ movl(rcx, Immediate(first)); @@ -764,11 +773,11 @@ static void SmiAddTest(MacroAssembler* masm, __ incq(rax); __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ movl(rcx, Immediate(first)); @@ -776,16 +785,17 @@ static void SmiAddTest(MacroAssembler* masm, __ incq(rax); __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); } TEST(SmiAdd) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -834,36 +844,36 @@ static void SmiSubTest(MacroAssembler* masm, __ movl(rax, Immediate(id)); // Test 0. __ SmiSub(r9, rcx, rdx, exit); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); // Test 1. __ SmiSub(rcx, rcx, rdx, exit); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ Move(rcx, Smi::FromInt(first)); __ incq(rax); // Test 2. __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); // Test 3. __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ Move(rcx, Smi::FromInt(first)); __ incq(rax); // Test 4. __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); // Test 5. __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); } @@ -886,7 +896,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } @@ -897,7 +907,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } @@ -909,7 +919,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } @@ -920,7 +930,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } @@ -933,7 +943,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } @@ -944,7 +954,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } @@ -956,7 +966,7 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } @@ -967,13 +977,14 @@ static void SmiSubOverflowTest(MacroAssembler* masm, __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); } } TEST(SmiSub) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1032,15 +1043,15 @@ void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ Move(r8, Smi::FromIntptr(result)); __ SmiMul(r9, rcx, rdx, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); __ SmiMul(rcx, rcx, rdx, exit); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); } else { __ movl(rax, Immediate(id + 8)); @@ -1049,7 +1060,7 @@ void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ jmp(exit); __ bind(&overflow_ok); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiMul(rcx, rcx, rdx, &overflow_ok2); @@ -1057,13 +1068,14 @@ void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ bind(&overflow_ok2); // 31-bit version doesn't preserve rcx on failure. // __ incq(rax); - // __ SmiCompare(r11, rcx); + // __ cmpq(r11, rcx); // __ j(not_equal, exit); } } TEST(SmiMul) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, @@ -1120,30 +1132,30 @@ void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) { if (!fraction && !overflow && !negative_zero && !division_by_zero) { // Division succeeds __ movq(rcx, r11); - __ movq(r12, Immediate(id)); + __ movq(r15, Immediate(id)); int result = x / y; __ Move(r8, Smi::FromInt(result)); __ SmiDiv(r9, rcx, r14, exit); // Might have destroyed rcx and r14. - __ incq(r12); - __ SmiCompare(r9, r8); + __ incq(r15); + __ cmpq(r9, r8); __ j(not_equal, exit); - __ incq(r12); + __ incq(r15); __ movq(rcx, r11); __ Move(r14, Smi::FromInt(y)); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); - __ incq(r12); + __ incq(r15); __ SmiDiv(rcx, rcx, r14, exit); - __ incq(r12); - __ SmiCompare(rcx, r8); + __ incq(r15); + __ cmpq(rcx, r8); __ j(not_equal, exit); } else { // Division fails. - __ movq(r12, Immediate(id + 8)); + __ movq(r15, Immediate(id + 8)); Label fail_ok, fail_ok2; __ movq(rcx, r11); @@ -1151,23 +1163,24 @@ void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ jmp(exit); __ bind(&fail_ok); - __ incq(r12); - __ SmiCompare(rcx, r11); + __ incq(r15); + __ cmpq(rcx, r11); __ j(not_equal, exit); - __ incq(r12); + __ incq(r15); __ SmiDiv(rcx, rcx, r14, &fail_ok2); __ jmp(exit); __ bind(&fail_ok2); - __ incq(r12); - __ SmiCompare(rcx, r11); + __ incq(r15); + __ cmpq(rcx, r11); __ j(not_equal, exit); } } TEST(SmiDiv) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1184,7 +1197,7 @@ TEST(SmiDiv) { Label exit; __ push(r14); - __ push(r12); + __ push(r15); TestSmiDiv(masm, &exit, 0x10, 1, 1); TestSmiDiv(masm, &exit, 0x20, 1, 0); TestSmiDiv(masm, &exit, 0x30, -1, 0); @@ -1206,10 +1219,10 @@ TEST(SmiDiv) { TestSmiDiv(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue); TestSmiDiv(masm, &exit, 0x140, Smi::kMinValue, -1); - __ xor_(r12, r12); // Success. + __ xor_(r15, r15); // Success. __ bind(&exit); - __ movq(rax, r12); - __ pop(r12); + __ movq(rax, r15); + __ pop(r15); __ pop(r14); ExitCode(masm); __ ret(0); @@ -1232,51 +1245,52 @@ void TestSmiMod(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ Move(r14, Smi::FromInt(y)); if (!division_overflow && !negative_zero && !division_by_zero) { // Modulo succeeds - __ movq(r12, Immediate(id)); + __ movq(r15, Immediate(id)); int result = x % y; __ Move(r8, Smi::FromInt(result)); __ SmiMod(r9, rcx, r14, exit); - __ incq(r12); - __ SmiCompare(r9, r8); + __ incq(r15); + __ cmpq(r9, r8); __ j(not_equal, exit); - __ incq(r12); - __ SmiCompare(rcx, r11); + __ incq(r15); + __ cmpq(rcx, r11); __ j(not_equal, exit); - __ incq(r12); + __ incq(r15); __ SmiMod(rcx, rcx, r14, exit); - __ incq(r12); - __ SmiCompare(rcx, r8); + __ incq(r15); + __ cmpq(rcx, r8); __ j(not_equal, exit); } else { // Modulo fails. - __ movq(r12, Immediate(id + 8)); + __ movq(r15, Immediate(id + 8)); Label fail_ok, fail_ok2; __ SmiMod(r9, rcx, r14, &fail_ok); __ jmp(exit); __ bind(&fail_ok); - __ incq(r12); - __ SmiCompare(rcx, r11); + __ incq(r15); + __ cmpq(rcx, r11); __ j(not_equal, exit); - __ incq(r12); + __ incq(r15); __ SmiMod(rcx, rcx, r14, &fail_ok2); __ jmp(exit); __ bind(&fail_ok2); - __ incq(r12); - __ SmiCompare(rcx, r11); + __ incq(r15); + __ cmpq(rcx, r11); __ j(not_equal, exit); } } TEST(SmiMod) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1293,7 +1307,7 @@ TEST(SmiMod) { Label exit; __ push(r14); - __ push(r12); + __ push(r15); TestSmiMod(masm, &exit, 0x10, 1, 1); TestSmiMod(masm, &exit, 0x20, 1, 0); TestSmiMod(masm, &exit, 0x30, -1, 0); @@ -1315,10 +1329,10 @@ TEST(SmiMod) { TestSmiMod(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue); TestSmiMod(masm, &exit, 0x140, Smi::kMinValue, -1); - __ xor_(r12, r12); // Success. + __ xor_(r15, r15); // Success. __ bind(&exit); - __ movq(rax, r12); - __ pop(r12); + __ movq(rax, r15); + __ pop(r15); __ pop(r14); ExitCode(masm); __ ret(0); @@ -1340,7 +1354,7 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); __ shl(index.reg, Immediate(index.scale)); __ Set(r8, static_cast<intptr_t>(x) << i); - __ SmiCompare(index.reg, r8); + __ cmpq(index.reg, r8); __ j(not_equal, exit); __ incq(rax); __ Move(rcx, Smi::FromInt(x)); @@ -1348,7 +1362,7 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { ASSERT(index.reg.is(rcx)); __ shl(rcx, Immediate(index.scale)); __ Set(r8, static_cast<intptr_t>(x) << i); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ incq(rax); @@ -1357,7 +1371,7 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); __ shl(index.reg, Immediate(index.scale)); __ Set(r8, static_cast<intptr_t>(-x) << i); - __ SmiCompare(index.reg, r8); + __ cmpq(index.reg, r8); __ j(not_equal, exit); __ incq(rax); __ Move(rcx, Smi::FromInt(x)); @@ -1365,13 +1379,14 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { ASSERT(index.reg.is(rcx)); __ shl(rcx, Immediate(index.scale)); __ Set(r8, static_cast<intptr_t>(-x) << i); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ incq(rax); } } TEST(SmiIndex) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1414,7 +1429,7 @@ void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ SelectNonSmi(r9, rcx, rdx, exit); __ incq(rax); - __ SmiCompare(r9, rdx); + __ cmpq(r9, rdx); __ j(not_equal, exit); __ incq(rax); @@ -1424,7 +1439,7 @@ void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ SelectNonSmi(r9, rcx, rdx, exit); __ incq(rax); - __ SmiCompare(r9, rcx); + __ cmpq(r9, rcx); __ j(not_equal, exit); __ incq(rax); @@ -1440,6 +1455,7 @@ void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiSelectNonSmi) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1488,36 +1504,37 @@ void TestSmiAnd(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ Move(rdx, Smi::FromInt(y)); __ Move(r8, Smi::FromInt(result)); __ SmiAnd(r9, rcx, rdx); - __ SmiCompare(r8, r9); + __ cmpq(r8, r9); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiAnd(rcx, rcx, rdx); - __ SmiCompare(r8, rcx); + __ cmpq(r8, rcx); __ j(not_equal, exit); __ movq(rcx, r11); __ incq(rax); __ SmiAndConstant(r9, rcx, Smi::FromInt(y)); - __ SmiCompare(r8, r9); + __ cmpq(r8, r9); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); - __ SmiCompare(r8, rcx); + __ cmpq(r8, rcx); __ j(not_equal, exit); } TEST(SmiAnd) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1568,36 +1585,37 @@ void TestSmiOr(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ Move(rdx, Smi::FromInt(y)); __ Move(r8, Smi::FromInt(result)); __ SmiOr(r9, rcx, rdx); - __ SmiCompare(r8, r9); + __ cmpq(r8, r9); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiOr(rcx, rcx, rdx); - __ SmiCompare(r8, rcx); + __ cmpq(r8, rcx); __ j(not_equal, exit); __ movq(rcx, r11); __ incq(rax); __ SmiOrConstant(r9, rcx, Smi::FromInt(y)); - __ SmiCompare(r8, r9); + __ cmpq(r8, r9); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); - __ SmiCompare(r8, rcx); + __ cmpq(r8, rcx); __ j(not_equal, exit); } TEST(SmiOr) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1650,36 +1668,37 @@ void TestSmiXor(MacroAssembler* masm, Label* exit, int id, int x, int y) { __ Move(rdx, Smi::FromInt(y)); __ Move(r8, Smi::FromInt(result)); __ SmiXor(r9, rcx, rdx); - __ SmiCompare(r8, r9); + __ cmpq(r8, r9); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiXor(rcx, rcx, rdx); - __ SmiCompare(r8, rcx); + __ cmpq(r8, rcx); __ j(not_equal, exit); __ movq(rcx, r11); __ incq(rax); __ SmiXorConstant(r9, rcx, Smi::FromInt(y)); - __ SmiCompare(r8, r9); + __ cmpq(r8, r9); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); - __ SmiCompare(r8, rcx); + __ cmpq(r8, rcx); __ j(not_equal, exit); } TEST(SmiXor) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1731,21 +1750,22 @@ void TestSmiNot(MacroAssembler* masm, Label* exit, int id, int x) { __ movq(r11, rcx); __ SmiNot(r9, rcx); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); + __ cmpq(r11, rcx); __ j(not_equal, exit); __ incq(rax); __ SmiNot(rcx, rcx); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); } TEST(SmiNot) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1797,7 +1817,7 @@ void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { __ SmiShiftLeftConstant(r9, rcx, shift); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); @@ -1805,7 +1825,7 @@ void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { __ SmiShiftLeftConstant(rcx, rcx, shift); __ incq(rax); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ incq(rax); @@ -1814,7 +1834,7 @@ void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { __ SmiShiftLeft(r9, rdx, rcx); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); @@ -1823,7 +1843,7 @@ void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { __ SmiShiftLeft(r9, rdx, r11); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); @@ -1832,7 +1852,7 @@ void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { __ SmiShiftLeft(rdx, rdx, r11); __ incq(rax); - __ SmiCompare(rdx, r8); + __ cmpq(rdx, r8); __ j(not_equal, exit); __ incq(rax); @@ -1841,6 +1861,7 @@ void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { TEST(SmiShiftLeft) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1893,7 +1914,7 @@ void TestSmiShiftLogicalRight(MacroAssembler* masm, __ SmiShiftLogicalRightConstant(r9, rcx, shift, exit); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); @@ -1902,7 +1923,7 @@ void TestSmiShiftLogicalRight(MacroAssembler* masm, __ SmiShiftLogicalRight(r9, rdx, rcx, exit); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); @@ -1911,7 +1932,7 @@ void TestSmiShiftLogicalRight(MacroAssembler* masm, __ SmiShiftLogicalRight(r9, rdx, r11, exit); __ incq(rax); - __ SmiCompare(r9, r8); + __ cmpq(r9, r8); __ j(not_equal, exit); __ incq(rax); @@ -1925,7 +1946,7 @@ void TestSmiShiftLogicalRight(MacroAssembler* masm, __ bind(&fail_ok); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); __ incq(rax); @@ -1936,7 +1957,7 @@ void TestSmiShiftLogicalRight(MacroAssembler* masm, __ bind(&fail_ok3); __ incq(rax); - __ SmiCompare(rcx, r11); + __ cmpq(rcx, r11); __ j(not_equal, exit); __ addq(rax, Immediate(3)); @@ -1946,6 +1967,7 @@ void TestSmiShiftLogicalRight(MacroAssembler* masm, TEST(SmiShiftLogicalRight) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -1997,7 +2019,7 @@ void TestSmiShiftArithmeticRight(MacroAssembler* masm, __ Move(rcx, Smi::FromInt(x)); __ SmiShiftArithmeticRightConstant(rcx, rcx, shift); - __ SmiCompare(rcx, r8); + __ cmpq(rcx, r8); __ j(not_equal, exit); __ incq(rax); @@ -2005,7 +2027,7 @@ void TestSmiShiftArithmeticRight(MacroAssembler* masm, __ Move(r11, Smi::FromInt(shift)); __ SmiShiftArithmeticRight(rdx, rdx, r11); - __ SmiCompare(rdx, r8); + __ cmpq(rdx, r8); __ j(not_equal, exit); __ incq(rax); @@ -2014,6 +2036,7 @@ void TestSmiShiftArithmeticRight(MacroAssembler* masm, TEST(SmiShiftArithmeticRight) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = @@ -2062,14 +2085,14 @@ void TestPositiveSmiPowerUp(MacroAssembler* masm, Label* exit, int id, int x) { __ Move(rcx, Smi::FromInt(x)); __ movq(r11, rcx); __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rcx, power); - __ SmiCompare(rdx, r8); + __ cmpq(rdx, r8); __ j(not_equal, exit); __ incq(rax); - __ SmiCompare(r11, rcx); // rcx unchanged. + __ cmpq(r11, rcx); // rcx unchanged. __ j(not_equal, exit); __ incq(rax); __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); - __ SmiCompare(rdx, r8); + __ cmpq(rdx, r8); __ j(not_equal, exit); __ incq(rax); } @@ -2077,10 +2100,11 @@ void TestPositiveSmiPowerUp(MacroAssembler* masm, Label* exit, int id, int x) { TEST(PositiveSmiTimesPowerOfTwoToInteger64) { + v8::internal::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = - static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, + static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, &actual_size, true)); CHECK(buffer); @@ -2116,6 +2140,7 @@ TEST(PositiveSmiTimesPowerOfTwoToInteger64) { TEST(OperandOffset) { + v8::internal::V8::Initialize(NULL); int data[256]; for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } @@ -2150,7 +2175,7 @@ TEST(OperandOffset) { __ push(Immediate(0x108)); __ push(Immediate(0x109)); // <-- rsp // rbp = rsp[9] - // r12 = rsp[3] + // r15 = rsp[3] // rbx = rsp[5] // r13 = rsp[7] __ lea(r14, Operand(rsp, 3 * kPointerSize)); diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc index 3e3175e7..6d1b5ce6 100644 --- a/test/cctest/test-mark-compact.cc +++ b/test/cctest/test-mark-compact.cc @@ -31,7 +31,6 @@ #include "global-handles.h" #include "snapshot.h" -#include "top.h" #include "cctest.h" using namespace v8::internal; @@ -79,7 +78,7 @@ TEST(Promotion) { // from new space. FLAG_gc_global = true; FLAG_always_compact = true; - Heap::ConfigureHeap(2*256*KB, 4*MB, 4*MB); + HEAP->ConfigureHeap(2*256*KB, 4*MB, 4*MB); InitializeVM(); @@ -87,25 +86,25 @@ TEST(Promotion) { // Allocate a fixed array in the new space. int array_size = - (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / + (HEAP->MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / (kPointerSize * 4); - Object* obj = Heap::AllocateFixedArray(array_size)->ToObjectChecked(); + Object* obj = HEAP->AllocateFixedArray(array_size)->ToObjectChecked(); Handle<FixedArray> array(FixedArray::cast(obj)); // Array should be in the new space. - CHECK(Heap::InSpace(*array, NEW_SPACE)); + CHECK(HEAP->InSpace(*array, NEW_SPACE)); // Call the m-c collector, so array becomes an old object. - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); // Array now sits in the old space - CHECK(Heap::InSpace(*array, OLD_POINTER_SPACE)); + CHECK(HEAP->InSpace(*array, OLD_POINTER_SPACE)); } TEST(NoPromotion) { - Heap::ConfigureHeap(2*256*KB, 4*MB, 4*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 @@ -114,23 +113,23 @@ TEST(NoPromotion) { v8::HandleScope sc; // Do a mark compact GC to shrink the heap. - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); // Allocate a big Fixed array in the new space. - int size = (Heap::MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / + int size = (HEAP->MaxObjectSizeInPagedSpace() - FixedArray::kHeaderSize) / kPointerSize; - Object* obj = Heap::AllocateFixedArray(size)->ToObjectChecked(); + Object* obj = HEAP->AllocateFixedArray(size)->ToObjectChecked(); Handle<FixedArray> array(FixedArray::cast(obj)); // Array still stays in the new space. - CHECK(Heap::InSpace(*array, NEW_SPACE)); + CHECK(HEAP->InSpace(*array, NEW_SPACE)); // Allocate objects in the old space until out of memory. FixedArray* host = *array; while (true) { Object* obj; - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(100, TENURED); + { MaybeObject* maybe_obj = HEAP->AllocateFixedArray(100, TENURED); if (!maybe_obj->ToObject(&obj)) break; } @@ -139,10 +138,10 @@ TEST(NoPromotion) { } // Call mark compact GC, and it should pass. - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); // array should not be promoted because the old space is full. - CHECK(Heap::InSpace(*array, NEW_SPACE)); + CHECK(HEAP->InSpace(*array, NEW_SPACE)); } @@ -151,90 +150,86 @@ TEST(MarkCompactCollector) { v8::HandleScope sc; // call mark-compact when heap is empty - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); // keep allocating garbage in new space until it fails const int ARRAY_SIZE = 100; Object* array; MaybeObject* maybe_array; do { - maybe_array = Heap::AllocateFixedArray(ARRAY_SIZE); + maybe_array = HEAP->AllocateFixedArray(ARRAY_SIZE); } while (maybe_array->ToObject(&array)); - Heap::CollectGarbage(NEW_SPACE); + HEAP->CollectGarbage(NEW_SPACE); - array = Heap::AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked(); + array = HEAP->AllocateFixedArray(ARRAY_SIZE)->ToObjectChecked(); // keep allocating maps until it fails Object* mapp; MaybeObject* maybe_mapp; do { - maybe_mapp = Heap::AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); + maybe_mapp = HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); } while (maybe_mapp->ToObject(&mapp)); - Heap::CollectGarbage(MAP_SPACE); - mapp = Heap::AllocateMap(JS_OBJECT_TYPE, + HEAP->CollectGarbage(MAP_SPACE); + mapp = HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)->ToObjectChecked(); // allocate a garbage String* func_name = - String::cast(Heap::LookupAsciiSymbol("theFunction")->ToObjectChecked()); + String::cast(HEAP->LookupAsciiSymbol("theFunction")->ToObjectChecked()); SharedFunctionInfo* function_share = SharedFunctionInfo::cast( - Heap::AllocateSharedFunctionInfo(func_name)->ToObjectChecked()); + HEAP->AllocateSharedFunctionInfo(func_name)->ToObjectChecked()); JSFunction* function = JSFunction::cast( - Heap::AllocateFunction(*Top::function_map(), + HEAP->AllocateFunction(*Isolate::Current()->function_map(), function_share, - Heap::undefined_value())->ToObjectChecked()); + HEAP->undefined_value())->ToObjectChecked()); Map* initial_map = - Map::cast(Heap::AllocateMap(JS_OBJECT_TYPE, + Map::cast(HEAP->AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize)->ToObjectChecked()); function->set_initial_map(initial_map); - Top::context()->global()->SetProperty(func_name, - function, - NONE, - kNonStrictMode)->ToObjectChecked(); + Isolate::Current()->context()->global()->SetProperty( + func_name, function, NONE, kNonStrictMode)->ToObjectChecked(); - JSObject* obj = - JSObject::cast(Heap::AllocateJSObject(function)->ToObjectChecked()); - Heap::CollectGarbage(OLD_POINTER_SPACE); + JSObject* obj = JSObject::cast( + HEAP->AllocateJSObject(function)->ToObjectChecked()); + HEAP->CollectGarbage(OLD_POINTER_SPACE); func_name = - String::cast(Heap::LookupAsciiSymbol("theFunction")->ToObjectChecked()); - CHECK(Top::context()->global()->HasLocalProperty(func_name)); - Object* func_value = - Top::context()->global()->GetProperty(func_name)->ToObjectChecked(); + String::cast(HEAP->LookupAsciiSymbol("theFunction")->ToObjectChecked()); + CHECK(Isolate::Current()->context()->global()->HasLocalProperty(func_name)); + Object* func_value = Isolate::Current()->context()->global()-> + GetProperty(func_name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); function = JSFunction::cast(func_value); - obj = JSObject::cast(Heap::AllocateJSObject(function)->ToObjectChecked()); + obj = JSObject::cast(HEAP->AllocateJSObject(function)->ToObjectChecked()); String* obj_name = - String::cast(Heap::LookupAsciiSymbol("theObject")->ToObjectChecked()); - Top::context()->global()->SetProperty(obj_name, - obj, - NONE, - kNonStrictMode)->ToObjectChecked(); + String::cast(HEAP->LookupAsciiSymbol("theObject")->ToObjectChecked()); + Isolate::Current()->context()->global()->SetProperty( + obj_name, obj, NONE, kNonStrictMode)->ToObjectChecked(); String* prop_name = - String::cast(Heap::LookupAsciiSymbol("theSlot")->ToObjectChecked()); + String::cast(HEAP->LookupAsciiSymbol("theSlot")->ToObjectChecked()); obj->SetProperty(prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); obj_name = - String::cast(Heap::LookupAsciiSymbol("theObject")->ToObjectChecked()); - CHECK(Top::context()->global()->HasLocalProperty(obj_name)); - CHECK(Top::context()->global()-> - GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); - obj = JSObject::cast( - Top::context()->global()->GetProperty(obj_name)->ToObjectChecked()); + String::cast(HEAP->LookupAsciiSymbol("theObject")->ToObjectChecked()); + CHECK(Isolate::Current()->context()->global()->HasLocalProperty(obj_name)); + CHECK(Isolate::Current()->context()->global()-> + GetProperty(obj_name)->ToObjectChecked()->IsJSObject()); + obj = JSObject::cast(Isolate::Current()->context()->global()-> + GetProperty(obj_name)->ToObjectChecked()); prop_name = - String::cast(Heap::LookupAsciiSymbol("theSlot")->ToObjectChecked()); - CHECK(obj->GetProperty(prop_name)->ToObjectChecked() == Smi::FromInt(23)); + String::cast(HEAP->LookupAsciiSymbol("theSlot")->ToObjectChecked()); + CHECK(obj->GetProperty(prop_name) == Smi::FromInt(23)); } static Handle<Map> CreateMap() { - return Factory::NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); + return FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); } @@ -246,20 +241,20 @@ TEST(MapCompact) { v8::HandleScope sc; // keep allocating maps while pointers are still encodable and thus // mark compact is permitted. - Handle<JSObject> root = Factory::NewJSObjectFromMap(CreateMap()); + Handle<JSObject> root = FACTORY->NewJSObjectFromMap(CreateMap()); do { Handle<Map> map = CreateMap(); map->set_prototype(*root); - root = Factory::NewJSObjectFromMap(map); - } while (Heap::map_space()->MapPointersEncodable()); + root = FACTORY->NewJSObjectFromMap(map); + } while (HEAP->map_space()->MapPointersEncodable()); } // Now, as we don't have any handles to just allocated maps, we should // 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(true); + HEAP->CollectAllGarbage(true); // And now map pointers should be encodable again. - CHECK(Heap::map_space()->MapPointersEncodable()); + CHECK(HEAP->map_space()->MapPointersEncodable()); } @@ -281,16 +276,16 @@ static void GCEpilogueCallbackFunc() { TEST(GCCallback) { InitializeVM(); - Heap::SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc); - Heap::SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc); + HEAP->SetGlobalGCPrologueCallback(&GCPrologueCallbackFunc); + HEAP->SetGlobalGCEpilogueCallback(&GCEpilogueCallbackFunc); // Scavenge does not call GC callback functions. - Heap::PerformScavenge(); + HEAP->PerformScavenge(); CHECK_EQ(0, gc_starts); CHECK_EQ(gc_ends, gc_starts); - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); CHECK_EQ(1, gc_starts); CHECK_EQ(gc_ends, gc_starts); } @@ -298,39 +293,51 @@ TEST(GCCallback) { static int NumberOfWeakCalls = 0; static void WeakPointerCallback(v8::Persistent<v8::Value> handle, void* id) { + ASSERT(id == reinterpret_cast<void*>(1234)); NumberOfWeakCalls++; handle.Dispose(); } TEST(ObjectGroups) { + GlobalHandles* global_handles = Isolate::Current()->global_handles(); InitializeVM(); NumberOfWeakCalls = 0; v8::HandleScope handle_scope; Handle<Object> g1s1 = - GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); + global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); Handle<Object> g1s2 = - GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); - GlobalHandles::MakeWeak(g1s1.location(), - reinterpret_cast<void*>(1234), - &WeakPointerCallback); - GlobalHandles::MakeWeak(g1s2.location(), - reinterpret_cast<void*>(1234), - &WeakPointerCallback); + global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); + Handle<Object> g1c1 = + global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); + global_handles->MakeWeak(g1s1.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + global_handles->MakeWeak(g1s2.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + global_handles->MakeWeak(g1c1.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); Handle<Object> g2s1 = - GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); + global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); Handle<Object> g2s2 = - GlobalHandles::Create(Heap::AllocateFixedArray(1)->ToObjectChecked()); - GlobalHandles::MakeWeak(g2s1.location(), - reinterpret_cast<void*>(1234), - &WeakPointerCallback); - GlobalHandles::MakeWeak(g2s2.location(), - reinterpret_cast<void*>(1234), - &WeakPointerCallback); - - Handle<Object> root = GlobalHandles::Create(*g1s1); // make a root. + global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); + Handle<Object> g2c1 = + global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked()); + global_handles->MakeWeak(g2s1.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + global_handles->MakeWeak(g2s2.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + global_handles->MakeWeak(g2c1.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + + Handle<Object> root = global_handles->Create(*g1s1); // make a root. // Connect group 1 and 2, make a cycle. Handle<FixedArray>::cast(g1s2)->set(0, *g2s2); @@ -338,31 +345,58 @@ TEST(ObjectGroups) { { Object** g1_objects[] = { g1s1.location(), g1s2.location() }; + Object** g1_children[] = { g1c1.location() }; Object** g2_objects[] = { g2s1.location(), g2s2.location() }; - GlobalHandles::AddGroup(g1_objects, 2); - GlobalHandles::AddGroup(g2_objects, 2); + Object** g2_children[] = { g2c1.location() }; + global_handles->AddObjectGroup(g1_objects, 2, NULL); + global_handles->AddImplicitReferences(HeapObject::cast(*g1s1), + g1_children, 1); + global_handles->AddObjectGroup(g2_objects, 2, NULL); + global_handles->AddImplicitReferences(HeapObject::cast(*g2s2), + g2_children, 1); } // Do a full GC - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); // All object should be alive. CHECK_EQ(0, NumberOfWeakCalls); // Weaken the root. - GlobalHandles::MakeWeak(root.location(), - reinterpret_cast<void*>(1234), - &WeakPointerCallback); + global_handles->MakeWeak(root.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + // But make children strong roots---all the objects (except for children) + // should be collectable now. + global_handles->ClearWeakness(g1c1.location()); + global_handles->ClearWeakness(g2c1.location()); // Groups are deleted, rebuild groups. { Object** g1_objects[] = { g1s1.location(), g1s2.location() }; + Object** g1_children[] = { g1c1.location() }; Object** g2_objects[] = { g2s1.location(), g2s2.location() }; - GlobalHandles::AddGroup(g1_objects, 2); - GlobalHandles::AddGroup(g2_objects, 2); + Object** g2_children[] = { g2c1.location() }; + global_handles->AddObjectGroup(g1_objects, 2, NULL); + global_handles->AddImplicitReferences(HeapObject::cast(*g1s1), + g1_children, 1); + global_handles->AddObjectGroup(g2_objects, 2, NULL); + global_handles->AddImplicitReferences(HeapObject::cast(*g2s2), + g2_children, 1); } - Heap::CollectGarbage(OLD_POINTER_SPACE); + HEAP->CollectGarbage(OLD_POINTER_SPACE); // All objects should be gone. 5 global handles in total. CHECK_EQ(5, NumberOfWeakCalls); + + // And now make children weak again and collect them. + global_handles->MakeWeak(g1c1.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + global_handles->MakeWeak(g2c1.location(), + reinterpret_cast<void*>(1234), + &WeakPointerCallback); + + HEAP->CollectGarbage(OLD_POINTER_SPACE); + CHECK_EQ(7, NumberOfWeakCalls); } diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index 8ee40385..98a5870a 100755 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -31,6 +31,7 @@ #include "v8.h" +#include "isolate.h" #include "token.h" #include "scanner.h" #include "parser.h" @@ -153,7 +154,7 @@ TEST(ScanHTMLEndComments) { // Parser/Scanner needs a stack limit. int marker; - i::StackGuard::SetStackLimit( + i::Isolate::Current()->stack_guard()->SetStackLimit( reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); for (int i = 0; tests[i]; i++) { @@ -184,7 +185,7 @@ TEST(Preparsing) { v8::Persistent<v8::Context> context = v8::Context::New(); v8::Context::Scope context_scope(context); int marker; - i::StackGuard::SetStackLimit( + i::Isolate::Current()->stack_guard()->SetStackLimit( reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); // Source containing functions that might be lazily compiled and all types @@ -245,7 +246,7 @@ TEST(Preparsing) { TEST(StandAlonePreParser) { int marker; - i::StackGuard::SetStackLimit( + i::Isolate::Current()->stack_guard()->SetStackLimit( reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); const char* programs[] = { @@ -257,14 +258,14 @@ TEST(StandAlonePreParser) { NULL }; - uintptr_t stack_limit = i::StackGuard::real_climit(); + uintptr_t stack_limit = ISOLATE->stack_guard()->real_climit(); for (int i = 0; programs[i]; i++) { const char* program = programs[i]; i::Utf8ToUC16CharacterStream stream( reinterpret_cast<const i::byte*>(program), static_cast<unsigned>(strlen(program))); i::CompleteParserRecorder log; - i::V8JavaScriptScanner scanner; + i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); scanner.Initialize(&stream); v8::preparser::PreParser::PreParseResult result = @@ -281,7 +282,7 @@ TEST(StandAlonePreParser) { TEST(RegressChromium62639) { int marker; - i::StackGuard::SetStackLimit( + ISOLATE->stack_guard()->SetStackLimit( reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); const char* program = "var x = 'something';\n" @@ -306,7 +307,7 @@ TEST(Regress928) { // the block could be lazily compiled, and an extra, unexpected, // entry was added to the data. int marker; - i::StackGuard::SetStackLimit( + ISOLATE->stack_guard()->SetStackLimit( reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); const char* program = @@ -342,7 +343,7 @@ TEST(Regress928) { TEST(PreParseOverflow) { int marker; - i::StackGuard::SetStackLimit( + ISOLATE->stack_guard()->SetStackLimit( reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); size_t kProgramSize = 1024 * 1024; @@ -351,13 +352,13 @@ TEST(PreParseOverflow) { memset(*program, '(', kProgramSize); program[kProgramSize] = '\0'; - uintptr_t stack_limit = i::StackGuard::real_climit(); + uintptr_t stack_limit = ISOLATE->stack_guard()->real_climit(); i::Utf8ToUC16CharacterStream stream( reinterpret_cast<const i::byte*>(*program), static_cast<unsigned>(kProgramSize)); i::CompleteParserRecorder log; - i::V8JavaScriptScanner scanner; + i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); scanner.Initialize(&stream); @@ -405,10 +406,10 @@ void TestCharacterStream(const char* ascii_source, } i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length)); i::Handle<i::String> ascii_string( - i::Factory::NewStringFromAscii(ascii_vector)); + FACTORY->NewStringFromAscii(ascii_vector)); TestExternalResource resource(*uc16_buffer, length); i::Handle<i::String> uc16_string( - i::Factory::NewExternalStringFromTwoByte(&resource)); + FACTORY->NewExternalStringFromTwoByte(&resource)); i::ExternalTwoByteStringUC16CharacterStream uc16_stream( i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end); @@ -575,7 +576,7 @@ void TestStreamScanner(i::UC16CharacterStream* stream, i::Token::Value* expected_tokens, int skip_pos = 0, // Zero means not skipping. int skip_to = 0) { - i::V8JavaScriptScanner scanner; + i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); scanner.Initialize(stream); int i = 0; @@ -654,7 +655,7 @@ void TestScanRegExp(const char* re_source, const char* expected) { i::Utf8ToUC16CharacterStream stream( reinterpret_cast<const i::byte*>(re_source), static_cast<unsigned>(strlen(re_source))); - i::V8JavaScriptScanner scanner; + i::V8JavaScriptScanner scanner(ISOLATE->scanner_constants()); scanner.Initialize(&stream); i::Token::Value start = scanner.peek(); diff --git a/test/cctest/test-platform-linux.cc b/test/cctest/test-platform-linux.cc index e1a00e10..756b9473 100644 --- a/test/cctest/test-platform-linux.cc +++ b/test/cctest/test-platform-linux.cc @@ -67,6 +67,7 @@ TEST(BusyLock) { TEST(VirtualMemory) { + OS::Setup(); VirtualMemory* vm = new VirtualMemory(1 * MB); CHECK(vm->IsReserved()); void* block_addr = vm->address(); diff --git a/test/cctest/test-platform-tls.cc b/test/cctest/test-platform-tls.cc new file mode 100644 index 00000000..b2cb101f --- /dev/null +++ b/test/cctest/test-platform-tls.cc @@ -0,0 +1,66 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// +// Tests of fast TLS support. + +#include "v8.h" + +#include "cctest.h" +#include "checks.h" +#include "platform.h" + +using v8::internal::Thread; + +static const int kValueCount = 128; + +static Thread::LocalStorageKey keys[kValueCount]; + +static void* GetValue(int num) { + return reinterpret_cast<void*>(static_cast<intptr_t>(num + 1)); +} + +static void DoTest() { + for (int i = 0; i < kValueCount; i++) { + CHECK(!Thread::HasThreadLocal(keys[i])); + } + for (int i = 0; i < kValueCount; i++) { + Thread::SetThreadLocal(keys[i], GetValue(i)); + } + for (int i = 0; i < kValueCount; i++) { + CHECK(Thread::HasThreadLocal(keys[i])); + } + for (int i = 0; i < kValueCount; i++) { + CHECK_EQ(GetValue(i), Thread::GetThreadLocal(keys[i])); + CHECK_EQ(GetValue(i), Thread::GetExistingThreadLocal(keys[i])); + } + for (int i = 0; i < kValueCount; i++) { + Thread::SetThreadLocal(keys[i], GetValue(kValueCount - i - 1)); + } + for (int i = 0; i < kValueCount; i++) { + CHECK(Thread::HasThreadLocal(keys[i])); + } + for (int i = 0; i < kValueCount; i++) { + CHECK_EQ(GetValue(kValueCount - i - 1), + Thread::GetThreadLocal(keys[i])); + CHECK_EQ(GetValue(kValueCount - i - 1), + Thread::GetExistingThreadLocal(keys[i])); + } +} + +class TestThread : public Thread { + public: + TestThread() : Thread(NULL, "TestThread") {} + + virtual void Run() { + DoTest(); + } +}; + +TEST(FastTLS) { + for (int i = 0; i < kValueCount; i++) { + keys[i] = Thread::CreateThreadLocalKey(); + } + DoTest(); + TestThread thread; + thread.Start(); + thread.Join(); +} diff --git a/test/cctest/test-platform-win32.cc b/test/cctest/test-platform-win32.cc index a5a6dd58..9bd0014c 100644 --- a/test/cctest/test-platform-win32.cc +++ b/test/cctest/test-platform-win32.cc @@ -13,6 +13,7 @@ using namespace ::v8::internal; TEST(VirtualMemory) { + OS::Setup(); VirtualMemory* vm = new VirtualMemory(1 * MB); CHECK(vm->IsReserved()); void* block_addr = vm->address(); diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index c60d0720..fbe5834e 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -56,7 +56,7 @@ TEST(TokenEnumerator) { CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); } CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); - i::Heap::CollectAllGarbage(false); + 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/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc index 51fef714..e7026d42 100644 --- a/test/cctest/test-regexp.cc +++ b/test/cctest/test-regexp.cc @@ -45,6 +45,10 @@ #include "arm/macro-assembler-arm.h" #include "arm/regexp-macro-assembler-arm.h" #endif +#ifdef V8_TARGET_ARCH_MIPS +#include "mips/macro-assembler-mips.h" +#include "mips/regexp-macro-assembler-mips.h" +#endif #ifdef V8_TARGET_ARCH_X64 #include "x64/macro-assembler-x64.h" #include "x64/regexp-macro-assembler-x64.h" @@ -62,7 +66,7 @@ static bool CheckParse(const char* input) { V8::Initialize(NULL); v8::HandleScope scope; ZoneScope zone_scope(DELETE_ON_EXIT); - FlatStringReader reader(CStrVector(input)); + FlatStringReader reader(Isolate::Current(), CStrVector(input)); RegExpCompileData result; return v8::internal::RegExpParser::ParseRegExp(&reader, false, &result); } @@ -72,7 +76,7 @@ static SmartPointer<const char> Parse(const char* input) { V8::Initialize(NULL); v8::HandleScope scope; ZoneScope zone_scope(DELETE_ON_EXIT); - FlatStringReader reader(CStrVector(input)); + FlatStringReader reader(Isolate::Current(), CStrVector(input)); RegExpCompileData result; CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); CHECK(result.tree != NULL); @@ -86,7 +90,7 @@ static bool CheckSimple(const char* input) { v8::HandleScope scope; unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); ZoneScope zone_scope(DELETE_ON_EXIT); - FlatStringReader reader(CStrVector(input)); + FlatStringReader reader(Isolate::Current(), CStrVector(input)); RegExpCompileData result; CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); CHECK(result.tree != NULL); @@ -104,7 +108,7 @@ static MinMaxPair CheckMinMaxMatch(const char* input) { v8::HandleScope scope; unibrow::Utf8InputBuffer<> buffer(input, StrLength(input)); ZoneScope zone_scope(DELETE_ON_EXIT); - FlatStringReader reader(CStrVector(input)); + FlatStringReader reader(Isolate::Current(), CStrVector(input)); RegExpCompileData result; CHECK(v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); CHECK(result.tree != NULL); @@ -375,7 +379,7 @@ static void ExpectError(const char* input, V8::Initialize(NULL); v8::HandleScope scope; ZoneScope zone_scope(DELETE_ON_EXIT); - FlatStringReader reader(CStrVector(input)); + FlatStringReader reader(Isolate::Current(), CStrVector(input)); RegExpCompileData result; CHECK(!v8::internal::RegExpParser::ParseRegExp(&reader, false, &result)); CHECK(result.tree == NULL); @@ -471,6 +475,7 @@ static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { TEST(CharacterClassEscapes) { + v8::internal::V8::Initialize(NULL); TestCharacterClassEscapes('.', IsRegExpNewline); TestCharacterClassEscapes('d', IsDigit); TestCharacterClassEscapes('D', NotDigit); @@ -483,12 +488,12 @@ TEST(CharacterClassEscapes) { static RegExpNode* Compile(const char* input, bool multiline, bool is_ascii) { V8::Initialize(NULL); - FlatStringReader reader(CStrVector(input)); + FlatStringReader reader(Isolate::Current(), CStrVector(input)); RegExpCompileData compile_data; if (!v8::internal::RegExpParser::ParseRegExp(&reader, multiline, &compile_data)) return NULL; - Handle<String> pattern = Factory::NewStringFromUtf8(CStrVector(input)); + Handle<String> pattern = FACTORY->NewStringFromUtf8(CStrVector(input)); RegExpEngine::Compile(&compile_data, false, multiline, pattern, is_ascii); return compile_data.node; } @@ -538,6 +543,7 @@ static unsigned PseudoRandom(int i, int j) { TEST(SplayTreeSimple) { + v8::internal::V8::Initialize(NULL); static const unsigned kLimit = 1000; ZoneScope zone_scope(DELETE_ON_EXIT); ZoneSplayTree<TestConfig> tree; @@ -590,6 +596,7 @@ TEST(SplayTreeSimple) { TEST(DispatchTableConstruction) { + v8::internal::V8::Initialize(NULL); // Initialize test data. static const int kLimit = 1000; static const int kRangeCount = 8; @@ -667,13 +674,13 @@ typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; #elif V8_TARGET_ARCH_ARM typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; #elif V8_TARGET_ARCH_MIPS -typedef RegExpMacroAssembler ArchRegExpMacroAssembler; +typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; #endif class ContextInitializer { public: ContextInitializer() - : env_(), scope_(), zone_(DELETE_ON_EXIT), stack_guard_() { + : env_(), scope_(), zone_(DELETE_ON_EXIT) { env_ = v8::Context::New(); env_->Enter(); } @@ -685,7 +692,6 @@ class ContextInitializer { v8::Persistent<v8::Context> env_; v8::HandleScope scope_; v8::internal::ZoneScope zone_; - v8::internal::StackGuard stack_guard_; }; @@ -701,7 +707,8 @@ static ArchRegExpMacroAssembler::Result Execute(Code* code, start_offset, input_start, input_end, - captures); + captures, + Isolate::Current()); } @@ -713,12 +720,12 @@ TEST(MacroAssemblerNativeSuccess) { m.Succeed(); - Handle<String> source = Factory::NewStringFromAscii(CStrVector("")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); int captures[4] = {42, 37, 87, 117}; - Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); + Handle<String> input = FACTORY->NewStringFromAscii(CStrVector("foofoo")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); const byte* start_adr = reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); @@ -757,12 +764,12 @@ TEST(MacroAssemblerNativeSimple) { m.Bind(&fail); m.Fail(); - Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("^foo")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); int captures[4] = {42, 37, 87, 117}; - Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); + Handle<String> input = FACTORY->NewStringFromAscii(CStrVector("foofoo")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -780,7 +787,7 @@ TEST(MacroAssemblerNativeSimple) { CHECK_EQ(-1, captures[2]); CHECK_EQ(-1, captures[3]); - input = Factory::NewStringFromAscii(CStrVector("barbarbar")); + input = FACTORY->NewStringFromAscii(CStrVector("barbarbar")); seq_input = Handle<SeqAsciiString>::cast(input); start_adr = seq_input->GetCharsAddress(); @@ -813,14 +820,14 @@ TEST(MacroAssemblerNativeSimpleUC16) { m.Bind(&fail); m.Fail(); - Handle<String> source = Factory::NewStringFromAscii(CStrVector("^foo")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("^foo")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); int captures[4] = {42, 37, 87, 117}; const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', '\xa0'}; Handle<String> input = - Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); + FACTORY->NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -839,7 +846,7 @@ TEST(MacroAssemblerNativeSimpleUC16) { CHECK_EQ(-1, captures[3]); const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', '\xa0'}; - input = Factory::NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); + input = FACTORY->NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); seq_input = Handle<SeqTwoByteString>::cast(input); start_adr = seq_input->GetCharsAddress(); @@ -871,11 +878,11 @@ TEST(MacroAssemblerNativeBacktrack) { m.Bind(&backtrack); m.Fail(); - Handle<String> source = Factory::NewStringFromAscii(CStrVector("..........")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("..........")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); - Handle<String> input = Factory::NewStringFromAscii(CStrVector("foofoo")); + Handle<String> input = FACTORY->NewStringFromAscii(CStrVector("foofoo")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -912,11 +919,11 @@ TEST(MacroAssemblerNativeBackReferenceASCII) { m.Bind(&missing_match); m.Fail(); - Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("^(..)..\1")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); - Handle<String> input = Factory::NewStringFromAscii(CStrVector("fooofo")); + Handle<String> input = FACTORY->NewStringFromAscii(CStrVector("fooofo")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -958,13 +965,13 @@ TEST(MacroAssemblerNativeBackReferenceUC16) { m.Bind(&missing_match); m.Fail(); - Handle<String> source = Factory::NewStringFromAscii(CStrVector("^(..)..\1")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("^(..)..\1")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); const uc16 input_data[6] = {'f', 0x2028, 'o', 'o', 'f', 0x2028}; Handle<String> input = - Factory::NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); + FACTORY->NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1013,11 +1020,11 @@ TEST(MacroAssemblernativeAtStart) { m.CheckNotCharacter('b', &fail); m.Succeed(); - Handle<String> source = Factory::NewStringFromAscii(CStrVector("(^f|ob)")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("(^f|ob)")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); - Handle<String> input = Factory::NewStringFromAscii(CStrVector("foobar")); + Handle<String> input = FACTORY->NewStringFromAscii(CStrVector("foobar")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1071,12 +1078,12 @@ TEST(MacroAssemblerNativeBackRefNoCase) { m.Succeed(); Handle<String> source = - Factory::NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); + FACTORY->NewStringFromAscii(CStrVector("^(abc)\1\1(?!\1)...(?!\1)")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); Handle<String> input = - Factory::NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); + FACTORY->NewStringFromAscii(CStrVector("aBcAbCABCxYzab")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1169,13 +1176,13 @@ TEST(MacroAssemblerNativeRegisters) { m.Fail(); Handle<String> source = - Factory::NewStringFromAscii(CStrVector("<loop test>")); + FACTORY->NewStringFromAscii(CStrVector("<loop test>")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); // String long enough for test (content doesn't matter). Handle<String> input = - Factory::NewStringFromAscii(CStrVector("foofoofoofoofoo")); + FACTORY->NewStringFromAscii(CStrVector("foofoofoofoofoo")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1210,13 +1217,13 @@ TEST(MacroAssemblerStackOverflow) { m.GoTo(&loop); Handle<String> source = - Factory::NewStringFromAscii(CStrVector("<stack overflow test>")); + FACTORY->NewStringFromAscii(CStrVector("<stack overflow test>")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); // String long enough for test (content doesn't matter). Handle<String> input = - Factory::NewStringFromAscii(CStrVector("dummy")); + FACTORY->NewStringFromAscii(CStrVector("dummy")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1229,8 +1236,8 @@ TEST(MacroAssemblerStackOverflow) { NULL); CHECK_EQ(NativeRegExpMacroAssembler::EXCEPTION, result); - CHECK(Top::has_pending_exception()); - Top::clear_pending_exception(); + CHECK(Isolate::Current()->has_pending_exception()); + Isolate::Current()->clear_pending_exception(); } @@ -1254,13 +1261,13 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { m.Succeed(); Handle<String> source = - Factory::NewStringFromAscii(CStrVector("<huge register space test>")); + FACTORY->NewStringFromAscii(CStrVector("<huge register space test>")); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); // String long enough for test (content doesn't matter). Handle<String> input = - Factory::NewStringFromAscii(CStrVector("sample text")); + FACTORY->NewStringFromAscii(CStrVector("sample text")); Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1277,7 +1284,7 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { CHECK_EQ(0, captures[0]); CHECK_EQ(42, captures[1]); - Top::clear_pending_exception(); + Isolate::Current()->clear_pending_exception(); } #else // V8_INTERPRETED_REGEXP @@ -1322,13 +1329,13 @@ TEST(MacroAssembler) { v8::HandleScope scope; - Handle<String> source = Factory::NewStringFromAscii(CStrVector("^f(o)o")); + Handle<String> source = FACTORY->NewStringFromAscii(CStrVector("^f(o)o")); Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source)); int captures[5]; const uc16 str1[] = {'f', 'o', 'o', 'b', 'a', 'r'}; Handle<String> f1_16 = - Factory::NewStringFromTwoByte(Vector<const uc16>(str1, 6)); + FACTORY->NewStringFromTwoByte(Vector<const uc16>(str1, 6)); CHECK(IrregexpInterpreter::Match(array, f1_16, captures, 0)); CHECK_EQ(0, captures[0]); @@ -1339,7 +1346,7 @@ TEST(MacroAssembler) { const uc16 str2[] = {'b', 'a', 'r', 'f', 'o', 'o'}; Handle<String> f2_16 = - Factory::NewStringFromTwoByte(Vector<const uc16>(str2, 6)); + FACTORY->NewStringFromTwoByte(Vector<const uc16>(str2, 6)); CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0)); CHECK_EQ(42, captures[0]); @@ -1349,6 +1356,7 @@ TEST(MacroAssembler) { TEST(AddInverseToTable) { + v8::internal::V8::Initialize(NULL); static const int kLimit = 1000; static const int kRangeCount = 16; for (int t = 0; t < 10; t++) { @@ -1507,6 +1515,7 @@ static void TestSimpleRangeCaseIndependence(CharacterRange input, TEST(CharacterRangeCaseIndependence) { + v8::internal::V8::Initialize(NULL); TestSimpleRangeCaseIndependence(CharacterRange::Singleton('a'), CharacterRange::Singleton('A')); TestSimpleRangeCaseIndependence(CharacterRange::Singleton('z'), @@ -1548,6 +1557,7 @@ static bool InClass(uc16 c, ZoneList<CharacterRange>* ranges) { TEST(CharClassDifference) { + v8::internal::V8::Initialize(NULL); ZoneScope zone_scope(DELETE_ON_EXIT); ZoneList<CharacterRange>* base = new ZoneList<CharacterRange>(1); base->Add(CharacterRange::Everything()); @@ -1574,6 +1584,7 @@ TEST(CharClassDifference) { TEST(CanonicalizeCharacterSets) { + v8::internal::V8::Initialize(NULL); ZoneScope scope(DELETE_ON_EXIT); ZoneList<CharacterRange>* list = new ZoneList<CharacterRange>(4); CharacterSet set(list); @@ -1644,6 +1655,7 @@ static bool CharacterInSet(ZoneList<CharacterRange>* set, uc16 value) { } TEST(CharacterRangeMerge) { + v8::internal::V8::Initialize(NULL); ZoneScope zone_scope(DELETE_ON_EXIT); ZoneList<CharacterRange> l1(4); ZoneList<CharacterRange> l2(4); diff --git a/test/cctest/test-reloc-info.cc b/test/cctest/test-reloc-info.cc index 2b9beac1..0378fb34 100644 --- a/test/cctest/test-reloc-info.cc +++ b/test/cctest/test-reloc-info.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -42,24 +42,31 @@ static void WriteRinfo(RelocInfoWriter* writer, // Tests that writing both types of positions and then reading either // or both works as expected. TEST(Positions) { - const int instr_size = 10 << 10; - const int reloc_size = 10 << 10; - const int buf_size = instr_size + reloc_size; - SmartPointer<byte> buf(new byte[buf_size]); - byte* pc = *buf; - CodeDesc desc = { *buf, buf_size, instr_size, reloc_size, NULL }; + const int code_size = 10 * KB; + int relocation_info_size = 10 * KB; + const int buffer_size = code_size + relocation_info_size; + SmartPointer<byte> buffer(new byte[buffer_size]); - RelocInfoWriter writer(*buf + buf_size, pc); + byte* pc = *buffer; + byte* buffer_end = *buffer + buffer_size; + + RelocInfoWriter writer(buffer_end, pc); + byte* relocation_info_end = buffer_end - relocation_info_size; for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; WriteRinfo(&writer, pc, mode, pos); + CHECK(writer.pos() - RelocInfoWriter::kMaxSize >= relocation_info_end); } + relocation_info_size = static_cast<int>(buffer_end - writer.pos()); + CodeDesc desc = { *buffer, buffer_size, code_size, + relocation_info_size, NULL }; + // Read only (non-statement) positions. { RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::POSITION)); - pc = *buf; + pc = *buffer; for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; @@ -76,7 +83,7 @@ TEST(Positions) { // Read only statement positions. { RelocIterator it(desc, RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION)); - pc = *buf; + pc = *buffer; for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; @@ -93,7 +100,7 @@ TEST(Positions) { // Read both types of positions. { RelocIterator it(desc, RelocInfo::kPositionMask); - pc = *buf; + pc = *buffer; for (int i = 0, pos = 0; i < 100; i++, pc += i, pos += i) { RelocInfo::Mode mode = (i % 2 == 0) ? RelocInfo::STATEMENT_POSITION : RelocInfo::POSITION; diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 80910c25..730d72a9 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -83,7 +83,7 @@ static int* counter_function(const char* name) { template <class T> static Address AddressOf(T id) { - return ExternalReference(id).address(); + return ExternalReference(id, i::Isolate::Current()).address(); } @@ -99,70 +99,75 @@ static int make_code(TypeCode type, int id) { TEST(ExternalReferenceEncoder) { - StatsTable::SetCounterFunction(counter_function); - Heap::Setup(false); + OS::Setup(); + Isolate* isolate = i::Isolate::Current(); + isolate->stats_table()->SetCounterFunction(counter_function); + HEAP->Setup(false); ExternalReferenceEncoder encoder; - CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode), - Encode(encoder, Builtins::ArrayCode)); + CHECK_EQ(make_code(BUILTIN, Builtins::kArrayCode), + Encode(encoder, Builtins::kArrayCode)); CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), Encode(encoder, Runtime::kAbort)); CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); ExternalReference keyed_load_function_prototype = - ExternalReference(&Counters::keyed_load_function_prototype); + 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(); + 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(); + ExternalReference::address_of_stack_limit(isolate); CHECK_EQ(make_code(UNCLASSIFIED, 4), encoder.Encode(stack_limit_address.address())); ExternalReference real_stack_limit_address = - ExternalReference::address_of_real_stack_limit(); + ExternalReference::address_of_real_stack_limit(isolate); CHECK_EQ(make_code(UNCLASSIFIED, 5), encoder.Encode(real_stack_limit_address.address())); #ifdef ENABLE_DEBUGGER_SUPPORT CHECK_EQ(make_code(UNCLASSIFIED, 15), - encoder.Encode(ExternalReference::debug_break().address())); + encoder.Encode(ExternalReference::debug_break(isolate).address())); #endif // ENABLE_DEBUGGER_SUPPORT CHECK_EQ(make_code(UNCLASSIFIED, 10), - encoder.Encode(ExternalReference::new_space_start().address())); + encoder.Encode( + ExternalReference::new_space_start(isolate).address())); CHECK_EQ(make_code(UNCLASSIFIED, 3), - encoder.Encode(ExternalReference::roots_address().address())); + encoder.Encode(ExternalReference::roots_address(isolate).address())); } TEST(ExternalReferenceDecoder) { - StatsTable::SetCounterFunction(counter_function); - Heap::Setup(false); + OS::Setup(); + Isolate* isolate = i::Isolate::Current(); + isolate->stats_table()->SetCounterFunction(counter_function); + HEAP->Setup(false); ExternalReferenceDecoder decoder; - CHECK_EQ(AddressOf(Builtins::ArrayCode), - decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode))); + CHECK_EQ(AddressOf(Builtins::kArrayCode), + decoder.Decode(make_code(BUILTIN, Builtins::kArrayCode))); CHECK_EQ(AddressOf(Runtime::kAbort), decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort))); CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); ExternalReference keyed_load_function = - ExternalReference(&Counters::keyed_load_function_prototype); + ExternalReference(isolate->counters()->keyed_load_function_prototype()); CHECK_EQ(keyed_load_function.address(), decoder.Decode( make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype))); - CHECK_EQ(ExternalReference::the_hole_value_location().address(), + CHECK_EQ(ExternalReference::the_hole_value_location(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 2))); - CHECK_EQ(ExternalReference::address_of_stack_limit().address(), + CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 4))); - CHECK_EQ(ExternalReference::address_of_real_stack_limit().address(), + 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().address(), + CHECK_EQ(ExternalReference::debug_break(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 15))); #endif // ENABLE_DEBUGGER_SUPPORT - CHECK_EQ(ExternalReference::new_space_start().address(), + CHECK_EQ(ExternalReference::new_space_start(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 10))); } @@ -276,12 +281,12 @@ static void Deserialize() { static void SanityCheck() { v8::HandleScope scope; #ifdef DEBUG - Heap::Verify(); + HEAP->Verify(); #endif - CHECK(Top::global()->IsJSObject()); - CHECK(Top::global_context()->IsContext()); - CHECK(Heap::symbol_table()->IsSymbolTable()); - CHECK(!Factory::LookupAsciiSymbol("Empty")->IsFailure()); + CHECK(Isolate::Current()->global()->IsJSObject()); + CHECK(Isolate::Current()->global_context()->IsContext()); + CHECK(HEAP->symbol_table()->IsSymbolTable()); + CHECK(!FACTORY->LookupAsciiSymbol("Empty")->IsFailure()); } @@ -291,7 +296,6 @@ DEPENDENT_TEST(Deserialize, Serialize) { // serialize a snapshot in a VM that is booted from a snapshot. if (!Snapshot::IsEnabled()) { v8::HandleScope scope; - Deserialize(); v8::Persistent<v8::Context> env = v8::Context::New(); @@ -305,7 +309,6 @@ DEPENDENT_TEST(Deserialize, Serialize) { DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { if (!Snapshot::IsEnabled()) { v8::HandleScope scope; - Deserialize(); v8::Persistent<v8::Context> env = v8::Context::New(); @@ -319,7 +322,6 @@ DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { if (!Snapshot::IsEnabled()) { v8::HandleScope scope; - Deserialize(); v8::Persistent<v8::Context> env = v8::Context::New(); @@ -337,7 +339,6 @@ DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, SerializeTwice) { if (!Snapshot::IsEnabled()) { v8::HandleScope scope; - Deserialize(); v8::Persistent<v8::Context> env = v8::Context::New(); @@ -361,11 +362,11 @@ TEST(PartialSerialization) { // Make sure all builtin scripts are cached. { HandleScope scope; for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { - Bootstrapper::NativesSourceLookup(i); + Isolate::Current()->bootstrapper()->NativesSourceLookup(i); } } - Heap::CollectAllGarbage(true); - Heap::CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); + HEAP->CollectAllGarbage(true); Object* raw_foo; { @@ -425,7 +426,7 @@ static void ReserveSpaceForPartialSnapshot(const char* file_name) { #undef fscanf #endif fclose(fp); - Heap::ReserveSpace(new_size, + HEAP->ReserveSpace(new_size, pointer_size, data_size, code_size, @@ -482,12 +483,12 @@ TEST(ContextSerialization) { // Make sure all builtin scripts are cached. { HandleScope scope; for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { - Bootstrapper::NativesSourceLookup(i); + Isolate::Current()->bootstrapper()->NativesSourceLookup(i); } } // 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(true); + HEAP->CollectAllGarbage(true); int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; Vector<char> startup_name = Vector<char>::New(file_name_length + 1); @@ -561,7 +562,7 @@ TEST(LinearAllocation) { for (int size = 1000; size < 5 * MB; size += size >> 1) { int new_space_size = (size < new_space_max) ? size : new_space_max; - Heap::ReserveSpace( + HEAP->ReserveSpace( new_space_size, size, // Old pointer space. size, // Old data space. @@ -584,7 +585,7 @@ TEST(LinearAllocation) { i + kSmallFixedArraySize <= new_space_size; i += kSmallFixedArraySize) { Object* obj = - Heap::AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked(); + HEAP->AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked(); if (new_last != NULL) { CHECK(reinterpret_cast<char*>(obj) == reinterpret_cast<char*>(new_last) + kSmallFixedArraySize); @@ -596,7 +597,7 @@ TEST(LinearAllocation) { for (int i = 0; i + kSmallFixedArraySize <= size; i += kSmallFixedArraySize) { - Object* obj = Heap::AllocateFixedArray(kSmallFixedArrayLength, + Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength, TENURED)->ToObjectChecked(); int old_page_fullness = i % Page::kPageSize; int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; @@ -614,7 +615,7 @@ TEST(LinearAllocation) { Object* data_last = NULL; for (int i = 0; i + kSmallStringSize <= size; i += kSmallStringSize) { - Object* obj = Heap::AllocateRawAsciiString(kSmallStringLength, + Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength, TENURED)->ToObjectChecked(); int old_page_fullness = i % Page::kPageSize; int page_fullness = (i + kSmallStringSize) % Page::kPageSize; @@ -632,7 +633,7 @@ TEST(LinearAllocation) { Object* map_last = NULL; for (int i = 0; i + kMapSize <= size; i += kMapSize) { - Object* obj = Heap::AllocateMap(JS_OBJECT_TYPE, + Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE, 42 * kPointerSize)->ToObjectChecked(); int old_page_fullness = i % Page::kPageSize; int page_fullness = (i + kMapSize) % Page::kPageSize; @@ -654,7 +655,7 @@ TEST(LinearAllocation) { AlwaysAllocateScope always; int large_object_array_length = (size - FixedArray::kHeaderSize) / kPointerSize; - Object* obj = Heap::AllocateFixedArray(large_object_array_length, + Object* obj = HEAP->AllocateFixedArray(large_object_array_length, TENURED)->ToObjectChecked(); CHECK(!obj->IsFailure()); } diff --git a/test/cctest/test-sockets.cc b/test/cctest/test-sockets.cc index 822a23fa..5246d097 100644 --- a/test/cctest/test-sockets.cc +++ b/test/cctest/test-sockets.cc @@ -10,8 +10,12 @@ using namespace ::v8::internal; class SocketListenerThread : public Thread { public: - explicit SocketListenerThread(int port, int data_size) - : port_(port), data_size_(data_size), server_(NULL), client_(NULL), + explicit SocketListenerThread(Isolate* isolate, int port, int data_size) + : Thread(isolate, "SocketListenerThread"), + port_(port), + data_size_(data_size), + server_(NULL), + client_(NULL), listening_(OS::CreateSemaphore(0)) { data_ = new char[data_size_]; } @@ -88,7 +92,8 @@ static void SendAndReceive(int port, char *data, int len) { OS::SNPrintF(Vector<char>(port_str, kPortBuferLen), "%d", port); // Create a socket listener. - SocketListenerThread* listener = new SocketListenerThread(port, len); + SocketListenerThread* listener = new SocketListenerThread(Isolate::Current(), + port, len); listener->Start(); listener->WaitForListening(); diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc index 706c6bf9..de0c41e2 100644 --- a/test/cctest/test-spaces.cc +++ b/test/cctest/test-spaces.cc @@ -65,6 +65,8 @@ TEST(Page) { Address page_start = RoundUp(start, Page::kPageSize); Page* p = Page::FromAddress(page_start); + // Initialized Page has heap pointer, normally set by memory_allocator. + p->heap_ = HEAP; CHECK(p->address() == page_start); CHECK(p->is_valid()); @@ -90,37 +92,45 @@ TEST(Page) { TEST(MemoryAllocator) { - CHECK(Heap::ConfigureHeapDefault()); - CHECK(MemoryAllocator::Setup(Heap::MaxReserved(), Heap::MaxExecutableSize())); - - OldSpace faked_space(Heap::MaxReserved(), OLD_POINTER_SPACE, NOT_EXECUTABLE); + OS::Setup(); + Isolate* isolate = Isolate::Current(); + CHECK(HEAP->ConfigureHeapDefault()); + CHECK(isolate->memory_allocator()->Setup(HEAP->MaxReserved(), + HEAP->MaxExecutableSize())); + + OldSpace faked_space(HEAP, + HEAP->MaxReserved(), + OLD_POINTER_SPACE, + NOT_EXECUTABLE); 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 = - MemoryAllocator::AllocatePages(requested, &allocated, &faked_space); + isolate->memory_allocator()->AllocatePages( + requested, &allocated, &faked_space); CHECK(first_page->is_valid()); CHECK(allocated == requested || allocated == requested - 1); total_pages += allocated; Page* last_page = first_page; for (Page* p = first_page; p->is_valid(); p = p->next_page()) { - CHECK(MemoryAllocator::IsPageInSpace(p, &faked_space)); + CHECK(isolate->memory_allocator()->IsPageInSpace(p, &faked_space)); last_page = p; } // Again, we should get n or n - 1 pages. Page* others = - MemoryAllocator::AllocatePages(requested, &allocated, &faked_space); + isolate->memory_allocator()->AllocatePages( + requested, &allocated, &faked_space); CHECK(others->is_valid()); CHECK(allocated == requested || allocated == requested - 1); total_pages += allocated; - MemoryAllocator::SetNextPage(last_page, others); + isolate->memory_allocator()->SetNextPage(last_page, others); int page_count = 0; for (Page* p = first_page; p->is_valid(); p = p->next_page()) { - CHECK(MemoryAllocator::IsPageInSpace(p, &faked_space)); + CHECK(isolate->memory_allocator()->IsPageInSpace(p, &faked_space)); page_count++; } CHECK(total_pages == page_count); @@ -131,31 +141,34 @@ TEST(MemoryAllocator) { // 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 = MemoryAllocator::FreePages(second_page); + Page* free_return = isolate->memory_allocator()->FreePages(second_page); CHECK(free_return == second_page); - MemoryAllocator::SetNextPage(first_page, free_return); + isolate->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 = MemoryAllocator::FreePages(first_page); + Page* invalid_page = isolate->memory_allocator()->FreePages(first_page); CHECK(!invalid_page->is_valid()); - MemoryAllocator::TearDown(); + isolate->memory_allocator()->TearDown(); } TEST(NewSpace) { - CHECK(Heap::ConfigureHeapDefault()); - CHECK(MemoryAllocator::Setup(Heap::MaxReserved(), Heap::MaxExecutableSize())); + OS::Setup(); + CHECK(HEAP->ConfigureHeapDefault()); + CHECK(Isolate::Current()->memory_allocator()->Setup( + HEAP->MaxReserved(), HEAP->MaxExecutableSize())); - NewSpace new_space; + NewSpace new_space(HEAP); void* chunk = - MemoryAllocator::ReserveInitialChunk(4 * Heap::ReservedSemiSpaceSize()); + Isolate::Current()->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())); + 2 * HEAP->ReservedSemiSpaceSize()); + CHECK(new_space.Setup(start, 2 * HEAP->ReservedSemiSpaceSize())); CHECK(new_space.HasBeenSetup()); while (new_space.Available() >= Page::kMaxHeapObjectSize) { @@ -165,24 +178,28 @@ TEST(NewSpace) { } new_space.TearDown(); - MemoryAllocator::TearDown(); + Isolate::Current()->memory_allocator()->TearDown(); } TEST(OldSpace) { - CHECK(Heap::ConfigureHeapDefault()); - CHECK(MemoryAllocator::Setup(Heap::MaxReserved(), Heap::MaxExecutableSize())); + OS::Setup(); + CHECK(HEAP->ConfigureHeapDefault()); + CHECK(Isolate::Current()->memory_allocator()->Setup( + HEAP->MaxReserved(), HEAP->MaxExecutableSize())); - OldSpace* s = new OldSpace(Heap::MaxOldGenerationSize(), + OldSpace* s = new OldSpace(HEAP, + HEAP->MaxOldGenerationSize(), OLD_POINTER_SPACE, NOT_EXECUTABLE); CHECK(s != NULL); void* chunk = - MemoryAllocator::ReserveInitialChunk(4 * Heap::ReservedSemiSpaceSize()); + Isolate::Current()->memory_allocator()->ReserveInitialChunk( + 4 * HEAP->ReservedSemiSpaceSize()); CHECK(chunk != NULL); Address start = static_cast<Address>(chunk); - size_t size = RoundUp(start, 2 * Heap::ReservedSemiSpaceSize()) - start; + size_t size = RoundUp(start, 2 * HEAP->ReservedSemiSpaceSize()) - start; CHECK(s->Setup(start, size)); @@ -192,14 +209,15 @@ TEST(OldSpace) { s->TearDown(); delete s; - MemoryAllocator::TearDown(); + Isolate::Current()->memory_allocator()->TearDown(); } TEST(LargeObjectSpace) { - CHECK(Heap::Setup(false)); + OS::Setup(); + CHECK(HEAP->Setup(false)); - LargeObjectSpace* lo = Heap::lo_space(); + LargeObjectSpace* lo = HEAP->lo_space(); CHECK(lo != NULL); Map* faked_map = reinterpret_cast<Map*>(HeapObject::FromAddress(0)); @@ -233,5 +251,5 @@ TEST(LargeObjectSpace) { lo->TearDown(); delete lo; - MemoryAllocator::TearDown(); + Isolate::Current()->memory_allocator()->TearDown(); } diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc index 3f02b32b..9c76d2c9 100644 --- a/test/cctest/test-strings.cc +++ b/test/cctest/test-strings.cc @@ -94,7 +94,7 @@ static void InitializeBuildingBlocks( buf[j] = gen() % 65536; } building_blocks[i] = - Factory::NewStringFromTwoByte(Vector<const uc16>(buf, len)); + FACTORY->NewStringFromTwoByte(Vector<const uc16>(buf, len)); for (int j = 0; j < len; j++) { CHECK_EQ(buf[j], building_blocks[i]->Get(j)); } @@ -106,19 +106,19 @@ static void InitializeBuildingBlocks( buf[j] = gen() % 128; } building_blocks[i] = - Factory::NewStringFromAscii(Vector<const char>(buf, len)); + FACTORY->NewStringFromAscii(Vector<const char>(buf, len)); for (int j = 0; j < len; j++) { CHECK_EQ(buf[j], building_blocks[i]->Get(j)); } break; } case 2: { - uc16* buf = Zone::NewArray<uc16>(len); + uc16* buf = ZONE->NewArray<uc16>(len); for (int j = 0; j < len; j++) { buf[j] = gen() % 65536; } Resource* resource = new Resource(Vector<const uc16>(buf, len)); - building_blocks[i] = Factory::NewExternalStringFromTwoByte(resource); + building_blocks[i] = FACTORY->NewExternalStringFromTwoByte(resource); for (int j = 0; j < len; j++) { CHECK_EQ(buf[j], building_blocks[i]->Get(j)); } @@ -130,7 +130,7 @@ static void InitializeBuildingBlocks( buf[j] = gen() % 128; } building_blocks[i] = - Factory::NewStringFromAscii(Vector<const char>(buf, len)); + FACTORY->NewStringFromAscii(Vector<const char>(buf, len)); for (int j = 0; j < len; j++) { CHECK_EQ(buf[j], building_blocks[i]->Get(j)); } @@ -145,9 +145,9 @@ static void InitializeBuildingBlocks( static Handle<String> ConstructLeft( Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS], int depth) { - Handle<String> answer = Factory::NewStringFromAscii(CStrVector("")); + Handle<String> answer = FACTORY->NewStringFromAscii(CStrVector("")); for (int i = 0; i < depth; i++) { - answer = Factory::NewConsString( + answer = FACTORY->NewConsString( answer, building_blocks[i % NUMBER_OF_BUILDING_BLOCKS]); } @@ -158,9 +158,9 @@ static Handle<String> ConstructLeft( static Handle<String> ConstructRight( Handle<String> building_blocks[NUMBER_OF_BUILDING_BLOCKS], int depth) { - Handle<String> answer = Factory::NewStringFromAscii(CStrVector("")); + Handle<String> answer = FACTORY->NewStringFromAscii(CStrVector("")); for (int i = depth - 1; i >= 0; i--) { - answer = Factory::NewConsString( + answer = FACTORY->NewConsString( building_blocks[i % NUMBER_OF_BUILDING_BLOCKS], answer); } @@ -177,7 +177,7 @@ static Handle<String> ConstructBalancedHelper( return building_blocks[from % NUMBER_OF_BUILDING_BLOCKS]; } if (to - from == 2) { - return Factory::NewConsString( + return FACTORY->NewConsString( building_blocks[from % NUMBER_OF_BUILDING_BLOCKS], building_blocks[(from+1) % NUMBER_OF_BUILDING_BLOCKS]); } @@ -185,7 +185,7 @@ static Handle<String> ConstructBalancedHelper( ConstructBalancedHelper(building_blocks, from, from + ((to - from) / 2)); Handle<String> part2 = ConstructBalancedHelper(building_blocks, from + ((to - from) / 2), to); - return Factory::NewConsString(part1, part2); + return FACTORY->NewConsString(part1, part2); } @@ -286,12 +286,12 @@ TEST(DeepAscii) { foo[i] = "foo "[i % 4]; } Handle<String> string = - Factory::NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH)); - Handle<String> foo_string = Factory::NewStringFromAscii(CStrVector("foo")); + FACTORY->NewStringFromAscii(Vector<const char>(foo, DEEP_ASCII_DEPTH)); + Handle<String> foo_string = FACTORY->NewStringFromAscii(CStrVector("foo")); for (int i = 0; i < DEEP_ASCII_DEPTH; i += 10) { - string = Factory::NewConsString(string, foo_string); + string = FACTORY->NewConsString(string, foo_string); } - Handle<String> flat_string = Factory::NewConsString(string, foo_string); + Handle<String> flat_string = FACTORY->NewConsString(string, foo_string); FlattenString(flat_string); for (int i = 0; i < 500; i++) { @@ -365,7 +365,7 @@ TEST(ExternalShortStringAdd) { // Generate short ascii and non-ascii external strings. for (int i = 0; i <= kMaxLength; i++) { - char* ascii = Zone::NewArray<char>(i + 1); + char* ascii = ZONE->NewArray<char>(i + 1); for (int j = 0; j < i; j++) { ascii[j] = 'a'; } @@ -377,7 +377,7 @@ TEST(ExternalShortStringAdd) { v8::String::NewExternal(ascii_resource); ascii_external_strings->Set(v8::Integer::New(i), ascii_external_string); - uc16* non_ascii = Zone::NewArray<uc16>(i + 1); + uc16* non_ascii = ZONE->NewArray<uc16>(i + 1); for (int j = 0; j < i; j++) { non_ascii[j] = 0x1234; } @@ -459,10 +459,10 @@ TEST(CachedHashOverflow) { Handle<Smi> fortytwo(Smi::FromInt(42)); Handle<Smi> thirtyseven(Smi::FromInt(37)); Handle<Object> results[] = { - Factory::undefined_value(), + FACTORY->undefined_value(), fortytwo, - Factory::undefined_value(), - Factory::undefined_value(), + FACTORY->undefined_value(), + FACTORY->undefined_value(), thirtyseven, fortytwo, thirtyseven // Bug yielded 42 here. diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc index aed7466a..5635b176 100644 --- a/test/cctest/test-thread-termination.cc +++ b/test/cctest/test-thread-termination.cc @@ -159,6 +159,9 @@ TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) { class TerminatorThread : public v8::internal::Thread { + public: + explicit TerminatorThread(i::Isolate* isolate) + : Thread(isolate, "TerminatorThread") { } void Run() { semaphore->Wait(); CHECK(!v8::V8::IsExecutionTerminating()); @@ -171,7 +174,7 @@ class TerminatorThread : public v8::internal::Thread { // from the side by another thread. TEST(TerminateOnlyV8ThreadFromOtherThread) { semaphore = v8::internal::OS::CreateSemaphore(0); - TerminatorThread thread; + TerminatorThread thread(i::Isolate::Current()); thread.Start(); v8::HandleScope scope; @@ -193,6 +196,8 @@ TEST(TerminateOnlyV8ThreadFromOtherThread) { class LoopingThread : public v8::internal::Thread { public: + explicit LoopingThread(i::Isolate* isolate) + : Thread(isolate, "LoopingThread") { } void Run() { v8::Locker locker; v8::HandleScope scope; @@ -225,9 +230,9 @@ TEST(TerminateMultipleV8Threads) { v8::Locker::StartPreemption(1); semaphore = v8::internal::OS::CreateSemaphore(0); } - LoopingThread thread1; + LoopingThread thread1(i::Isolate::Current()); thread1.Start(); - LoopingThread thread2; + LoopingThread thread2(i::Isolate::Current()); thread2.Start(); // Wait until both threads have signaled the semaphore. semaphore->Wait(); diff --git a/test/cctest/test-threads.cc b/test/cctest/test-threads.cc index 0f48e248..37f02050 100644 --- a/test/cctest/test-threads.cc +++ b/test/cctest/test-threads.cc @@ -64,6 +64,7 @@ static Turn turn = FILL_CACHE; class ThreadA: public v8::internal::Thread { public: + explicit ThreadA(i::Isolate* isolate) : Thread(isolate, "ThreadA") { } void Run() { v8::Locker locker; v8::HandleScope scope; @@ -99,6 +100,7 @@ class ThreadA: public v8::internal::Thread { class ThreadB: public v8::internal::Thread { public: + explicit ThreadB(i::Isolate* isolate) : Thread(isolate, "ThreadB") { } void Run() { do { { @@ -108,7 +110,7 @@ class ThreadB: public v8::internal::Thread { v8::Context::Scope context_scope(v8::Context::New()); // Clear the caches by forcing major GC. - v8::internal::Heap::CollectAllGarbage(false); + HEAP->CollectAllGarbage(false); turn = SECOND_TIME_FILL_CACHE; break; } @@ -123,8 +125,8 @@ class ThreadB: public v8::internal::Thread { TEST(JSFunctionResultCachesInTwoThreads) { v8::V8::Initialize(); - ThreadA threadA; - ThreadB threadB; + ThreadA threadA(i::Isolate::Current()); + ThreadB threadB(i::Isolate::Current()); threadA.Start(); threadB.Start(); diff --git a/test/cctest/test-utils.cc b/test/cctest/test-utils.cc index b48dcb8b..018018a1 100644 --- a/test/cctest/test-utils.cc +++ b/test/cctest/test-utils.cc @@ -103,7 +103,7 @@ void TestMemCopy(Vector<byte> src, TEST(MemCopy) { - V8::Initialize(NULL); + OS::Setup(); const int N = kMinComplexMemCopy + 128; Vector<byte> buffer1 = Vector<byte>::New(N); Vector<byte> buffer2 = Vector<byte>::New(N); diff --git a/test/cctest/testcfg.py b/test/cctest/testcfg.py index b15342ed..a137275f 100644 --- a/test/cctest/testcfg.py +++ b/test/cctest/testcfg.py @@ -34,11 +34,12 @@ import utils class CcTestCase(test.TestCase): - def __init__(self, path, executable, mode, raw_name, dependency, context): + def __init__(self, path, executable, mode, raw_name, dependency, context, variant_flags): super(CcTestCase, self).__init__(context, path, mode) self.executable = executable self.raw_name = raw_name self.dependency = dependency + self.variant_flags = variant_flags def GetLabel(self): return "%s %s %s" % (self.mode, self.path[-2], self.path[-1]) @@ -49,6 +50,8 @@ class CcTestCase(test.TestCase): def BuildCommand(self, name): serialization_file = join('obj', 'test', self.mode, 'serdes') serialization_file += '_' + self.GetName() + serialization_file = join(self.context.buildspace, serialization_file) + serialization_file += ''.join(self.variant_flags).replace('-', '_') serialization_option = '--testing_serialization_file=' + serialization_file result = [ self.executable, name, serialization_option ] result += self.context.GetVmFlags(self, self.mode) @@ -74,10 +77,11 @@ class CcTestConfiguration(test.TestConfiguration): def GetBuildRequirements(self): return ['cctests'] - def ListTests(self, current_path, path, mode): + def ListTests(self, current_path, path, mode, variant_flags): executable = join('obj', 'test', mode, 'cctest') if utils.IsWindows(): executable += '.exe' + executable = join(self.context.buildspace, executable) output = test.Execute([executable, '--list'], self.context) if output.exit_code != 0: print output.stdout @@ -91,7 +95,7 @@ class CcTestConfiguration(test.TestConfiguration): if dependency != '': dependency = relative_path[0] + '/' + dependency if self.Contains(path, full_path): - result.append(CcTestCase(full_path, executable, mode, raw_test, dependency, self.context)) + result.append(CcTestCase(full_path, executable, mode, raw_test, dependency, self.context, variant_flags)) result.sort() return result diff --git a/test/es5conform/es5conform.status b/test/es5conform/es5conform.status index d6f7caf5..1dc90d32 100644 --- a/test/es5conform/es5conform.status +++ b/test/es5conform/es5conform.status @@ -239,20 +239,11 @@ chapter15/15.10/15.10.7/15.10.7.5/15.10.7.5-2: FAIL_OK # Incorrect test - need double escape in eval. chapter07/7.8/7.8.4/7.8.4-1-s: FAIL -# arguments[i] remains same after changing actual parameters in strict mode -chapter10/10.6/10.6-10-c-ii-1-s: FAIL -# arguments[i] doesn't map to actual parameters in strict mode -chapter10/10.6/10.6-10-c-ii-2-s: FAIL - -# Accessing caller property of Arguments object throws TypeError in strict mode -chapter10/10.6/10.6-13-b-1-s: FAIL -# arguments.caller exists in strict mode -chapter10/10.6/10.6-13-b-2-s: FAIL # arguments.caller is non-configurable in strict mode +# Invalid test case. Checks for "writable == true" and presence of "put".. chapter10/10.6/10.6-13-b-3-s: FAIL -# Accessing callee property of Arguments object throws TypeError in strict mode -chapter10/10.6/10.6-13-c-1-s: FAIL # arguments.callee is non-configurable in strict mode +# Invalid test case. Checks for "put" property accessor. chapter10/10.6/10.6-13-c-3-s: FAIL # simple assignment throws TypeError if LeftHandSide is a property reference diff --git a/test/es5conform/testcfg.py b/test/es5conform/testcfg.py index e3a60cc4..af74b8c5 100644 --- a/test/es5conform/testcfg.py +++ b/test/es5conform/testcfg.py @@ -73,7 +73,7 @@ class ES5ConformTestConfiguration(test.TestConfiguration): def __init__(self, context, root): super(ES5ConformTestConfiguration, self).__init__(context, root) - def ListTests(self, current_path, path, mode): + def ListTests(self, current_path, path, mode, variant_flags): tests = [] current_root = join(self.root, 'data', 'TestCases') harness = [] diff --git a/test/message/testcfg.py b/test/message/testcfg.py index 21a0428f..aabbfef9 100644 --- a/test/message/testcfg.py +++ b/test/message/testcfg.py @@ -103,7 +103,7 @@ class MessageTestConfiguration(test.TestConfiguration): else: return [] - def ListTests(self, current_path, path, mode): + def ListTests(self, current_path, path, mode, variant_flags): mjsunit = [current_path + [t] for t in self.Ls(self.root)] regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'regress'))] bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))] diff --git a/test/mjsunit/accessors-on-global-object.js b/test/mjsunit/accessors-on-global-object.js index 8d95692c..dc910b7e 100644 --- a/test/mjsunit/accessors-on-global-object.js +++ b/test/mjsunit/accessors-on-global-object.js @@ -28,7 +28,7 @@ // Test that installing a getter on the global object instead of a // normal property works. -var x = 0; +x = 0; function getX() { return x; } @@ -41,7 +41,7 @@ for (var i = 0; i < 10; i++) { // Test that installing a setter on the global object instead of a // normal property works. -var y = 0; +y = 0; var setter_y; function setY(value) { y = value; } @@ -67,6 +67,6 @@ for (var i = 0; i < 10; i++) { assertEquals(i < 5 ? 42 : 0, getZ()); if (i == 4) { delete z; - var z = 0; + z = 0; } } diff --git a/test/mjsunit/bitops-info.js b/test/mjsunit/bitops-info.js index 4660fdf9..4b114c54 100644 --- a/test/mjsunit/bitops-info.js +++ b/test/mjsunit/bitops-info.js @@ -37,7 +37,6 @@ function hidden_int32() { return 1600822924; // It's a signed Int32. } - function f() { var x = non_int32(); // Not a constant. var y = hidden_smi(); // Not a constant. @@ -66,6 +65,13 @@ function f() { assertEquals(46512102 & 2600822924, x & y, "10rev"); assertEquals(1600822924 & 2600822924, x & z, "11rev"); + assertEquals((46512102 & -0x20123456) | 1, (y & -0x20123456) | 1, "12"); + assertEquals((1600822924 & -0x20123456) | 1, (z & -0x20123456) | 1, "13"); + assertEquals((2600822924 & -0x20123456) | 1, (x & -0x20123456) | 1, "14"); + assertEquals((46512102 & -0x20123456) | 1, (-0x20123456 & y) | 1, "12rev"); + assertEquals((1600822924 & -0x20123456) | 1, (-0x20123456 & z) | 1, "13rev"); + assertEquals((2600822924 & -0x20123456) | 1, (-0x20123456 & x) | 1, "14rev"); + assertEquals(2600822924 & 2600822924, x & x, "xx"); assertEquals(y, y & y, "yy"); assertEquals(z, z & z, "zz"); diff --git a/test/mjsunit/compiler/array-length.js b/test/mjsunit/compiler/array-length.js index 7adb9abb..126c7a02 100644 --- a/test/mjsunit/compiler/array-length.js +++ b/test/mjsunit/compiler/array-length.js @@ -36,7 +36,7 @@ function Test(a0, a2, a5) { var a0 = []; var a2 = [1,2]; var a5 = [1,2,3,4,5]; -for (var i = 0; i < 10000000; i++) Test(a0, a2, a5); +for (var i = 0; i < 100000; i++) Test(a0, a2, a5); assertEquals("undefined", typeof(ArrayLength(0))); -for (var i = 0; i < 10000000; i++) Test(a0, a2, a5); +for (var i = 0; i < 100000; i++) Test(a0, a2, a5); assertEquals(4, ArrayLength("hest")); diff --git a/test/mjsunit/compiler/pic.js b/test/mjsunit/compiler/pic.js index a0b5d8f9..06f2b3eb 100644 --- a/test/mjsunit/compiler/pic.js +++ b/test/mjsunit/compiler/pic.js @@ -53,7 +53,7 @@ o1.f = o2.f = o3.f = function() { return 99; } // Run the test until we're fairly sure we've optimized the // polymorphic property access. -for (var i = 0; i < 1000000; i++) { +for (var i = 0; i < 100000; i++) { Test(o1); Test(o2); Test(o3); diff --git a/test/mjsunit/compiler/regress-loadfield.js b/test/mjsunit/compiler/regress-loadfield.js new file mode 100644 index 00000000..a2028919 --- /dev/null +++ b/test/mjsunit/compiler/regress-loadfield.js @@ -0,0 +1,65 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Regression test for GVN on field loads. + +function bar() {} + +// Make sure there is a transition on adding "bar" inobject property. +var b = new bar(); +b.bar = "bar"; + +function test(a) { + var b = new Array(10); + for (var i = 0; i < 10; i++) { + b[i] = new bar(); + } + + for (var i = 0; i < 10; i++) { + b[i].bar = a.foo; + } +} + +// Create an object with fast backing store properties. +var a = {}; +a.p1 = ""; +a.p2 = ""; +a.p3 = ""; +a.p4 = ""; +a.p5 = ""; +a.p6 = ""; +a.p7 = ""; +a.p8 = ""; +a.p9 = ""; +a.p10 = ""; +a.p11 = ""; +a.foo = "foo"; +for (var i = 0; i < 100000; i++) { + test(a); +} + +test(""); diff --git a/test/mjsunit/math-sqrt.js b/test/mjsunit/math-sqrt.js index fb00d5ba..43fbf6b2 100644 --- a/test/mjsunit/math-sqrt.js +++ b/test/mjsunit/math-sqrt.js @@ -29,7 +29,11 @@ function test(expected_sqrt, value) { assertEquals(expected_sqrt, Math.sqrt(value)); - if (isFinite(value)) { + if (isFinite(value)) { + if (value === 0 && (1 / value) == -Infinity) { + // Math.pow(-0, 0.5) must be zero, but Math.sqrt(-0) is -0. + expected_sqrt = 0; + } assertEquals(expected_sqrt, Math.pow(value, 0.5)); } } diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js index fe580f35..436bdc81 100644 --- a/test/mjsunit/mjsunit.js +++ b/test/mjsunit/mjsunit.js @@ -41,15 +41,62 @@ MjsUnitAssertionError.prototype.toString = function () { * the f-word and ignore all other lines. */ +function MjsUnitToString(value) { + switch (typeof value) { + case "string": + return JSON.stringify(value); + case "number": + if (value === 0 && (1 / value) < 0) return "-0"; + case "boolean": + case "null": + case "undefined": + case "function": + return String(value); + case "object": + if (value === null) return "null"; + var clazz = Object.prototype.toString.call(value); + clazz = clazz.substring(8, clazz.length - 1); + switch (clazz) { + case "Number": + case "String": + case "Boolean": + case "Date": + return clazz + "(" + MjsUnitToString(value.valueOf()) + ")"; + case "RegExp": + return value.toString(); + case "Array": + return "[" + value.map(MjsUnitArrayElementToString).join(",") + "]"; + case "Object": + break; + default: + return clazz + "()"; + } + // [[Class]] is "Object". + var constructor = value.constructor.name; + if (name) return name + "()"; + return "Object()"; + default: + return "-- unknown value --"; + } +} + + +function MjsUnitArrayElementToString(value, index, array) { + if (value === undefined && !(index in array)) return ""; + return MjsUnitToString(value); +} + + function fail(expected, found, name_opt) { - var start; + var message = "Fail" + "ure"; if (name_opt) { // Fix this when we ditch the old test runner. - start = "Fail" + "ure (" + name_opt + "): "; - } else { - start = "Fail" + "ure:"; + message += " (" + name_opt + ")"; } - throw new MjsUnitAssertionError(start + " expected <" + expected + "> found <" + found + ">"); + + message += ": expected <" + MjsUnitToString(expected) + + "> found <" + MjsUnitToString(found) + ">"; + throw new MjsUnitAssertionError(message); } @@ -73,13 +120,17 @@ function deepObjectEquals(a, b) { function deepEquals(a, b) { - if (a == b) return true; + if (a == b) { + // Check for -0. + if (a === 0 && b === 0) return (1 / a) === (1 / b); + return true; + } if (typeof a == "number" && typeof b == "number" && isNaN(a) && isNaN(b)) { return true; } if (a == null || b == null) return false; if (a.constructor === RegExp || b.constructor === RegExp) { - return (a.constructor === b.constructor) && (a.toString === b.toString); + return (a.constructor === b.constructor) && (a.toString() === b.toString()); } if ((typeof a) !== 'object' || (typeof b) !== 'object' || (a === null) || (b === null)) @@ -205,7 +256,7 @@ function assertDoesNotThrow(code) { function assertUnreachable(name_opt) { // Fix this when we ditch the old test runner. - var message = "Fail" + "ure: unreachable" + var message = "Fail" + "ure: unreachable"; if (name_opt) { message += " - " + name_opt; } diff --git a/test/mjsunit/mul-exhaustive.js b/test/mjsunit/mul-exhaustive.js index 452f9332..12689db3 100644 --- a/test/mjsunit/mul-exhaustive.js +++ b/test/mjsunit/mul-exhaustive.js @@ -26,41 +26,64 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. var x; -var y; -var a; -function f(a, y) { - assertEquals(a, x * y); - assertEquals(a, -x * -y); - assertEquals(-a, -x * y); - assertEquals(-a, x * -y); - assertEquals(a, y * x); - assertEquals(a, -y * -x); - assertEquals(-a, y * -x); - assertEquals(-a, -y * x); +// Converts a number to string respecting -0. +function stringify(n) { + if ((1 / n) === -Infinity) return "-0"; + return String(n); } +function f(expected, y) { + function testEval(string, x, y) { + var mulFunction = Function("x, y", "return " + string); + return mulFunction(x, y); + } + function mulTest(expected, x, y) { + assertEquals(expected, x * y); + assertEquals(expected, testEval(stringify(x) + " * y", x, y)); + assertEquals(expected, testEval("x * " + stringify(y), x, y)); + assertEquals(expected, testEval(stringify(x) + " * " + stringify(y), x, y)); + } + mulTest(expected, x, y); + mulTest(-expected, -x, y); + mulTest(-expected, x, -y); + mulTest(expected, -x, -y); + if (x === y) return; // Symmetric cases not necessary. + mulTest(expected, y, x); + mulTest(-expected, -y, x); + mulTest(-expected, y, -x); + mulTest(expected, -y, -x); +} + +x = 0; +f(0, 0); x = 1; +f(0, 0); f(1, 1); x = 2; +f(0, 0); f(2, 1); f(4, 2); x = 3; +f(0, 0); f(3, 1); f(6, 2); f(9, 3); x = 4; +f(0, 0); f(4, 1); f(8, 2); f(12, 3); f(16, 4); x = 5; +f(0, 0); f(5, 1); f(10, 2); f(15, 3); f(20, 4); f(25, 5); x = 7; +f(0, 0); f(7, 1); f(14, 2); f(21, 3); @@ -68,6 +91,7 @@ f(28, 4); f(35, 5); f(49, 7); x = 8; +f(0, 0); f(8, 1); f(16, 2); f(24, 3); @@ -76,6 +100,7 @@ f(40, 5); f(56, 7); f(64, 8); x = 9; +f(0, 0); f(9, 1); f(18, 2); f(27, 3); @@ -85,6 +110,7 @@ f(63, 7); f(72, 8); f(81, 9); x = 15; +f(0, 0); f(15, 1); f(30, 2); f(45, 3); @@ -95,6 +121,7 @@ f(120, 8); f(135, 9); f(225, 15); x = 16; +f(0, 0); f(16, 1); f(32, 2); f(48, 3); @@ -106,6 +133,7 @@ f(144, 9); f(240, 15); f(256, 16); x = 17; +f(0, 0); f(17, 1); f(34, 2); f(51, 3); @@ -118,6 +146,7 @@ f(255, 15); f(272, 16); f(289, 17); x = 31; +f(0, 0); f(31, 1); f(62, 2); f(93, 3); @@ -131,6 +160,7 @@ f(496, 16); f(527, 17); f(961, 31); x = 32; +f(0, 0); f(32, 1); f(64, 2); f(96, 3); @@ -145,6 +175,7 @@ f(544, 17); f(992, 31); f(1024, 32); x = 33; +f(0, 0); f(33, 1); f(66, 2); f(99, 3); @@ -160,6 +191,7 @@ f(1023, 31); f(1056, 32); f(1089, 33); x = 63; +f(0, 0); f(63, 1); f(126, 2); f(189, 3); @@ -176,6 +208,7 @@ f(2016, 32); f(2079, 33); f(3969, 63); x = 64; +f(0, 0); f(64, 1); f(128, 2); f(192, 3); @@ -193,6 +226,7 @@ f(2112, 33); f(4032, 63); f(4096, 64); x = 65; +f(0, 0); f(65, 1); f(130, 2); f(195, 3); @@ -211,6 +245,7 @@ f(4095, 63); f(4160, 64); f(4225, 65); x = 127; +f(0, 0); f(127, 1); f(254, 2); f(381, 3); @@ -230,6 +265,7 @@ f(8128, 64); f(8255, 65); f(16129, 127); x = 128; +f(0, 0); f(128, 1); f(256, 2); f(384, 3); @@ -250,6 +286,7 @@ f(8320, 65); f(16256, 127); f(16384, 128); x = 129; +f(0, 0); f(129, 1); f(258, 2); f(387, 3); @@ -271,6 +308,7 @@ f(16383, 127); f(16512, 128); f(16641, 129); x = 255; +f(0, 0); f(255, 1); f(510, 2); f(765, 3); @@ -293,6 +331,7 @@ f(32640, 128); f(32895, 129); f(65025, 255); x = 256; +f(0, 0); f(256, 1); f(512, 2); f(768, 3); @@ -316,6 +355,7 @@ f(33024, 129); f(65280, 255); f(65536, 256); x = 257; +f(0, 0); f(257, 1); f(514, 2); f(771, 3); @@ -340,6 +380,7 @@ f(65535, 255); f(65792, 256); f(66049, 257); x = 511; +f(0, 0); f(511, 1); f(1022, 2); f(1533, 3); @@ -365,6 +406,7 @@ f(130816, 256); f(131327, 257); f(261121, 511); x = 512; +f(0, 0); f(512, 1); f(1024, 2); f(1536, 3); @@ -391,6 +433,7 @@ f(131584, 257); f(261632, 511); f(262144, 512); x = 513; +f(0, 0); f(513, 1); f(1026, 2); f(1539, 3); @@ -418,6 +461,7 @@ f(262143, 511); f(262656, 512); f(263169, 513); x = 1023; +f(0, 0); f(1023, 1); f(2046, 2); f(3069, 3); @@ -446,6 +490,7 @@ f(523776, 512); f(524799, 513); f(1046529, 1023); x = 1024; +f(0, 0); f(1024, 1); f(2048, 2); f(3072, 3); @@ -475,6 +520,7 @@ f(525312, 513); f(1047552, 1023); f(1048576, 1024); x = 1025; +f(0, 0); f(1025, 1); f(2050, 2); f(3075, 3); @@ -505,6 +551,7 @@ f(1048575, 1023); f(1049600, 1024); f(1050625, 1025); x = 2047; +f(0, 0); f(2047, 1); f(4094, 2); f(6141, 3); @@ -536,6 +583,7 @@ f(2096128, 1024); f(2098175, 1025); f(4190209, 2047); x = 2048; +f(0, 0); f(2048, 1); f(4096, 2); f(6144, 3); @@ -568,6 +616,7 @@ f(2099200, 1025); f(4192256, 2047); f(4194304, 2048); x = 2049; +f(0, 0); f(2049, 1); f(4098, 2); f(6147, 3); @@ -601,6 +650,7 @@ f(4194303, 2047); f(4196352, 2048); f(4198401, 2049); x = 4095; +f(0, 0); f(4095, 1); f(8190, 2); f(12285, 3); @@ -635,6 +685,7 @@ f(8386560, 2048); f(8390655, 2049); f(16769025, 4095); x = 4096; +f(0, 0); f(4096, 1); f(8192, 2); f(12288, 3); @@ -670,6 +721,7 @@ f(8392704, 2049); f(16773120, 4095); f(16777216, 4096); x = 4097; +f(0, 0); f(4097, 1); f(8194, 2); f(12291, 3); @@ -706,6 +758,7 @@ f(16777215, 4095); f(16781312, 4096); f(16785409, 4097); x = 8191; +f(0, 0); f(8191, 1); f(16382, 2); f(24573, 3); @@ -743,6 +796,7 @@ f(33550336, 4096); f(33558527, 4097); f(67092481, 8191); x = 8192; +f(0, 0); f(8192, 1); f(16384, 2); f(24576, 3); @@ -781,6 +835,7 @@ f(33562624, 4097); f(67100672, 8191); f(67108864, 8192); x = 8193; +f(0, 0); f(8193, 1); f(16386, 2); f(24579, 3); @@ -820,6 +875,7 @@ f(67108863, 8191); f(67117056, 8192); f(67125249, 8193); x = 16383; +f(0, 0); f(16383, 1); f(32766, 2); f(49149, 3); @@ -860,6 +916,7 @@ f(134209536, 8192); f(134225919, 8193); f(268402689, 16383); x = 16384; +f(0, 0); f(16384, 1); f(32768, 2); f(49152, 3); @@ -901,6 +958,7 @@ f(134234112, 8193); f(268419072, 16383); f(268435456, 16384); x = 16385; +f(0, 0); f(16385, 1); f(32770, 2); f(49155, 3); @@ -943,6 +1001,7 @@ f(268435455, 16383); f(268451840, 16384); f(268468225, 16385); x = 32767; +f(0, 0); f(32767, 1); f(65534, 2); f(98301, 3); @@ -986,6 +1045,7 @@ f(536854528, 16384); f(536887295, 16385); f(1073676289, 32767); x = 32768; +f(0, 0); f(32768, 1); f(65536, 2); f(98304, 3); @@ -1030,6 +1090,7 @@ f(536903680, 16385); f(1073709056, 32767); f(1073741824, 32768); x = 32769; +f(0, 0); f(32769, 1); f(65538, 2); f(98307, 3); @@ -1075,6 +1136,7 @@ f(1073741823, 32767); f(1073774592, 32768); f(1073807361, 32769); x = 65535; +f(0, 0); f(65535, 1); f(131070, 2); f(196605, 3); @@ -1121,6 +1183,7 @@ f(2147450880, 32768); f(2147516415, 32769); f(4294836225, 65535); x = 65536; +f(0, 0); f(65536, 1); f(131072, 2); f(196608, 3); @@ -1168,6 +1231,7 @@ f(2147549184, 32769); f(4294901760, 65535); f(4294967296, 65536); x = 65537; +f(0, 0); f(65537, 1); f(131074, 2); f(196611, 3); @@ -1216,6 +1280,7 @@ f(4294967295, 65535); f(4295032832, 65536); f(4295098369, 65537); x = 131071; +f(0, 0); f(131071, 1); f(262142, 2); f(393213, 3); @@ -1265,6 +1330,7 @@ f(8589869056, 65536); f(8590000127, 65537); f(17179607041, 131071); x = 131072; +f(0, 0); f(131072, 1); f(262144, 2); f(393216, 3); @@ -1315,6 +1381,7 @@ f(8590065664, 65537); f(17179738112, 131071); f(17179869184, 131072); x = 131073; +f(0, 0); f(131073, 1); f(262146, 2); f(393219, 3); @@ -1366,6 +1433,7 @@ f(17179869183, 131071); f(17180000256, 131072); f(17180131329, 131073); x = 262143; +f(0, 0); f(262143, 1); f(524286, 2); f(786429, 3); @@ -1418,6 +1486,7 @@ f(34359607296, 131072); f(34359869439, 131073); f(68718952449, 262143); x = 262144; +f(0, 0); f(262144, 1); f(524288, 2); f(786432, 3); @@ -1471,6 +1540,7 @@ f(34360000512, 131073); f(68719214592, 262143); f(68719476736, 262144); x = 262145; +f(0, 0); f(262145, 1); f(524290, 2); f(786435, 3); @@ -1525,6 +1595,7 @@ f(68719476735, 262143); f(68719738880, 262144); f(68720001025, 262145); x = 524287; +f(0, 0); f(524287, 1); f(1048574, 2); f(1572861, 3); @@ -1580,6 +1651,7 @@ f(137438691328, 262144); f(137439215615, 262145); f(274876858369, 524287); x = 524288; +f(0, 0); f(524288, 1); f(1048576, 2); f(1572864, 3); @@ -1636,6 +1708,7 @@ f(137439477760, 262145); f(274877382656, 524287); f(274877906944, 524288); x = 524289; +f(0, 0); f(524289, 1); f(1048578, 2); f(1572867, 3); @@ -1693,6 +1766,7 @@ f(274877906943, 524287); f(274878431232, 524288); f(274878955521, 524289); x = 1048575; +f(0, 0); f(1048575, 1); f(2097150, 2); f(3145725, 3); @@ -1751,6 +1825,7 @@ f(549755289600, 524288); f(549756338175, 524289); f(1099509530625, 1048575); x = 1048576; +f(0, 0); f(1048576, 1); f(2097152, 2); f(3145728, 3); @@ -1810,6 +1885,7 @@ f(549756862464, 524289); f(1099510579200, 1048575); f(1099511627776, 1048576); x = 1048577; +f(0, 0); f(1048577, 1); f(2097154, 2); f(3145731, 3); @@ -1870,6 +1946,7 @@ f(1099511627775, 1048575); f(1099512676352, 1048576); f(1099513724929, 1048577); x = 2097151; +f(0, 0); f(2097151, 1); f(4194302, 2); f(6291453, 3); @@ -1931,6 +2008,7 @@ f(2199022206976, 1048576); f(2199024304127, 1048577); f(4398042316801, 2097151); x = 2097152; +f(0, 0); f(2097152, 1); f(4194304, 2); f(6291456, 3); @@ -1993,6 +2071,7 @@ f(2199025352704, 1048577); f(4398044413952, 2097151); f(4398046511104, 2097152); x = 2097153; +f(0, 0); f(2097153, 1); f(4194306, 2); f(6291459, 3); @@ -2056,6 +2135,7 @@ f(4398046511103, 2097151); f(4398048608256, 2097152); f(4398050705409, 2097153); x = 4194303; +f(0, 0); f(4194303, 1); f(8388606, 2); f(12582909, 3); @@ -2120,6 +2200,7 @@ f(8796090925056, 2097152); f(8796095119359, 2097153); f(17592177655809, 4194303); x = 4194304; +f(0, 0); f(4194304, 1); f(8388608, 2); f(12582912, 3); @@ -2185,6 +2266,7 @@ f(8796097216512, 2097153); f(17592181850112, 4194303); f(17592186044416, 4194304); x = 4194305; +f(0, 0); f(4194305, 1); f(8388610, 2); f(12582915, 3); @@ -2251,6 +2333,7 @@ f(17592186044415, 4194303); f(17592190238720, 4194304); f(17592194433025, 4194305); x = 8388607; +f(0, 0); f(8388607, 1); f(16777214, 2); f(25165821, 3); @@ -2318,6 +2401,7 @@ f(35184367894528, 4194304); f(35184376283135, 4194305); f(70368727400449, 8388607); x = 8388608; +f(0, 0); f(8388608, 1); f(16777216, 2); f(25165824, 3); @@ -2386,6 +2470,7 @@ f(35184380477440, 4194305); f(70368735789056, 8388607); f(70368744177664, 8388608); x = 8388609; +f(0, 0); f(8388609, 1); f(16777218, 2); f(25165827, 3); @@ -2455,6 +2540,7 @@ f(70368744177663, 8388607); f(70368752566272, 8388608); f(70368760954881, 8388609); x = 16777215; +f(0, 0); f(16777215, 1); f(33554430, 2); f(50331645, 3); @@ -2525,6 +2611,7 @@ f(140737479966720, 8388608); f(140737496743935, 8388609); f(281474943156225, 16777215); x = 16777216; +f(0, 0); f(16777216, 1); f(33554432, 2); f(50331648, 3); @@ -2596,6 +2683,7 @@ f(140737505132544, 8388609); f(281474959933440, 16777215); f(281474976710656, 16777216); x = 16777217; +f(0, 0); f(16777217, 1); f(33554434, 2); f(50331651, 3); @@ -2668,6 +2756,7 @@ f(281474976710655, 16777215); f(281474993487872, 16777216); f(281475010265089, 16777217); x = 33554431; +f(0, 0); f(33554431, 1); f(67108862, 2); f(100663293, 3); @@ -2741,6 +2830,7 @@ f(562949936644096, 16777216); f(562949970198527, 16777217); f(1125899839733761, 33554431); x = 33554432; +f(0, 0); f(33554432, 1); f(67108864, 2); f(100663296, 3); @@ -2815,6 +2905,7 @@ f(562949986975744, 16777217); f(1125899873288192, 33554431); f(1125899906842624, 33554432); x = 33554433; +f(0, 0); f(33554433, 1); f(67108866, 2); f(100663299, 3); @@ -2890,6 +2981,7 @@ f(1125899906842623, 33554431); f(1125899940397056, 33554432); f(1125899973951489, 33554433); x = 67108863; +f(0, 0); f(67108863, 1); f(134217726, 2); f(201326589, 3); @@ -2962,6 +3054,7 @@ f(1125899822956545, 16777215); f(1125899890065408, 16777216); f(1125899957174271, 16777217); x = 67108864; +f(0, 0); f(67108864, 1); f(134217728, 2); f(201326592, 3); @@ -3034,6 +3127,7 @@ f(1125899839733760, 16777215); f(1125899906842624, 16777216); f(1125899973951488, 16777217); x = 67108865; +f(0, 0); f(67108865, 1); f(134217730, 2); f(201326595, 3); @@ -3106,6 +3200,7 @@ f(1125899856510975, 16777215); f(1125899923619840, 16777216); f(1125899990728705, 16777217); x = 134217727; +f(0, 0); f(134217727, 1); f(268435454, 2); f(402653181, 3); @@ -3175,6 +3270,7 @@ f(1125899764236289, 8388607); f(1125899898454016, 8388608); f(1125900032671743, 8388609); x = 134217728; +f(0, 0); f(134217728, 1); f(268435456, 2); f(402653184, 3); @@ -3244,6 +3340,7 @@ f(1125899772624896, 8388607); f(1125899906842624, 8388608); f(1125900041060352, 8388609); x = 134217729; +f(0, 0); f(134217729, 1); f(268435458, 2); f(402653187, 3); @@ -3313,6 +3410,7 @@ f(1125899781013503, 8388607); f(1125899915231232, 8388608); f(1125900049448961, 8388609); x = 268435455; +f(0, 0); f(268435455, 1); f(536870910, 2); f(805306365, 3); @@ -3379,6 +3477,7 @@ f(1125899634212865, 4194303); f(1125899902648320, 4194304); f(1125900171083775, 4194305); x = 268435456; +f(0, 0); f(268435456, 1); f(536870912, 2); f(805306368, 3); @@ -3445,6 +3544,7 @@ f(1125899638407168, 4194303); f(1125899906842624, 4194304); f(1125900175278080, 4194305); x = 268435457; +f(0, 0); f(268435457, 1); f(536870914, 2); f(805306371, 3); @@ -3511,6 +3611,7 @@ f(1125899642601471, 4194303); f(1125899911036928, 4194304); f(1125900179472385, 4194305); x = 536870911; +f(0, 0); f(536870911, 1); f(1073741822, 2); f(1610612733, 3); @@ -3574,6 +3675,7 @@ f(1125899367874561, 2097151); f(1125899904745472, 2097152); f(1125900441616383, 2097153); x = 536870912; +f(0, 0); f(536870912, 1); f(1073741824, 2); f(1610612736, 3); @@ -3637,6 +3739,7 @@ f(1125899369971712, 2097151); f(1125899906842624, 2097152); f(1125900443713536, 2097153); x = 536870913; +f(0, 0); f(536870913, 1); f(1073741826, 2); f(1610612739, 3); @@ -3700,6 +3803,7 @@ f(1125899372068863, 2097151); f(1125899908939776, 2097152); f(1125900445810689, 2097153); x = 1073741823; +f(0, 0); f(1073741823, 1); f(2147483646, 2); f(3221225469, 3); @@ -3760,6 +3864,7 @@ f(1125898832052225, 1048575); f(1125899905794048, 1048576); f(1125900979535871, 1048577); x = 1073741824; +f(0, 0); f(1073741824, 1); f(2147483648, 2); f(3221225472, 3); @@ -3820,6 +3925,7 @@ f(1125898833100800, 1048575); f(1125899906842624, 1048576); f(1125900980584448, 1048577); x = 1073741825; +f(0, 0); f(1073741825, 1); f(2147483650, 2); f(3221225475, 3); @@ -3880,6 +3986,7 @@ f(1125898834149375, 1048575); f(1125899907891200, 1048576); f(1125900981633025, 1048577); x = 2147483647; +f(0, 0); f(2147483647, 1); f(4294967294, 2); f(6442450941, 3); @@ -3937,6 +4044,7 @@ f(1125897758834689, 524287); f(1125899906318336, 524288); f(1125902053801983, 524289); x = 2147483648; +f(0, 0); f(2147483648, 1); f(4294967296, 2); f(6442450944, 3); @@ -3994,6 +4102,7 @@ f(1125897759358976, 524287); f(1125899906842624, 524288); f(1125902054326272, 524289); x = 2147483649; +f(0, 0); f(2147483649, 1); f(4294967298, 2); f(6442450947, 3); @@ -4051,6 +4160,7 @@ f(1125897759883263, 524287); f(1125899907366912, 524288); f(1125902054850561, 524289); x = 4294967295; +f(0, 0); f(4294967295, 1); f(8589934590, 2); f(12884901885, 3); @@ -4105,6 +4215,7 @@ f(1125895611613185, 262143); f(1125899906580480, 262144); f(1125904201547775, 262145); x = 4294967296; +f(0, 0); f(4294967296, 1); f(8589934592, 2); f(12884901888, 3); @@ -4159,6 +4270,7 @@ f(1125895611875328, 262143); f(1125899906842624, 262144); f(1125904201809920, 262145); x = 4294967297; +f(0, 0); f(4294967297, 1); f(8589934594, 2); f(12884901891, 3); @@ -4213,6 +4325,7 @@ f(1125895612137471, 262143); f(1125899907104768, 262144); f(1125904202072065, 262145); x = 8589934591; +f(0, 0); f(8589934591, 1); f(17179869182, 2); f(25769803773, 3); @@ -4264,6 +4377,7 @@ f(1125891316776961, 131071); f(1125899906711552, 131072); f(1125908496646143, 131073); x = 8589934592; +f(0, 0); f(8589934592, 1); f(17179869184, 2); f(25769803776, 3); @@ -4315,6 +4429,7 @@ f(1125891316908032, 131071); f(1125899906842624, 131072); f(1125908496777216, 131073); x = 8589934593; +f(0, 0); f(8589934593, 1); f(17179869186, 2); f(25769803779, 3); @@ -4366,6 +4481,7 @@ f(1125891317039103, 131071); f(1125899906973696, 131072); f(1125908496908289, 131073); x = 17179869183; +f(0, 0); f(17179869183, 1); f(34359738366, 2); f(51539607549, 3); @@ -4414,6 +4530,7 @@ f(1125882726907905, 65535); f(1125899906777088, 65536); f(1125917086646271, 65537); x = 17179869184; +f(0, 0); f(17179869184, 1); f(34359738368, 2); f(51539607552, 3); @@ -4462,6 +4579,7 @@ f(1125882726973440, 65535); f(1125899906842624, 65536); f(1125917086711808, 65537); x = 17179869185; +f(0, 0); f(17179869185, 1); f(34359738370, 2); f(51539607555, 3); diff --git a/test/mjsunit/negate-zero.js b/test/mjsunit/negate-zero.js index 31d460a2..558be94c 100644 --- a/test/mjsunit/negate-zero.js +++ b/test/mjsunit/negate-zero.js @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. function IsNegativeZero(x) { - assertEquals(0, x); + assertTrue(x == 0); // Is 0 or -0. var y = 1 / x; assertFalse(isFinite(y)); return y < 0; diff --git a/test/mjsunit/object-freeze.js b/test/mjsunit/object-freeze.js index 15e19abb..3eefffda 100644 --- a/test/mjsunit/object-freeze.js +++ b/test/mjsunit/object-freeze.js @@ -70,12 +70,8 @@ Object.freeze(obj); assertFalse(Object.isExtensible(obj)); assertTrue(Object.isFrozen(obj)); -try { - obj.foo = 42; - assertUnreachable(); -} catch(e) { - assertTrue(/object is not extensible/.test(e)); -} +obj.foo = 42; +assertEquals(obj.foo, undefined); desc = Object.getOwnPropertyDescriptor(obj, 'x'); assertFalse(desc.writable); @@ -88,7 +84,7 @@ assertFalse(desc.configurable); assertEquals("foobar", desc.value); // Make sure that even if we try overwrite a value that is not writable, it is -// not changed. +// not changed. obj.x = "tete"; assertEquals(42, obj.x); obj.x = { get: function() {return 43}, set: function() {} }; @@ -118,12 +114,8 @@ assertEquals(undefined, desc.value); assertEquals(set, desc.set); assertEquals(get, desc.get); -try { - obj2.foo = 42; - assertUnreachable(); -} catch(e) { - assertTrue(/object is not extensible/.test(e)); -} +obj2.foo = 42; +assertEquals(obj2.foo, undefined); // Test freeze on arrays. diff --git a/test/mjsunit/object-prevent-extensions.js b/test/mjsunit/object-prevent-extensions.js index ebc2cfa6..dc32342c 100644 --- a/test/mjsunit/object-prevent-extensions.js +++ b/test/mjsunit/object-prevent-extensions.js @@ -35,22 +35,11 @@ Object.preventExtensions(obj1); // Make sure the is_extensible flag is set. assertFalse(Object.isExtensible(obj1)); -// Try adding a new property. -try { - obj1.x = 42; - assertUnreachable(); -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} +obj1.x = 42; assertEquals(undefined, obj1.x); // Try adding a new element. -try { - obj1[1] = 42; - assertUnreachable(); -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} +obj1[1] = 42; assertEquals(undefined, obj1[1]); @@ -64,25 +53,14 @@ assertTrue(Object.isExtensible(obj2)); Object.preventExtensions(obj2); assertEquals(42, obj2.x); -try { - obj2.y = 42; - assertUnreachable(); -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} - +obj2.y = 42; // obj2.y should still be undefined. assertEquals(undefined, obj2.y); // Make sure we can still write values to obj.x. obj2.x = 43; assertEquals(43, obj2.x) -try { - obj2.y = new function() { return 42; }; - assertUnreachable(); -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} +obj2.y = new function() { return 42; }; // obj2.y should still be undefined. assertEquals(undefined, obj2.y); assertEquals(43, obj2.x) @@ -97,12 +75,7 @@ try { assertEquals(undefined, obj2.y); assertEquals(43, obj2.x); -try { - obj2[1] = 42; -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} - +obj2[1] = 42; assertEquals(undefined, obj2[1]); var arr = new Array(); @@ -110,12 +83,7 @@ arr[1] = 10; Object.preventExtensions(arr); -try { - arr[2] = 42; - assertUnreachable(); -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} +arr[2] = 42; assertEquals(10, arr[1]); // We should still be able to change exiting elements. @@ -134,12 +102,7 @@ var child = Object.create(parent); child.y = 42; // This should have no influence on the parent class. -try { - parent.y = 29; - assertUnreachable(); -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} +parent.y = 29; // Test that attributes on functions are also handled correctly. @@ -149,9 +112,5 @@ function foo() { Object.preventExtensions(foo); -try { - foo.x = 29; - assertUnreachable(); -} catch (e) { - assertTrue(/object is not extensible/.test(e)); -} +foo.x = 29; +assertEquals(undefined, foo.x); diff --git a/test/mjsunit/object-seal.js b/test/mjsunit/object-seal.js index 9e7f44b9..3ce2367b 100644 --- a/test/mjsunit/object-seal.js +++ b/test/mjsunit/object-seal.js @@ -75,12 +75,8 @@ assertTrue(Object.isSealed(obj)); assertFalse(Object.isFrozen(obj)); // We should not allow new properties to be added. -try { - obj.foo = 42; - assertUnreachable(); -} catch(e) { - assertTrue(/object is not extensible/.test(e)); -} +obj.foo = 42; +assertEquals(obj.foo, undefined); desc = Object.getOwnPropertyDescriptor(obj, 'x'); assertTrue(desc.writable); @@ -125,13 +121,8 @@ assertEquals(undefined, desc.value); assertEquals(set, desc.set); assertEquals(get, desc.get); -try { - obj2.foo = 42; - assertUnreachable(); -} catch(e) { - assertTrue(/object is not extensible/.test(e)); -} - +obj2.foo = 42; +assertEquals(obj2.foo, undefined); // Test seal on arrays. var arr = new Array(42,43); diff --git a/test/cctest/test-mips.cc b/test/mjsunit/regress/regress-1233.js index efd4cc97..a09b7152 100644 --- a/test/cctest/test-mips.cc +++ b/test/mjsunit/regress/regress-1233.js @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -25,28 +25,23 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Test that Object.freeze and Object.getOwnPropertyDescriptor do not +// call toString or valueOf on members of the object. -#include "v8.h" -#include "execution.h" +// See http://code.google.com/p/v8/issues/detail?id=1233. -#include "cctest.h" -using ::v8::Local; -using ::v8::String; -using ::v8::Script; +var delicate = new Object(); +delicate.toString = function(){ throw Error("toString"); }; +delicate.valueOf = function(){ throw Error("valueOf"); }; -namespace i = ::v8::internal; +var x = { foo: delicate }; -TEST(MIPSFunctionCalls) { - // Disable compilation of natives. - i::FLAG_disable_native_files = true; - i::FLAG_full_compiler = false; +var status = "fail"; +try { + Object.getOwnPropertyDescriptor(x, "foo"); + Object.freeze(x); + status = "succeed"; +} catch (e) {} - v8::HandleScope scope; - LocalContext env; // from cctest.h - - const char* c_source = "function foo() { return 0x1234; }; foo();"; - Local<String> source = ::v8::String::New(c_source); - Local<Script> script = ::v8::Script::Compile(source); - CHECK_EQ(0x1234, script->Run()->Int32Value()); -} +assertEquals("succeed", status); diff --git a/test/mjsunit/regress/regress-1236.js b/test/mjsunit/regress/regress-1236.js new file mode 100644 index 00000000..48e3d3d3 --- /dev/null +++ b/test/mjsunit/regress/regress-1236.js @@ -0,0 +1,34 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Should not crash. + +pattern = RegExp("",""); // RegExp is irrelevant, as long as it's not an atom. +string = 'a'; // Anything non-empty (flat ASCII). +pattern.exec(string); // Ensure that JSRegExp is compiled. +pattern["@"] = 42; // Change layout of JSRegExp object. +pattern.exec(string); // Call again to trigger bug in stub. diff --git a/test/mjsunit/regress/regress-1237.js b/test/mjsunit/regress/regress-1237.js new file mode 100644 index 00000000..f97f9786 --- /dev/null +++ b/test/mjsunit/regress/regress-1237.js @@ -0,0 +1,36 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Deoptimization after a conditional expression in an effect context should +// not see the value of the expression. +function observe(x, y) { return x; } +function test(x) { + return observe(1, ((x? observe(observe.prototype.x): 'c'), x + 1)); +} + +for (var i = 0; i < 10000000; ++i) test(0); +test("a"); diff --git a/test/mjsunit/regress/regress-1240.js b/test/mjsunit/regress/regress-1240.js new file mode 100644 index 00000000..1a0bf2ed --- /dev/null +++ b/test/mjsunit/regress/regress-1240.js @@ -0,0 +1,39 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This regression tests that we are not allowed to overwrite an existing +// non-configurable getter with a new getter. In addition, we should not +// be able to change the configurable flag from false to true. + +var a = {}; +Object.defineProperty(a, 'b', + { get: function () { return 42; }, configurable: false }); +// Do not allow us to redefine b on a. +a.__defineGetter__('b', function _b(){ return 'foo'; }); +assertEquals(42, a.b); +var desc = Object.getOwnPropertyDescriptor(a, 'b'); +assertFalse(desc.configurable); diff --git a/test/mjsunit/regress/regress-1257.js b/test/mjsunit/regress/regress-1257.js new file mode 100644 index 00000000..c20fb860 --- /dev/null +++ b/test/mjsunit/regress/regress-1257.js @@ -0,0 +1,58 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function g(y) { assertEquals(y, 12); } + +var X = 0; + +function foo () { + var cnt = 0; + var l = -1; + var x = 0; + while (1) switch (l) { + case -1: + var y = x + 12; + l = 0; + break; + case 0: + // Loop for to hit OSR. + if (cnt++ < 10000000) { + l = 0; + break; + } else { + l = 1; + break; + } + case 1: + // This case will contain deoptimization + // because it has no type feedback. + g(y); + return; + }; +} + +foo(); diff --git a/test/mjsunit/regress/regress-1278.js b/test/mjsunit/regress/regress-1278.js new file mode 100644 index 00000000..7ad8cda7 --- /dev/null +++ b/test/mjsunit/regress/regress-1278.js @@ -0,0 +1,69 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// See: http://code.google.com/p/v8/issues/detail?id=1278 + +// Test that that handling of 0/-0 is correct for binary operations when the +// TypeRecordingBinaryOpStub transitions through different states. + +function add(x, y) { + return x + y; +} + +function sub(x, y) { + return x - y; +} + +function mul(x, y) { + return x * y; +} + +function div(x, y) { + return x / y; +} + +for (var i = 0; i < 10; i++) { + assertEquals(0, add(0, 0)); + assertEquals(0, add(0, -0)); + assertEquals(0, add(-0, 0)); + assertEquals(-0, add(-0, -0)); + + assertEquals(0, sub(0, 0)); + assertEquals(0, sub(0, -0)); + assertEquals(-0, sub(-0, 0)); + assertEquals(0, sub(-0, -0)); + + assertEquals(0, mul(0, 0)); + assertEquals(-0, mul(0, -0)); + assertEquals(-0, mul(-0, 0)); + assertEquals(0, mul(-0, -0)); + + assertEquals(0, div(0, 1)); + assertEquals(-0, div(0, -1)); + assertEquals(-0, div(-0, 1)); + assertEquals(0, div(-0, -1)); +} diff --git a/test/mjsunit/regress/regress-create-exception.js b/test/mjsunit/regress/regress-create-exception.js index 2119ce2b..d3face9f 100644 --- a/test/mjsunit/regress/regress-create-exception.js +++ b/test/mjsunit/regress/regress-create-exception.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --max-new-space-size=256 +"use strict"; // Check for GC bug constructing exceptions. var v = [1, 2, 3, 4] diff --git a/test/mjsunit/regress/regress-lazy-deopt-reloc.js b/test/mjsunit/regress/regress-lazy-deopt-reloc.js new file mode 100644 index 00000000..f1fe6d55 --- /dev/null +++ b/test/mjsunit/regress/regress-lazy-deopt-reloc.js @@ -0,0 +1,52 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Do not generate debug code since that will space things differently +// in the generated code. +// Flags: --allow-natives-syntax --expose-gc --nodebug-code + +// Regression test for issue where we did not pad the relocation +// information enough to have room for lazy deoptimization. + +function kaboom() { + var a = function () {}, + b = function () {}, + c, d = function () { var d = []; }, + e = function () { var e = {}; }; + c = function () { d(); b(); }; + return function (x, y) { + c(); + a(); + return function f() { }({}); + }; +} + +kaboom(); + +%DeoptimizeFunction(kaboom); + +gc(); diff --git a/test/mjsunit/sin-cos.js b/test/mjsunit/sin-cos.js index ae02451f..e38dfdf8 100644 --- a/test/mjsunit/sin-cos.js +++ b/test/mjsunit/sin-cos.js @@ -1,4 +1,4 @@ -// Copyright 2009 the V8 project authors. All rights reserved. +// Copyright 2011 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: @@ -27,19 +27,24 @@ // Test Math.sin and Math.cos. -var input_sin = [0, Math.PI / 2]; -var input_cos = [0, Math.PI]; +function sinTest() { + assertEquals(0, Math.sin(0)); + assertEquals(1, Math.sin(Math.PI / 2)); +} -var output_sin = input_sin.map(Math.sin); -var output_cos = input_cos.map(Math.cos); +function cosTest() { + assertEquals(1, Math.cos(0)); + assertEquals(-1, Math.cos(Math.PI)); +} -var expected_sin = [0, 1]; -var expected_cos = [1, -1]; - -assertArrayEquals(expected_sin, output_sin, "sine"); -assertArrayEquals(expected_cos, output_cos, "cosine"); +sinTest(); +cosTest(); // By accident, the slow case for sine and cosine were both sine at // some point. This is a regression test for that issue. var x = Math.pow(2, 70); assertTrue(Math.sin(x) != Math.cos(x)); + +// Ensure that sine and log are not the same. +x = 0.5; +assertTrue(Math.sin(x) != Math.log(x)); diff --git a/test/mjsunit/smi-negative-zero.js b/test/mjsunit/smi-negative-zero.js index ea2fa5a9..1bab920d 100644 --- a/test/mjsunit/smi-negative-zero.js +++ b/test/mjsunit/smi-negative-zero.js @@ -109,5 +109,5 @@ function foo(x) { return -x; } -assertEquals(0, foo(x)); -assertEquals(0, foo(x)); +assertEquals(-0, foo(x)); +assertEquals(-0, foo(x)); diff --git a/test/mjsunit/str-to-num.js b/test/mjsunit/str-to-num.js index 28e98d9f..bbfa7d33 100644 --- a/test/mjsunit/str-to-num.js +++ b/test/mjsunit/str-to-num.js @@ -190,7 +190,7 @@ assertEquals(100, toNumber("000100")); assertEquals(Infinity, toNumber("1e999"), "1e999"); assertEquals(-Infinity, toNumber("-1e999")); assertEquals(0, toNumber("1e-999")); -assertEquals(0, toNumber("-1e-999")); +assertEquals(-0, toNumber("-1e-999")); assertEquals(Infinity, 1 / toNumber("1e-999"), "1e-999"); assertEquals(-Infinity, 1 / toNumber("-1e-999")); diff --git a/test/mjsunit/strict-mode.js b/test/mjsunit/strict-mode.js index 69be19c2..84ccb30f 100644 --- a/test/mjsunit/strict-mode.js +++ b/test/mjsunit/strict-mode.js @@ -957,3 +957,181 @@ repeat(10, function() { testAssignToUndefined(false); }); assertThrows(function() { str_obj.length = 1; }, TypeError); assertThrows(function() { str_cat.length = 1; }, TypeError); })(); + + +(function TestArgumentsAliasing() { + function strict(a, b) { + "use strict"; + a = "c"; + b = "d"; + return [a, b, arguments[0], arguments[1]]; + } + + function nonstrict(a, b) { + a = "c"; + b = "d"; + return [a, b, arguments[0], arguments[1]]; + } + + assertEquals(["c", "d", "a", "b"], strict("a", "b")); + assertEquals(["c", "d", "c", "d"], nonstrict("a", "b")); +})(); + + +function CheckPillDescriptor(func, name) { + + function CheckPill(pill) { + assertEquals("function", typeof pill); + assertInstanceof(pill, Function); + pill.property = "value"; + assertEquals(pill.value, undefined); + assertThrows(function() { 'use strict'; pill.property = "value"; }, + TypeError); + assertThrows(pill, TypeError); + assertEquals(pill.prototype, (function(){}).prototype); + var d = Object.getOwnPropertyDescriptor(pill, "prototype"); + assertFalse(d.writable); + assertFalse(d.configurable); + assertFalse(d.enumerable); + } + + var descriptor = Object.getOwnPropertyDescriptor(func, name); + CheckPill(descriptor.get) + CheckPill(descriptor.set); + assertFalse(descriptor.enumerable); + assertFalse(descriptor.configurable); +} + + +(function TestStrictFunctionPills() { + function strict() { + "use strict"; + } + assertThrows(function() { strict.caller; }, TypeError); + assertThrows(function() { strict.arguments; }, TypeError); + + var another = new Function("'use strict'"); + assertThrows(function() { another.caller; }, TypeError); + assertThrows(function() { another.arguments; }, TypeError); + + var third = (function() { "use strict"; return function() {}; })(); + assertThrows(function() { third.caller; }, TypeError); + assertThrows(function() { third.arguments; }, TypeError); + + CheckPillDescriptor(strict, "caller"); + CheckPillDescriptor(strict, "arguments"); + CheckPillDescriptor(another, "caller"); + CheckPillDescriptor(another, "arguments"); + CheckPillDescriptor(third, "caller"); + CheckPillDescriptor(third, "arguments"); +})(); + + +(function TestStrictFunctionWritablePrototype() { + "use strict"; + function TheClass() { + } + assertThrows(function() { TheClass.caller; }, TypeError); + assertThrows(function() { TheClass.arguments; }, TypeError); + + // Strict functions must have writable prototype. + TheClass.prototype = { + func: function() { return "func_value"; }, + get accessor() { return "accessor_value"; }, + property: "property_value", + }; + + var o = new TheClass(); + assertEquals(o.func(), "func_value"); + assertEquals(o.accessor, "accessor_value"); + assertEquals(o.property, "property_value"); +})(); + + +(function TestStrictArgumentPills() { + function strict() { + "use strict"; + return arguments; + } + + var args = strict(); + CheckPillDescriptor(args, "caller"); + CheckPillDescriptor(args, "callee"); + + args = strict(17, "value", strict); + assertEquals(17, args[0]) + assertEquals("value", args[1]) + assertEquals(strict, args[2]); + CheckPillDescriptor(args, "caller"); + CheckPillDescriptor(args, "callee"); + + function outer() { + "use strict"; + function inner() { + return arguments; + } + return inner; + } + + var args = outer()(); + CheckPillDescriptor(args, "caller"); + CheckPillDescriptor(args, "callee"); + + args = outer()(17, "value", strict); + assertEquals(17, args[0]) + assertEquals("value", args[1]) + assertEquals(strict, args[2]); + CheckPillDescriptor(args, "caller"); + CheckPillDescriptor(args, "callee"); +})(); + + +(function TestNonStrictFunctionCallerPillSimple() { + function return_my_caller() { + return return_my_caller.caller; + } + + function strict() { + "use strict"; + return_my_caller(); + } + assertThrows(strict, TypeError); + + function non_strict() { + return return_my_caller(); + } + assertSame(non_strict(), non_strict); +})(); + + +(function TestNonStrictFunctionCallerPill() { + function strict(n) { + "use strict"; + non_strict(n); + } + + function recurse(n, then) { + if (n > 0) { + recurse(n - 1); + } else { + return then(); + } + } + + function non_strict(n) { + recurse(n, function() { non_strict.caller; }); + } + + function test(n) { + try { + recurse(n, function() { strict(n); }); + } catch(e) { + return e instanceof TypeError; + } + return false; + } + + for (var i = 0; i < 10; i ++) { + assertEquals(test(i), true); + } +})(); diff --git a/test/mjsunit/testcfg.py b/test/mjsunit/testcfg.py index 5cb46bc2..3dd65817 100644 --- a/test/mjsunit/testcfg.py +++ b/test/mjsunit/testcfg.py @@ -38,24 +38,31 @@ SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") class MjsunitTestCase(test.TestCase): - def __init__(self, path, file, mode, context, config): + def __init__(self, path, file, mode, context, config, isolates): super(MjsunitTestCase, self).__init__(context, path, mode) self.file = file self.config = config self.self_script = False + self.isolates = isolates def GetLabel(self): return "%s %s" % (self.mode, self.GetName()) def GetName(self): - return self.path[-1] + return self.path[-1] + ["", "-isolates"][self.isolates] - def GetCommand(self): + def TestsIsolates(self): + return self.isolates + + def GetVmCommand(self, source): result = self.config.context.GetVmCommand(self, self.mode) - source = open(self.file).read() flags_match = FLAGS_PATTERN.search(source) if flags_match: result += flags_match.group(1).strip().split() + return result + + def GetVmArguments(self, source): + result = [] additional_files = [] files_match = FILES_PATTERN.search(source); # Accept several lines of 'Files:' @@ -73,6 +80,15 @@ class MjsunitTestCase(test.TestCase): result += [framework, self.file] return result + def GetCommand(self): + source = open(self.file).read() + result = self.GetVmCommand(source) + result += self.GetVmArguments(source) + if self.isolates: + result.append("--isolate") + result += self.GetVmArguments(source) + return result + def GetSource(self): return open(self.file).read() @@ -104,7 +120,7 @@ class MjsunitTestConfiguration(test.TestConfiguration): return name.endswith('.js') and name != 'mjsunit.js' return [f[:-3] for f in os.listdir(path) if SelectTest(f)] - def ListTests(self, current_path, path, mode): + def ListTests(self, current_path, path, mode, variant_flags): mjsunit = [current_path + [t] for t in self.Ls(self.root)] regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'regress'))] bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs'))] @@ -122,7 +138,8 @@ class MjsunitTestConfiguration(test.TestConfiguration): for test in all_tests: if self.Contains(path, test): file_path = join(self.root, reduce(join, test[1:], "") + ".js") - result.append(MjsunitTestCase(test, file_path, mode, self.context, self)) + result.append(MjsunitTestCase(test, file_path, mode, self.context, self, False)) + result.append(MjsunitTestCase(test, file_path, mode, self.context, self, True)) return result def GetBuildRequirements(self): diff --git a/test/mjsunit/tools/tickprocessor-test-func-info.log b/test/mjsunit/tools/tickprocessor-test-func-info.log index 755fbb2a..e4015d48 100644 --- a/test/mjsunit/tools/tickprocessor-test-func-info.log +++ b/test/mjsunit/tools/tickprocessor-test-func-info.log @@ -5,7 +5,7 @@ profiler,"begin",1 code-creation,Stub,0x424260,348,"CompareStub_GE" code-creation,LazyCompile,0x2a8100,18535,"DrawQube 3d-cube.js:188",0xf43abcac, code-creation,LazyCompile,0x480100,3908,"DrawLine 3d-cube.js:17",0xf43abc50, -tick,0x424284,0xbfffeea0,0x480600,0,0x2aaaa5 -tick,0x42429f,0xbfffed88,0x480600,0,0x2aacb4 -tick,0x48063d,0xbfffec7c,0x2d0f7c,0,0x2aaec6 +tick,0x424284,0xbfffeea0,0,0x480600,0,0x2aaaa5 +tick,0x42429f,0xbfffed88,0,0x480600,0,0x2aacb4 +tick,0x48063d,0xbfffec7c,0,0x2d0f7c,0,0x2aaec6 profiler,"end" diff --git a/test/mjsunit/tools/tickprocessor-test.log b/test/mjsunit/tools/tickprocessor-test.log index 80e7ec1a..db8be79f 100644 --- a/test/mjsunit/tools/tickprocessor-test.log +++ b/test/mjsunit/tools/tickprocessor-test.log @@ -9,17 +9,17 @@ code-creation,LazyCompile,0xf541d120,145,"exp native math.js:41" function-creation,0xf441d280,0xf541d120 code-creation,LoadIC,0xf541d280,117,"j" code-creation,LoadIC,0xf541d360,63,"i" -tick,0x80f82d1,0xffdfe880,0,0,0xf541ce5c -tick,0x80f89a1,0xffdfecf0,0,0,0xf541ce5c -tick,0x8123b5c,0xffdff1a0,0,0,0xf541d1a1,0xf541ceea -tick,0x8123b65,0xffdff1a0,0,0,0xf541d1a1,0xf541ceea -tick,0xf541d2be,0xffdff1e4,0,0 -tick,0xf541d320,0xffdff1dc,0,0 -tick,0xf541d384,0xffdff1d8,0,0 -tick,0xf7db94da,0xffdff0ec,0,0,0xf541d1a1,0xf541ceea -tick,0xf7db951c,0xffdff0f0,0,0,0xf541d1a1,0xf541ceea -tick,0xf7dbc508,0xffdff14c,0,0,0xf541d1a1,0xf541ceea -tick,0xf7dbff21,0xffdff198,0,0,0xf541d1a1,0xf541ceea -tick,0xf7edec90,0xffdff0ec,0,0,0xf541d1a1,0xf541ceea -tick,0xffffe402,0xffdff488,0,0 +tick,0x80f82d1,0xffdfe880,0,0,0,0xf541ce5c +tick,0x80f89a1,0xffdfecf0,0,0,0,0xf541ce5c +tick,0x8123b5c,0xffdff1a0,0,0,0,0xf541d1a1,0xf541ceea +tick,0x8123b65,0xffdff1a0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf541d2be,0xffdff1e4,0,0,0 +tick,0xf541d320,0xffdff1dc,0,0,0 +tick,0xf541d384,0xffdff1d8,0,0,0 +tick,0xf7db94da,0xffdff0ec,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7db951c,0xffdff0f0,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7dbc508,0xffdff14c,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7dbff21,0xffdff198,0,0,0,0xf541d1a1,0xf541ceea +tick,0xf7edec90,0xffdff0ec,0,0,0,0xf541d1a1,0xf541ceea +tick,0xffffe402,0xffdff488,0,0,0 profiler,"end" diff --git a/test/mozilla/mozilla.status b/test/mozilla/mozilla.status index 3b6a524c..b9528bd9 100644 --- a/test/mozilla/mozilla.status +++ b/test/mozilla/mozilla.status @@ -745,8 +745,6 @@ js1_5/extensions/regress-342960: FAIL_OK || TIMEOUT if $mode == debug # error message in debug mode. js1_5/extensions/regress-336410-1: FAIL_OK || TIMEOUT if ($mode == debug && $arch == x64) - - ##################### DECOMPILATION TESTS ##################### # We don't really about the outcome of running the diff --git a/test/mozilla/testcfg.py b/test/mozilla/testcfg.py index 7a6438f1..3728f790 100644 --- a/test/mozilla/testcfg.py +++ b/test/mozilla/testcfg.py @@ -92,7 +92,7 @@ class MozillaTestConfiguration(test.TestConfiguration): def __init__(self, context, root): super(MozillaTestConfiguration, self).__init__(context, root) - def ListTests(self, current_path, path, mode): + def ListTests(self, current_path, path, mode, variant_flags): tests = [] for test_dir in TEST_DIRS: current_root = join(self.root, 'data', test_dir) diff --git a/test/sputnik/testcfg.py b/test/sputnik/testcfg.py index 31e4b226..c1e3c1bb 100644 --- a/test/sputnik/testcfg.py +++ b/test/sputnik/testcfg.py @@ -81,7 +81,7 @@ class SputnikTestConfiguration(test.TestConfiguration): def __init__(self, context, root): super(SputnikTestConfiguration, self).__init__(context, root) - def ListTests(self, current_path, path, mode): + def ListTests(self, current_path, path, mode, variant_flags): # Import the sputnik test runner script as a module testroot = join(self.root, 'sputniktests') modroot = join(testroot, 'tools') diff --git a/test/test262/README b/test/test262/README new file mode 100644 index 00000000..6d9e56e7 --- /dev/null +++ b/test/test262/README @@ -0,0 +1,16 @@ +This directory contains code for binding the test262 test suite +into the v8 test harness. To use the tests check out the test262 +tests from + + http://hg.ecmascript.org/tests/test262 + +at revision 62 as 'data' in this directory. Using later version +may be possible but the tests are only known to pass (and indeed run) +with that revision. + +hg clone -r 62 http://hg.ecmascript.org/tests/test262 data + +If you do update to a newer revision you may have to change the test +harness adapter code since it uses internal functionality from the +harness that comes bundled with the tests. You will most likely also +have to update the test expectation file. diff --git a/test/test262/harness-adapt.js b/test/test262/harness-adapt.js new file mode 100644 index 00000000..b52afdba --- /dev/null +++ b/test/test262/harness-adapt.js @@ -0,0 +1,80 @@ +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function fnGlobalObject() { return (function() { return this; })(); } + +var ES5Harness = (function() { + var currentTest = {}; + var $this = this; + + function Test262Error(id, path, description, codeString, + preconditionString, result, error) { + this.id = id; + this.path = path; + this.description = description; + this.result = result; + this.error = error; + this.code = codeString; + this.pre = preconditionString; + } + + Test262Error.prototype.toString = function() { + return this.result; + } + + function registerTest(test) { + if (!(test.precondition && !test.precondition())) { + var error; + try { + var res = test.test.call($this); + } catch(e) { + print(e); + res = 'fail'; error = e; + } + var retVal = /^s/i.test(test.id) + ? (res === true || typeof res == 'undefined' ? 'pass' : 'fail') + : (res === true ? 'pass' : 'fail'); + + if (retVal != 'pass') { + throw new Test262Error( + test.id, + test.path, + test.description, + test.test.toString(), + (test.precondition !== undefined) + ? test.precondition.toString() + : '', + retVal, + error); + } + } + } + + return { + registerTest: registerTest + } +})(); diff --git a/test/test262/test262.status b/test/test262/test262.status new file mode 100644 index 00000000..bdc8b9c7 --- /dev/null +++ b/test/test262/test262.status @@ -0,0 +1,1506 @@ +# Copyright 2011 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +# +# ietestcenter tests. +# + +prefix ietestcenter + +# BUG: 7.6 - SyntaxError expected: reserved words used as Identifier +# Names in UTF8: class (class) +7.6-30: FAIL +# BUG: 7.6 - SyntaxError expected: reserved words used as Identifier +# Names in UTF8: extends (extends) +7.6-31: FAIL +# BUG: 7.6 - SyntaxError expected: reserved words used as Identifier +# Names in UTF8: \u0065\u006e\u0075\u006d (enum) +7.6-32: FAIL +# BUG: 7.6 - SyntaxError expected: reserved words used as Identifier +# Names in UTF8: \u0073uper (super) +7.6-33: FAIL +# BUG: 7.6 - SyntaxError expected: reserved words used as Identifier +# Names in UTF8: expor\u0074 (export) +7.6-35: FAIL +# BUG: 7.6 - SyntaxError expected: reserved words used as Identifier +# Names in UTF8: \u0069\u006d\u0070\u006f\u0072\u0074 (import) +7.6-36: FAIL +# Invalid test: https://bugs.ecmascript.org/show_bug.cgi?id=76 +10.4.2-2-c-1: FAIL +# BUG: 11.8.2 Greater-than Operator - Partial left to right order enforced +# when using Greater-than operator: valueOf > valueOf +11.8.2-1: FAIL +# BUG: 11.8.2 Greater-than Operator - Partial left to right order enforced +# when using Greater-than operator: valueOf > toString +11.8.2-2: FAIL +# BUG: 11.8.2 Greater-than Operator - Partial left to right order enforced +# when using Greater-than operator: toString > valueOf +11.8.2-3: FAIL +# BUG: 11.8.2 Greater-than Operator - Partial left to right order enforced +# when using Greater-than operator: toString > toString +11.8.2-4: FAIL +# BUG: 11.8.3 Less-than-or-equal Operator - Partial left to right order +# enforced when using Less-than-or-equal operator: valueOf <= valueOf +11.8.3-1: FAIL +# BUG: 11.8.3 Less-than-or-equal Operator - Partial left to right order +# enforced when using Less-than-or-equal operator: valueOf <= toString +11.8.3-2: FAIL +# BUG: 11.8.3 Less-than-or-equal Operator - Partial left to right order +# enforced when using Less-than-or-equal operator: toString <= valueOf +11.8.3-3: FAIL +# BUG: 11.8.3 Less-than-or-equal Operator - Partial left to right order +# enforced when using Less-than-or-equal operator: toString <= toString +11.8.3-4: FAIL +# BUG: 11.8.3 Less-than-or-equal Operator - Partial left to right order +# enforced when using Less-than-or-equal operator: valueOf <= valueOf +11.8.3-5: FAIL +# BUG: Global.NaN is a data property with default attribute values +15.1.1.1-0: FAIL +# BUG: Global.Infinity is a data property with default attribute values +15.1.1.2-0: FAIL +# BUG: Global.undefined is a data property with default attribute values +15.1.1.3-0: FAIL +# BUG: Object.getOwnPropertyDescriptor returns data desc (all false) +# for properties on built-ins (Global.NaN) +15.2.3.3-4-178: FAIL +# BUG: Object.getOwnPropertyDescriptor returns data desc (all false) +# for properties on built-ins (Global.Infinity) +15.2.3.3-4-179: FAIL +# BUG: Object.getOwnPropertyDescriptor returns data desc (all false) +# for properties on built-ins (Global.undefined) +15.2.3.3-4-180: FAIL +# BUG: Object.getOwnPropertyDescriptor returns data desc (all false) +# for properties on built-ins (RegExp.prototype.source) +# There is no RegExp.prototype.source +15.2.3.3-4-212: FAIL +# BUG: Object.getOwnPropertyDescriptor returns data desc (all false) +# for properties on built-ins (RegExp.prototype.global) +# There is no RegExp.prototype.global +15.2.3.3-4-213: FAIL +# BUG: Object.getOwnPropertyDescriptor returns data desc (all false) +# for properties on built-ins (RegExp.prototype.ignoreCase) +# There is no RegExp.prototype.ignoreCase +15.2.3.3-4-214: FAIL +# BUG: Object.getOwnPropertyDescriptor returns data desc (all false) +# for properties on built-ins (RegExp.prototype.multiline) +15.2.3.3-4-215: FAIL +# Bug? Object.create - 'set' property of one property in 'Properties' +# is not present (8.10.5 step 8) +# V8 throws. +15.2.3.5-4-267: FAIL +# Bug? Object.create - 'set' property of one property in 'Properties' +# is undefined (8.10.5 step 8.b) +# V8 throws. +15.2.3.5-4-292: FAIL +# Bug? Object.defineProperty - 'set' property in 'Attributes' is not +# present (8.10.5 step 8) +# V8 throws. +15.2.3.6-3-236: FAIL +# Bug? Object.defineProperty - 'set' property in 'Attributes' is own +# accessor property without a get function (8.10.5 step 8.a) +# V8 throws. +15.2.3.6-3-245: FAIL +# Bug? Object.defineProperty - 'set' property in 'Attributes' is own +# accessor property(without a get function) that overrides an inherited +# accessor property (8.10.5 step 8.a) +# V8 throws. +15.2.3.6-3-246: FAIL +# Bug? Object.defineProperty - 'set' property in 'Attributes' is an +# inherited accessor property without a get function (8.10.5 step 8.a) +# V8 throws. +15.2.3.6-3-247: FAIL +# Bug? Object.defineProperty - value of 'set' property in 'Attributes' +# is undefined (8.10.5 step 8.b) +# V8 throws. +15.2.3.6-3-261: FAIL +# Bug? Object.defineProperty - Update [[Enumerable]] attribute of 'name' +# property to true successfully when [[Enumerable]] attribute of 'name' +# is false and [[Configurable]] attribute of 'name' is true, the 'desc' +# is a generic descriptor which only contains [[Enumerable]] attribute +# as true, 'name' property is an index data property (8.12.9 step 8) +15.2.3.6-4-82-18: FAIL +# Bug? Object.defineProperty - Update [[Enumerable]] attribute of 'name' +# property to false successfully when [[Enumerable]] and [[Configurable]] +# attributes of 'name' property are true, the 'desc' is a generic +# descriptor which only contains [Enumerable]] attribute as false and +# 'name' property is an index accessor property (8.12.9 step 8) +15.2.3.6-4-82-19: FAIL +# Bug? Object.defineProperty - Update [[Enumerable]] attribute of 'name' +# property to false successfully when [[Enumerable]] and [[Configurable]] +# attributes of 'name' property are true, the 'desc' is a generic +# descriptor which contains [Enumerable]] attribute as false and +# [[Configurable]] property is true, 'name' property is an index accessor +# property (8.12.9 step 8) +15.2.3.6-4-82-20: FAIL +# Bug? Object.defineProperty - Update [[Configurable]] attribute of 'name' +# property to false successfully when [[Enumerable]] and [[Configurable]] +# attributes of 'name' property are true, the 'desc' is a generic +# descriptor which only contains [[Configurable]] attribute as false, +# 'name' property is an index accessor property (8.12.9 step 8) +15.2.3.6-4-82-21: FAIL +# Bug? Object.defineProperty - Update [[Configurable]] attribute of 'name' +# property to false successfully when [[Enumerable]] and [[Configurable]] +# attributes of 'name' property are true, the 'desc' is a generic +# descriptor which contains [[Enumerable]] attribute as true and +# [[Configurable]] attribute is false, 'name' property is an index accessor +# property (8.12.9 step 8) +15.2.3.6-4-82-22: FAIL +# Bug? Object.defineProperty - Update [[Enumerable]] and [[Configurable]] +# attributes of 'name' property to false successfully when [[Enumerable]] +# and [[Configurable]] attributes of 'name' property are true, the 'desc' +# is a generic descriptor which contains [[Enumerable]] and +# [[Configurable]] attributes as false, 'name' property is an index +# accessor property (8.12.9 step 8) +15.2.3.6-4-82-23: FAIL +# Bug? Object.defineProperty - Update [[Enumerable]] attributes of 'name' +# property to true successfully when [[Enumerable]] attribute of 'name' is +# false and [[Configurable]] attribute of 'name' is true, the 'desc' is a +# generic descriptor which only contains [[Enumerable]] attribute as true, +# 'name' property is an index accessor property (8.12.9 step 8) +15.2.3.6-4-82-24: FAIL +# Bug? Object.defineProperty - 'O' is an Array, test the length property of 'O' +# is own data property (15.4.5.1 step 1) +15.2.3.6-4-116: FAIL +# Bug? Object.defineProperty - 'O' is an Array, test the length property of 'O' +# is own data property that overrides an inherited data property (15.4.5.1 +# step 1) +15.2.3.6-4-117: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test that RangeError exception is thrown when [[Value]] field of +# 'desc' is undefined (15.4.5.1 step 3.c) +15.2.3.6-4-125: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is null (15.4.5.1 step 3.c) +15.2.3.6-4-126: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is a boolean with value false +# (15.4.5.1 step 3.c) +15.2.3.6-4-127: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is a boolean with value true +# (15.4.5.1 step 3.c) +15.2.3.6-4-128: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is not thrown when the [[Value]] field of +# 'desc' is 0 (15.4.5.1 step 3.c) +15.2.3.6-4-129: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is not thrown when the [[Value]] field of +# 'desc' is +0 (15.4.5.1 step 3.c) +15.2.3.6-4-130: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is not thrown when the [[Value]] field of +# 'desc' is -0 (15.4.5.1 step 3.c) +15.2.3.6-4-131: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is not thrown when the [[Value]] field of +# 'desc' is a positive number (15.4.5.1 step 3.c) +15.2.3.6-4-132: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is a negative number (15.4.5.1 step 3.c) +15.2.3.6-4-133: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is +Infinity (15.4.5.1 step 3.c) +15.2.3.6-4-134: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is -Infinity (15.4.5.1 step 3.c) +15.2.3.6-4-135: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is NaN (15.4.5.1 step 3.c) +15.2.3.6-4-136: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is not thrown when the [[Value]] field of +# 'desc' is a string containing a positive number (15.4.5.1 step 3.c) +15.2.3.6-4-137: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is a string containing a negative number (15.4.5.1 step 3.c) +15.2.3.6-4-138: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is a string containing a decimal number (15.4.5.1 step 3.c) +15.2.3.6-4-139: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is a string containing +Infinity (15.4.5.1 step 3.c) +15.2.3.6-4-140: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is a string containing -Infinity (15.4.5.1 step 3.c) +15.2.3.6-4-141: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is a string containing an +# exponential number (15.4.5.1 step 3.c) +15.2.3.6-4-142: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is a string containing a hex +# number (15.4.5.1 step 3.c) +15.2.3.6-4-143: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is a string containing a number +# with leading zeros (15.4.5.1 step 3.c) +15.2.3.6-4-144: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError exception is thrown when the [[Value]] field of +# 'desc' is a string which doesn't convert to a number (15.4.5.1 step 3.c) +15.2.3.6-4-145: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is an object which has an own +# toString method (15.4.5.1 step 3.c) +15.2.3.6-4-146: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is an Object which has an own +# valueOf method (15.4.5.1 step 3.c) +15.2.3.6-4-147: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is an Object which has an own +# valueOf method that returns an object and toString method that returns a +# string (15.4.5.1 step 3.c) +15.2.3.6-4-148: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is an Object which has an own +# toString and valueOf method (15.4.5.1 step 3.c) +15.2.3.6-4-149: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test TypeError is thrown when the [[Value]] field of 'desc' is an +# Object that both toString and valueOf wouldn't return primitive value +# (15.4.5.1 step 3.c) +15.2.3.6-4-150: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', and the [[Value]] field of 'desc' is an Object with an own toString +# method and an inherited valueOf method (15.4.5.1 step 3.c), test that the +# inherited valueOf method is used +15.2.3.6-4-151: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError is thrown when the [[Value]] field of 'desc' is a +# positive non-integer values (15.4.5.1 step 3.c) +15.2.3.6-4-152: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length prosperty +# of 'O', test RangeError is thrown when the [[Value]] field of 'desc' is a +# negative non-integer values (15.4.5.1 step 3.c) +15.2.3.6-4-153: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is boundary value 2^32 - 2 +# (15.4.5.1 step 3.c) +15.2.3.6-4-154: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test the [[Value]] field of 'desc' is boundary value 2^32 - 1 +# (15.4.5.1 step 3.c) +15.2.3.6-4-155: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError is thrown when the [[Value]] field of 'desc' is +# boundary value 2^32 (15.4.5.1 step 3.c) +15.2.3.6-4-156: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', test RangeError is thrown when the [[Value]] field of 'desc' is +# boundary value 2^32 + 1 (15.4.5.1 step 3.c) +15.2.3.6-4-157: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', set the [[Value]] field of 'desc' to a value greater than the +# existing value of length (15.4.5.1 step 3.f) +15.2.3.6-4-159: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', set the [[Value]] field of 'desc' to a value lesser than the +# existing value of length and test that indexes beyond the new length are +# deleted(15.4.5.1 step 3.f) +15.2.3.6-4-161: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to true after deleting properties with large index named if the +# [[Writable]] field of 'desc' is absent (15.4.5.1 step 3.h) +15.2.3.6-4-165: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to true after deleting properties with large index named if the +# [[Writable]] field of 'desc' is true (15.4.5.1 step 3.h) +15.2.3.6-4-166: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to false after deleting properties with large index named if the +# [[Writable]] field of 'desc' is false (15.4.5.1 step 3.i.ii) +15.2.3.6-4-167: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', whose writable attribute is being changed to false and the [[Value]] +# field of 'desc' is less than value of the length property and also lesser +# than an index of the array which is set to configurable:false, test that +# new length is set to a value greater than the non-deletable index by 1, +# writable attribute of length is set to false and TypeError exception is +# thrown (15.4.5.1 step 3.i.iii) +15.2.3.6-4-168: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property and also lesser than an index of the array which is set to +# configurable: false, test that new length is set to a value greater than +# the non-deletable index by 1, and TypeError is thrown (15.4.5.1 step +# 3.l.i) +15.2.3.6-4-169: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property and also lesser than an index of the array which is set to +# configurable: false, test that new length is set to a value greater than +# the non-deletable index by 1, writable attribute of length is set to +# false and TypeError exception is thrown (15.4.5.1 step 3.l.ii) +15.2.3.6-4-170: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of an inherited data +# property with large index named in 'O' can't stop deleting index named +# properties (15.4.5.1 step 3.l.ii) +15.2.3.6-4-171: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own data property with +# large index named in 'O' that overrides an inherited data property can +# stop deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.6-4-172: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own data property with +# large index named in 'O' that overrides an inherited accessor property +# can stop deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.6-4-173: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own accessor property +# with large index named in 'O' can stop deleting index named properties +# (15.4.5.1 step 3.l.ii) +15.2.3.6-4-174: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of an inherited accessor +# property with large index named in 'O' can't stop deleting index named +# properties (15.4.5.1 step 3.l.ii) +15.2.3.6-4-175: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own accessor property +# with large index named in 'O' that overrides an inherited data property +# can stop deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.6-4-176: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own accessor property +# with large index named in 'O' that overrides an inherited accessor +# property can stop deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.6-4-177: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the configurable large index named property of 'O' is +# deleted (15.4.5.1 step 3.l.ii) +15.2.3.6-4-178: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is greater than value of the length +# property, test value of the length property is same as [[Value]] +# (15.4.5.1 step 3.l.iii.1) +15.2.3.6-4-179-1: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to false at last when the [[Writable]] field of 'desc' is false and 'O' +# doesn't contain non-configurable large index named property (15.4.5.1 +# step 3.m) +15.2.3.6-4-181: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, 'name' is boundary value 2^32 - 2 (15.4.5.1 step 4.a) +15.2.3.6-4-183: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, test TypeError is thrown if the [[Writable]] attribute of the +# length property in 'O' is false and value of 'name' equals to value of +# the length property (15.4.5.1 step 4.b) +15.2.3.6-4-188: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, test TypeError is thrown if the [[Writable]] attribute of the +# length property in 'O' is false and value of 'name' is greater than value +# of the length property (15.4.5.1 step 4.b) +15.2.3.6-4-189: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, 'desc' is accessor descriptor, test updating all attribute +# values of 'name' (15.4.5.1 step 4.c) +15.2.3.6-4-209: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, 'name' is accessor property and assignment to the accessor +# property, fails to convert accessor property from accessor property to +# data property (15.4.5.1 step 4.c) +15.2.3.6-4-243-1: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, name is accessor property and 'desc' is accessor descriptor, +# test updating the [[Enumerable]] attribute value of 'name' (15.4.5.1 step +# 4.c) +15.2.3.6-4-271: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, name is accessor property and 'desc' is accessor descriptor, +# test updating the [[Configurable]] attribute value of 'name' (15.4.5.1 +# step 4.c) +15.2.3.6-4-272: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, name is accessor property and 'desc' is accessor descriptor, +# test updating multiple attribute values of 'name' (15.4.5.1 step 4.c) +15.2.3.6-4-273: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, test the length property of 'O' is set as ToUint32('name') + 1 +# if ToUint32('name') equals to value of the length property in 'O' +# (15.4.5.1 step 4.e.ii) +15.2.3.6-4-275: FAIL +# Bug? Object.defineProperty - 'O' is an Array, 'name' is an array index named +# property, test the length property of 'O' is set as ToUint32('name') + 1 +# if ToUint32('name') is greater than value of the length property in 'O' +# (15.4.5.1 step 4.e.ii) +15.2.3.6-4-276: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is own property which is defined in both +# [[ParameterMap]] of 'O' and 'O', and is deleted afterwards, and 'desc' is +# data descriptor, test 'name' is redefined in 'O' with all correct +# attribute values (10.6 [[DefineOwnProperty]] step 3) +15.2.3.6-4-289-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is own property which is defined in both +# [[ParameterMap]] of 'O' and 'O', is deleted afterwards, and 'desc' is +# accessor descriptor, test 'name' is redefined in 'O' with all correct +# attribute values (10.6 [[DefineOwnProperty]] step 3) +15.2.3.6-4-290-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is own accessor property of 'O' which is also +# defined in [[ParameterMap]] of 'O', and 'desc' is accessor descriptor, +# test updating multiple attribute values of 'name' (10.6 +# [[DefineOwnProperty]] step 3 and 5.a.i) +15.2.3.6-4-291-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object, 'name' is own +# accessor property of 'O', and 'desc' is accessor descriptor, test +# updating multiple attribute values of 'name' (10.6 [[DefineOwnProperty]] +# step 3) +15.2.3.6-4-291: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is own data property of 'O' which is also +# defined in [[ParameterMap]] of 'O', test TypeError is not thrown when +# updating the [[Value]] attribute value of 'name' which is defined as +# non-writable and configurable (10.6 [[DefineOwnProperty]] step 3 and step +# 5.b) +15.2.3.6-4-293-3: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is own accessor property of 'O' which is also +# defined in [[ParameterMap]] of 'O', test TypeError is thrown when +# updating the [[Get]] attribute value of 'name' which is defined as +# non-configurable (10.6 [[DefineOwnProperty]] step 4 and step 5a) +15.2.3.6-4-297-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is own accessor property of 'O' which is also +# defined in [[ParameterMap]] of 'O', test TypeError is thrown when +# updating the [[Set]] attribute value of 'name' which is defined as +# non-configurable (10.6 [[DefineOwnProperty]] steps 4 and 5a) +15.2.3.6-4-298-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is own accessor property of 'O' which is also +# defined in [[ParameterMap]] of 'O', test TypeError is thrown when +# updating the [[Enumerable]] attribute value of 'name' which is defined as +# non-configurable (10.6 [[DefineOwnProperty]] steps 4 and 5a) +15.2.3.6-4-299-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is an index named property of 'O', and 'desc' +# is data descriptor, test 'name' is defined in 'O' with all correct +# attribute values (10.6 [[DefineOwnProperty]] step 3) +15.2.3.6-4-301-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object of a function that has +# formal parameters, 'name' is an index named property of 'O' but not +# defined in [[ParameterMap]] of 'O', and 'desc' is accessor descriptor, +# test 'name' is defined in 'O' with all correct attribute values (10.6 +# [[DefineOwnProperty]] step 3 and step 5a) +15.2.3.6-4-302-1: FAIL +# Bug? Object.defineProperty - 'O' is an Arguments object, 'name' is an index +# named accessor property of 'O' but not defined in [[ParameterMap]] of +# 'O', and 'desc' is accessor descriptor, test updating multiple attribute +# values of 'name' (10.6 [[DefineOwnProperty]] step 3) +15.2.3.6-4-303: FAIL +# Bug? ES5 Attributes - [[Value]] attribute of data property is the activex host +# object +15.2.3.6-4-401: FAIL +# Bug? ES5 Attributes - Failed to add a property to an object when the object's +# object has a property with same name and [[Writable]] attribute is set to +# false (Number instance) +15.2.3.6-4-405: FAIL +# Bug? ES5 Attributes - Failed to add a property to an object when the object's +# prototype has a property with the same name and [[Writable]] set to false +# (JSON) +15.2.3.6-4-410: FAIL +# Bug? ES5 Attributes - Failed to add properties to an object when the object's +# prototype has properties with the same name and [[Writable]] set to false +# (Object.create) +15.2.3.6-4-415: FAIL +# Bug? ES5 Attributes - Failed to add a property to an object when the object's +# prototype has a property with the same name and [[Writable]] set to +# false(Function.prototype.bind) +15.2.3.6-4-420: FAIL +# Bug? ES5 Attributes - Fail to add property into object (Number instance) +15.2.3.6-4-581: FAIL +# Bug? ES5 Attributes - Fail to update value of property into of [[Proptotype]] +# internal property (JSON) +15.2.3.6-4-586: FAIL +# Bug? ES5 Attributes - Fail to update value of property of [[Proptotype]] +# internal property (Object.create) +15.2.3.6-4-591: FAIL +# Bug? ES5 Attributes - Fail to update value of property into of [[Proptotype]] +# internal property (Function.prototype.bind) +15.2.3.6-4-596: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.indexOf are correct +15.2.3.6-4-612: FAIL +# Bug? ES5 Attributes - all attributes in Object.lastIndexOf are correct +15.2.3.6-4-613: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.every are correct +15.2.3.6-4-614: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.some are correct +15.2.3.6-4-615: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.forEach are correct +15.2.3.6-4-616: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.map are correct +15.2.3.6-4-617: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.filter are correct +15.2.3.6-4-618: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.reduce are correct +15.2.3.6-4-619: FAIL +# Bug? ES5 Attributes - all attributes in Array.prototype.reduceRight are +# correct +15.2.3.6-4-620: FAIL +# Bug? ES5 Attributes - all attributes in String.prototype.trim are correct +15.2.3.6-4-621: FAIL +# Bug? ES5 Attributes - all attributes in Date.prototype.toISOString are correct +15.2.3.6-4-623: FAIL +# Bug? ES5 Attributes - all attributes in Date.prototype.toJSON are correct +15.2.3.6-4-624: FAIL +# Bug? Object.defineProperties - argument 'Properties' is an Error object +# props.description = obj1; +15.2.3.7-2-15: FAIL +# Bug? Object.defineProperties - 'Properties' is an Error object which +# implements its own [[Get]] method to get enumerable own property +# props.description = obj1; +15.2.3.7-5-a-16: FAIL +# Bug? Object.defineProperties - 'set' property of 'descObj' is not present +# (8.10.5 step 8) +15.2.3.7-5-b-227: FAIL +# Bug? Object.defineProperties - 'descObj' is an Error object which implements +# its own [[Get]] method to get 'set' property (8.10.5 step 8.a) +# descObj.description = { value: 11 }; +15.2.3.7-5-b-248: FAIL +# Bug? Object.defineProperties - 'O' is an Array, test the length property of +# 'O' is own data property (15.4.5.1 step 1) +15.2.3.7-6-a-112: FAIL +# Bug? Object.defineProperties - 'O' is an Array, test the length property of +# 'O' is own data property that overrides an inherited data property +# (15.4.5.1 step 1) +15.2.3.7-6-a-113: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', test RangeError is thrown when setting the [[Value]] field of 'desc' +# to undefined (15.4.5.1 step 3.c) +15.2.3.7-6-a-121: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', test setting the [[Value]] field of 'desc' to null actuall is set to +# 0 (15.4.5.1 step 3.c) +15.2.3.7-6-a-122: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a boolean with value false +# (15.4.5.1 step 3.c) +15.2.3.7-6-a-123: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a boolean with value true +# (15.4.5.1 step 3.c) +15.2.3.7-6-a-124: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is 0 (15.4.5.1 step 3.c) +15.2.3.7-6-a-125: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is +0 (15.4.5.1 step 3.c) +15.2.3.7-6-a-126: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is -0 (15.4.5.1 step 3.c) +15.2.3.7-6-a-127: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is positive number (15.4.5.1 +# step 3.c) +15.2.3.7-6-a-128: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is negative number (15.4.5.1 +# step 3.c) +15.2.3.7-6-a-129: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is +Infinity (15.4.5.1 step +# 3.c) +15.2.3.7-6-a-130: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is -Infinity (15.4.5.1 step +# 3.c) +15.2.3.7-6-a-131: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is NaN (15.4.5.1 step 3.c) +15.2.3.7-6-a-132: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing a +# positive number (15.4.5.1 step 3.c) +15.2.3.7-6-a-133: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing a +# negative number (15.4.5.1 step 3.c) +15.2.3.7-6-a-134: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing a +# decimal number (15.4.5.1 step 3.c) +15.2.3.7-6-a-135: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing +# +Infinity (15.4.5.1 step 3.c) +15.2.3.7-6-a-136: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing +# -Infinity (15.4.5.1 step 3.c) +15.2.3.7-6-a-137: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing an +# exponential number (15.4.5.1 step 3.c) +15.2.3.7-6-a-138: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing an hex +# number (15.4.5.1 step 3.c) +15.2.3.7-6-a-139: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is a string containing an +# leading zero number (15.4.5.1 step 3.c) +15.2.3.7-6-a-140: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', test the [[Value]] field of 'desc' is a string which doesn't convert +# to a number (15.4.5.1 step 3.c) +15.2.3.7-6-a-141: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', test the [[Value]] field of 'desc' is an Object which has an own +# toString method (15.4.5.1 step 3.c) +15.2.3.7-6-a-142: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is an Object which has an own +# valueOf method (15.4.5.1 step 3.c) +15.2.3.7-6-a-143: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is an Object which has an own +# valueOf method that returns an object and toString method that returns a +# string (15.4.5.1 step 3.c) +15.2.3.7-6-a-144: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is an Object which has an own +# toString and valueOf method (15.4.5.1 step 3.c) +15.2.3.7-6-a-145: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test TypeError is thrown when the [[Value]] field of 'desc' is an +# Object that both toString and valueOf wouldn't return primitive value +# (15.4.5.1 step 3.c) +15.2.3.7-6-a-146: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test using inherited valueOf method when the [[Value]] field of +# 'desc' is an Objec with an own toString and inherited valueOf methods +# (15.4.5.1 step 3.c) +15.2.3.7-6-a-147: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test RangeError is thrown when the [[Value]] field of 'desc' is +# positive non-integer values (15.4.5.1 step 3.c) +15.2.3.7-6-a-148: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test RangeError is thrown when the [[Value]] field of 'desc' is +# negative non-integer values (15.4.5.1 step 3.c) +15.2.3.7-6-a-149: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is boundary value 2^32 - 2 +# (15.4.5.1 step 3.c) +15.2.3.7-6-a-150: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test the [[Value]] field of 'desc' is boundary value 2^32 - 1 +# (15.4.5.1 step 3.c) +15.2.3.7-6-a-151: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test RangeError is thrown when the [[Value]] field of 'desc' is +# boundary value 2^32 (15.4.5.1 step 3.c) +15.2.3.7-6-a-152: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'name' is the length property +# of 'O', test RangeError is thrown when the [[Value]] field of 'desc' is +# boundary value 2^32 + 1 (15.4.5.1 step 3.c) +15.2.3.7-6-a-153: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', test the [[Value]] field of 'desc' which is greater than value of +# the length property is defined into 'O' without deleting any property +# with large index named (15.4.5.1 step 3.f) +15.2.3.7-6-a-155: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', test the [[Value]] field of 'desc' which is less than value of the +# length property is defined into 'O' with deleting properties with large +# index named (15.4.5.1 step 3.f) +15.2.3.7-6-a-157: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to true at last after deleting properties with large index named if the +# [[Writable]] field of 'desc' is absent (15.4.5.1 step 3.h) +15.2.3.7-6-a-161: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to true at last after deleting properties with large index named if the +# [[Writable]] field of 'desc' is true (15.4.5.1 step 3.h) +15.2.3.7-6-a-162: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to false at last after deleting properties with large index named if the +# [[Writable]] field of 'desc' is false (15.4.5.1 step 3.i.ii) +15.2.3.7-6-a-163: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property in 'O' +# is set as true before deleting properties with large index named +# (15.4.5.1 step 3.i.iii) +15.2.3.7-6-a-164: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the length property is decreased by 1 (15.4.5.1 step +# 3.l.i) +15.2.3.7-6-a-165: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own data property with +# large index named in 'O' can stop deleting index named properties +# (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-166: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of inherited data property +# with large index named in 'O' can't stop deleting index named properties +# (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-167: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own data property with +# large index named in 'O' that overrides inherited data property can stop +# deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-168: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own data property with +# large index named in 'O' that overrides inherited accessor property can +# stop deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-169: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own accessor property +# with large index named in 'O' can stop deleting index named properties +# (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-170: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of inherited accessor +# property with large index named in 'O' can't stop deleting index named +# properties (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-171: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own accessor property +# with large index named in 'O' that overrides inherited data property can +# stop deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-172: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Configurable]] attribute of own accessor property +# with large index named in 'O' that overrides inherited accessor property +# can stop deleting index named properties (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-173: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the configurable large index named property of 'O' can be +# deleted (15.4.5.1 step 3.l.ii) +15.2.3.7-6-a-174: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test value of the length property is set to the last +# non-configurable index named property of 'O' plus 1 (15.4.5.1 step +# 3.l.iii.1) +15.2.3.7-6-a-175: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to false at last when the [[Writable]] field of 'desc' is false and 'O' +# contains non-configurable large index named property (15.4.5.1 step +# 3.l.iii.2) +15.2.3.7-6-a-176: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is the length property of +# 'O', the [[Value]] field of 'desc' is less than value of the length +# property, test the [[Writable]] attribute of the length property is set +# to false at last when the [[Writable]] field of 'desc' is false and 'O' +# doesn't contain non-configurable large index named property (15.4.5.1 +# step 3.m) +15.2.3.7-6-a-177: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is an array index named +# property, 'P' is boundary value 2^32 - 2 (15.4.5.1 step 4.a) +15.2.3.7-6-a-179: FAIL +# Bug? Object.defineProperties - TypeError is thrown if 'O' is an Array, 'P' is +# an array index named property,[[Writable]] attribute of the length +# property in 'O' is false, value of 'P' is equal to value of the length +# property in 'O' (15.4.5.1 step 4.b) +15.2.3.7-6-a-184: FAIL +# Bug? Object.defineProperties - TypeError is thrown if 'O' is an Array, 'P' is +# an array index named property,[[Writable]] attribute of the length +# property in 'O' is false, value of 'P' is bigger than value of the length +# property in 'O' (15.4.5.1 step 4.b) +15.2.3.7-6-a-185: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is an array index named +# property, 'desc' is accessor descriptor, test updating all attribute +# values of 'P' (15.4.5.1 step 4.c) +15.2.3.7-6-a-205: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is an array index named +# property that already exists on 'O' is accessor property and 'desc' is +# accessor descriptor, test updating the [[Enumerable]] attribute value of +# 'P' (15.4.5.1 step 4.c) +15.2.3.7-6-a-260: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is an array index named +# property that already exists on 'O' is accessor property and 'desc' is +# accessor descriptor, test updating the [[Configurable]] attribute value +# of 'P' (15.4.5.1 step 4.c) +15.2.3.7-6-a-261: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is an array index named +# property that already exists on 'O' is accessor property and 'desc' is +# accessor descriptor, test updating multiple attribute values of 'P' +# (15.4.5.1 step 4.c) +15.2.3.7-6-a-262: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is an array index named +# property, test the length property of 'O' is set as ToUint32('P') + 1 if +# ToUint32('P') equals to value of the length property in 'O' (15.4.5.1 +# step 4.e.ii) +15.2.3.7-6-a-264: FAIL +# Bug? Object.defineProperties - 'O' is an Array, 'P' is an array index named +# property, test the length property of 'O' is set as ToUint32('P') + 1 if +# ToUint32('P') is greater than value of the length property in 'O' +# (15.4.5.1 step 4.e.ii) +15.2.3.7-6-a-265: FAIL +# Bug? Object.defineProperties - 'O' is an Arguments object, 'P' is own accessor +# property of 'O' which is also defined in [[ParameterMap]] of 'O', and +# 'desc' is accessor descriptor, test updating multiple attribute values of +# 'P' (10.6 [[DefineOwnProperty]] step 3) +15.2.3.7-6-a-280: FAIL +# Bug? Object.defineProperties - 'O' is an Arguments object, 'P' is an array +# index named accessor property of 'O' but not defined in [[ParameterMap]] +# of 'O', and 'desc' is accessor descriptor, test updating multiple +# attribute values of 'P' (10.6 [[DefineOwnProperty]] step 3) +15.2.3.7-6-a-292: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into the +# returned object +15.2.3.10-3-2: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into a +# Function object +15.2.3.10-3-3: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into an +# Array object +15.2.3.10-3-4: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into a +# String object +15.2.3.10-3-5-1: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into a +# Boolean object +15.2.3.10-3-6: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into a +# Number object +15.2.3.10-3-7: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into a Date +# object +15.2.3.10-3-8: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into a +# RegExp object +15.2.3.10-3-9: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into an +# Error object +15.2.3.10-3-10: FAIL +# Bug? Object.preventExtensions - indexed properties cannot be added into an +# Arguments object +15.2.3.10-3-11: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into the +# returned object +15.2.3.10-3-12: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into a +# Function object +15.2.3.10-3-13: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into an Array +# object +15.2.3.10-3-14: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into a String +# object +15.2.3.10-3-15: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into a +# Boolean object +15.2.3.10-3-16: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into a Number +# object +15.2.3.10-3-17: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into a Date +# object +15.2.3.10-3-18: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into a RegExp +# object +15.2.3.10-3-19: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into an Error +# object +15.2.3.10-3-20: FAIL +# Bug? Object.preventExtensions - named properties cannot be added into an +# Arguments object +15.2.3.10-3-21: FAIL +# Bug? Object.prototype.toString - '[object Undefined]' will be returned when +# 'this' value is undefined +15.2.4.2-1-1: FAIL +# Bug? Object.prototype.toString - '[object Undefined]' will be returned when +# 'this' value is undefined +15.2.4.2-1-2: FAIL +# Bug? Object.prototype.toString - '[object Null]' will be returned when 'this' +# value is null +15.2.4.2-2-1: FAIL +# Bug? Object.prototype.toString - '[object Null]' will be returned when 'this' +# value is null +15.2.4.2-2-2: FAIL +# Bug? Function.prototype.bind - [[Get]] attribute of 'caller' property in 'F' +# is thrower +15.3.4.5-20-2: FAIL +# Bug? Function.prototype.bind - [[Set]] attribute of 'caller' property in 'F' +# is thrower +15.3.4.5-20-3: FAIL +# Bug? Function.prototype.bind - [[Get]] attribute of 'arguments' property in +# 'F' is thrower +15.3.4.5-21-2: FAIL +# Bug? Function.prototype.bind - [[Set]] attribute of 'arguments' property in +# 'F' is thrower +15.3.4.5-21-3: FAIL +# Bug? Array.prototype.concat will concat an Array when index property +# (read-only) exists in Array.prototype (Step 5.c.i) +15.4.4.4-5-c-i-1: FAIL +# Bug? Array.prototype.indexOf applied to undefined throws a TypeError +15.4.4.14-1-1: FAIL +# Bug? Array.prototype.indexOf applied to null throws a TypeError +15.4.4.14-1-2: FAIL +# Bug? Array.prototype.indexOf - side effects produced by step 1 are visible +# when an exception occurs +15.4.4.14-5-28: FAIL +# Bug? Array.prototype.indexOf - decreasing length of array does not delete +# non-configurable properties +15.4.4.14-9-a-19: FAIL +# Bug? Array.prototype.indexOf - element to be retrieved is own accessor +# property that overrides an inherited data property on an Array +15.4.4.14-9-b-i-11: FAIL +# Bug? Array.prototype.indexOf - element to be retrieved is own accessor +# property that overrides an inherited accessor property on an Array +15.4.4.14-9-b-i-13: FAIL +# Bug? Array.prototype.indexOf - element to be retrieved is own accessor +# property without a get function on an Array +15.4.4.14-9-b-i-17: FAIL +# Bug? Array.prototype.indexOf - element to be retrieved is own accessor +# property without a get function that overrides an inherited accessor +# property on an Array +15.4.4.14-9-b-i-19: FAIL +# Bug? Array.prototype.indexOf - side-effects are visible in subsequent +# iterations on an Array +15.4.4.14-9-b-i-28: FAIL +# Bug? Array.prototype.indexOf - terminates iteration on unhandled exception on +# an Array +15.4.4.14-9-b-i-30: FAIL +# Bug? Array.prototype.lastIndexOf applied to undefined throws a TypeError +15.4.4.15-1-1: FAIL +# Bug? Array.prototype.lastIndexOf applied to null throws a TypeError +15.4.4.15-1-2: FAIL +# Bug? Array.prototype.lastIndexOf - side effects produced by step 1 are visible +# when an exception occurs +15.4.4.15-5-28: FAIL +# Bug? Array.prototype.lastIndexOf - deleting property of prototype causes +# prototype index property not to be visited on an Array +15.4.4.15-8-a-14: FAIL +# Bug? Array.prototype.lastIndexOf - decreasing length of array does not delete +# non-configurable properties +15.4.4.15-8-a-19: FAIL +# Bug? Array.prototype.lastIndexOf - element to be retrieved is own accessor +# property that overrides an inherited data property on an Array +15.4.4.15-8-b-i-11: FAIL +# Bug? Array.prototype.lastIndexOf - element to be retrieved is own accessor +# property that overrides an inherited accessor property on an Array +15.4.4.15-8-b-i-13: FAIL +# Bug? Array.prototype.lastIndexOf - element to be retrieved is own accessor +# property without a get function on an Array +15.4.4.15-8-b-i-17: FAIL +# Bug? Array.prototype.lastIndexOf - side-effects are visible in subsequent +# iterations on an Array +15.4.4.15-8-b-i-28: FAIL +# Bug? Array.prototype.lastIndexOf terminates iteration on unhandled exception +# on an Array +15.4.4.15-8-b-i-30: FAIL +# Bug? Array.prototype.every - side effects produced by step 2 are visible when +# an exception occurs +15.4.4.16-4-8: FAIL +# Bug? Array.prototype.every - side effects produced by step 3 are visible when +# an exception occurs +15.4.4.16-4-9: FAIL +# Bug? Array.prototype.every - the exception is not thrown if exception was +# thrown by step 2 +15.4.4.16-4-10: FAIL +# Bug? Array.prototype.every - the exception is not thrown if exception was +# thrown by step 3 +15.4.4.16-4-11: FAIL +# Bug? Array.prototype.every - calling with no callbackfn is the same as passing +# undefined for callbackfn +15.4.4.16-4-15: FAIL +# Bug? Array.prototype.every - decreasing length of array does not delete +# non-configurable properties +15.4.4.16-7-b-16: FAIL +# Bug? Array.prototype.every - element to be retrieved is own accessor property +# on an Array +15.4.4.16-7-c-i-10: FAIL +# Bug? Array.prototype.every - element to be retrieved is own accessor property +# that overrides an inherited data property on an Array +15.4.4.16-7-c-i-12: FAIL +# Bug? Array.prototype.every - element to be retrieved is own accessor property +# that overrides an inherited accessor property on an Array +15.4.4.16-7-c-i-14: FAIL +# Bug? Array.prototype.every - element to be retrieved is own accessor property +# without a get function on an Array +15.4.4.16-7-c-i-18: FAIL +# Bug? Array.prototype.every - element to be retrieved is own accessor property +# without a get function that overrides an inherited accessor property on +# an Array +15.4.4.16-7-c-i-20: FAIL +# Bug? Array.prototype.every - element changed by getter on previous iterations +# is observed on an Array +15.4.4.16-7-c-i-28: FAIL +# Bug? Array.prototype.some - side effects produced by step 2 are visible when +# an exception occurs +15.4.4.17-4-8: FAIL +# Bug? Array.prototype.some - side effects produced by step 3 are visible when +# an exception occurs +15.4.4.17-4-9: FAIL +# Bug? Array.prototype.some - the exception is not thrown if exception was +# thrown by step 2 +15.4.4.17-4-10: FAIL +# Bug? Array.prototype.some - the exception is not thrown if exception was +# thrown by step 3 +15.4.4.17-4-11: FAIL +# Bug? Array.prototype.some - calling with no callbackfn is the same as passing +# undefined for callbackfn +15.4.4.17-4-15: FAIL +# Bug? Array.prototype.some - decreasing length of array does not delete +# non-configurable properties +15.4.4.17-7-b-16: FAIL +# Bug? Array.prototype.some - element to be retrieved is own accessor property +# on an Array +15.4.4.17-7-c-i-10: FAIL +# Bug? Array.prototype.some - element to be retrieved is own accessor property +# that overrides an inherited data property on an Array +15.4.4.17-7-c-i-12: FAIL +# Bug? Array.prototype.some - element to be retrieved is own accessor property +# that overrides an inherited accessor property on an Array +15.4.4.17-7-c-i-14: FAIL +# Bug? Array.prototype.some - element to be retrieved is own accessor property +# without a get function on an Array +15.4.4.17-7-c-i-18: FAIL +# Bug? Array.prototype.some - element to be retrieved is own accessor property +# without a get function that overrides an inherited accessor property on +# an Array +15.4.4.17-7-c-i-20: FAIL +# Bug? Array.prototype.some - element changed by getter on previous iterations +# is observed on an Array +15.4.4.17-7-c-i-28: FAIL +# Bug? Array.prototype.forEach - side effects produced by step 2 are visible +# when an exception occurs +15.4.4.18-4-8: FAIL +# Bug? Array.prototype.forEach - side effects produced by step 3 are visible +# when an exception occurs +15.4.4.18-4-9: FAIL +# Bug? Array.prototype.forEach - the exception is not thrown if exception was +# thrown by step 2 +15.4.4.18-4-10: FAIL +# Bug? Array.prototype.forEach - the exception is not thrown if exception was +# thrown by step 3 +15.4.4.18-4-11: FAIL +# Bug? Array.prototype.forEach - calling with no callbackfn is the same as +# passing undefined for callbackfn +15.4.4.18-4-15: FAIL +# Bug? Array.prototype.forEach - decreasing length of array does not delete +# non-configurable properties +15.4.4.18-7-b-16: FAIL +# Bug? Array.prototype.forEach - element to be retrieved is own accessor +# property on an Array +15.4.4.18-7-c-i-10: FAIL +# Bug? Array.prototype.forEach - element to be retrieved is own accessor +# property that overrides an inherited data property on an Array +15.4.4.18-7-c-i-12: FAIL +# Bug? Array.prototype.forEach - element to be retrieved is own accessor +# property that overrides an inherited accessor property on an Array +15.4.4.18-7-c-i-14: FAIL +# Bug? Array.prototype.forEach - element to be retrieved is own accessor +# property without a get function on an Array +15.4.4.18-7-c-i-18: FAIL +# Bug? Array.prototype.forEach - element to be retrieved is own accessor +# property without a get function that overrides an inherited accessor +# property on an Array +15.4.4.18-7-c-i-20: FAIL +# Bug? Array.prototype.forEach - element changed by getter on previous +# iterations is observed on an Array +15.4.4.18-7-c-i-28: FAIL +# Bug? Array.prototype.map - applied to Array-like object, 'length' is an own +# data property that overrides an inherited accessor property +15.4.4.19-2-5: FAIL +# Bug? Array.prototype.map - Side effects produced by step 2 are visible when an +# exception occurs +15.4.4.19-4-8: FAIL +# Bug? Array.prototype.map - Side effects produced by step 3 are visible when an +# exception occurs +15.4.4.19-4-9: FAIL +# Bug? Array.prototype.map - the exception is not thrown if exception was thrown +# by step 2 +15.4.4.19-4-10: FAIL +# Bug? Array.prototype.map - the exception is not thrown if exception was thrown +# by step 3 +15.4.4.19-4-11: FAIL +# Bug? Array.prototype.map - calling with no callbackfn is the same as passing +# undefined for callbackfn +15.4.4.19-4-15: FAIL +# Bug? Array.prototype.map - decreasing length of array does not delete +# non-configurable properties +15.4.4.19-8-b-16: FAIL +# Bug? Array.prototype.map - element to be retrieved is own accessor property on +# an Array +15.4.4.19-8-c-i-10: FAIL +# Bug? Array.prototype.map - element to be retrieved is own accessor property +# that overrides an inherited data property on an Array +15.4.4.19-8-c-i-12: FAIL +# Bug? Array.prototype.map - element to be retrieved is own accessor property +# that overrides an inherited accessor property on an Array +15.4.4.19-8-c-i-14: FAIL +# Bug? Array.prototype.map - element to be retrieved is own accessor property +# without a get function on an Array +15.4.4.19-8-c-i-18: FAIL +# Bug? Array.prototype.map - element to be retrieved is own accessor property +# without a get function that overrides an inherited accessor property on +# an Array +15.4.4.19-8-c-i-19: FAIL +# Bug? Array.prototype.map - element changed by getter on previous iterations is +# observed on an Array +15.4.4.19-8-c-i-28: FAIL +# Bug? Array.prototype.filter - value of 'length' is a number (value is +# negative) +15.4.4.20-3-7: FAIL +# Bug? Array.prototype.filter - value of 'length' is a number (value is +# Infinity) +# V8 timeout +15.4.4.20-3-8: SKIP +# Bug? Array.prototype.filter - 'length' is a string containing a negative +# number +15.4.4.20-3-12: FAIL +# Bug? Array.prototype.filter - 'length' is a string containing a decimal number +15.4.4.20-3-13: FAIL +# Bug? Array.prototype.filter - 'length' is a string containing +/-Infinity +15.4.4.20-3-14: SKIP +# Bug? Array.prototype.filter - value of 'length' is a positive non-integer, +# ensure truncation occurs in the proper direction +# V8 timeout +15.4.4.20-3-24: FAIL +# Bug? Array.prototype.filter - value of 'length' is a negative non-integer, +# ensure truncation occurs in the proper direction +15.4.4.20-3-25: FAIL +# Bug? Array.prototype.filter - value of 'length' is boundary value (2^32) +# V8 timeout +15.4.4.20-3-28: SKIP +# Bug? Array.prototype.filter - value of 'length' is boundary value (2^32 + 1) +# V8 timeout +15.4.4.20-3-29: SKIP +# Bug? Array.prototype.filter - side effects produced by step 2 are visible when +# an exception occurs +15.4.4.20-4-8: FAIL +# Bug? Array.prototype.filter - side effects produced by step 3 are visible when +# an exception occurs +15.4.4.20-4-9: FAIL +# Bug? Array.prototype.filter - the exception is not thrown if exception was +# thrown by step 2 +15.4.4.20-4-10: FAIL +# Bug? Array.prototype.filter - the exception is not thrown if exception was +# thrown by step 3 +15.4.4.20-4-11: FAIL +# Bug? Array.prototype.filter - calling with no callbackfn is the same as +# passing undefined for callbackfn +15.4.4.20-4-15: FAIL +# Bug? Array.prototype.filter - properties can be added to prototype after +# current position are visited on an Array-like object +15.4.4.20-9-b-6: FAIL +# Bug? Array.prototype.filter - properties can be added to prototype after +# current position are visited on an Array +15.4.4.20-9-b-7: FAIL +# Bug? Array.prototype.filter - decreasing length of array does not delete +# non-configurable properties +15.4.4.20-9-b-16: FAIL +# Bug? Array.prototype.filter - element to be retrieved is own data property +# that overrides an inherited accessor property on an Array +15.4.4.20-9-c-i-6: FAIL +# Bug? Array.prototype.filter - element to be retrieved is own accessor property +# on an Array +15.4.4.20-9-c-i-10: FAIL +# Bug? Array.prototype.filter - element to be retrieved is own accessor property +# that overrides an inherited data property on an Array +15.4.4.20-9-c-i-12: FAIL +# Bug? Array.prototype.filter - element to be retrieved is own accessor property +# that overrides an inherited accessor property on an Array +15.4.4.20-9-c-i-14: FAIL +# Bug? Array.prototype.filter - element to be retrieved is inherited accessor +# property on an Array +15.4.4.20-9-c-i-16: FAIL +# Bug? Array.prototype.filter - element to be retrieved is own accessor property +# without a get function on an Array +15.4.4.20-9-c-i-18: FAIL +# Bug? Array.prototype.filter - element to be retrieved is own accessor property +# without a get function that overrides an inherited accessor property on +# an Array +15.4.4.20-9-c-i-20: FAIL +# Bug? Array.prototype.filter - element to be retrieved is inherited accessor +# property without a get function on an Array +15.4.4.20-9-c-i-22: FAIL +# Bug? Array.prototype.filter - element changed by getter on previous iterations +# is observed on an Array +15.4.4.20-9-c-i-28: FAIL +# Bug? Array.prototype.reduce - value of 'length' is a number (value is +# negative) +15.4.4.21-3-7: FAIL +# Bug? Array.prototype.reduce - value of 'length' is a number (value is +# Infinity) +# V8 timeout. +15.4.4.21-3-8: SKIP +# Bug? Array.prototype.reduce - 'length' is a string containing a negative +# number +15.4.4.21-3-12: FAIL +# Bug? Array.prototype.reduce - 'length' is a string containing a decimal number +15.4.4.21-3-13: FAIL +# Bug? Array.prototype.reduce - 'length' is a string containing +/-Infinity +# V8 timeout. +15.4.4.21-3-14: SKIP +# Bug? Array.prototype.reduce - value of 'length' is a positive non-integer, +# ensure truncation occurs in the proper direction +15.4.4.21-3-24: FAIL +# Bug? Array.prototype.reduce - value of 'length' is a negative non-integer, +# ensure truncation occurs in the proper direction +15.4.4.21-3-25: FAIL +# Bug? Array.prototype.reduce - value of 'length' is boundary value (2^32) +# V8 timeout. +15.4.4.21-3-28: SKIP +# Bug? Array.prototype.reduce - value of 'length' is boundary value (2^32 + 1) +# V8 timeout. +15.4.4.21-3-29: SKIP +# Bug? Array.prototype.reduce - side effects produced by step 2 are visible when +# an exception occurs +15.4.4.21-4-8: FAIL +# Bug? Array.prototype.reduce - side effects produced by step 3 are visible when +# an exception occurs +15.4.4.21-4-9: FAIL +# Bug? Array.prototype.reduce - the exception is not thrown if exception was +# thrown by step 2 +15.4.4.21-4-10: FAIL +# Bug? Array.prototype.reduce - the exception is not thrown if exception was +# thrown by step 3 +15.4.4.21-4-11: FAIL +# Bug? Array.prototype.reduce - calling with no callbackfn is the same as +# passing undefined for callbackfn +15.4.4.21-4-15: FAIL +# Bug? Array.prototype.reduce - decreasing length of array in step 8 does not +# delete non-configurable properties +15.4.4.21-9-b-16: FAIL +# Bug? Array.prototype.reduce - decreasing length of array does not delete +# non-configurable properties +15.4.4.21-9-b-29: FAIL +# Bug? Array.prototype.reduceRight - value of 'length' is a number (value is +# negative) +15.4.4.22-3-7: FAIL +# Bug? Array.prototype.reduceRight - value of 'length' is a number (value is +# Infinity) +# V8 timeout. +15.4.4.22-3-8: SKIP +# Bug? Array.prototype.reduceRight - value of 'length' is a string containing a +# negative number +15.4.4.22-3-12: FAIL +# Bug? Array.prototype.reduceRight - value of 'length' is a string containing a +# decimal number +15.4.4.22-3-13: FAIL +# Bug? Array.prototype.reduceRight - value of 'length' is a string containing +# +/-Infinity +# V8 timeout. +15.4.4.22-3-14: SKIP +# Bug? Array.prototype.reduceRight - value of 'length' is a positive +# non-integer, ensure truncation occurs in the proper direction +15.4.4.22-3-24: FAIL +# Bug? Array.prototype.reduceRight - value of 'length' is a negative +# non-integer, ensure truncation occurs in the proper direction +15.4.4.22-3-25: FAIL +# Bug? Array.prototype.reduceRight - value of 'length' is boundary value (2^32) +# V8 timeout. +15.4.4.22-3-28: SKIP +# Bug? Array.prototype.reduceRight - value of 'length' is boundary value (2^32 + +# 1) +# V8 timeout. +15.4.4.22-3-29: SKIP +# Bug? Array.prototype.reduceRight - side effects produced by step 2 are visible +# when an exception occurs +15.4.4.22-4-8: FAIL +# Bug? Array.prototype.reduceRight - side effects produced by step 3 are visible +# when an exception occurs +15.4.4.22-4-9: FAIL +# Bug? Array.prototype.reduceRight - the exception is not thrown if exception +# was thrown by step 2 +15.4.4.22-4-10: FAIL +# Bug? Array.prototype.reduceRight - the exception is not thrown if exception +# was thrown by step 3 +15.4.4.22-4-11: FAIL +# Bug? Array.prototype.reduceRight - calling with no callbackfn is the same as +# passing undefined for callbackfn +15.4.4.22-4-15: FAIL +# Bug? Array.prototype.reduceRight - element to be retrieved is own accessor +# property that overrides an inherited data property on an Array +15.4.4.22-8-b-iii-1-12: FAIL +# Bug? Array.prototype.reduceRight - element to be retrieved is own accessor +# property without a get function on an Array +15.4.4.22-8-b-iii-1-18: FAIL +# Bug? Array.prototype.reduceRight - element to be retrieved is own accessor +# property without a get function that overrides an inherited accessor +# property on an Array +15.4.4.22-8-b-iii-1-20: FAIL +# Bug? Array.prototype.reduceRight - element changed by getter on current +# iteration is observed in subsequent iterations on an Array +15.4.4.22-8-b-iii-1-30: FAIL +# Bug? Array.prototype.reduceRight - Exception in getter terminate iteration on +# an Array +15.4.4.22-8-b-iii-1-33: FAIL +# Bug? Array.prototype.reduceRight - modifications to length don't change number +# of iterations in step 9 +15.4.4.22-8-b-2: FAIL +# Bug? Array.prototype.reduceRight - deleting own property in step 8 causes +# deleted index property not to be visited on an Array +15.4.4.22-9-b-9: FAIL +# Bug? Array.prototype.reduceRight - deleting own property with prototype +# property in step 8 causes prototype index property to be visited on an +# Array +15.4.4.22-9-b-13: FAIL +# Bug? Array.prototype.reduceRight - decreasing length of array in step 8 does +# not delete non-configurable properties +15.4.4.22-9-b-16: FAIL +# Bug? Array.prototype.reduceRight - deleting property of prototype causes +# deleted index property not to be visited on an Array +15.4.4.22-9-b-24: FAIL +# Bug? Array.prototype.reduceRight - deleting own property with prototype +# property causes prototype index property to be visited on an Array +15.4.4.22-9-b-26: FAIL +# Bug? Array.prototype.reduceRight - decreasing length of array does not delete +# non-configurable properties +15.4.4.22-9-b-29: FAIL +# Bug? Array.prototype.reduceRight - element changed by getter on previous +# iterations is observed on an Array +15.4.4.22-9-c-i-30: FAIL +# Bug? Array.prototype.reduceRight - modifications to length will change number +# of iterations +15.4.4.22-9-9: FAIL +# Bug? String.prototype.trim throws TypeError when string is undefined +15.5.4.20-1-1: FAIL +# Bug? String.prototype.trim throws TypeError when string is null +15.5.4.20-1-2: FAIL +# Bug? String.prototype.trim - 'S' is a string with all WhiteSpace +15.5.4.20-3-2: FAIL +# Bug? String.prototype.trim - 'S' is a string with all union of WhiteSpace and +# LineTerminator +15.5.4.20-3-3: FAIL +# Bug? String.prototype.trim - 'S' is a string start with union of all +# LineTerminator and all WhiteSpace +15.5.4.20-3-4: FAIL +# Bug? String.prototype.trim - 'S' is a string end with union of all +# LineTerminator and all WhiteSpace +15.5.4.20-3-5: FAIL +# Bug? String.prototype.trim - 'S' is a string start with union of all +# LineTerminator and all WhiteSpace and end with union of all +# LineTerminator and all WhiteSpace +15.5.4.20-3-6: FAIL +# Bug? String.prototype.trim handles whitepace and lineterminators (\\uFEFFabc) +15.5.4.20-4-10: FAIL +# Bug? String.prototype.trim handles whitepace and lineterminators (abc\\uFEFF) +15.5.4.20-4-18: FAIL +# Bug? String.prototype.trim handles whitepace and lineterminators +# (\\uFEFF\\uFEFF) +15.5.4.20-4-34: FAIL +# Bug? Date Time String Format - specified default values will be set for all +# optional fields(MM, DD, mm, ss and time zone) when they are absent +15.9.1.15-1: FAIL +# Bug? Date.prototype.toISOString - RangeError is thrown when value of date is +# Date(1970, 0, -99999999, 0, 0, 0, -1), the time zone is UTC(0) +15.9.5.43-0-8: FAIL +# Bug? Date.prototype.toISOString - RangeError is not thrown when value of date +# is Date(1970, 0, 100000001, 0, 0, 0, -1), the time zone is UTC(0) +15.9.5.43-0-11: FAIL +# Bug? Date.prototype.toISOString - RangeError is not thrown when value of date +# is Date(1970, 0, 100000001, 0, 0, 0, 0), the time zone is UTC(0) +15.9.5.43-0-12: FAIL +# Bug? Date.prototype.toISOString - RangeError is thrown when value of date is +# Date(1970, 0, 100000001, 0, 0, 0, 1), the time zone is UTC(0) +15.9.5.43-0-13: FAIL +# Bug? Date.prototype.toISOString - when value of year is -Infinity +# Date.prototype.toISOString throw the RangeError +15.9.5.43-0-14: FAIL +# Bug? Date.prototype.toISOString - value of year is Infinity +# Date.prototype.toISOString throw the RangeError +15.9.5.43-0-15: FAIL +# Bug? RegExp - the thrown error is SyntaxError instead of RegExpError when 'F' +# contains any character other than 'g', 'i', or 'm' +15.10.4.1-3: FAIL +# Bug? RegExp.prototype is itself a RegExp +15.10.6: FAIL +# Bug? RegExp.prototype.source is of type String +15.10.7.1-1: FAIL +# Bug? RegExp.prototype.source is a data property with default attribute values +# (false) +15.10.7.1-2: FAIL +# Bug? RegExp.prototype.global is of type Boolean +15.10.7.2-1: FAIL +# Bug? RegExp.prototype.global is a data property with default attribute values +# (false) +15.10.7.2-2: FAIL +# Bug? RegExp.prototype.ignoreCase is of type Boolean +15.10.7.3-1: FAIL +# Bug? RegExp.prototype.ignoreCase is a data property with default attribute +# values (false) +15.10.7.3-2: FAIL +# Bug? RegExp.prototype.multiline is of type Boolean +15.10.7.4-1: FAIL +# Bug? RegExp.prototype.multiline is a data property with default attribute +# values (false) +15.10.7.4-2: FAIL +# Bug? RegExp.prototype.lastIndex is of type Number +15.10.7.5-1: FAIL +# Bug? RegExp.prototype.lastIndex is a data property with specified attribute +# values +15.10.7.5-2: FAIL +# Bug? Error.prototype.toString return the value of 'msg' when 'name' is empty +# string and 'msg' isn't undefined +15.11.4.4-8-1: FAIL diff --git a/test/test262/testcfg.py b/test/test262/testcfg.py new file mode 100644 index 00000000..aa1212e4 --- /dev/null +++ b/test/test262/testcfg.py @@ -0,0 +1,123 @@ +# Copyright 2011 the V8 project authors. All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +import test +import os +from os.path import join, exists + + +TEST_262_HARNESS = ['sta.js'] + + +class Test262TestCase(test.TestCase): + + def __init__(self, filename, path, context, root, mode, framework): + super(Test262TestCase, self).__init__(context, path, mode) + self.filename = filename + self.framework = framework + self.root = root + + def IsNegative(self): + return self.filename.endswith('-n.js') + + def GetLabel(self): + return "%s test262 %s %s" % (self.mode, self.GetGroup(), self.GetName()) + + def IsFailureOutput(self, output): + if output.exit_code != 0: + return True + return 'FAILED!' in output.stdout + + def GetCommand(self): + result = self.context.GetVmCommand(self, self.mode) + result += ['-e', 'var window = this'] + result += self.framework + result.append(self.filename) + return result + + def GetName(self): + return self.path[-1] + + def GetGroup(self): + return self.path[0] + + def GetSource(self): + return open(self.filename).read() + + +class Test262TestConfiguration(test.TestConfiguration): + + def __init__(self, context, root): + super(Test262TestConfiguration, self).__init__(context, root) + + def AddIETestCenter(self, tests, current_path, path, mode): + current_root = join(self.root, 'data', 'test', 'suite', 'ietestcenter') + harness = [join(self.root, 'data', 'test', 'harness', f) + for f in TEST_262_HARNESS] + harness += [join(self.root, 'harness-adapt.js')] + for root, dirs, files in os.walk(current_root): + for dotted in [x for x in dirs if x.startswith('.')]: + dirs.remove(dotted) + dirs.sort() + root_path = root[len(self.root):].split(os.path.sep) + root_path = current_path + [x for x in root_path if x] + files.sort() + for file in files: + if file.endswith('.js'): + if self.Contains(path, root_path): + test_path = ['ietestcenter', file[:-3]] + test = Test262TestCase(join(root, file), test_path, self.context, + self.root, mode, harness) + tests.append(test) + + def AddSputnikConvertedTests(self, tests, current_path, path, mode): + # To be enabled + pass + + def AddSputnikTests(self, tests, current_path, path, mode): + # To be enabled + pass + + def ListTests(self, current_path, path, mode, variant_flags): + tests = [] + self.AddIETestCenter(tests, current_path, path, mode) + self.AddSputnikConvertedTests(tests, current_path, path, mode) + self.AddSputnikTests(tests, current_path, path, mode) + return tests + + def GetBuildRequirements(self): + return ['sample', 'sample=shell'] + + def GetTestStatus(self, sections, defs): + status_file = join(self.root, 'test262.status') + if exists(status_file): + test.ReadConfigurationInto(status_file, sections, defs) + + +def GetConfiguration(context, root): + return Test262TestConfiguration(context, root) |
