diff options
author | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
commit | 6bcea4ff932144a5fd02affefd45164fbf471e67 (patch) | |
tree | a8e078c679b12f0daebe10ed254239cb0d79e146 /deps/v8/test | |
parent | 4fae2356d105e394115188a814097c4a95ae0c5d (diff) | |
download | node-new-6bcea4ff932144a5fd02affefd45164fbf471e67.tar.gz |
deps: update v8 to 3.29.93.1
Diffstat (limited to 'deps/v8/test')
587 files changed, 12394 insertions, 13451 deletions
diff --git a/deps/v8/test/base-unittests/DEPS b/deps/v8/test/base-unittests/DEPS deleted file mode 100644 index 90b080063f..0000000000 --- a/deps/v8/test/base-unittests/DEPS +++ /dev/null @@ -1,8 +0,0 @@ -include_rules = [ - "-include", - "+include/v8config.h", - "+include/v8stdint.h", - "-src", - "+src/base", - "+testing/gtest", -] diff --git a/deps/v8/test/base-unittests/base-unittests.gyp b/deps/v8/test/base-unittests/base-unittests.gyp deleted file mode 100644 index 339269db1b..0000000000 --- a/deps/v8/test/base-unittests/base-unittests.gyp +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2014 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'variables': { - 'v8_code': 1, - }, - 'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'], - 'targets': [ - { - 'target_name': 'base-unittests', - 'type': 'executable', - 'dependencies': [ - '../../testing/gtest.gyp:gtest', - '../../testing/gtest.gyp:gtest_main', - '../../tools/gyp/v8.gyp:v8_libbase', - ], - 'include_dirs': [ - '../..', - ], - 'sources': [ ### gcmole(all) ### - 'cpu-unittest.cc', - 'platform/condition-variable-unittest.cc', - 'platform/mutex-unittest.cc', - 'platform/platform-unittest.cc', - 'platform/time-unittest.cc', - 'utils/random-number-generator-unittest.cc', - ], - 'conditions': [ - ['os_posix == 1', { - # TODO(svenpanne): This is a temporary work-around to fix the warnings - # that show up because we use -std=gnu++0x instead of -std=c++11. - 'cflags!': [ - '-pedantic', - ], - }], - ], - }, - ], -} diff --git a/deps/v8/test/base-unittests/cpu-unittest.cc b/deps/v8/test/base-unittests/cpu-unittest.cc deleted file mode 100644 index 5c58f86238..0000000000 --- a/deps/v8/test/base-unittests/cpu-unittest.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/base/cpu.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace v8 { -namespace base { - -TEST(CPUTest, FeatureImplications) { - CPU cpu; - - // ia32 and x64 features - EXPECT_TRUE(!cpu.has_sse() || cpu.has_mmx()); - EXPECT_TRUE(!cpu.has_sse2() || cpu.has_sse()); - EXPECT_TRUE(!cpu.has_sse3() || cpu.has_sse2()); - EXPECT_TRUE(!cpu.has_ssse3() || cpu.has_sse3()); - EXPECT_TRUE(!cpu.has_sse41() || cpu.has_sse3()); - EXPECT_TRUE(!cpu.has_sse42() || cpu.has_sse41()); - - // arm features - EXPECT_TRUE(!cpu.has_vfp3_d32() || cpu.has_vfp3()); -} - - -TEST(CPUTest, RequiredFeatures) { - CPU cpu; - -#if V8_HOST_ARCH_ARM - EXPECT_TRUE(cpu.has_fpu()); -#endif - -#if V8_HOST_ARCH_IA32 - EXPECT_TRUE(cpu.has_fpu()); - EXPECT_TRUE(cpu.has_sahf()); -#endif - -#if V8_HOST_ARCH_X64 - EXPECT_TRUE(cpu.has_fpu()); - EXPECT_TRUE(cpu.has_cmov()); - EXPECT_TRUE(cpu.has_mmx()); - EXPECT_TRUE(cpu.has_sse()); - EXPECT_TRUE(cpu.has_sse2()); -#endif -} - -} // namespace base -} // namespace v8 diff --git a/deps/v8/test/base-unittests/platform/condition-variable-unittest.cc b/deps/v8/test/base-unittests/platform/condition-variable-unittest.cc deleted file mode 100644 index ea1efd0d5b..0000000000 --- a/deps/v8/test/base-unittests/platform/condition-variable-unittest.cc +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/base/platform/condition-variable.h" - -#include "src/base/platform/platform.h" -#include "src/base/platform/time.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace v8 { -namespace base { - -TEST(ConditionVariable, WaitForAfterNofityOnSameThread) { - for (int n = 0; n < 10; ++n) { - Mutex mutex; - ConditionVariable cv; - - LockGuard<Mutex> lock_guard(&mutex); - - cv.NotifyOne(); - EXPECT_FALSE(cv.WaitFor(&mutex, TimeDelta::FromMicroseconds(n))); - - cv.NotifyAll(); - EXPECT_FALSE(cv.WaitFor(&mutex, TimeDelta::FromMicroseconds(n))); - } -} - - -namespace { - -class ThreadWithMutexAndConditionVariable V8_FINAL : public Thread { - public: - ThreadWithMutexAndConditionVariable() - : Thread(Options("ThreadWithMutexAndConditionVariable")), - running_(false), - finished_(false) {} - virtual ~ThreadWithMutexAndConditionVariable() {} - - virtual void Run() V8_OVERRIDE { - LockGuard<Mutex> lock_guard(&mutex_); - running_ = true; - cv_.NotifyOne(); - while (running_) { - cv_.Wait(&mutex_); - } - finished_ = true; - cv_.NotifyAll(); - } - - bool running_; - bool finished_; - ConditionVariable cv_; - Mutex mutex_; -}; - -} - - -TEST(ConditionVariable, MultipleThreadsWithSeparateConditionVariables) { - static const int kThreadCount = 128; - ThreadWithMutexAndConditionVariable threads[kThreadCount]; - - for (int n = 0; n < kThreadCount; ++n) { - LockGuard<Mutex> lock_guard(&threads[n].mutex_); - EXPECT_FALSE(threads[n].running_); - EXPECT_FALSE(threads[n].finished_); - threads[n].Start(); - // Wait for nth thread to start. - while (!threads[n].running_) { - threads[n].cv_.Wait(&threads[n].mutex_); - } - } - - for (int n = kThreadCount - 1; n >= 0; --n) { - LockGuard<Mutex> lock_guard(&threads[n].mutex_); - EXPECT_TRUE(threads[n].running_); - EXPECT_FALSE(threads[n].finished_); - } - - for (int n = 0; n < kThreadCount; ++n) { - LockGuard<Mutex> lock_guard(&threads[n].mutex_); - EXPECT_TRUE(threads[n].running_); - EXPECT_FALSE(threads[n].finished_); - // Tell the nth thread to quit. - threads[n].running_ = false; - threads[n].cv_.NotifyOne(); - } - - for (int n = kThreadCount - 1; n >= 0; --n) { - // Wait for nth thread to quit. - LockGuard<Mutex> lock_guard(&threads[n].mutex_); - while (!threads[n].finished_) { - threads[n].cv_.Wait(&threads[n].mutex_); - } - EXPECT_FALSE(threads[n].running_); - EXPECT_TRUE(threads[n].finished_); - } - - for (int n = 0; n < kThreadCount; ++n) { - threads[n].Join(); - LockGuard<Mutex> lock_guard(&threads[n].mutex_); - EXPECT_FALSE(threads[n].running_); - EXPECT_TRUE(threads[n].finished_); - } -} - - -namespace { - -class ThreadWithSharedMutexAndConditionVariable V8_FINAL : public Thread { - public: - ThreadWithSharedMutexAndConditionVariable() - : Thread(Options("ThreadWithSharedMutexAndConditionVariable")), - running_(false), - finished_(false), - cv_(NULL), - mutex_(NULL) {} - virtual ~ThreadWithSharedMutexAndConditionVariable() {} - - virtual void Run() V8_OVERRIDE { - LockGuard<Mutex> lock_guard(mutex_); - running_ = true; - cv_->NotifyAll(); - while (running_) { - cv_->Wait(mutex_); - } - finished_ = true; - cv_->NotifyAll(); - } - - bool running_; - bool finished_; - ConditionVariable* cv_; - Mutex* mutex_; -}; - -} - - -TEST(ConditionVariable, MultipleThreadsWithSharedSeparateConditionVariables) { - static const int kThreadCount = 128; - ThreadWithSharedMutexAndConditionVariable threads[kThreadCount]; - ConditionVariable cv; - Mutex mutex; - - for (int n = 0; n < kThreadCount; ++n) { - threads[n].mutex_ = &mutex; - threads[n].cv_ = &cv; - } - - // Start all threads. - { - LockGuard<Mutex> lock_guard(&mutex); - for (int n = 0; n < kThreadCount; ++n) { - EXPECT_FALSE(threads[n].running_); - EXPECT_FALSE(threads[n].finished_); - threads[n].Start(); - } - } - - // Wait for all threads to start. - { - LockGuard<Mutex> lock_guard(&mutex); - for (int n = kThreadCount - 1; n >= 0; --n) { - while (!threads[n].running_) { - cv.Wait(&mutex); - } - } - } - - // Make sure that all threads are running. - { - LockGuard<Mutex> lock_guard(&mutex); - for (int n = 0; n < kThreadCount; ++n) { - EXPECT_TRUE(threads[n].running_); - EXPECT_FALSE(threads[n].finished_); - } - } - - // Tell all threads to quit. - { - LockGuard<Mutex> lock_guard(&mutex); - for (int n = kThreadCount - 1; n >= 0; --n) { - EXPECT_TRUE(threads[n].running_); - EXPECT_FALSE(threads[n].finished_); - // Tell the nth thread to quit. - threads[n].running_ = false; - } - cv.NotifyAll(); - } - - // Wait for all threads to quit. - { - LockGuard<Mutex> lock_guard(&mutex); - for (int n = 0; n < kThreadCount; ++n) { - while (!threads[n].finished_) { - cv.Wait(&mutex); - } - } - } - - // Make sure all threads are finished. - { - LockGuard<Mutex> lock_guard(&mutex); - for (int n = kThreadCount - 1; n >= 0; --n) { - EXPECT_FALSE(threads[n].running_); - EXPECT_TRUE(threads[n].finished_); - } - } - - // Join all threads. - for (int n = 0; n < kThreadCount; ++n) { - threads[n].Join(); - } -} - - -namespace { - -class LoopIncrementThread V8_FINAL : public Thread { - public: - LoopIncrementThread(int rem, int* counter, int limit, int thread_count, - ConditionVariable* cv, Mutex* mutex) - : Thread(Options("LoopIncrementThread")), - rem_(rem), - counter_(counter), - limit_(limit), - thread_count_(thread_count), - cv_(cv), - mutex_(mutex) { - EXPECT_LT(rem, thread_count); - EXPECT_EQ(0, limit % thread_count); - } - - virtual void Run() V8_OVERRIDE { - int last_count = -1; - while (true) { - LockGuard<Mutex> lock_guard(mutex_); - int count = *counter_; - while (count % thread_count_ != rem_ && count < limit_) { - cv_->Wait(mutex_); - count = *counter_; - } - if (count >= limit_) break; - EXPECT_EQ(*counter_, count); - if (last_count != -1) { - EXPECT_EQ(last_count + (thread_count_ - 1), count); - } - count++; - *counter_ = count; - last_count = count; - cv_->NotifyAll(); - } - } - - private: - const int rem_; - int* counter_; - const int limit_; - const int thread_count_; - ConditionVariable* cv_; - Mutex* mutex_; -}; - -} - - -TEST(ConditionVariable, LoopIncrement) { - static const int kMaxThreadCount = 16; - Mutex mutex; - ConditionVariable cv; - for (int thread_count = 1; thread_count < kMaxThreadCount; ++thread_count) { - int limit = thread_count * 10; - int counter = 0; - - // Setup the threads. - Thread** threads = new Thread*[thread_count]; - for (int n = 0; n < thread_count; ++n) { - threads[n] = new LoopIncrementThread( - n, &counter, limit, thread_count, &cv, &mutex); - } - - // Start all threads. - for (int n = thread_count - 1; n >= 0; --n) { - threads[n]->Start(); - } - - // Join and cleanup all threads. - for (int n = 0; n < thread_count; ++n) { - threads[n]->Join(); - delete threads[n]; - } - delete[] threads; - - EXPECT_EQ(limit, counter); - } -} - -} // namespace base -} // namespace v8 diff --git a/deps/v8/test/base-unittests/platform/mutex-unittest.cc b/deps/v8/test/base-unittests/platform/mutex-unittest.cc deleted file mode 100644 index 5af5efb5a9..0000000000 --- a/deps/v8/test/base-unittests/platform/mutex-unittest.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/base/platform/mutex.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace v8 { -namespace base { - -TEST(Mutex, LockGuardMutex) { - Mutex mutex; - { LockGuard<Mutex> lock_guard(&mutex); } - { LockGuard<Mutex> lock_guard(&mutex); } -} - - -TEST(Mutex, LockGuardRecursiveMutex) { - RecursiveMutex recursive_mutex; - { LockGuard<RecursiveMutex> lock_guard(&recursive_mutex); } - { - LockGuard<RecursiveMutex> lock_guard1(&recursive_mutex); - LockGuard<RecursiveMutex> lock_guard2(&recursive_mutex); - } -} - - -TEST(Mutex, LockGuardLazyMutex) { - LazyMutex lazy_mutex = LAZY_MUTEX_INITIALIZER; - { LockGuard<Mutex> lock_guard(lazy_mutex.Pointer()); } - { LockGuard<Mutex> lock_guard(lazy_mutex.Pointer()); } -} - - -TEST(Mutex, LockGuardLazyRecursiveMutex) { - LazyRecursiveMutex lazy_recursive_mutex = LAZY_RECURSIVE_MUTEX_INITIALIZER; - { LockGuard<RecursiveMutex> lock_guard(lazy_recursive_mutex.Pointer()); } - { - LockGuard<RecursiveMutex> lock_guard1(lazy_recursive_mutex.Pointer()); - LockGuard<RecursiveMutex> lock_guard2(lazy_recursive_mutex.Pointer()); - } -} - - -TEST(Mutex, MultipleMutexes) { - Mutex mutex1; - Mutex mutex2; - Mutex mutex3; - // Order 1 - mutex1.Lock(); - mutex2.Lock(); - mutex3.Lock(); - mutex1.Unlock(); - mutex2.Unlock(); - mutex3.Unlock(); - // Order 2 - mutex1.Lock(); - mutex2.Lock(); - mutex3.Lock(); - mutex3.Unlock(); - mutex2.Unlock(); - mutex1.Unlock(); -} - - -TEST(Mutex, MultipleRecursiveMutexes) { - RecursiveMutex recursive_mutex1; - RecursiveMutex recursive_mutex2; - // Order 1 - recursive_mutex1.Lock(); - recursive_mutex2.Lock(); - EXPECT_TRUE(recursive_mutex1.TryLock()); - EXPECT_TRUE(recursive_mutex2.TryLock()); - recursive_mutex1.Unlock(); - recursive_mutex1.Unlock(); - recursive_mutex2.Unlock(); - recursive_mutex2.Unlock(); - // Order 2 - recursive_mutex1.Lock(); - EXPECT_TRUE(recursive_mutex1.TryLock()); - recursive_mutex2.Lock(); - EXPECT_TRUE(recursive_mutex2.TryLock()); - recursive_mutex2.Unlock(); - recursive_mutex1.Unlock(); - recursive_mutex2.Unlock(); - recursive_mutex1.Unlock(); -} - -} // namespace base -} // namespace v8 diff --git a/deps/v8/test/base-unittests/platform/platform-unittest.cc b/deps/v8/test/base-unittests/platform/platform-unittest.cc deleted file mode 100644 index 3530ff8073..0000000000 --- a/deps/v8/test/base-unittests/platform/platform-unittest.cc +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/base/platform/platform.h" - -#if V8_OS_POSIX -#include <unistd.h> // NOLINT -#endif - -#if V8_OS_WIN -#include "src/base/win32-headers.h" -#endif -#include "testing/gtest/include/gtest/gtest.h" - -namespace v8 { -namespace base { - -TEST(OS, GetCurrentProcessId) { -#if V8_OS_POSIX - EXPECT_EQ(static_cast<int>(getpid()), OS::GetCurrentProcessId()); -#endif - -#if V8_OS_WIN - EXPECT_EQ(static_cast<int>(::GetCurrentProcessId()), - OS::GetCurrentProcessId()); -#endif -} - - -TEST(OS, NumberOfProcessorsOnline) { - EXPECT_GT(OS::NumberOfProcessorsOnline(), 0); -} - - -namespace { - -class SelfJoinThread V8_FINAL : public Thread { - public: - SelfJoinThread() : Thread(Options("SelfJoinThread")) {} - virtual void Run() V8_OVERRIDE { Join(); } -}; - -} - - -TEST(Thread, SelfJoin) { - SelfJoinThread thread; - thread.Start(); - thread.Join(); -} - - -namespace { - -class ThreadLocalStorageTest : public Thread, public ::testing::Test { - public: - ThreadLocalStorageTest() : Thread(Options("ThreadLocalStorageTest")) { - for (size_t i = 0; i < ARRAY_SIZE(keys_); ++i) { - keys_[i] = Thread::CreateThreadLocalKey(); - } - } - ~ThreadLocalStorageTest() { - for (size_t i = 0; i < ARRAY_SIZE(keys_); ++i) { - Thread::DeleteThreadLocalKey(keys_[i]); - } - } - - virtual void Run() V8_FINAL V8_OVERRIDE { - for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { - CHECK(!Thread::HasThreadLocal(keys_[i])); - } - for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { - Thread::SetThreadLocal(keys_[i], GetValue(i)); - } - for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { - CHECK(Thread::HasThreadLocal(keys_[i])); - } - for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { - CHECK_EQ(GetValue(i), Thread::GetThreadLocal(keys_[i])); - CHECK_EQ(GetValue(i), Thread::GetExistingThreadLocal(keys_[i])); - } - for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { - Thread::SetThreadLocal(keys_[i], GetValue(ARRAY_SIZE(keys_) - i - 1)); - } - for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { - CHECK(Thread::HasThreadLocal(keys_[i])); - } - for (size_t i = 0; i < ARRAY_SIZE(keys_); i++) { - CHECK_EQ(GetValue(ARRAY_SIZE(keys_) - i - 1), - Thread::GetThreadLocal(keys_[i])); - CHECK_EQ(GetValue(ARRAY_SIZE(keys_) - i - 1), - Thread::GetExistingThreadLocal(keys_[i])); - } - } - - private: - static void* GetValue(size_t x) { - return reinterpret_cast<void*>(static_cast<uintptr_t>(x + 1)); - } - - Thread::LocalStorageKey keys_[256]; -}; - -} - - -TEST_F(ThreadLocalStorageTest, DoTest) { - Run(); - Start(); - Join(); -} - -} // namespace base -} // namespace v8 diff --git a/deps/v8/test/base-unittests/platform/time-unittest.cc b/deps/v8/test/base-unittests/platform/time-unittest.cc deleted file mode 100644 index 409323a8d6..0000000000 --- a/deps/v8/test/base-unittests/platform/time-unittest.cc +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/base/platform/time.h" - -#if V8_OS_MACOSX -#include <mach/mach_time.h> -#endif -#if V8_OS_POSIX -#include <sys/time.h> -#endif - -#if V8_OS_WIN -#include "src/base/win32-headers.h" -#endif - -#include "src/base/platform/elapsed-timer.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace v8 { -namespace base { - -TEST(TimeDelta, FromAndIn) { - EXPECT_EQ(TimeDelta::FromDays(2), TimeDelta::FromHours(48)); - EXPECT_EQ(TimeDelta::FromHours(3), TimeDelta::FromMinutes(180)); - EXPECT_EQ(TimeDelta::FromMinutes(2), TimeDelta::FromSeconds(120)); - EXPECT_EQ(TimeDelta::FromSeconds(2), TimeDelta::FromMilliseconds(2000)); - EXPECT_EQ(TimeDelta::FromMilliseconds(2), TimeDelta::FromMicroseconds(2000)); - EXPECT_EQ(static_cast<int>(13), TimeDelta::FromDays(13).InDays()); - EXPECT_EQ(static_cast<int>(13), TimeDelta::FromHours(13).InHours()); - EXPECT_EQ(static_cast<int>(13), TimeDelta::FromMinutes(13).InMinutes()); - EXPECT_EQ(static_cast<int64_t>(13), TimeDelta::FromSeconds(13).InSeconds()); - EXPECT_DOUBLE_EQ(13.0, TimeDelta::FromSeconds(13).InSecondsF()); - EXPECT_EQ(static_cast<int64_t>(13), - TimeDelta::FromMilliseconds(13).InMilliseconds()); - EXPECT_DOUBLE_EQ(13.0, TimeDelta::FromMilliseconds(13).InMillisecondsF()); - EXPECT_EQ(static_cast<int64_t>(13), - TimeDelta::FromMicroseconds(13).InMicroseconds()); -} - - -#if V8_OS_MACOSX -TEST(TimeDelta, MachTimespec) { - TimeDelta null = TimeDelta(); - EXPECT_EQ(null, TimeDelta::FromMachTimespec(null.ToMachTimespec())); - TimeDelta delta1 = TimeDelta::FromMilliseconds(42); - EXPECT_EQ(delta1, TimeDelta::FromMachTimespec(delta1.ToMachTimespec())); - TimeDelta delta2 = TimeDelta::FromDays(42); - EXPECT_EQ(delta2, TimeDelta::FromMachTimespec(delta2.ToMachTimespec())); -} -#endif - - -TEST(Time, JsTime) { - Time t = Time::FromJsTime(700000.3); - EXPECT_DOUBLE_EQ(700000.3, t.ToJsTime()); -} - - -#if V8_OS_POSIX -TEST(Time, Timespec) { - Time null; - EXPECT_TRUE(null.IsNull()); - EXPECT_EQ(null, Time::FromTimespec(null.ToTimespec())); - Time now = Time::Now(); - EXPECT_EQ(now, Time::FromTimespec(now.ToTimespec())); - Time now_sys = Time::NowFromSystemTime(); - EXPECT_EQ(now_sys, Time::FromTimespec(now_sys.ToTimespec())); - Time unix_epoch = Time::UnixEpoch(); - EXPECT_EQ(unix_epoch, Time::FromTimespec(unix_epoch.ToTimespec())); - Time max = Time::Max(); - EXPECT_TRUE(max.IsMax()); - EXPECT_EQ(max, Time::FromTimespec(max.ToTimespec())); -} - - -TEST(Time, Timeval) { - Time null; - EXPECT_TRUE(null.IsNull()); - EXPECT_EQ(null, Time::FromTimeval(null.ToTimeval())); - Time now = Time::Now(); - EXPECT_EQ(now, Time::FromTimeval(now.ToTimeval())); - Time now_sys = Time::NowFromSystemTime(); - EXPECT_EQ(now_sys, Time::FromTimeval(now_sys.ToTimeval())); - Time unix_epoch = Time::UnixEpoch(); - EXPECT_EQ(unix_epoch, Time::FromTimeval(unix_epoch.ToTimeval())); - Time max = Time::Max(); - EXPECT_TRUE(max.IsMax()); - EXPECT_EQ(max, Time::FromTimeval(max.ToTimeval())); -} -#endif - - -#if V8_OS_WIN -TEST(Time, Filetime) { - Time null; - EXPECT_TRUE(null.IsNull()); - EXPECT_EQ(null, Time::FromFiletime(null.ToFiletime())); - Time now = Time::Now(); - EXPECT_EQ(now, Time::FromFiletime(now.ToFiletime())); - Time now_sys = Time::NowFromSystemTime(); - EXPECT_EQ(now_sys, Time::FromFiletime(now_sys.ToFiletime())); - Time unix_epoch = Time::UnixEpoch(); - EXPECT_EQ(unix_epoch, Time::FromFiletime(unix_epoch.ToFiletime())); - Time max = Time::Max(); - EXPECT_TRUE(max.IsMax()); - EXPECT_EQ(max, Time::FromFiletime(max.ToFiletime())); -} -#endif - - -namespace { - -template <typename T> -static void ResolutionTest(T (*Now)(), TimeDelta target_granularity) { - // We're trying to measure that intervals increment in a VERY small amount - // of time -- according to the specified target granularity. Unfortunately, - // if we happen to have a context switch in the middle of our test, the - // context switch could easily exceed our limit. So, we iterate on this - // several times. As long as we're able to detect the fine-granularity - // timers at least once, then the test has succeeded. - static const TimeDelta kExpirationTimeout = TimeDelta::FromSeconds(1); - ElapsedTimer timer; - timer.Start(); - TimeDelta delta; - do { - T start = Now(); - T now = start; - // Loop until we can detect that the clock has changed. Non-HighRes timers - // will increment in chunks, i.e. 15ms. By spinning until we see a clock - // change, we detect the minimum time between measurements. - do { - now = Now(); - delta = now - start; - } while (now <= start); - EXPECT_NE(static_cast<int64_t>(0), delta.InMicroseconds()); - } while (delta > target_granularity && !timer.HasExpired(kExpirationTimeout)); - EXPECT_LE(delta, target_granularity); -} - -} - - -TEST(Time, NowResolution) { - // We assume that Time::Now() has at least 16ms resolution. - static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(16); - ResolutionTest<Time>(&Time::Now, kTargetGranularity); -} - - -TEST(TimeTicks, NowResolution) { - // We assume that TimeTicks::Now() has at least 16ms resolution. - static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(16); - ResolutionTest<TimeTicks>(&TimeTicks::Now, kTargetGranularity); -} - - -TEST(TimeTicks, HighResolutionNowResolution) { - if (!TimeTicks::IsHighResolutionClockWorking()) return; - - // We assume that TimeTicks::HighResolutionNow() has sub-ms resolution. - static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(1); - ResolutionTest<TimeTicks>(&TimeTicks::HighResolutionNow, kTargetGranularity); -} - - -TEST(TimeTicks, IsMonotonic) { - TimeTicks previous_normal_ticks; - TimeTicks previous_highres_ticks; - ElapsedTimer timer; - timer.Start(); - while (!timer.HasExpired(TimeDelta::FromMilliseconds(100))) { - TimeTicks normal_ticks = TimeTicks::Now(); - TimeTicks highres_ticks = TimeTicks::HighResolutionNow(); - EXPECT_GE(normal_ticks, previous_normal_ticks); - EXPECT_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0); - EXPECT_GE(highres_ticks, previous_highres_ticks); - EXPECT_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0); - previous_normal_ticks = normal_ticks; - previous_highres_ticks = highres_ticks; - } -} - -} // namespace base -} // namespace v8 diff --git a/deps/v8/test/base-unittests/testcfg.py b/deps/v8/test/base-unittests/testcfg.py deleted file mode 100644 index 0ed46dcdb1..0000000000 --- a/deps/v8/test/base-unittests/testcfg.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2014 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import os -import shutil - -from testrunner.local import commands -from testrunner.local import testsuite -from testrunner.local import utils -from testrunner.objects import testcase - - -class BaseUnitTestsSuite(testsuite.TestSuite): - def __init__(self, name, root): - super(BaseUnitTestsSuite, self).__init__(name, root) - - def ListTests(self, context): - shell = os.path.abspath(os.path.join(context.shell_dir, self.shell())) - if utils.IsWindows(): - shell += ".exe" - output = commands.Execute(context.command_prefix + - [shell, "--gtest_list_tests"] + - context.extra_flags) - if output.exit_code != 0: - print output.stdout - print output.stderr - return [] - tests = [] - test_case = '' - for test_desc in output.stdout.strip().split(): - if test_desc.endswith('.'): - test_case = test_desc - else: - test = testcase.TestCase(self, test_case + test_desc, dependency=None) - tests.append(test) - tests.sort() - return tests - - def GetFlagsForTestCase(self, testcase, context): - return (testcase.flags + ["--gtest_filter=" + testcase.path] + - ["--gtest_random_seed=%s" % context.random_seed] + - ["--gtest_print_time=0"] + - context.mode_flags) - - def shell(self): - return "base-unittests" - - -def GetSuite(name, root): - return BaseUnitTestsSuite(name, root) diff --git a/deps/v8/test/base-unittests/utils/random-number-generator-unittest.cc b/deps/v8/test/base-unittests/utils/random-number-generator-unittest.cc deleted file mode 100644 index 7c533db4f0..0000000000 --- a/deps/v8/test/base-unittests/utils/random-number-generator-unittest.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <climits> - -#include "src/base/utils/random-number-generator.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace v8 { -namespace base { - -class RandomNumberGeneratorTest : public ::testing::TestWithParam<int> {}; - - -static const int kMaxRuns = 12345; - - -TEST_P(RandomNumberGeneratorTest, NextIntWithMaxValue) { - RandomNumberGenerator rng(GetParam()); - for (int max = 1; max <= kMaxRuns; ++max) { - int n = rng.NextInt(max); - EXPECT_LE(0, n); - EXPECT_LT(n, max); - } -} - - -TEST_P(RandomNumberGeneratorTest, NextBooleanReturnsFalseOrTrue) { - RandomNumberGenerator rng(GetParam()); - for (int k = 0; k < kMaxRuns; ++k) { - bool b = rng.NextBool(); - EXPECT_TRUE(b == false || b == true); - } -} - - -TEST_P(RandomNumberGeneratorTest, NextDoubleReturnsValueBetween0And1) { - RandomNumberGenerator rng(GetParam()); - for (int k = 0; k < kMaxRuns; ++k) { - double d = rng.NextDouble(); - EXPECT_LE(0.0, d); - EXPECT_LT(d, 1.0); - } -} - - -INSTANTIATE_TEST_CASE_P(RandomSeeds, RandomNumberGeneratorTest, - ::testing::Values(INT_MIN, -1, 0, 1, 42, 100, - 1234567890, 987654321, INT_MAX)); - -} // namespace base -} // namespace v8 diff --git a/deps/v8/test/benchmarks/benchmarks.status b/deps/v8/test/benchmarks/benchmarks.status index 1afd5eca24..a08fa41c15 100644 --- a/deps/v8/test/benchmarks/benchmarks.status +++ b/deps/v8/test/benchmarks/benchmarks.status @@ -29,7 +29,7 @@ [ALWAYS, { # Too slow in Debug mode. 'octane/mandreel': [PASS, ['mode == debug', SKIP]], - # TODO(mstarzinger,ishell): Timeout with TF in predictable mode. - 'octane/richards': [PASS, NO_VARIANTS], + # TODO(turbofan): Too slow in debug mode for now. + 'octane/pdfjs': [PASS, ['mode == debug', SKIP]], }], # ALWAYS ] diff --git a/deps/v8/test/benchmarks/testcfg.py b/deps/v8/test/benchmarks/testcfg.py index 8c573ba30b..6607bef8cc 100644 --- a/deps/v8/test/benchmarks/testcfg.py +++ b/deps/v8/test/benchmarks/testcfg.py @@ -31,7 +31,6 @@ import shutil import subprocess import tarfile -from testrunner.local import statusfile from testrunner.local import testsuite from testrunner.objects import testcase @@ -184,8 +183,6 @@ class BenchmarksTestSuite(testsuite.TestSuite): os.chdir(old_cwd) def VariantFlags(self, testcase, default_flags): - if testcase.outcomes and statusfile.OnlyStandardVariant(testcase.outcomes): - return [[]] # Both --nocrankshaft and --stressopt are very slow. Add TF but without # always opt to match the way the benchmarks are run for performance # testing. diff --git a/deps/v8/test/cctest/OWNERS b/deps/v8/test/cctest/OWNERS index 6d5f927e73..93565c5a7a 100644 --- a/deps/v8/test/cctest/OWNERS +++ b/deps/v8/test/cctest/OWNERS @@ -1,2 +1,5 @@ -per-file *-mips.*=plind44@gmail.com -per-file *-mips.*=gergely@homejinni.com +per-file *-mips*=paul.lind@imgtec.com +per-file *-mips*=gergely.kis@imgtec.com +per-file *-mips*=akos.palfi@imgtec.com +per-file *-mips*=balazs.kilvady@imgtec.com +per-file *-mips*=dusan.milosavljevic@imgtec.com diff --git a/deps/v8/test/cctest/cctest.cc b/deps/v8/test/cctest/cctest.cc index 2bb08b0ec9..f03710a3b0 100644 --- a/deps/v8/test/cctest/cctest.cc +++ b/deps/v8/test/cctest/cctest.cc @@ -34,6 +34,13 @@ #include "test/cctest/profiler-extension.h" #include "test/cctest/trace-extension.h" +#if (defined(_WIN32) || defined(_WIN64)) +#include <windows.h> // NOLINT +#if defined(_MSC_VER) +#include <crtdbg.h> +#endif // defined(_MSC_VER) +#endif // defined(_WIN32) || defined(_WIN64) + enum InitializationState {kUnset, kUnintialized, kInitialized}; static InitializationState initialization_state_ = kUnset; static bool disable_automatic_dispose_ = false; @@ -138,11 +145,27 @@ static void SuggestTestHarness(int tests) { int main(int argc, char* argv[]) { +#if (defined(_WIN32) || defined(_WIN64)) + UINT new_flags = + SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX; + UINT existing_flags = SetErrorMode(new_flags); + SetErrorMode(existing_flags | new_flags); +#if defined(_MSC_VER) + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); + _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE); + _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); + _set_error_mode(_OUT_TO_STDERR); +#endif // _MSC_VER +#endif // defined(_WIN32) || defined(_WIN64) + v8::V8::InitializeICU(); v8::Platform* platform = v8::platform::CreateDefaultPlatform(); v8::V8::InitializePlatform(platform); - v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); + v8::V8::Initialize(); CcTestArrayBufferAllocator array_buffer_allocator; v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); @@ -159,10 +182,6 @@ int main(int argc, char* argv[]) { for (int i = 1; i < argc; i++) { char* arg = argv[i]; if (strcmp(arg, "--list") == 0) { - // TODO(svenpanne) Serializer::enabled() and Serializer::code_address_map_ - // are fundamentally broken, so we can't unconditionally initialize and - // dispose V8. - v8::V8::Initialize(); PrintTestList(CcTest::last()); print_run_count = false; diff --git a/deps/v8/test/cctest/cctest.gyp b/deps/v8/test/cctest/cctest.gyp index 42946f5bfe..f993d2659a 100644 --- a/deps/v8/test/cctest/cctest.gyp +++ b/deps/v8/test/cctest/cctest.gyp @@ -44,6 +44,7 @@ ], 'sources': [ ### gcmole(all) ### '<(generated_file)', + 'compiler/c-signature.h', 'compiler/codegen-tester.cc', 'compiler/codegen-tester.h', 'compiler/function-tester.h', @@ -52,12 +53,12 @@ 'compiler/graph-tester.h', 'compiler/simplified-graph-builder.cc', 'compiler/simplified-graph-builder.h', + 'compiler/test-basic-block-profiler.cc', 'compiler/test-branch-combine.cc', 'compiler/test-changes-lowering.cc', 'compiler/test-codegen-deopt.cc', 'compiler/test-gap-resolver.cc', 'compiler/test-graph-reducer.cc', - 'compiler/test-instruction-selector.cc', 'compiler/test-instruction.cc', 'compiler/test-js-context-specialization.cc', 'compiler/test-js-constant-cache.cc', @@ -72,18 +73,18 @@ 'compiler/test-pipeline.cc', 'compiler/test-representation-change.cc', 'compiler/test-run-deopt.cc', + 'compiler/test-run-inlining.cc', 'compiler/test-run-intrinsics.cc', 'compiler/test-run-jsbranches.cc', 'compiler/test-run-jscalls.cc', 'compiler/test-run-jsexceptions.cc', 'compiler/test-run-jsops.cc', 'compiler/test-run-machops.cc', + 'compiler/test-run-properties.cc', 'compiler/test-run-variables.cc', 'compiler/test-schedule.cc', 'compiler/test-scheduler.cc', 'compiler/test-simplified-lowering.cc', - 'compiler/test-structured-ifbuilder-fuzzer.cc', - 'compiler/test-structured-machine-assembler.cc', 'cctest.cc', 'gay-fixed.cc', 'gay-precision.cc', @@ -125,9 +126,6 @@ 'test-heap.cc', 'test-heap-profiler.cc', 'test-hydrogen-types.cc', - 'test-libplatform-default-platform.cc', - 'test-libplatform-task-queue.cc', - 'test-libplatform-worker-thread.cc', 'test-list.cc', 'test-liveedit.cc', 'test-lockers.cc', @@ -145,7 +143,6 @@ 'test-regexp.cc', 'test-reloc-info.cc', 'test-representation.cc', - 'test-semaphore.cc', 'test-serialize.cc', 'test-spaces.cc', 'test-strings.cc', @@ -167,7 +164,6 @@ 'conditions': [ ['v8_target_arch=="ia32"', { 'sources': [ ### gcmole(arch:ia32) ### - 'compiler/test-instruction-selector-ia32.cc', 'test-assembler-ia32.cc', 'test-code-stubs.cc', 'test-code-stubs-ia32.cc', @@ -188,7 +184,6 @@ }], ['v8_target_arch=="arm"', { 'sources': [ ### gcmole(arch:arm) ### - 'compiler/test-instruction-selector-arm.cc', 'test-assembler-arm.cc', 'test-code-stubs.cc', 'test-code-stubs-arm.cc', diff --git a/deps/v8/test/cctest/cctest.h b/deps/v8/test/cctest/cctest.h index 2ab973c52d..6d27074a6f 100644 --- a/deps/v8/test/cctest/cctest.h +++ b/deps/v8/test/cctest/cctest.h @@ -53,6 +53,13 @@ static void Test##Name() #endif +#ifndef UNINITIALIZED_DEPENDENT_TEST +#define UNINITIALIZED_DEPENDENT_TEST(Name, Dep) \ + static void Test##Name(); \ + CcTest register_test_##Name(Test##Name, __FILE__, #Name, #Dep, true, false); \ + static void Test##Name() +#endif + #ifndef DISABLED_TEST #define DISABLED_TEST(Name) \ static void Test##Name(); \ diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index 60baaca081..5198af6ff5 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -35,10 +35,6 @@ # BUG(382): Weird test. Can't guarantee that it never times out. 'test-api/ApplyInterruption': [PASS, TIMEOUT], - # TODO(mstarzinger): Fail gracefully on multiple V8::Dispose calls. - 'test-api/InitializeAndDisposeOnce': [SKIP], - 'test-api/InitializeAndDisposeMultiple': [SKIP], - # 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], @@ -75,40 +71,28 @@ # BUG(2999). (test/cpu-profiler/CollectCpuProfile) # BUG(3287). (test-cpu-profiler/SampleWhenFrameIsNotSetup) 'test-cpu-profiler/*': [PASS, FLAKY], - - ############################################################################## - # TurboFan compiler failures. - - # TODO(mstarzinger): These need investigation and are not categorized yet. 'test-cpu-profiler/*': [SKIP], - 'test-heap/NextCodeLinkIsWeak': [PASS, NO_VARIANTS], - # TODO(mstarzinger/verwaest): This access check API is borked. - 'test-api/TurnOnAccessCheck': [PASS, NO_VARIANTS], - 'test-api/TurnOnAccessCheckAndRecompile': [PASS, NO_VARIANTS], + # BUG(3525). Test crashes flakily. + 'test-debug/RecursiveBreakpoints': [PASS, FLAKY], + 'test-debug/RecursiveBreakpointsGlobal': [PASS, FLAKY], - # TODO(mstarzinger): Sometimes the try-catch blacklist fails. - 'test-debug/DebugEvaluateWithoutStack': [PASS, NO_VARIANTS], - 'test-debug/MessageQueues': [PASS, NO_VARIANTS], - 'test-debug/NestedBreakEventContextData': [PASS, NO_VARIANTS], - 'test-debug/SendClientDataToHandler': [PASS, NO_VARIANTS], + ############################################################################## + # TurboFan compiler failures. - # TODO(dcarney): C calls are broken all over the place. - 'test-run-machops/RunCall*': [SKIP], - 'test-run-machops/RunLoadImmIndex': [SKIP], - 'test-run-machops/RunSpillLotsOfThingsWithCall': [SKIP], + # TODO(sigurds): The schedule is borked with multiple inlinees, + # and cannot handle free-floating loops yet + 'test-run-inlining/InlineTwiceDependentDiamond': [SKIP], + 'test-run-inlining/InlineTwiceDependentDiamondDifferent': [SKIP], + 'test-run-inlining/InlineLoop': [SKIP], # Some tests are just too slow to run for now. 'test-api/Threading*': [PASS, NO_VARIANTS], - 'test-api/RequestInterruptTestWithMathAbs': [PASS, NO_VARIANTS], 'test-heap/IncrementalMarkingStepMakesBigProgressWithLargeObjects': [PASS, NO_VARIANTS], 'test-heap-profiler/ManyLocalsInSharedContext': [PASS, NO_VARIANTS], 'test-debug/ThreadedDebugging': [PASS, NO_VARIANTS], 'test-debug/DebugBreakLoop': [PASS, NO_VARIANTS], - # Support for lazy deoptimization is missing. - 'test-deoptimization/DeoptimizeCompare': [PASS, NO_VARIANTS], - # Support for breakpoints requires using LoadICs and StoreICs. 'test-debug/BreakPointICStore': [PASS, NO_VARIANTS], 'test-debug/BreakPointICLoad': [PASS, NO_VARIANTS], @@ -190,7 +174,7 @@ 'test-heap/ReleaseOverReservedPages': [PASS, FAIL], # BUG(v8:3155). - 'test-strings/AsciiArrayJoin': [PASS, ['mode == debug', FAIL]], + 'test-strings/OneByteArrayJoin': [PASS, ['mode == debug', FAIL]], # BUG(v8:3247). 'test-mark-compact/NoPromotion': [SKIP], @@ -199,7 +183,7 @@ 'test-mark-compact/Promotion': [PASS, FAIL], # BUG(v8:3434). - ' test-api/LoadICFastApi_DirectCall_GCMoveStubWithProfiler': [SKIP] + ' test-api/LoadICFastApi_DirectCall_GCMoveStubWithProfiler': [SKIP], }], # 'arch == arm64' ['arch == arm64 and simulator_run == True', { @@ -306,6 +290,11 @@ 'test-serialize/DeserializeFromSecondSerializationAndRunScript2': [SKIP], 'test-serialize/DeserializeAndRunScript2': [SKIP], 'test-serialize/DeserializeFromSecondSerialization': [SKIP], + + # Test requires turbofan: + 'test-simplified-lowering/LowerStringOps_to_call_and_compare': [SKIP], + 'codegen-tester/CompareWrapper': [SKIP], + 'codegen-tester/ParametersEqual': [SKIP], }], # 'arch == mipsel or arch == mips' ############################################################################## @@ -322,23 +311,20 @@ 'test-serialize/DeserializeFromSecondSerializationAndRunScript2': [SKIP], 'test-serialize/DeserializeAndRunScript2': [SKIP], 'test-serialize/DeserializeFromSecondSerialization': [SKIP], + + # Test requires turbofan: + 'test-simplified-lowering/LowerStringOps_to_call_and_compare': [SKIP], + 'codegen-tester/CompareWrapper': [SKIP], + 'codegen-tester/ParametersEqual': [SKIP], }], # 'arch == mips64el' ############################################################################## ['arch == x87', { - # TODO (weiliang): Enable below tests after fixing the double register - # allocation limit in X87 port. - 'test-serialize/Serialize': [PASS, ['mode == debug', SKIP]], - 'test-serialize/Deserialize': [PASS, ['mode == debug', SKIP]], - 'test-serialize/SerializeTwice': [PASS, ['mode == debug', SKIP]], - 'test-serialize/ContextSerialization': [PASS, ['mode == debug', SKIP]], - 'test-serialize/ContextDeserialization': [PASS, ['mode == debug', SKIP]], - 'test-serialize/PartialDeserialization': [PASS, ['mode == debug', SKIP]], - 'test-serialize/PartialSerialization': [PASS, ['mode == debug', SKIP]], - 'test-serialize/DeserializeAndRunScript2': [PASS, ['mode == debug', SKIP]], - 'test-serialize/DeserializeFromSecondSerializationAndRunScript2': [PASS, ['mode == debug', SKIP]], - 'test-serialize/DeserializeFromSecondSerialization': [PASS, ['mode == debug', SKIP]], + # Test requires turbofan: + 'codegen-tester/CompareWrapper': [SKIP], + 'codegen-tester/ParametersEqual': [SKIP], + 'test-simplified-lowering/LowerStringOps_to_call_and_compare': [SKIP], }], # 'arch == x87' ############################################################################## @@ -435,10 +421,10 @@ 'test-constantpool/ConstantPool' : [SKIP], 'test-compiler/GetScriptLineNumber' : [SKIP], 'test-api/ScriptMakingExternalString' : [SKIP], - 'test-api/ScriptMakingExternalAsciiString' : [SKIP], + 'test-api/ScriptMakingExternalOneByteString' : [SKIP], 'test-api/MakingExternalStringConditions' : [SKIP], - 'test-api/MakingExternalAsciiStringConditions' : [SKIP], - 'test-api/MakingExternalUnalignedAsciiString' : [SKIP], + 'test-api/MakingExternalOneByteStringConditions' : [SKIP], + 'test-api/MakingExternalUnalignedOneByteString' : [SKIP], 'test-api/IndexedInterceptorUnboxedDoubleWithIndexedAccessor' : [SKIP], 'test-api/IndependentWeakHandle' : [SKIP], 'test-api/GCFromWeakCallbacks' : [SKIP], diff --git a/deps/v8/test/cctest/compiler/c-signature.h b/deps/v8/test/cctest/compiler/c-signature.h new file mode 100644 index 0000000000..5d161dbe7a --- /dev/null +++ b/deps/v8/test/cctest/compiler/c-signature.h @@ -0,0 +1,133 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_COMPILER_C_SIGNATURE_H_ +#define V8_COMPILER_C_SIGNATURE_H_ + +#include "src/compiler/machine-type.h" + +namespace v8 { +namespace internal { +namespace compiler { + +template <typename T> +inline MachineType MachineTypeForC() { + CHECK(false); // Instantiated with invalid type. + return kMachNone; +} + +template <> +inline MachineType MachineTypeForC<void>() { + return kMachNone; +} + +template <> +inline MachineType MachineTypeForC<int8_t>() { + return kMachInt8; +} + +template <> +inline MachineType MachineTypeForC<uint8_t>() { + return kMachUint8; +} + +template <> +inline MachineType MachineTypeForC<int16_t>() { + return kMachInt16; +} + +template <> +inline MachineType MachineTypeForC<uint16_t>() { + return kMachUint16; +} + +template <> +inline MachineType MachineTypeForC<int32_t>() { + return kMachInt32; +} + +template <> +inline MachineType MachineTypeForC<uint32_t>() { + return kMachUint32; +} + +template <> +inline MachineType MachineTypeForC<int64_t>() { + return kMachInt64; +} + +template <> +inline MachineType MachineTypeForC<uint64_t>() { + return kMachUint64; +} + +template <> +inline MachineType MachineTypeForC<double>() { + return kMachFloat64; +} + +template <> +inline MachineType MachineTypeForC<Object*>() { + return kMachAnyTagged; +} + +template <typename Ret, uint16_t kParamCount> +class CSignatureOf : public MachineSignature { + protected: + MachineType storage_[1 + kParamCount]; + + CSignatureOf() + : MachineSignature(MachineTypeForC<Ret>() != kMachNone ? 1 : 0, + kParamCount, + reinterpret_cast<MachineType*>(&storage_)) { + if (return_count_ == 1) storage_[0] = MachineTypeForC<Ret>(); + } + void Set(int index, MachineType type) { + DCHECK(index >= 0 && index < kParamCount); + reps_[return_count_ + index] = type; + } +}; + +// Helper classes for instantiating Signature objects to be callable from C. +template <typename Ret> +class CSignature0 : public CSignatureOf<Ret, 0> { + public: + CSignature0() : CSignatureOf<Ret, 0>() {} +}; + +template <typename Ret, typename P1> +class CSignature1 : public CSignatureOf<Ret, 1> { + public: + CSignature1() : CSignatureOf<Ret, 1>() { + this->Set(0, MachineTypeForC<P1>()); + } +}; + +template <typename Ret, typename P1, typename P2> +class CSignature2 : public CSignatureOf<Ret, 2> { + public: + CSignature2() : CSignatureOf<Ret, 2>() { + this->Set(0, MachineTypeForC<P1>()); + this->Set(1, MachineTypeForC<P2>()); + } +}; + +template <typename Ret, typename P1, typename P2, typename P3> +class CSignature3 : public CSignatureOf<Ret, 3> { + public: + CSignature3() : CSignatureOf<Ret, 3>() { + this->Set(0, MachineTypeForC<P1>()); + this->Set(1, MachineTypeForC<P2>()); + this->Set(2, MachineTypeForC<P3>()); + } +}; + +static const CSignature2<int32_t, int32_t, int32_t> int32_int32_to_int32; +static const CSignature2<uint32_t, uint32_t, uint32_t> uint32_uint32_to_uint32; +static const CSignature2<double, double, double> float64_float64_to_float64; +} +} +} // namespace v8::internal::compiler + +#endif // V8_COMPILER_C_SIGNATURE_H_ diff --git a/deps/v8/test/cctest/compiler/call-tester.h b/deps/v8/test/cctest/compiler/call-tester.h index 40189ab405..e86416028b 100644 --- a/deps/v8/test/cctest/compiler/call-tester.h +++ b/deps/v8/test/cctest/compiler/call-tester.h @@ -23,6 +23,7 @@ namespace v8 { namespace internal { namespace compiler { +// TODO(titzer): use c-signature.h instead of ReturnValueTraits template <typename R> struct ReturnValueTraits { static R Cast(uintptr_t r) { return reinterpret_cast<R>(r); } @@ -32,72 +33,74 @@ struct ReturnValueTraits { while (false) { *(static_cast<Object* volatile*>(0)) = static_cast<R>(0); } - return kMachineTagged; + return kMachAnyTagged; } }; template <> struct ReturnValueTraits<int32_t*> { static int32_t* Cast(uintptr_t r) { return reinterpret_cast<int32_t*>(r); } - static MachineType Representation() { - return MachineOperatorBuilder::pointer_rep(); - } + static MachineType Representation() { return kMachPtr; } }; template <> struct ReturnValueTraits<void> { static void Cast(uintptr_t r) {} - static MachineType Representation() { - return MachineOperatorBuilder::pointer_rep(); - } + static MachineType Representation() { return kMachPtr; } }; template <> struct ReturnValueTraits<bool> { static bool Cast(uintptr_t r) { return static_cast<bool>(r); } - static MachineType Representation() { - return MachineOperatorBuilder::pointer_rep(); - } + static MachineType Representation() { return kRepBit; } }; template <> struct ReturnValueTraits<int32_t> { static int32_t Cast(uintptr_t r) { return static_cast<int32_t>(r); } - static MachineType Representation() { return kMachineWord32; } + static MachineType Representation() { return kMachInt32; } }; template <> struct ReturnValueTraits<uint32_t> { static uint32_t Cast(uintptr_t r) { return static_cast<uint32_t>(r); } - static MachineType Representation() { return kMachineWord32; } + static MachineType Representation() { return kMachUint32; } }; template <> struct ReturnValueTraits<int64_t> { static int64_t Cast(uintptr_t r) { return static_cast<int64_t>(r); } - static MachineType Representation() { return kMachineWord64; } + static MachineType Representation() { return kMachInt64; } }; template <> struct ReturnValueTraits<uint64_t> { static uint64_t Cast(uintptr_t r) { return static_cast<uint64_t>(r); } - static MachineType Representation() { return kMachineWord64; } + static MachineType Representation() { return kMachUint64; } }; template <> struct ReturnValueTraits<int16_t> { static int16_t Cast(uintptr_t r) { return static_cast<int16_t>(r); } - static MachineType Representation() { - return MachineOperatorBuilder::pointer_rep(); - } + static MachineType Representation() { return kMachInt16; } +}; + +template <> +struct ReturnValueTraits<uint16_t> { + static uint16_t Cast(uintptr_t r) { return static_cast<uint16_t>(r); } + static MachineType Representation() { return kMachUint16; } }; template <> struct ReturnValueTraits<int8_t> { static int8_t Cast(uintptr_t r) { return static_cast<int8_t>(r); } - static MachineType Representation() { - return MachineOperatorBuilder::pointer_rep(); - } + static MachineType Representation() { return kMachInt8; } +}; + +template <> +struct ReturnValueTraits<uint8_t> { + static uint8_t Cast(uintptr_t r) { return static_cast<uint8_t>(r); } + static MachineType Representation() { return kMachUint8; } }; template <> @@ -106,7 +109,7 @@ struct ReturnValueTraits<double> { UNREACHABLE(); return 0.0; } - static MachineType Representation() { return kMachineFloat64; } + static MachineType Representation() { return kMachFloat64; } }; @@ -127,34 +130,40 @@ struct ParameterTraits<T*> { class CallHelper { public: - explicit CallHelper(Isolate* isolate) : isolate_(isolate) { USE(isolate_); } + explicit CallHelper(Isolate* isolate, MachineSignature* machine_sig) + : machine_sig_(machine_sig), isolate_(isolate) { + USE(isolate_); + } virtual ~CallHelper() {} - static MachineCallDescriptorBuilder* ToCallDescriptorBuilder( - Zone* zone, MachineType return_type, MachineType p0 = kMachineLast, - MachineType p1 = kMachineLast, MachineType p2 = kMachineLast, - MachineType p3 = kMachineLast, MachineType p4 = kMachineLast) { - const int kSize = 5; - MachineType* params = zone->NewArray<MachineType>(kSize); - params[0] = p0; - params[1] = p1; - params[2] = p2; - params[3] = p3; - params[4] = p4; - int parameter_count = 0; - for (int i = 0; i < kSize; ++i) { - if (params[i] == kMachineLast) { - break; - } - parameter_count++; + static MachineSignature* MakeMachineSignature( + Zone* zone, MachineType return_type, MachineType p0 = kMachNone, + MachineType p1 = kMachNone, MachineType p2 = kMachNone, + MachineType p3 = kMachNone, MachineType p4 = kMachNone) { + // Count the number of parameters. + size_t param_count = 5; + MachineType types[] = {p0, p1, p2, p3, p4}; + while (param_count > 0 && types[param_count - 1] == kMachNone) + param_count--; + size_t return_count = return_type == kMachNone ? 0 : 1; + + // Build the machine signature. + MachineSignature::Builder builder(zone, return_count, param_count); + if (return_count > 0) builder.AddReturn(return_type); + for (size_t i = 0; i < param_count; i++) { + builder.AddParam(types[i]); } - return new (zone) - MachineCallDescriptorBuilder(return_type, parameter_count, params); + return builder.Build(); } protected: - virtual void VerifyParameters(int parameter_count, - MachineType* parameters) = 0; + MachineSignature* machine_sig_; + void VerifyParameters(size_t parameter_count, MachineType* parameter_types) { + CHECK(machine_sig_->parameter_count() == parameter_count); + for (size_t i = 0; i < parameter_count; i++) { + CHECK_EQ(machine_sig_->GetParam(i), parameter_types[i]); + } + } virtual byte* Generate() = 0; private: @@ -277,14 +286,14 @@ class CallHelper { template <typename P1> void VerifyParameters1() { MachineType parameters[] = {ReturnValueTraits<P1>::Representation()}; - VerifyParameters(ARRAY_SIZE(parameters), parameters); + VerifyParameters(arraysize(parameters), parameters); } template <typename P1, typename P2> void VerifyParameters2() { MachineType parameters[] = {ReturnValueTraits<P1>::Representation(), ReturnValueTraits<P2>::Representation()}; - VerifyParameters(ARRAY_SIZE(parameters), parameters); + VerifyParameters(arraysize(parameters), parameters); } template <typename P1, typename P2, typename P3> @@ -292,7 +301,7 @@ class CallHelper { MachineType parameters[] = {ReturnValueTraits<P1>::Representation(), ReturnValueTraits<P2>::Representation(), ReturnValueTraits<P3>::Representation()}; - VerifyParameters(ARRAY_SIZE(parameters), parameters); + VerifyParameters(arraysize(parameters), parameters); } template <typename P1, typename P2, typename P3, typename P4> @@ -301,7 +310,7 @@ class CallHelper { ReturnValueTraits<P2>::Representation(), ReturnValueTraits<P3>::Representation(), ReturnValueTraits<P4>::Representation()}; - VerifyParameters(ARRAY_SIZE(parameters), parameters); + VerifyParameters(arraysize(parameters), parameters); } #endif diff --git a/deps/v8/test/cctest/compiler/codegen-tester.cc b/deps/v8/test/cctest/compiler/codegen-tester.cc index 24b2c6e9f0..be445de3ce 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.cc +++ b/deps/v8/test/cctest/compiler/codegen-tester.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/compiler/generic-node-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/value-helper.h" @@ -293,7 +294,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { for (int i = -2; i < num_int_inputs; i++) { // for all left shapes for (int j = -2; j < num_int_inputs; j++) { // for all right shapes if (i >= 0 && j >= 0) break; // No constant/constant combos - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); Node* n0; @@ -303,7 +304,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { if (i == -2) { n0 = p0; } else if (i == -1) { - n0 = m.LoadFromPointer(&input_a, kMachineWord32); + n0 = m.LoadFromPointer(&input_a, kMachInt32); } else { n0 = m.Int32Constant(inputs[i]); } @@ -312,7 +313,7 @@ void Int32BinopInputShapeTester::TestAllInputShapes() { if (j == -2) { n1 = p1; } else if (j == -1) { - n1 = m.LoadFromPointer(&input_b, kMachineWord32); + n1 = m.LoadFromPointer(&input_b, kMachInt32); } else { n1 = m.Int32Constant(inputs[j]); } @@ -369,8 +370,10 @@ void Int32BinopInputShapeTester::RunRight( } +#if V8_TURBOFAN_TARGET + TEST(ParametersEqual) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); Node* p1 = m.Parameter(1); CHECK_NE(NULL, p1); Node* p0 = m.Parameter(0); @@ -380,8 +383,6 @@ TEST(ParametersEqual) { } -#if V8_TURBOFAN_TARGET - void RunSmiConstant(int32_t v) { // TODO(dcarney): on x64 Smis are generated with the SmiConstantRegister #if !V8_TARGET_ARCH_X64 @@ -486,7 +487,7 @@ TEST(RunHeapNumberConstant) { TEST(RunParam1) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); m.Return(m.Parameter(0)); FOR_INT32_INPUTS(i) { @@ -497,7 +498,7 @@ TEST(RunParam1) { TEST(RunParam2_1) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); m.Return(p0); @@ -511,7 +512,7 @@ TEST(RunParam2_1) { TEST(RunParam2_2) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); m.Return(p1); @@ -526,8 +527,7 @@ TEST(RunParam2_2) { TEST(RunParam3) { for (int i = 0; i < 3; i++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)}; m.Return(nodes[i]); diff --git a/deps/v8/test/cctest/compiler/codegen-tester.h b/deps/v8/test/cctest/compiler/codegen-tester.h index 300381b493..6aa5bae560 100644 --- a/deps/v8/test/cctest/compiler/codegen-tester.h +++ b/deps/v8/test/cctest/compiler/codegen-tester.h @@ -9,7 +9,6 @@ #include "src/compiler/pipeline.h" #include "src/compiler/raw-machine-assembler.h" -#include "src/compiler/structured-machine-assembler.h" #include "src/simulator.h" #include "test/cctest/compiler/call-tester.h" @@ -26,11 +25,13 @@ class MachineAssemblerTester : public HandleAndZoneScope, MachineType p1, MachineType p2, MachineType p3, MachineType p4) : HandleAndZoneScope(), - CallHelper(main_isolate()), - MachineAssembler(new (main_zone()) Graph(main_zone()), - ToCallDescriptorBuilder(main_zone(), return_type, p0, - p1, p2, p3, p4), - MachineOperatorBuilder::pointer_rep()) {} + CallHelper( + main_isolate(), + MakeMachineSignature(main_zone(), return_type, p0, p1, p2, p3, p4)), + MachineAssembler( + new (main_zone()) Graph(main_zone()), + MakeMachineSignature(main_zone(), return_type, p0, p1, p2, p3, p4), + kMachPtr) {} Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { return this->Load(rep, this->PointerConstant(address), @@ -59,15 +60,6 @@ class MachineAssemblerTester : public HandleAndZoneScope, void GenerateCode() { Generate(); } protected: - virtual void VerifyParameters(int parameter_count, - MachineType* parameter_types) { - CHECK_EQ(this->parameter_count(), parameter_count); - const MachineType* expected_types = this->parameter_types(); - for (int i = 0; i < parameter_count; i++) { - CHECK_EQ(expected_types[i], parameter_types[i]); - } - } - virtual byte* Generate() { if (code_.is_null()) { Schedule* schedule = this->Export(); @@ -91,11 +83,11 @@ class RawMachineAssemblerTester : public MachineAssemblerTester<RawMachineAssembler>, public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > { public: - RawMachineAssemblerTester(MachineType p0 = kMachineLast, - MachineType p1 = kMachineLast, - MachineType p2 = kMachineLast, - MachineType p3 = kMachineLast, - MachineType p4 = kMachineLast) + RawMachineAssemblerTester(MachineType p0 = kMachNone, + MachineType p1 = kMachNone, + MachineType p2 = kMachNone, + MachineType p3 = kMachNone, + MachineType p4 = kMachNone) : MachineAssemblerTester<RawMachineAssembler>( ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, p4) {} @@ -121,23 +113,6 @@ class RawMachineAssemblerTester }; -template <typename ReturnType> -class StructuredMachineAssemblerTester - : public MachineAssemblerTester<StructuredMachineAssembler>, - public CallHelper2<ReturnType, - StructuredMachineAssemblerTester<ReturnType> > { - public: - StructuredMachineAssemblerTester(MachineType p0 = kMachineLast, - MachineType p1 = kMachineLast, - MachineType p2 = kMachineLast, - MachineType p3 = kMachineLast, - MachineType p4 = kMachineLast) - : MachineAssemblerTester<StructuredMachineAssembler>( - ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, - p4) {} -}; - - static const bool USE_RESULT_BUFFER = true; static const bool USE_RETURN_REGISTER = false; static const int32_t CHECK_VALUE = 0x99BEEDCE; @@ -201,15 +176,25 @@ class BinopTester { // A helper class for testing code sequences that take two int parameters and // return an int value. class Int32BinopTester - : public BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER> { + : public BinopTester<int32_t, kMachInt32, USE_RETURN_REGISTER> { public: explicit Int32BinopTester(RawMachineAssemblerTester<int32_t>* tester) - : BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER>(tester) {} + : BinopTester<int32_t, kMachInt32, USE_RETURN_REGISTER>(tester) {} +}; + - int32_t call(uint32_t a0, uint32_t a1) { - p0 = static_cast<int32_t>(a0); - p1 = static_cast<int32_t>(a1); - return T->Call(); +// A helper class for testing code sequences that take two uint parameters and +// return an uint value. +class Uint32BinopTester + : public BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER> { + public: + explicit Uint32BinopTester(RawMachineAssemblerTester<int32_t>* tester) + : BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER>(tester) {} + + uint32_t call(uint32_t a0, uint32_t a1) { + p0 = a0; + p1 = a1; + return static_cast<uint32_t>(T->Call()); } }; @@ -218,10 +203,10 @@ class Int32BinopTester // return a double value. // TODO(titzer): figure out how to return doubles correctly on ia32. class Float64BinopTester - : public BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER> { + : public BinopTester<double, kMachFloat64, USE_RESULT_BUFFER> { public: explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester) - : BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER>(tester) {} + : BinopTester<double, kMachFloat64, USE_RESULT_BUFFER>(tester) {} }; @@ -230,10 +215,10 @@ class Float64BinopTester // TODO(titzer): pick word size of pointers based on V8_TARGET. template <typename Type> class PointerBinopTester - : public BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER> { + : public BinopTester<Type*, kMachPtr, USE_RETURN_REGISTER> { public: explicit PointerBinopTester(RawMachineAssemblerTester<int32_t>* tester) - : BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER>(tester) {} + : BinopTester<Type*, kMachPtr, USE_RETURN_REGISTER>(tester) {} }; @@ -241,10 +226,10 @@ class PointerBinopTester // return a tagged value. template <typename Type> class TaggedBinopTester - : public BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER> { + : public BinopTester<Type*, kMachAnyTagged, USE_RETURN_REGISTER> { public: explicit TaggedBinopTester(RawMachineAssemblerTester<int32_t>* tester) - : BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER>(tester) {} + : BinopTester<Type*, kMachAnyTagged, USE_RETURN_REGISTER>(tester) {} }; // A helper class for testing compares. Wraps a machine opcode and provides @@ -257,7 +242,7 @@ class CompareWrapper { return m->NewNode(op(m->machine()), a, b); } - Operator* op(MachineOperatorBuilder* machine) { + const Operator* op(MachineOperatorBuilder* machine) { switch (opcode) { case IrOpcode::kWord32Equal: return machine->Word32Equal(); diff --git a/deps/v8/test/cctest/compiler/function-tester.h b/deps/v8/test/cctest/compiler/function-tester.h index 2ed2fe9988..c869f00d19 100644 --- a/deps/v8/test/cctest/compiler/function-tester.h +++ b/deps/v8/test/cctest/compiler/function-tester.h @@ -26,10 +26,15 @@ namespace compiler { class FunctionTester : public InitializedHandleScope { public: - explicit FunctionTester(const char* source) + explicit FunctionTester(const char* source, uint32_t flags = 0) : isolate(main_isolate()), - function((FLAG_allow_natives_syntax = true, NewFunction(source))) { + function((FLAG_allow_natives_syntax = true, NewFunction(source))), + flags_(flags) { Compile(function); + const uint32_t supported_flags = CompilationInfo::kContextSpecializing | + CompilationInfo::kInliningEnabled | + CompilationInfo::kTypingEnabled; + CHECK_EQ(0, flags_ & ~supported_flags); } Isolate* isolate; @@ -40,17 +45,25 @@ class FunctionTester : public InitializedHandleScope { CompilationInfoWithZone info(function); CHECK(Parser::Parse(&info)); - StrictMode strict_mode = info.function()->strict_mode(); - info.SetStrictMode(strict_mode); info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); + if (flags_ & CompilationInfo::kContextSpecializing) { + info.MarkAsContextSpecializing(); + } + if (flags_ & CompilationInfo::kInliningEnabled) { + info.MarkAsInliningEnabled(); + } + if (flags_ & CompilationInfo::kTypingEnabled) { + info.MarkAsTypingEnabled(); + } CHECK(Rewriter::Rewrite(&info)); CHECK(Scope::Analyze(&info)); - CHECK_NE(NULL, info.scope()); - - EnsureDeoptimizationSupport(&info); + CHECK(Compiler::EnsureDeoptimizationSupport(&info)); Pipeline pipeline(&info); Handle<Code> code = pipeline.GenerateCode(); + if (FLAG_turbo_deoptimization) { + info.context()->native_context()->AddOptimizedCode(*code); + } CHECK(!code.is_null()); function->ReplaceCode(*code); @@ -70,23 +83,6 @@ class FunctionTester : public InitializedHandleScope { return function; } - static void EnsureDeoptimizationSupport(CompilationInfo* info) { - bool should_recompile = !info->shared_info()->has_deoptimization_support(); - if (should_recompile) { - CompilationInfoWithZone unoptimized(info->shared_info()); - // Note that we use the same AST that we will use for generating the - // optimized code. - unoptimized.SetFunction(info->function()); - unoptimized.PrepareForCompilation(info->scope()); - unoptimized.SetContext(info->context()); - if (should_recompile) unoptimized.EnableDeoptimizationSupport(); - bool succeeded = FullCodeGenerator::MakeCode(&unoptimized); - CHECK(succeeded); - Handle<SharedFunctionInfo> shared = info->shared_info(); - shared->EnableDeoptimizationSupport(*unoptimized.code()); - } - } - MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) { Handle<Object> args[] = {a, b}; return Execution::Call(isolate, function, undefined(), 2, args, false); @@ -186,6 +182,9 @@ class FunctionTester : public InitializedHandleScope { Handle<Object> true_value() { return isolate->factory()->true_value(); } Handle<Object> false_value() { return isolate->factory()->false_value(); } + + private: + uint32_t flags_; }; } } diff --git a/deps/v8/test/cctest/compiler/graph-builder-tester.cc b/deps/v8/test/cctest/compiler/graph-builder-tester.cc index fb6e4a28ce..bfa8226458 100644 --- a/deps/v8/test/cctest/compiler/graph-builder-tester.cc +++ b/deps/v8/test/cctest/compiler/graph-builder-tester.cc @@ -3,16 +3,16 @@ // found in the LICENSE file. #include "test/cctest/compiler/graph-builder-tester.h" + +#include "src/compiler/linkage.h" #include "src/compiler/pipeline.h" namespace v8 { namespace internal { namespace compiler { -MachineCallHelper::MachineCallHelper(Zone* zone, - MachineCallDescriptorBuilder* builder) - : CallHelper(zone->isolate()), - call_descriptor_builder_(builder), +MachineCallHelper::MachineCallHelper(Zone* zone, MachineSignature* machine_sig) + : CallHelper(zone->isolate(), machine_sig), parameters_(NULL), graph_(NULL) {} @@ -21,9 +21,10 @@ void MachineCallHelper::InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common) { DCHECK_EQ(NULL, parameters_); graph_ = builder->graph(); - if (parameter_count() == 0) return; - parameters_ = graph_->zone()->NewArray<Node*>(parameter_count()); - for (int i = 0; i < parameter_count(); ++i) { + int param_count = static_cast<int>(parameter_count()); + if (param_count == 0) return; + parameters_ = graph_->zone()->NewArray<Node*>(param_count); + for (int i = 0; i < param_count; ++i) { parameters_[i] = builder->NewNode(common->Parameter(i), graph_->start()); } } @@ -35,7 +36,8 @@ byte* MachineCallHelper::Generate() { if (code_.is_null()) { Zone* zone = graph_->zone(); CompilationInfo info(zone->isolate(), zone); - Linkage linkage(&info, call_descriptor_builder_->BuildCallDescriptor(zone)); + Linkage linkage(&info, + Linkage::GetSimplifiedCDescriptor(zone, machine_sig_)); Pipeline pipeline(&info); code_ = pipeline.GenerateCodeForMachineGraph(&linkage, graph_); } @@ -43,21 +45,10 @@ byte* MachineCallHelper::Generate() { } -void MachineCallHelper::VerifyParameters(int parameter_count, - MachineType* parameter_types) { - CHECK_EQ(this->parameter_count(), parameter_count); - const MachineType* expected_types = - call_descriptor_builder_->parameter_types(); - for (int i = 0; i < parameter_count; i++) { - CHECK_EQ(expected_types[i], parameter_types[i]); - } -} - - -Node* MachineCallHelper::Parameter(int offset) { +Node* MachineCallHelper::Parameter(size_t index) { DCHECK_NE(NULL, parameters_); - DCHECK(0 <= offset && offset < parameter_count()); - return parameters_[offset]; + DCHECK(index < parameter_count()); + return parameters_[index]; } } // namespace compiler diff --git a/deps/v8/test/cctest/compiler/graph-builder-tester.h b/deps/v8/test/cctest/compiler/graph-builder-tester.h index 64d9b8a73d..df79250823 100644 --- a/deps/v8/test/cctest/compiler/graph-builder-tester.h +++ b/deps/v8/test/cctest/compiler/graph-builder-tester.h @@ -10,9 +10,7 @@ #include "src/compiler/common-operator.h" #include "src/compiler/graph-builder.h" -#include "src/compiler/machine-node-factory.h" #include "src/compiler/machine-operator.h" -#include "src/compiler/simplified-node-factory.h" #include "src/compiler/simplified-operator.h" #include "test/cctest/compiler/call-tester.h" #include "test/cctest/compiler/simplified-graph-builder.h" @@ -28,8 +26,8 @@ class DirectGraphBuilder : public GraphBuilder { virtual ~DirectGraphBuilder() {} protected: - virtual Node* MakeNode(Operator* op, int value_input_count, - Node** value_inputs) { + virtual Node* MakeNode(const Operator* op, int value_input_count, + Node** value_inputs) FINAL { return graph()->NewNode(op, value_input_count, value_inputs); } }; @@ -37,24 +35,20 @@ class DirectGraphBuilder : public GraphBuilder { class MachineCallHelper : public CallHelper { public: - MachineCallHelper(Zone* zone, MachineCallDescriptorBuilder* builder); + MachineCallHelper(Zone* zone, MachineSignature* machine_sig); - Node* Parameter(int offset); + Node* Parameter(size_t index); void GenerateCode() { Generate(); } protected: virtual byte* Generate(); - virtual void VerifyParameters(int parameter_count, MachineType* parameters); void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common); protected: - int parameter_count() const { - return call_descriptor_builder_->parameter_count(); - } + size_t parameter_count() const { return machine_sig_->parameter_count(); } private: - MachineCallDescriptorBuilder* call_descriptor_builder_; Node** parameters_; // TODO(dcarney): shouldn't need graph stored. Graph* graph_; @@ -67,7 +61,6 @@ class GraphAndBuilders { explicit GraphAndBuilders(Zone* zone) : main_graph_(new (zone) Graph(zone)), main_common_(zone), - main_machine_(zone), main_simplified_(zone) {} protected: @@ -87,20 +80,20 @@ class GraphBuilderTester public SimplifiedGraphBuilder, public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > { public: - explicit GraphBuilderTester(MachineType p0 = kMachineLast, - MachineType p1 = kMachineLast, - MachineType p2 = kMachineLast, - MachineType p3 = kMachineLast, - MachineType p4 = kMachineLast) + explicit GraphBuilderTester(MachineType p0 = kMachNone, + MachineType p1 = kMachNone, + MachineType p2 = kMachNone, + MachineType p3 = kMachNone, + MachineType p4 = kMachNone) : GraphAndBuilders(main_zone()), MachineCallHelper( main_zone(), - ToCallDescriptorBuilder( + MakeMachineSignature( main_zone(), ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, p4)), SimplifiedGraphBuilder(main_graph_, &main_common_, &main_machine_, &main_simplified_) { - Begin(parameter_count()); + Begin(static_cast<int>(parameter_count())); InitParameters(this, &main_common_); } virtual ~GraphBuilderTester() {} diff --git a/deps/v8/test/cctest/compiler/instruction-selector-tester.h b/deps/v8/test/cctest/compiler/instruction-selector-tester.h index 60adaec823..3a28b2e5df 100644 --- a/deps/v8/test/cctest/compiler/instruction-selector-tester.h +++ b/deps/v8/test/cctest/compiler/instruction-selector-tester.h @@ -30,17 +30,17 @@ class InstructionSelectorTester : public HandleAndZoneScope, static MachineType* BuildParameterArray(Zone* zone) { MachineType* array = zone->NewArray<MachineType>(kParameterCount); for (int i = 0; i < kParameterCount; ++i) { - array[i] = kMachineWord32; + array[i] = kMachInt32; } return array; } InstructionSelectorTester() : RawMachineAssembler( - new (main_zone()) Graph(main_zone()), new (main_zone()) - MachineCallDescriptorBuilder(kMachineWord32, kParameterCount, - BuildParameterArray(main_zone())), - MachineOperatorBuilder::pointer_rep()) {} + new (main_zone()) Graph(main_zone()), + new (main_zone()) MachineCallDescriptorBuilder( + kMachInt32, kParameterCount, BuildParameterArray(main_zone())), + kMachPtr) {} void SelectInstructions(CpuFeature feature) { SelectInstructions(InstructionSelector::Features(feature)); diff --git a/deps/v8/test/cctest/compiler/simplified-graph-builder.cc b/deps/v8/test/cctest/compiler/simplified-graph-builder.cc index c688399eae..c44d5ed52e 100644 --- a/deps/v8/test/cctest/compiler/simplified-graph-builder.cc +++ b/deps/v8/test/cctest/compiler/simplified-graph-builder.cc @@ -4,6 +4,9 @@ #include "test/cctest/compiler/simplified-graph-builder.h" +#include "src/compiler/operator-properties.h" +#include "src/compiler/operator-properties-inl.h" + namespace v8 { namespace internal { namespace compiler { @@ -11,7 +14,10 @@ namespace compiler { SimplifiedGraphBuilder::SimplifiedGraphBuilder( Graph* graph, CommonOperatorBuilder* common, MachineOperatorBuilder* machine, SimplifiedOperatorBuilder* simplified) - : StructuredGraphBuilder(graph, common), + : GraphBuilder(graph), + effect_(NULL), + return_(NULL), + common_(common), machine_(machine), simplified_(simplified) {} @@ -20,57 +26,63 @@ void SimplifiedGraphBuilder::Begin(int num_parameters) { DCHECK(graph()->start() == NULL); Node* start = graph()->NewNode(common()->Start(num_parameters)); graph()->SetStart(start); - set_environment(new (zone()) Environment(this, start)); + effect_ = start; } void SimplifiedGraphBuilder::Return(Node* value) { - Node* control = NewNode(common()->Return(), value); - UpdateControlDependencyToLeaveFunction(control); + return_ = + graph()->NewNode(common()->Return(), value, effect_, graph()->start()); + effect_ = NULL; } void SimplifiedGraphBuilder::End() { - environment()->UpdateControlDependency(exit_control()); - graph()->SetEnd(NewNode(common()->End())); -} - - -SimplifiedGraphBuilder::Environment::Environment( - SimplifiedGraphBuilder* builder, Node* control_dependency) - : StructuredGraphBuilder::Environment(builder, control_dependency) {} - - -Node* SimplifiedGraphBuilder::Environment::Top() { - DCHECK(!values()->empty()); - return values()->back(); -} - - -void SimplifiedGraphBuilder::Environment::Push(Node* node) { - values()->push_back(node); -} - - -Node* SimplifiedGraphBuilder::Environment::Pop() { - DCHECK(!values()->empty()); - Node* back = values()->back(); - values()->pop_back(); - return back; -} - - -void SimplifiedGraphBuilder::Environment::Poke(size_t depth, Node* node) { - DCHECK(depth < values()->size()); - size_t index = values()->size() - depth - 1; - values()->at(index) = node; + Node* end = graph()->NewNode(common()->End(), return_); + graph()->SetEnd(end); } -Node* SimplifiedGraphBuilder::Environment::Peek(size_t depth) { - DCHECK(depth < values()->size()); - size_t index = values()->size() - depth - 1; - return values()->at(index); +Node* SimplifiedGraphBuilder::MakeNode(const Operator* op, + int value_input_count, + Node** value_inputs) { + DCHECK(op->InputCount() == value_input_count); + + DCHECK(!OperatorProperties::HasContextInput(op)); + DCHECK(!OperatorProperties::HasFrameStateInput(op)); + bool has_control = OperatorProperties::GetControlInputCount(op) == 1; + bool has_effect = OperatorProperties::GetEffectInputCount(op) == 1; + + DCHECK(OperatorProperties::GetControlInputCount(op) < 2); + DCHECK(OperatorProperties::GetEffectInputCount(op) < 2); + + Node* result = NULL; + if (!has_control && !has_effect) { + result = graph()->NewNode(op, value_input_count, value_inputs); + } else { + int input_count_with_deps = value_input_count; + if (has_control) ++input_count_with_deps; + if (has_effect) ++input_count_with_deps; + Node** buffer = zone()->NewArray<Node*>(input_count_with_deps); + memcpy(buffer, value_inputs, kPointerSize * value_input_count); + Node** current_input = buffer + value_input_count; + if (has_effect) { + *current_input++ = effect_; + } + if (has_control) { + *current_input++ = graph()->start(); + } + result = graph()->NewNode(op, input_count_with_deps, buffer); + if (has_effect) { + effect_ = result; + } + if (OperatorProperties::HasControlOutput(result->op())) { + // This graph builder does not support control flow. + UNREACHABLE(); + } + } + + return result; } } // namespace compiler diff --git a/deps/v8/test/cctest/compiler/simplified-graph-builder.h b/deps/v8/test/cctest/compiler/simplified-graph-builder.h index fa9161e171..1b637b7676 100644 --- a/deps/v8/test/cctest/compiler/simplified-graph-builder.h +++ b/deps/v8/test/cctest/compiler/simplified-graph-builder.h @@ -7,9 +7,7 @@ #include "src/compiler/common-operator.h" #include "src/compiler/graph-builder.h" -#include "src/compiler/machine-node-factory.h" #include "src/compiler/machine-operator.h" -#include "src/compiler/simplified-node-factory.h" #include "src/compiler/simplified-operator.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/call-tester.h" @@ -18,40 +16,18 @@ namespace v8 { namespace internal { namespace compiler { -class SimplifiedGraphBuilder - : public StructuredGraphBuilder, - public MachineNodeFactory<SimplifiedGraphBuilder>, - public SimplifiedNodeFactory<SimplifiedGraphBuilder> { +class SimplifiedGraphBuilder : public GraphBuilder { public: SimplifiedGraphBuilder(Graph* graph, CommonOperatorBuilder* common, MachineOperatorBuilder* machine, SimplifiedOperatorBuilder* simplified); virtual ~SimplifiedGraphBuilder() {} - class Environment : public StructuredGraphBuilder::Environment { - public: - Environment(SimplifiedGraphBuilder* builder, Node* control_dependency); - - // TODO(dcarney): encode somehow and merge into StructuredGraphBuilder. - // SSA renaming operations. - Node* Top(); - void Push(Node* node); - Node* Pop(); - void Poke(size_t depth, Node* node); - Node* Peek(size_t depth); - }; - + Zone* zone() const { return graph()->zone(); } Isolate* isolate() const { return zone()->isolate(); } - Zone* zone() const { return StructuredGraphBuilder::zone(); } - CommonOperatorBuilder* common() const { - return StructuredGraphBuilder::common(); - } + CommonOperatorBuilder* common() const { return common_; } MachineOperatorBuilder* machine() const { return machine_; } SimplifiedOperatorBuilder* simplified() const { return simplified_; } - Environment* environment() { - return reinterpret_cast<Environment*>( - StructuredGraphBuilder::environment()); - } // Initialize graph and builder. void Begin(int num_parameters); @@ -61,7 +37,114 @@ class SimplifiedGraphBuilder // Close the graph. void End(); + Node* PointerConstant(void* value) { + intptr_t intptr_value = reinterpret_cast<intptr_t>(value); + return kPointerSize == 8 ? NewNode(common()->Int64Constant(intptr_value)) + : Int32Constant(static_cast<int>(intptr_value)); + } + Node* Int32Constant(int32_t value) { + return NewNode(common()->Int32Constant(value)); + } + Node* HeapConstant(Handle<Object> object) { + Unique<Object> val = Unique<Object>::CreateUninitialized(object); + return NewNode(common()->HeapConstant(val)); + } + + Node* BooleanNot(Node* a) { return NewNode(simplified()->BooleanNot(), a); } + + Node* NumberEqual(Node* a, Node* b) { + return NewNode(simplified()->NumberEqual(), a, b); + } + Node* NumberLessThan(Node* a, Node* b) { + return NewNode(simplified()->NumberLessThan(), a, b); + } + Node* NumberLessThanOrEqual(Node* a, Node* b) { + return NewNode(simplified()->NumberLessThanOrEqual(), a, b); + } + Node* NumberAdd(Node* a, Node* b) { + return NewNode(simplified()->NumberAdd(), a, b); + } + Node* NumberSubtract(Node* a, Node* b) { + return NewNode(simplified()->NumberSubtract(), a, b); + } + Node* NumberMultiply(Node* a, Node* b) { + return NewNode(simplified()->NumberMultiply(), a, b); + } + Node* NumberDivide(Node* a, Node* b) { + return NewNode(simplified()->NumberDivide(), a, b); + } + Node* NumberModulus(Node* a, Node* b) { + return NewNode(simplified()->NumberModulus(), a, b); + } + Node* NumberToInt32(Node* a) { + return NewNode(simplified()->NumberToInt32(), a); + } + Node* NumberToUint32(Node* a) { + return NewNode(simplified()->NumberToUint32(), a); + } + + Node* StringEqual(Node* a, Node* b) { + return NewNode(simplified()->StringEqual(), a, b); + } + Node* StringLessThan(Node* a, Node* b) { + return NewNode(simplified()->StringLessThan(), a, b); + } + Node* StringLessThanOrEqual(Node* a, Node* b) { + return NewNode(simplified()->StringLessThanOrEqual(), a, b); + } + Node* StringAdd(Node* a, Node* b) { + return NewNode(simplified()->StringAdd(), a, b); + } + + Node* ChangeTaggedToInt32(Node* a) { + return NewNode(simplified()->ChangeTaggedToInt32(), a); + } + Node* ChangeTaggedToUint32(Node* a) { + return NewNode(simplified()->ChangeTaggedToUint32(), a); + } + Node* ChangeTaggedToFloat64(Node* a) { + return NewNode(simplified()->ChangeTaggedToFloat64(), a); + } + Node* ChangeInt32ToTagged(Node* a) { + return NewNode(simplified()->ChangeInt32ToTagged(), a); + } + Node* ChangeUint32ToTagged(Node* a) { + return NewNode(simplified()->ChangeUint32ToTagged(), a); + } + Node* ChangeFloat64ToTagged(Node* a) { + return NewNode(simplified()->ChangeFloat64ToTagged(), a); + } + Node* ChangeBoolToBit(Node* a) { + return NewNode(simplified()->ChangeBoolToBit(), a); + } + Node* ChangeBitToBool(Node* a) { + return NewNode(simplified()->ChangeBitToBool(), a); + } + + Node* LoadField(const FieldAccess& access, Node* object) { + return NewNode(simplified()->LoadField(access), object); + } + Node* StoreField(const FieldAccess& access, Node* object, Node* value) { + return NewNode(simplified()->StoreField(access), object, value); + } + Node* LoadElement(const ElementAccess& access, Node* object, Node* index, + Node* length) { + return NewNode(simplified()->LoadElement(access), object, index, length); + } + Node* StoreElement(const ElementAccess& access, Node* object, Node* index, + Node* length, Node* value) { + return NewNode(simplified()->StoreElement(access), object, index, length, + value); + } + + protected: + virtual Node* MakeNode(const Operator* op, int value_input_count, + Node** value_inputs) FINAL; + private: + Node* effect_; + Node* return_; + CommonOperatorBuilder* common_; MachineOperatorBuilder* machine_; SimplifiedOperatorBuilder* simplified_; }; diff --git a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc new file mode 100644 index 0000000000..dd96499a35 --- /dev/null +++ b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc @@ -0,0 +1,115 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/v8.h" + +#include "src/basic-block-profiler.h" +#include "src/compiler/generic-node-inl.h" +#include "test/cctest/cctest.h" +#include "test/cctest/compiler/codegen-tester.h" + +#if V8_TURBOFAN_TARGET + +using namespace v8::internal; +using namespace v8::internal::compiler; + +typedef RawMachineAssembler::Label MLabel; + +class BasicBlockProfilerTest : public RawMachineAssemblerTester<int32_t> { + public: + BasicBlockProfilerTest() : RawMachineAssemblerTester<int32_t>(kMachInt32) { + FLAG_turbo_profiling = true; + } + + void ResetCounts() { isolate()->basic_block_profiler()->ResetCounts(); } + + void Expect(size_t size, uint32_t* expected) { + CHECK_NE(NULL, isolate()->basic_block_profiler()); + const BasicBlockProfiler::DataList* l = + isolate()->basic_block_profiler()->data_list(); + CHECK_NE(0, static_cast<int>(l->size())); + const BasicBlockProfiler::Data* data = l->back(); + CHECK_EQ(static_cast<int>(size), static_cast<int>(data->n_blocks())); + const uint32_t* counts = data->counts(); + for (size_t i = 0; i < size; ++i) { + CHECK_EQ(static_cast<int>(expected[i]), static_cast<int>(counts[i])); + } + } +}; + + +TEST(ProfileDiamond) { + BasicBlockProfilerTest m; + + MLabel blocka, blockb, end; + m.Branch(m.Parameter(0), &blocka, &blockb); + m.Bind(&blocka); + m.Goto(&end); + m.Bind(&blockb); + m.Goto(&end); + m.Bind(&end); + m.Return(m.Int32Constant(0)); + + m.GenerateCode(); + { + uint32_t expected[] = {0, 0, 0, 0}; + m.Expect(arraysize(expected), expected); + } + + m.Call(0); + { + uint32_t expected[] = {1, 1, 0, 1}; + m.Expect(arraysize(expected), expected); + } + + m.ResetCounts(); + + m.Call(1); + { + uint32_t expected[] = {1, 0, 1, 1}; + m.Expect(arraysize(expected), expected); + } + + m.Call(0); + { + uint32_t expected[] = {2, 1, 1, 2}; + m.Expect(arraysize(expected), expected); + } +} + + +TEST(ProfileLoop) { + BasicBlockProfilerTest m; + + MLabel header, body, end; + Node* one = m.Int32Constant(1); + m.Goto(&header); + + m.Bind(&header); + Node* count = m.Phi(kMachInt32, m.Parameter(0), one); + m.Branch(count, &body, &end); + + m.Bind(&body); + count->ReplaceInput(1, m.Int32Sub(count, one)); + m.Goto(&header); + + m.Bind(&end); + m.Return(one); + + m.GenerateCode(); + { + uint32_t expected[] = {0, 0, 0, 0}; + m.Expect(arraysize(expected), expected); + } + + uint32_t runs[] = {0, 1, 500, 10000}; + for (size_t i = 0; i < arraysize(runs); i++) { + m.ResetCounts(); + CHECK_EQ(1, m.Call(static_cast<int>(runs[i]))); + uint32_t expected[] = {1, runs[i] + 1, runs[i], 1}; + m.Expect(arraysize(expected), expected); + } +} + +#endif // V8_TURBOFAN_TARGET diff --git a/deps/v8/test/cctest/compiler/test-branch-combine.cc b/deps/v8/test/cctest/compiler/test-branch-combine.cc index 61dffdca87..52590c0453 100644 --- a/deps/v8/test/cctest/compiler/test-branch-combine.cc +++ b/deps/v8/test/cctest/compiler/test-branch-combine.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/compiler/generic-node-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/value-helper.h" @@ -23,7 +24,7 @@ static IrOpcode::Value int32cmp_opcodes[] = { TEST(BranchCombineWord32EqualZero_1) { // Test combining a branch with x == 0 - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); int32_t eq_constant = -1033; int32_t ne_constant = 825118; Node* p0 = m.Parameter(0); @@ -49,7 +50,7 @@ TEST(BranchCombineWord32EqualZero_chain) { int32_t ne_constant = 815118; for (int k = 0; k < 6; k++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); Node* p0 = m.Parameter(0); MLabel blocka, blockb; Node* cond = p0; @@ -74,7 +75,7 @@ TEST(BranchCombineWord32EqualZero_chain) { TEST(BranchCombineInt32LessThanZero_1) { // Test combining a branch with x < 0 - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); int32_t eq_constant = -1433; int32_t ne_constant = 845118; Node* p0 = m.Parameter(0); @@ -96,7 +97,7 @@ TEST(BranchCombineInt32LessThanZero_1) { TEST(BranchCombineUint32LessThan100_1) { // Test combining a branch with x < 100 - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32); int32_t eq_constant = 1471; int32_t ne_constant = 88845718; Node* p0 = m.Parameter(0); @@ -118,7 +119,7 @@ TEST(BranchCombineUint32LessThan100_1) { TEST(BranchCombineUint32LessThanOrEqual100_1) { // Test combining a branch with x <= 100 - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32); int32_t eq_constant = 1479; int32_t ne_constant = 77845719; Node* p0 = m.Parameter(0); @@ -140,7 +141,7 @@ TEST(BranchCombineUint32LessThanOrEqual100_1) { TEST(BranchCombineZeroLessThanInt32_1) { // Test combining a branch with 0 < x - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); int32_t eq_constant = -2033; int32_t ne_constant = 225118; Node* p0 = m.Parameter(0); @@ -162,7 +163,7 @@ TEST(BranchCombineZeroLessThanInt32_1) { TEST(BranchCombineInt32GreaterThanZero_1) { // Test combining a branch with x > 0 - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); int32_t eq_constant = -1073; int32_t ne_constant = 825178; Node* p0 = m.Parameter(0); @@ -184,7 +185,7 @@ TEST(BranchCombineInt32GreaterThanZero_1) { TEST(BranchCombineWord32EqualP) { // Test combining a branch with an Word32Equal. - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); int32_t eq_constant = -1035; int32_t ne_constant = 825018; Node* p0 = m.Parameter(0); @@ -214,7 +215,7 @@ TEST(BranchCombineWord32EqualI) { for (int left = 0; left < 2; left++) { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); int32_t a = *i; Node* p0 = m.Int32Constant(a); @@ -243,7 +244,7 @@ TEST(BranchCombineInt32CmpP) { int32_t ne_constant = 725018; for (int op = 0; op < 2; op++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); @@ -275,7 +276,7 @@ TEST(BranchCombineInt32CmpI) { for (int op = 0; op < 2; op++) { FOR_INT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); int32_t a = *i; Node* p0 = m.Int32Constant(a); Node* p1 = m.Parameter(0); @@ -360,7 +361,7 @@ class CmpBranchGen : public BinopGen<int32_t> { TEST(BranchCombineInt32CmpAllInputShapes_materialized) { - for (size_t i = 0; i < ARRAY_SIZE(int32cmp_opcodes); i++) { + for (size_t i = 0; i < arraysize(int32cmp_opcodes); i++) { CmpMaterializeBoolGen gen(int32cmp_opcodes[i], false); Int32BinopInputShapeTester tester(&gen); tester.TestAllInputShapes(); @@ -369,7 +370,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_materialized) { TEST(BranchCombineInt32CmpAllInputShapes_inverted_materialized) { - for (size_t i = 0; i < ARRAY_SIZE(int32cmp_opcodes); i++) { + for (size_t i = 0; i < arraysize(int32cmp_opcodes); i++) { CmpMaterializeBoolGen gen(int32cmp_opcodes[i], true); Int32BinopInputShapeTester tester(&gen); tester.TestAllInputShapes(); @@ -378,7 +379,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_inverted_materialized) { TEST(BranchCombineInt32CmpAllInputShapes_branch_true) { - for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) { + for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) { CmpBranchGen gen(int32cmp_opcodes[i], false, false, 995 + i, -1011 - i); Int32BinopInputShapeTester tester(&gen); tester.TestAllInputShapes(); @@ -387,7 +388,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_branch_true) { TEST(BranchCombineInt32CmpAllInputShapes_branch_false) { - for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) { + for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) { CmpBranchGen gen(int32cmp_opcodes[i], false, true, 795 + i, -2011 - i); Int32BinopInputShapeTester tester(&gen); tester.TestAllInputShapes(); @@ -396,7 +397,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_branch_false) { TEST(BranchCombineInt32CmpAllInputShapes_inverse_branch_true) { - for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) { + for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) { CmpBranchGen gen(int32cmp_opcodes[i], true, false, 695 + i, -3011 - i); Int32BinopInputShapeTester tester(&gen); tester.TestAllInputShapes(); @@ -405,7 +406,7 @@ TEST(BranchCombineInt32CmpAllInputShapes_inverse_branch_true) { TEST(BranchCombineInt32CmpAllInputShapes_inverse_branch_false) { - for (int i = 0; i < static_cast<int>(ARRAY_SIZE(int32cmp_opcodes)); i++) { + for (int i = 0; i < static_cast<int>(arraysize(int32cmp_opcodes)); i++) { CmpBranchGen gen(int32cmp_opcodes[i], true, true, 595 + i, -4011 - i); Int32BinopInputShapeTester tester(&gen); tester.TestAllInputShapes(); @@ -428,12 +429,12 @@ TEST(BranchCombineFloat64Compares) { CompareWrapper(IrOpcode::kFloat64LessThan), CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)}; - for (size_t c = 0; c < ARRAY_SIZE(cmps); c++) { + for (size_t c = 0; c < arraysize(cmps); c++) { CompareWrapper cmp = cmps[c]; for (int invert = 0; invert < 2; invert++) { RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); + Node* a = m.LoadFromPointer(&input_a, kMachFloat64); + Node* b = m.LoadFromPointer(&input_b, kMachFloat64); MLabel blocka, blockb; Node* cond = cmp.MakeNode(&m, a, b); @@ -444,8 +445,8 @@ TEST(BranchCombineFloat64Compares) { m.Bind(&blockb); m.Return(m.Int32Constant(ne_constant)); - for (size_t i = 0; i < ARRAY_SIZE(inputs); i++) { - for (size_t j = 0; j < ARRAY_SIZE(inputs); j += 2) { + for (size_t i = 0; i < arraysize(inputs); i++) { + for (size_t j = 0; j < arraysize(inputs); j += 2) { input_a = inputs[i]; input_b = inputs[i]; int32_t expected = diff --git a/deps/v8/test/cctest/compiler/test-changes-lowering.cc b/deps/v8/test/cctest/compiler/test-changes-lowering.cc index 148f4b34f5..06308a0b50 100644 --- a/deps/v8/test/cctest/compiler/test-changes-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-changes-lowering.cc @@ -4,15 +4,16 @@ #include <limits> +#include "src/compiler/change-lowering.h" #include "src/compiler/control-builders.h" #include "src/compiler/generic-node-inl.h" +#include "src/compiler/js-graph.h" #include "src/compiler/node-properties-inl.h" #include "src/compiler/pipeline.h" -#include "src/compiler/simplified-lowering.h" -#include "src/compiler/simplified-node-factory.h" #include "src/compiler/typer.h" #include "src/compiler/verifier.h" #include "src/execution.h" +#include "src/globals.h" #include "src/parser.h" #include "src/rewriter.h" #include "src/scopes.h" @@ -27,18 +28,17 @@ using namespace v8::internal::compiler; template <typename ReturnType> class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { public: - explicit ChangesLoweringTester(MachineType p0 = kMachineLast) + explicit ChangesLoweringTester(MachineType p0 = kMachNone) : GraphBuilderTester<ReturnType>(p0), typer(this->zone()), - source_positions(this->graph()), - jsgraph(this->graph(), this->common(), &typer), - lowering(&jsgraph, &source_positions), + javascript(this->zone()), + jsgraph(this->graph(), this->common(), &javascript, &typer, + this->machine()), function(Handle<JSFunction>::null()) {} Typer typer; - SourcePositionTable source_positions; + JSOperatorBuilder javascript; JSGraph jsgraph; - SimplifiedLowering lowering; Handle<JSFunction> function; Node* start() { return this->graph()->start(); } @@ -55,12 +55,13 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { "(function() { 'use strict'; return 2.7123; })"))); CompilationInfoWithZone info(function); CHECK(Parser::Parse(&info)); - StrictMode strict_mode = info.function()->strict_mode(); - info.SetStrictMode(strict_mode); info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); CHECK(Rewriter::Rewrite(&info)); CHECK(Scope::Analyze(&info)); CHECK_NE(NULL, info.scope()); + Handle<ScopeInfo> scope_info = + ScopeInfo::Create(info.scope(), info.zone()); + info.shared_info()->set_scope_info(*scope_info); Pipeline pipeline(&info); Linkage linkage(&info); Handle<Code> code = @@ -77,29 +78,29 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { void StoreFloat64(Node* node, double* ptr) { Node* ptr_node = this->PointerConstant(ptr); - this->Store(kMachineFloat64, ptr_node, node); + this->Store(kMachFloat64, ptr_node, node); } Node* LoadInt32(int32_t* ptr) { Node* ptr_node = this->PointerConstant(ptr); - return this->Load(kMachineWord32, ptr_node); + return this->Load(kMachInt32, ptr_node); } Node* LoadUint32(uint32_t* ptr) { Node* ptr_node = this->PointerConstant(ptr); - return this->Load(kMachineWord32, ptr_node); + return this->Load(kMachUint32, ptr_node); } Node* LoadFloat64(double* ptr) { Node* ptr_node = this->PointerConstant(ptr); - return this->Load(kMachineFloat64, ptr_node); + return this->Load(kMachFloat64, ptr_node); } void CheckNumber(double expected, Object* number) { CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number)); } - void BuildAndLower(Operator* op) { + void BuildAndLower(const Operator* op) { // We build a graph by hand here, because the raw machine assembler // does not add the correct control and effect nodes. Node* p0 = this->Parameter(0); @@ -108,11 +109,11 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { this->start(), this->start()); Node* end = this->graph()->NewNode(this->common()->End(), ret); this->graph()->SetEnd(end); - this->lowering.LowerChange(change, this->start(), this->start()); - Verifier::Run(this->graph()); + LowerChange(change); } - void BuildStoreAndLower(Operator* op, Operator* store_op, void* location) { + void BuildStoreAndLower(const Operator* op, const Operator* store_op, + void* location) { // We build a graph by hand here, because the raw machine assembler // does not add the correct control and effect nodes. Node* p0 = this->Parameter(0); @@ -124,11 +125,11 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { this->common()->Return(), this->Int32Constant(0), store, this->start()); Node* end = this->graph()->NewNode(this->common()->End(), ret); this->graph()->SetEnd(end); - this->lowering.LowerChange(change, this->start(), this->start()); - Verifier::Run(this->graph()); + LowerChange(change); } - void BuildLoadAndLower(Operator* op, Operator* load_op, void* location) { + void BuildLoadAndLower(const Operator* op, const Operator* load_op, + void* location) { // We build a graph by hand here, because the raw machine assembler // does not add the correct control and effect nodes. Node* load = @@ -139,7 +140,17 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { this->start(), this->start()); Node* end = this->graph()->NewNode(this->common()->End(), ret); this->graph()->SetEnd(end); - this->lowering.LowerChange(change, this->start(), this->start()); + LowerChange(change); + } + + void LowerChange(Node* change) { + // Run the graph reducer with changes lowering on a single node. + CompilationInfo info(this->isolate(), this->zone()); + Linkage linkage(&info); + ChangeLowering lowering(&jsgraph, &linkage); + GraphReducer reducer(this->graph()); + reducer.AddReducer(&lowering); + reducer.ReduceNode(change); Verifier::Run(this->graph()); } @@ -150,7 +161,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { TEST(RunChangeTaggedToInt32) { // Build and lower a graph by hand. - ChangesLoweringTester<int32_t> t(kMachineTagged); + ChangesLoweringTester<int32_t> t(kMachAnyTagged); t.BuildAndLower(t.simplified()->ChangeTaggedToInt32()); if (Pipeline::SupportedTarget()) { @@ -180,7 +191,7 @@ TEST(RunChangeTaggedToInt32) { TEST(RunChangeTaggedToUint32) { // Build and lower a graph by hand. - ChangesLoweringTester<uint32_t> t(kMachineTagged); + ChangesLoweringTester<uint32_t> t(kMachAnyTagged); t.BuildAndLower(t.simplified()->ChangeTaggedToUint32()); if (Pipeline::SupportedTarget()) { @@ -209,12 +220,13 @@ TEST(RunChangeTaggedToUint32) { TEST(RunChangeTaggedToFloat64) { - ChangesLoweringTester<int32_t> t(kMachineTagged); + ChangesLoweringTester<int32_t> t(kMachAnyTagged); double result; - t.BuildStoreAndLower(t.simplified()->ChangeTaggedToFloat64(), - t.machine()->Store(kMachineFloat64, kNoWriteBarrier), - &result); + t.BuildStoreAndLower( + t.simplified()->ChangeTaggedToFloat64(), + t.machine()->Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier)), + &result); if (Pipeline::SupportedTarget()) { FOR_INT32_INPUTS(i) { @@ -259,7 +271,7 @@ TEST(RunChangeTaggedToFloat64) { TEST(RunChangeBoolToBit) { - ChangesLoweringTester<int32_t> t(kMachineTagged); + ChangesLoweringTester<int32_t> t(kMachAnyTagged); t.BuildAndLower(t.simplified()->ChangeBoolToBit()); if (Pipeline::SupportedTarget()) { @@ -277,7 +289,7 @@ TEST(RunChangeBoolToBit) { TEST(RunChangeBitToBool) { - ChangesLoweringTester<Object*> t(kMachineWord32); + ChangesLoweringTester<Object*> t(kMachInt32); t.BuildAndLower(t.simplified()->ChangeBitToBool()); if (Pipeline::SupportedTarget()) { @@ -294,73 +306,82 @@ TEST(RunChangeBitToBool) { } -bool TODO_INT32_TO_TAGGED_WILL_WORK(int32_t v) { - // TODO(titzer): enable all UI32 -> Tagged checking when inline allocation - // works. - return Smi::IsValid(v); -} - - -bool TODO_UINT32_TO_TAGGED_WILL_WORK(uint32_t v) { - // TODO(titzer): enable all UI32 -> Tagged checking when inline allocation - // works. - return v <= static_cast<uint32_t>(Smi::kMaxValue); -} - +#if V8_TURBOFAN_BACKEND +// TODO(titzer): disabled on ARM -TEST(RunChangeInt32ToTagged) { +TEST(RunChangeInt32ToTaggedSmi) { ChangesLoweringTester<Object*> t; int32_t input; t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), - t.machine()->Load(kMachineWord32), &input); + t.machine()->Load(kMachInt32), &input); if (Pipeline::SupportedTarget()) { FOR_INT32_INPUTS(i) { input = *i; - Object* result = t.CallWithPotentialGC<Object>(); - if (TODO_INT32_TO_TAGGED_WILL_WORK(input)) { - t.CheckNumber(static_cast<double>(input), result); - } - } - } - - if (Pipeline::SupportedTarget()) { - FOR_INT32_INPUTS(i) { - input = *i; - SimulateFullSpace(CcTest::heap()->new_space()); - Object* result = t.CallWithPotentialGC<Object>(); - if (TODO_INT32_TO_TAGGED_WILL_WORK(input)) { - t.CheckNumber(static_cast<double>(input), result); - } + if (!Smi::IsValid(input)) continue; + Object* result = t.Call(); + t.CheckNumber(static_cast<double>(input), result); } } } -TEST(RunChangeUint32ToTagged) { +TEST(RunChangeUint32ToTaggedSmi) { ChangesLoweringTester<Object*> t; uint32_t input; t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), - t.machine()->Load(kMachineWord32), &input); + t.machine()->Load(kMachUint32), &input); if (Pipeline::SupportedTarget()) { FOR_UINT32_INPUTS(i) { input = *i; - Object* result = t.CallWithPotentialGC<Object>(); + if (input > static_cast<uint32_t>(Smi::kMaxValue)) continue; + Object* result = t.Call(); double expected = static_cast<double>(input); - if (TODO_UINT32_TO_TAGGED_WILL_WORK(input)) { - t.CheckNumber(expected, result); + t.CheckNumber(expected, result); + } + } +} + + +TEST(RunChangeInt32ToTagged) { + ChangesLoweringTester<Object*> t; + int32_t input; + t.BuildLoadAndLower(t.simplified()->ChangeInt32ToTagged(), + t.machine()->Load(kMachInt32), &input); + + if (Pipeline::SupportedTarget()) { + for (int m = 0; m < 3; m++) { // Try 3 GC modes. + FOR_INT32_INPUTS(i) { + if (m == 0) CcTest::heap()->EnableInlineAllocation(); + if (m == 1) CcTest::heap()->DisableInlineAllocation(); + if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); + + input = *i; + Object* result = t.CallWithPotentialGC<Object>(); + t.CheckNumber(static_cast<double>(input), result); } } } +} + + +TEST(RunChangeUint32ToTagged) { + ChangesLoweringTester<Object*> t; + uint32_t input; + t.BuildLoadAndLower(t.simplified()->ChangeUint32ToTagged(), + t.machine()->Load(kMachUint32), &input); if (Pipeline::SupportedTarget()) { - FOR_UINT32_INPUTS(i) { - input = *i; - SimulateFullSpace(CcTest::heap()->new_space()); - Object* result = t.CallWithPotentialGC<Object>(); - double expected = static_cast<double>(static_cast<uint32_t>(input)); - if (TODO_UINT32_TO_TAGGED_WILL_WORK(input)) { + for (int m = 0; m < 3; m++) { // Try 3 GC modes. + FOR_UINT32_INPUTS(i) { + if (m == 0) CcTest::heap()->EnableInlineAllocation(); + if (m == 1) CcTest::heap()->DisableInlineAllocation(); + if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); + + input = *i; + Object* result = t.CallWithPotentialGC<Object>(); + double expected = static_cast<double>(input); t.CheckNumber(expected, result); } } @@ -368,30 +389,25 @@ TEST(RunChangeUint32ToTagged) { } -// TODO(titzer): lowering of Float64->Tagged needs inline allocation. -#define TODO_FLOAT64_TO_TAGGED false - TEST(RunChangeFloat64ToTagged) { ChangesLoweringTester<Object*> t; double input; t.BuildLoadAndLower(t.simplified()->ChangeFloat64ToTagged(), - t.machine()->Load(kMachineFloat64), &input); + t.machine()->Load(kMachFloat64), &input); - // TODO(titzer): need inline allocation to change float to tagged. - if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) { - FOR_FLOAT64_INPUTS(i) { - input = *i; - Object* result = t.CallWithPotentialGC<Object>(); - t.CheckNumber(input, result); - } - } - - if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) { - FOR_FLOAT64_INPUTS(i) { - input = *i; - SimulateFullSpace(CcTest::heap()->new_space()); - Object* result = t.CallWithPotentialGC<Object>(); - t.CheckNumber(input, result); + if (Pipeline::SupportedTarget()) { + for (int m = 0; m < 3; m++) { // Try 3 GC modes. + FOR_FLOAT64_INPUTS(i) { + if (m == 0) CcTest::heap()->EnableInlineAllocation(); + if (m == 1) CcTest::heap()->DisableInlineAllocation(); + if (m == 2) SimulateFullSpace(CcTest::heap()->new_space()); + + input = *i; + Object* result = t.CallWithPotentialGC<Object>(); + t.CheckNumber(input, result); + } } } } + +#endif // V8_TURBOFAN_BACKEND diff --git a/deps/v8/test/cctest/compiler/test-codegen-deopt.cc b/deps/v8/test/cctest/compiler/test-codegen-deopt.cc index b953ee53cc..8217229bd5 100644 --- a/deps/v8/test/cctest/compiler/test-codegen-deopt.cc +++ b/deps/v8/test/cctest/compiler/test-codegen-deopt.cc @@ -20,6 +20,7 @@ #include "src/parser.h" #include "src/rewriter.h" +#include "test/cctest/compiler/c-signature.h" #include "test/cctest/compiler/function-tester.h" using namespace v8::internal; @@ -44,14 +45,10 @@ class DeoptCodegenTester { info(function, scope->main_zone()), bailout_id(-1) { CHECK(Parser::Parse(&info)); - StrictMode strict_mode = info.function()->strict_mode(); - info.SetStrictMode(strict_mode); info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); CHECK(Rewriter::Rewrite(&info)); CHECK(Scope::Analyze(&info)); - CHECK_NE(NULL, info.scope()); - - FunctionTester::EnsureDeoptimizationSupport(&info); + CHECK(Compiler::EnsureDeoptimizationSupport(&info)); DCHECK(info.shared_info()->has_deoptimization_support()); @@ -62,7 +59,9 @@ class DeoptCodegenTester { void GenerateCodeFromSchedule(Schedule* schedule) { OFStream os(stdout); - os << *schedule; + if (FLAG_trace_turbo) { + os << *schedule; + } // Initialize the codegen and generate code. Linkage* linkage = new (scope_->main_zone()) Linkage(&info); @@ -72,20 +71,26 @@ class DeoptCodegenTester { InstructionSelector selector(code, &source_positions); selector.SelectInstructions(); - os << "----- Instruction sequence before register allocation -----\n" - << *code; + if (FLAG_trace_turbo) { + os << "----- Instruction sequence before register allocation -----\n" + << *code; + } RegisterAllocator allocator(code); CHECK(allocator.Allocate()); - os << "----- Instruction sequence after register allocation -----\n" - << *code; + if (FLAG_trace_turbo) { + os << "----- Instruction sequence after register allocation -----\n" + << *code; + } compiler::CodeGenerator generator(code); result_code = generator.GenerateCode(); -#ifdef DEBUG - result_code->Print(); +#ifdef OBJECT_PRINT + if (FLAG_print_opt_code || FLAG_trace_turbo) { + result_code->Print(); + } #endif } @@ -112,7 +117,6 @@ class TrivialDeoptCodegenTester : public DeoptCodegenTester { } Schedule* BuildGraphAndSchedule(Graph* graph) { - Isolate* isolate = info.isolate(); CommonOperatorBuilder common(zone()); // Manually construct a schedule for the function below: @@ -120,49 +124,42 @@ class TrivialDeoptCodegenTester : public DeoptCodegenTester { // deopt(); // } - MachineType parameter_reps[] = {kMachineTagged}; - MachineCallDescriptorBuilder descriptor_builder(kMachineTagged, 1, - parameter_reps); - - RawMachineAssembler m(graph, &descriptor_builder); - - Handle<Object> undef_object = - Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> undef_constant = - PrintableUnique<Object>::CreateUninitialized(zone(), undef_object); - Node* undef_node = m.NewNode(common.HeapConstant(undef_constant)); + CSignature1<Object*, Object*> sig; + RawMachineAssembler m(graph, &sig); Handle<JSFunction> deopt_function = NewFunction("function deopt() { %DeoptimizeFunction(foo); }; deopt"); - PrintableUnique<Object> deopt_fun_constant = - PrintableUnique<Object>::CreateUninitialized(zone(), deopt_function); + Unique<Object> deopt_fun_constant = + Unique<Object>::CreateUninitialized(deopt_function); Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant)); - MLabel deopt, cont; - Node* call = m.CallJS0(deopt_fun_node, undef_node, &cont, &deopt); - - m.Bind(&cont); - m.NewNode(common.Continuation(), call); - m.Return(undef_node); - - m.Bind(&deopt); - m.NewNode(common.LazyDeoptimization(), call); + Handle<Context> caller_context(function->context(), CcTest::i_isolate()); + Unique<Object> caller_context_constant = + Unique<Object>::CreateUninitialized(caller_context); + Node* caller_context_node = + m.NewNode(common.HeapConstant(caller_context_constant)); bailout_id = GetCallBailoutId(); - Node* parameters = m.NewNode(common.StateValues(1), undef_node); + Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); Node* locals = m.NewNode(common.StateValues(0)); Node* stack = m.NewNode(common.StateValues(0)); - Node* state_node = - m.NewNode(common.FrameState(bailout_id), parameters, locals, stack); - m.Deoptimize(state_node); + Node* state_node = m.NewNode( + common.FrameState(JS_FRAME, bailout_id, kIgnoreOutput), parameters, + locals, stack, caller_context_node, m.UndefinedConstant()); + + Handle<Context> context(deopt_function->context(), CcTest::i_isolate()); + Unique<Object> context_constant = + Unique<Object>::CreateUninitialized(context); + Node* context_node = m.NewNode(common.HeapConstant(context_constant)); + + m.CallJS0(deopt_fun_node, m.UndefinedConstant(), context_node, state_node); + + m.Return(m.UndefinedConstant()); // Schedule the graph: Schedule* schedule = m.Export(); - cont_block = cont.block(); - deopt_block = deopt.block(); - return schedule; } @@ -177,9 +174,6 @@ class TrivialDeoptCodegenTester : public DeoptCodegenTester { CHECK(false); return BailoutId(-1); } - - BasicBlock* cont_block; - BasicBlock* deopt_block; }; @@ -196,18 +190,10 @@ TEST(TurboTrivialDeoptCodegen) { DeoptimizationInputData* data = DeoptimizationInputData::cast(t.result_code->deoptimization_data()); - Label* cont_label = t.code->GetLabel(t.cont_block); - Label* deopt_label = t.code->GetLabel(t.deopt_block); - - // Check the patch table. It should patch the continuation address to the - // deoptimization block address. - CHECK_EQ(1, data->ReturnAddressPatchCount()); - CHECK_EQ(cont_label->pos(), data->ReturnAddressPc(0)->value()); - CHECK_EQ(deopt_label->pos(), data->PatchedAddressPc(0)->value()); + // TODO(jarin) Find a way to test the safepoint. // Check that we deoptimize to the right AST id. CHECK_EQ(1, data->DeoptCount()); - CHECK_EQ(1, data->DeoptCount()); CHECK_EQ(t.bailout_id.ToInt(), data->AstId(0).ToInt()); } @@ -248,7 +234,6 @@ class TrivialRuntimeDeoptCodegenTester : public DeoptCodegenTester { } Schedule* BuildGraphAndSchedule(Graph* graph) { - Isolate* isolate = info.isolate(); CommonOperatorBuilder common(zone()); // Manually construct a schedule for the function below: @@ -256,48 +241,35 @@ class TrivialRuntimeDeoptCodegenTester : public DeoptCodegenTester { // %DeoptimizeFunction(foo); // } - MachineType parameter_reps[] = {kMachineTagged}; - MachineCallDescriptorBuilder descriptor_builder(kMachineTagged, 2, - parameter_reps); - - RawMachineAssembler m(graph, &descriptor_builder); - - Handle<Object> undef_object = - Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> undef_constant = - PrintableUnique<Object>::CreateUninitialized(zone(), undef_object); - Node* undef_node = m.NewNode(common.HeapConstant(undef_constant)); + CSignature1<Object*, Object*> sig; + RawMachineAssembler m(graph, &sig); - PrintableUnique<Object> this_fun_constant = - PrintableUnique<Object>::CreateUninitialized(zone(), function); + Unique<Object> this_fun_constant = + Unique<Object>::CreateUninitialized(function); Node* this_fun_node = m.NewNode(common.HeapConstant(this_fun_constant)); - MLabel deopt, cont; - Node* call = m.CallRuntime1(Runtime::kDeoptimizeFunction, this_fun_node, - &cont, &deopt); - - m.Bind(&cont); - m.NewNode(common.Continuation(), call); - m.Return(undef_node); - - m.Bind(&deopt); - m.NewNode(common.LazyDeoptimization(), call); + Handle<Context> context(function->context(), CcTest::i_isolate()); + Unique<Object> context_constant = + Unique<Object>::CreateUninitialized(context); + Node* context_node = m.NewNode(common.HeapConstant(context_constant)); bailout_id = GetCallBailoutId(); - Node* parameters = m.NewNode(common.StateValues(1), undef_node); + Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant()); Node* locals = m.NewNode(common.StateValues(0)); Node* stack = m.NewNode(common.StateValues(0)); - Node* state_node = - m.NewNode(common.FrameState(bailout_id), parameters, locals, stack); - m.Deoptimize(state_node); + Node* state_node = m.NewNode( + common.FrameState(JS_FRAME, bailout_id, kIgnoreOutput), parameters, + locals, stack, context_node, m.UndefinedConstant()); + + m.CallRuntime1(Runtime::kDeoptimizeFunction, this_fun_node, context_node, + state_node); + + m.Return(m.UndefinedConstant()); // Schedule the graph: Schedule* schedule = m.Export(); - cont_block = cont.block(); - deopt_block = deopt.block(); - return schedule; } @@ -312,9 +284,6 @@ class TrivialRuntimeDeoptCodegenTester : public DeoptCodegenTester { CHECK(false); return BailoutId(-1); } - - BasicBlock* cont_block; - BasicBlock* deopt_block; }; diff --git a/deps/v8/test/cctest/compiler/test-gap-resolver.cc b/deps/v8/test/cctest/compiler/test-gap-resolver.cc index 00c220945d..6239f2a406 100644 --- a/deps/v8/test/cctest/compiler/test-gap-resolver.cc +++ b/deps/v8/test/cctest/compiler/test-gap-resolver.cc @@ -77,14 +77,14 @@ class InterpreterState { class MoveInterpreter : public GapResolver::Assembler { public: virtual void AssembleMove(InstructionOperand* source, - InstructionOperand* destination) V8_OVERRIDE { + InstructionOperand* destination) OVERRIDE { InterpreterState::Moves moves; moves.push_back(MoveOperands(source, destination)); state_.ExecuteInParallel(moves); } virtual void AssembleSwap(InstructionOperand* source, - InstructionOperand* destination) V8_OVERRIDE { + InstructionOperand* destination) OVERRIDE { InterpreterState::Moves moves; moves.push_back(MoveOperands(source, destination)); moves.push_back(MoveOperands(destination, source)); diff --git a/deps/v8/test/cctest/compiler/test-graph-reducer.cc b/deps/v8/test/cctest/compiler/test-graph-reducer.cc index 189b3db18e..b94ca45855 100644 --- a/deps/v8/test/cctest/compiler/test-graph-reducer.cc +++ b/deps/v8/test/cctest/compiler/test-graph-reducer.cc @@ -102,10 +102,10 @@ class InPlaceBCReducer : public Reducer { // Wraps all "OPA0" nodes in "OPB1" operators by allocating new nodes. -class A0Wrapper V8_FINAL : public Reducer { +class A0Wrapper FINAL : public Reducer { public: explicit A0Wrapper(Graph* graph) : graph_(graph) {} - virtual Reduction Reduce(Node* node) V8_OVERRIDE { + virtual Reduction Reduce(Node* node) OVERRIDE { switch (node->op()->opcode()) { case OPCODE_A0: CHECK_EQ(0, node->InputCount()); @@ -118,10 +118,10 @@ class A0Wrapper V8_FINAL : public Reducer { // Wraps all "OPB0" nodes in two "OPC1" operators by allocating new nodes. -class B0Wrapper V8_FINAL : public Reducer { +class B0Wrapper FINAL : public Reducer { public: explicit B0Wrapper(Graph* graph) : graph_(graph) {} - virtual Reduction Reduce(Node* node) V8_OVERRIDE { + virtual Reduction Reduce(Node* node) OVERRIDE { switch (node->op()->opcode()) { case OPCODE_B0: CHECK_EQ(0, node->InputCount()); @@ -470,9 +470,9 @@ TEST(ReduceForward1) { reducer.ReduceGraph(); CHECK_EQ(before, graph.NodeCount()); CHECK_EQ(&OPB0, n1->op()); - CHECK_EQ(&OPB1, n2->op()); + CHECK(n2->IsDead()); CHECK_EQ(n1, end->InputAt(0)); - CHECK_EQ(&OPB1, n3->op()); + CHECK(n3->IsDead()); CHECK_EQ(n1, end->InputAt(0)); CHECK_EQ(&OPB2, end->op()); CHECK_EQ(0, n2->UseCount()); @@ -621,41 +621,3 @@ TEST(Order) { } } } - - -// Tests that a reducer is only applied once. -class OneTimeReducer : public Reducer { - public: - OneTimeReducer(Reducer* reducer, Zone* zone) - : reducer_(reducer), - nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)) {} - virtual Reduction Reduce(Node* node) { - CHECK_EQ(0, static_cast<int>(nodes_.count(node))); - nodes_.insert(node); - return reducer_->Reduce(node); - } - Reducer* reducer_; - NodeSet nodes_; -}; - - -TEST(OneTimeReduce1) { - GraphTester graph; - - Node* n1 = graph.NewNode(&OPA0); - Node* end = graph.NewNode(&OPA1, n1); - graph.SetEnd(end); - - GraphReducer reducer(&graph); - InPlaceABReducer r; - OneTimeReducer once(&r, graph.zone()); - reducer.AddReducer(&once); - - // Tests A* => B* with in-place updates. Should only be applied once. - int before = graph.NodeCount(); - reducer.ReduceGraph(); - CHECK_EQ(before, graph.NodeCount()); - CHECK_EQ(&OPB0, n1->op()); - CHECK_EQ(&OPB1, end->op()); - CHECK_EQ(n1, end->InputAt(0)); -} diff --git a/deps/v8/test/cctest/compiler/test-instruction-selector-arm.cc b/deps/v8/test/cctest/compiler/test-instruction-selector-arm.cc deleted file mode 100644 index f62e09f978..0000000000 --- a/deps/v8/test/cctest/compiler/test-instruction-selector-arm.cc +++ /dev/null @@ -1,1863 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <list> - -#include "test/cctest/compiler/instruction-selector-tester.h" -#include "test/cctest/compiler/value-helper.h" - -using namespace v8::internal; -using namespace v8::internal::compiler; - -namespace { - -typedef RawMachineAssembler::Label MLabel; - -struct DPI { - Operator* op; - ArchOpcode arch_opcode; - ArchOpcode reverse_arch_opcode; - ArchOpcode test_arch_opcode; -}; - - -// ARM data processing instructions. -class DPIs V8_FINAL : public std::list<DPI>, private HandleAndZoneScope { - public: - DPIs() { - MachineOperatorBuilder machine(main_zone()); - DPI and_ = {machine.Word32And(), kArmAnd, kArmAnd, kArmTst}; - push_back(and_); - DPI or_ = {machine.Word32Or(), kArmOrr, kArmOrr, kArmOrr}; - push_back(or_); - DPI xor_ = {machine.Word32Xor(), kArmEor, kArmEor, kArmTeq}; - push_back(xor_); - DPI add = {machine.Int32Add(), kArmAdd, kArmAdd, kArmCmn}; - push_back(add); - DPI sub = {machine.Int32Sub(), kArmSub, kArmRsb, kArmCmp}; - push_back(sub); - } -}; - - -struct ODPI { - Operator* op; - ArchOpcode arch_opcode; - ArchOpcode reverse_arch_opcode; -}; - - -// ARM data processing instructions with overflow. -class ODPIs V8_FINAL : public std::list<ODPI>, private HandleAndZoneScope { - public: - ODPIs() { - MachineOperatorBuilder machine(main_zone()); - ODPI add = {machine.Int32AddWithOverflow(), kArmAdd, kArmAdd}; - push_back(add); - ODPI sub = {machine.Int32SubWithOverflow(), kArmSub, kArmRsb}; - push_back(sub); - } -}; - - -// ARM immediates. -class Immediates V8_FINAL : public std::list<int32_t> { - public: - Immediates() { - for (uint32_t imm8 = 0; imm8 < 256; ++imm8) { - for (uint32_t rot4 = 0; rot4 < 32; rot4 += 2) { - int32_t imm = (imm8 >> rot4) | (imm8 << (32 - rot4)); - CHECK(Assembler::ImmediateFitsAddrMode1Instruction(imm)); - push_back(imm); - } - } - } -}; - - -struct Shift { - Operator* op; - int32_t i_low; // lowest possible immediate - int32_t i_high; // highest possible immediate - AddressingMode i_mode; // Operand2_R_<shift>_I - AddressingMode r_mode; // Operand2_R_<shift>_R -}; - - -// ARM shifts. -class Shifts V8_FINAL : public std::list<Shift>, private HandleAndZoneScope { - public: - Shifts() { - MachineOperatorBuilder machine(main_zone()); - Shift sar = {machine.Word32Sar(), 1, 32, kMode_Operand2_R_ASR_I, - kMode_Operand2_R_ASR_R}; - Shift shl = {machine.Word32Shl(), 0, 31, kMode_Operand2_R_LSL_I, - kMode_Operand2_R_LSL_R}; - Shift shr = {machine.Word32Shr(), 1, 32, kMode_Operand2_R_LSR_I, - kMode_Operand2_R_LSR_R}; - push_back(sar); - push_back(shl); - push_back(shr); - } -}; - -} // namespace - - -TEST(InstructionSelectorDPIP) { - DPIs dpis; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - InstructionSelectorTester m; - m.Return(m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - } -} - - -TEST(InstructionSelectorDPIImm) { - DPIs dpis; - Immediates immediates; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - for (Immediates::const_iterator j = immediates.begin(); - j != immediates.end(); ++j) { - int32_t imm = *j; - { - InstructionSelectorTester m; - m.Return(m.NewNode(dpi.op, m.Parameter(0), m.Int32Constant(imm))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.NewNode(dpi.op, m.Int32Constant(imm), m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - } - } - } -} - - -TEST(InstructionSelectorDPIAndShiftP) { - DPIs dpis; - Shifts shifts; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - for (Shifts::const_iterator j = shifts.begin(); j != shifts.end(); ++j) { - Shift shift = *j; - { - InstructionSelectorTester m; - m.Return( - m.NewNode(dpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), m.Parameter(2)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.NewNode(dpi.op, - m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), - m.Parameter(2))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - } - } -} - - -TEST(InstructionSelectorDPIAndRotateRightP) { - DPIs dpis; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - { - InstructionSelectorTester m; - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = m.Word32Or( - m.Word32Shr(value, shift), - m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift))); - m.Return(m.NewNode(dpi.op, m.Parameter(0), ror)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = - m.Word32Or(m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift)), - m.Word32Shr(value, shift)); - m.Return(m.NewNode(dpi.op, m.Parameter(0), ror)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = m.Word32Or( - m.Word32Shr(value, shift), - m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift))); - m.Return(m.NewNode(dpi.op, ror, m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = - m.Word32Or(m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift)), - m.Word32Shr(value, shift)); - m.Return(m.NewNode(dpi.op, ror, m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - } - } -} - - -TEST(InstructionSelectorDPIAndShiftImm) { - DPIs dpis; - Shifts shifts; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - for (Shifts::const_iterator j = shifts.begin(); j != shifts.end(); ++j) { - Shift shift = *j; - for (int32_t imm = shift.i_low; imm <= shift.i_high; ++imm) { - { - InstructionSelectorTester m; - m.Return(m.NewNode( - dpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), m.Int32Constant(imm)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.NewNode( - dpi.op, m.NewNode(shift.op, m.Parameter(0), m.Int32Constant(imm)), - m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - } - } - } - } -} - - -TEST(InstructionSelectorODPIP) { - ODPIs odpis; - for (ODPIs::const_iterator i = odpis.begin(); i != odpis.end(); ++i) { - ODPI odpi = *i; - { - InstructionSelectorTester m; - m.Return( - m.Projection(1, m.NewNode(odpi.op, m.Parameter(0), m.Parameter(1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return( - m.Projection(0, m.NewNode(odpi.op, m.Parameter(0), m.Parameter(1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_none, m.code[0]->flags_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - Node* node = m.NewNode(odpi.op, m.Parameter(0), m.Parameter(1)); - m.Return(m.Word32Equal(m.Projection(0, node), m.Projection(1, node))); - m.SelectInstructions(); - CHECK_LE(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(2, m.code[0]->OutputCount()); - } - } -} - - -TEST(InstructionSelectorODPIImm) { - ODPIs odpis; - Immediates immediates; - for (ODPIs::const_iterator i = odpis.begin(); i != odpis.end(); ++i) { - ODPI odpi = *i; - for (Immediates::const_iterator j = immediates.begin(); - j != immediates.end(); ++j) { - int32_t imm = *j; - { - InstructionSelectorTester m; - m.Return(m.Projection( - 1, m.NewNode(odpi.op, m.Parameter(0), m.Int32Constant(imm)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 1, m.NewNode(odpi.op, m.Int32Constant(imm), m.Parameter(0)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 0, m.NewNode(odpi.op, m.Parameter(0), m.Int32Constant(imm)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_none, m.code[0]->flags_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 0, m.NewNode(odpi.op, m.Int32Constant(imm), m.Parameter(0)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_none, m.code[0]->flags_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - Node* node = m.NewNode(odpi.op, m.Parameter(0), m.Int32Constant(imm)); - m.Return(m.Word32Equal(m.Projection(0, node), m.Projection(1, node))); - m.SelectInstructions(); - CHECK_LE(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(2, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - Node* node = m.NewNode(odpi.op, m.Int32Constant(imm), m.Parameter(0)); - m.Return(m.Word32Equal(m.Projection(0, node), m.Projection(1, node))); - m.SelectInstructions(); - CHECK_LE(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(2, m.code[0]->OutputCount()); - } - } - } -} - - -TEST(InstructionSelectorODPIAndShiftP) { - ODPIs odpis; - Shifts shifts; - for (ODPIs::const_iterator i = odpis.begin(); i != odpis.end(); ++i) { - ODPI odpi = *i; - for (Shifts::const_iterator j = shifts.begin(); j != shifts.end(); ++j) { - Shift shift = *j; - { - InstructionSelectorTester m; - m.Return(m.Projection( - 1, m.NewNode(odpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), m.Parameter(2))))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 1, m.NewNode(odpi.op, - m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), - m.Parameter(2)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 0, m.NewNode(odpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), m.Parameter(2))))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_none, m.code[0]->flags_mode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 0, m.NewNode(odpi.op, - m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), - m.Parameter(2)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_none, m.code[0]->flags_mode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - Node* node = - m.NewNode(odpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), m.Parameter(2))); - m.Return(m.Word32Equal(m.Projection(0, node), m.Projection(1, node))); - m.SelectInstructions(); - CHECK_LE(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(2, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - Node* node = m.NewNode( - odpi.op, m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), - m.Parameter(2)); - m.Return(m.Word32Equal(m.Projection(0, node), m.Projection(1, node))); - m.SelectInstructions(); - CHECK_LE(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(2, m.code[0]->OutputCount()); - } - } - } -} - - -TEST(InstructionSelectorODPIAndShiftImm) { - ODPIs odpis; - Shifts shifts; - for (ODPIs::const_iterator i = odpis.begin(); i != odpis.end(); ++i) { - ODPI odpi = *i; - for (Shifts::const_iterator j = shifts.begin(); j != shifts.end(); ++j) { - Shift shift = *j; - for (int32_t imm = shift.i_low; imm <= shift.i_high; ++imm) { - { - InstructionSelectorTester m; - m.Return(m.Projection(1, m.NewNode(odpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), - m.Int32Constant(imm))))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 1, m.NewNode(odpi.op, m.NewNode(shift.op, m.Parameter(0), - m.Int32Constant(imm)), - m.Parameter(1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection(0, m.NewNode(odpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), - m.Int32Constant(imm))))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_none, m.code[0]->flags_mode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - m.Return(m.Projection( - 0, m.NewNode(odpi.op, m.NewNode(shift.op, m.Parameter(0), - m.Int32Constant(imm)), - m.Parameter(1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_none, m.code[0]->flags_mode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2))); - CHECK_LE(1, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - Node* node = m.NewNode( - odpi.op, m.Parameter(0), - m.NewNode(shift.op, m.Parameter(1), m.Int32Constant(imm))); - m.Return(m.Word32Equal(m.Projection(0, node), m.Projection(1, node))); - m.SelectInstructions(); - CHECK_LE(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2))); - CHECK_EQ(2, m.code[0]->OutputCount()); - } - { - InstructionSelectorTester m; - Node* node = m.NewNode(odpi.op, m.NewNode(shift.op, m.Parameter(0), - m.Int32Constant(imm)), - m.Parameter(1)); - m.Return(m.Word32Equal(m.Projection(0, node), m.Projection(1, node))); - m.SelectInstructions(); - CHECK_LE(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(2))); - CHECK_EQ(2, m.code[0]->OutputCount()); - } - } - } - } -} - - -TEST(InstructionSelectorWord32AndAndWord32XorWithMinus1P) { - { - InstructionSelectorTester m; - m.Return(m.Word32And(m.Parameter(0), - m.Word32Xor(m.Int32Constant(-1), m.Parameter(1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32And(m.Parameter(0), - m.Word32Xor(m.Parameter(1), m.Int32Constant(-1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32And(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0)), - m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32And(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1)), - m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - } -} - - -TEST(InstructionSelectorWord32AndAndWord32XorWithMinus1AndShiftP) { - Shifts shifts; - for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) { - Shift shift = *i; - { - InstructionSelectorTester m; - m.Return(m.Word32And( - m.Parameter(0), - m.Word32Xor(m.Int32Constant(-1), - m.NewNode(shift.op, m.Parameter(1), m.Parameter(2))))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32And( - m.Parameter(0), - m.Word32Xor(m.NewNode(shift.op, m.Parameter(1), m.Parameter(2)), - m.Int32Constant(-1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32And( - m.Word32Xor(m.Int32Constant(-1), - m.NewNode(shift.op, m.Parameter(0), m.Parameter(1))), - m.Parameter(2))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32And( - m.Word32Xor(m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), - m.Int32Constant(-1)), - m.Parameter(2))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBic, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - } -} - - -TEST(InstructionSelectorWord32XorWithMinus1P) { - { - InstructionSelectorTester m; - m.Return(m.Word32Xor(m.Int32Constant(-1), m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMvn, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Xor(m.Parameter(0), m.Int32Constant(-1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMvn, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - } -} - - -TEST(InstructionSelectorWord32XorWithMinus1AndShiftP) { - Shifts shifts; - for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) { - Shift shift = *i; - { - InstructionSelectorTester m; - m.Return( - m.Word32Xor(m.Int32Constant(-1), - m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMvn, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Xor(m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), - m.Int32Constant(-1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMvn, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - } - } -} - - -TEST(InstructionSelectorShiftP) { - Shifts shifts; - for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) { - Shift shift = *i; - InstructionSelectorTester m; - m.Return(m.NewNode(shift.op, m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMov, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - } -} - - -TEST(InstructionSelectorShiftImm) { - Shifts shifts; - for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) { - Shift shift = *i; - for (int32_t imm = shift.i_low; imm <= shift.i_high; ++imm) { - InstructionSelectorTester m; - m.Return(m.NewNode(shift.op, m.Parameter(0), m.Int32Constant(imm))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMov, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } - } -} - - -TEST(InstructionSelectorRotateRightP) { - { - InstructionSelectorTester m; - Node* value = m.Parameter(0); - Node* shift = m.Parameter(1); - m.Return( - m.Word32Or(m.Word32Shr(value, shift), - m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMov, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - } - { - InstructionSelectorTester m; - Node* value = m.Parameter(0); - Node* shift = m.Parameter(1); - m.Return( - m.Word32Or(m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift)), - m.Word32Shr(value, shift))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMov, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - } -} - - -TEST(InstructionSelectorRotateRightImm) { - FOR_INPUTS(uint32_t, ror, i) { - uint32_t shift = *i; - { - InstructionSelectorTester m; - Node* value = m.Parameter(0); - m.Return(m.Word32Or(m.Word32Shr(value, m.Int32Constant(shift)), - m.Word32Shl(value, m.Int32Constant(32 - shift)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMov, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_I, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(shift, m.ToInt32(m.code[0]->InputAt(1))); - } - { - InstructionSelectorTester m; - Node* value = m.Parameter(0); - m.Return(m.Word32Or(m.Word32Shl(value, m.Int32Constant(32 - shift)), - m.Word32Shr(value, m.Int32Constant(shift)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMov, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_I, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(shift, m.ToInt32(m.code[0]->InputAt(1))); - } - } -} - - -TEST(InstructionSelectorInt32MulP) { - InstructionSelectorTester m; - m.Return(m.Int32Mul(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMul, m.code[0]->arch_opcode()); -} - - -TEST(InstructionSelectorInt32MulImm) { - // x * (2^k + 1) -> (x >> k) + x - for (int k = 1; k < 31; ++k) { - InstructionSelectorTester m; - m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmAdd, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_LSL_I, m.code[0]->addressing_mode()); - } - // (2^k + 1) * x -> (x >> k) + x - for (int k = 1; k < 31; ++k) { - InstructionSelectorTester m; - m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmAdd, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_LSL_I, m.code[0]->addressing_mode()); - } - // x * (2^k - 1) -> (x >> k) - x - for (int k = 3; k < 31; ++k) { - InstructionSelectorTester m; - m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) - 1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmRsb, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_LSL_I, m.code[0]->addressing_mode()); - } - // (2^k - 1) * x -> (x >> k) - x - for (int k = 3; k < 31; ++k) { - InstructionSelectorTester m; - m.Return(m.Int32Mul(m.Int32Constant((1 << k) - 1), m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmRsb, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_LSL_I, m.code[0]->addressing_mode()); - } -} - - -TEST(InstructionSelectorWord32AndImm_ARMv7) { - for (uint32_t width = 1; width <= 32; ++width) { - InstructionSelectorTester m; - m.Return(m.Word32And(m.Parameter(0), - m.Int32Constant(0xffffffffu >> (32 - width)))); - m.SelectInstructions(ARMv7); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmUbfx, m.code[0]->arch_opcode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(0, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(width, m.ToInt32(m.code[0]->InputAt(2))); - } - for (uint32_t lsb = 0; lsb <= 31; ++lsb) { - for (uint32_t width = 1; width < 32 - lsb; ++width) { - uint32_t msk = ~((0xffffffffu >> (32 - width)) << lsb); - InstructionSelectorTester m; - m.Return(m.Word32And(m.Parameter(0), m.Int32Constant(msk))); - m.SelectInstructions(ARMv7); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmBfc, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK(UnallocatedOperand::cast(m.code[0]->Output()) - ->HasSameAsInputPolicy()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(lsb, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(width, m.ToInt32(m.code[0]->InputAt(2))); - } - } -} - - -TEST(InstructionSelectorWord32AndAndWord32ShrImm_ARMv7) { - for (uint32_t lsb = 0; lsb <= 31; ++lsb) { - for (uint32_t width = 1; width <= 32 - lsb; ++width) { - { - InstructionSelectorTester m; - m.Return(m.Word32And(m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)), - m.Int32Constant(0xffffffffu >> (32 - width)))); - m.SelectInstructions(ARMv7); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmUbfx, m.code[0]->arch_opcode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(lsb, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(width, m.ToInt32(m.code[0]->InputAt(2))); - } - { - InstructionSelectorTester m; - m.Return( - m.Word32And(m.Int32Constant(0xffffffffu >> (32 - width)), - m.Word32Shr(m.Parameter(0), m.Int32Constant(lsb)))); - m.SelectInstructions(ARMv7); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmUbfx, m.code[0]->arch_opcode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(lsb, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(width, m.ToInt32(m.code[0]->InputAt(2))); - } - } - } -} - - -TEST(InstructionSelectorWord32ShrAndWord32AndImm_ARMv7) { - for (uint32_t lsb = 0; lsb <= 31; ++lsb) { - for (uint32_t width = 1; width <= 32 - lsb; ++width) { - uint32_t max = 1 << lsb; - if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; - uint32_t jnk = CcTest::random_number_generator()->NextInt(max); - uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; - { - InstructionSelectorTester m; - m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), - m.Int32Constant(lsb))); - m.SelectInstructions(ARMv7); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmUbfx, m.code[0]->arch_opcode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(lsb, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(width, m.ToInt32(m.code[0]->InputAt(2))); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Shr(m.Word32And(m.Int32Constant(msk), m.Parameter(0)), - m.Int32Constant(lsb))); - m.SelectInstructions(ARMv7); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmUbfx, m.code[0]->arch_opcode()); - CHECK_EQ(3, m.code[0]->InputCount()); - CHECK_EQ(lsb, m.ToInt32(m.code[0]->InputAt(1))); - CHECK_EQ(width, m.ToInt32(m.code[0]->InputAt(2))); - } - } - } -} - - -TEST(InstructionSelectorInt32SubAndInt32MulP) { - InstructionSelectorTester m; - m.Return( - m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); - m.SelectInstructions(); - CHECK_EQ(2, m.code.size()); - CHECK_EQ(kArmMul, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(kArmSub, m.code[1]->arch_opcode()); - CHECK_EQ(2, m.code[1]->InputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[1]->InputAt(1)); -} - - -TEST(InstructionSelectorInt32SubAndInt32MulP_MLS) { - InstructionSelectorTester m; - m.Return( - m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); - m.SelectInstructions(MLS); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmMls, m.code[0]->arch_opcode()); -} - - -TEST(InstructionSelectorInt32DivP) { - InstructionSelectorTester m; - m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(4, m.code.size()); - CHECK_EQ(kArmVcvtF64S32, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(kArmVcvtF64S32, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(kArmVdivF64, m.code[2]->arch_opcode()); - CHECK_EQ(2, m.code[2]->InputCount()); - CHECK_EQ(1, m.code[2]->OutputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[2]->InputAt(0)); - CheckSameVreg(m.code[1]->Output(), m.code[2]->InputAt(1)); - CHECK_EQ(kArmVcvtS32F64, m.code[3]->arch_opcode()); - CHECK_EQ(1, m.code[3]->InputCount()); - CheckSameVreg(m.code[2]->Output(), m.code[3]->InputAt(0)); -} - - -TEST(InstructionSelectorInt32DivP_SUDIV) { - InstructionSelectorTester m; - m.Return(m.Int32Div(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(SUDIV); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmSdiv, m.code[0]->arch_opcode()); -} - - -TEST(InstructionSelectorInt32UDivP) { - InstructionSelectorTester m; - m.Return(m.Int32UDiv(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(4, m.code.size()); - CHECK_EQ(kArmVcvtF64U32, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(kArmVcvtF64U32, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(kArmVdivF64, m.code[2]->arch_opcode()); - CHECK_EQ(2, m.code[2]->InputCount()); - CHECK_EQ(1, m.code[2]->OutputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[2]->InputAt(0)); - CheckSameVreg(m.code[1]->Output(), m.code[2]->InputAt(1)); - CHECK_EQ(kArmVcvtU32F64, m.code[3]->arch_opcode()); - CHECK_EQ(1, m.code[3]->InputCount()); - CheckSameVreg(m.code[2]->Output(), m.code[3]->InputAt(0)); -} - - -TEST(InstructionSelectorInt32UDivP_SUDIV) { - InstructionSelectorTester m; - m.Return(m.Int32UDiv(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(SUDIV); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmUdiv, m.code[0]->arch_opcode()); -} - - -TEST(InstructionSelectorInt32ModP) { - InstructionSelectorTester m; - m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(6, m.code.size()); - CHECK_EQ(kArmVcvtF64S32, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(kArmVcvtF64S32, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(kArmVdivF64, m.code[2]->arch_opcode()); - CHECK_EQ(2, m.code[2]->InputCount()); - CHECK_EQ(1, m.code[2]->OutputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[2]->InputAt(0)); - CheckSameVreg(m.code[1]->Output(), m.code[2]->InputAt(1)); - CHECK_EQ(kArmVcvtS32F64, m.code[3]->arch_opcode()); - CHECK_EQ(1, m.code[3]->InputCount()); - CheckSameVreg(m.code[2]->Output(), m.code[3]->InputAt(0)); - CHECK_EQ(kArmMul, m.code[4]->arch_opcode()); - CHECK_EQ(1, m.code[4]->OutputCount()); - CHECK_EQ(2, m.code[4]->InputCount()); - CheckSameVreg(m.code[3]->Output(), m.code[4]->InputAt(0)); - CheckSameVreg(m.code[1]->InputAt(0), m.code[4]->InputAt(1)); - CHECK_EQ(kArmSub, m.code[5]->arch_opcode()); - CHECK_EQ(1, m.code[5]->OutputCount()); - CHECK_EQ(2, m.code[5]->InputCount()); - CheckSameVreg(m.code[0]->InputAt(0), m.code[5]->InputAt(0)); - CheckSameVreg(m.code[4]->Output(), m.code[5]->InputAt(1)); -} - - -TEST(InstructionSelectorInt32ModP_SUDIV) { - InstructionSelectorTester m; - m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(SUDIV); - CHECK_EQ(3, m.code.size()); - CHECK_EQ(kArmSdiv, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(kArmMul, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(2, m.code[1]->InputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[1]->InputAt(0)); - CheckSameVreg(m.code[0]->InputAt(1), m.code[1]->InputAt(1)); - CHECK_EQ(kArmSub, m.code[2]->arch_opcode()); - CHECK_EQ(1, m.code[2]->OutputCount()); - CHECK_EQ(2, m.code[2]->InputCount()); - CheckSameVreg(m.code[0]->InputAt(0), m.code[2]->InputAt(0)); - CheckSameVreg(m.code[1]->Output(), m.code[2]->InputAt(1)); -} - - -TEST(InstructionSelectorInt32ModP_MLS_SUDIV) { - InstructionSelectorTester m; - m.Return(m.Int32Mod(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(MLS, SUDIV); - CHECK_EQ(2, m.code.size()); - CHECK_EQ(kArmSdiv, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(kArmMls, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(3, m.code[1]->InputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[1]->InputAt(0)); - CheckSameVreg(m.code[0]->InputAt(1), m.code[1]->InputAt(1)); - CheckSameVreg(m.code[0]->InputAt(0), m.code[1]->InputAt(2)); -} - - -TEST(InstructionSelectorInt32UModP) { - InstructionSelectorTester m; - m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(6, m.code.size()); - CHECK_EQ(kArmVcvtF64U32, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(kArmVcvtF64U32, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(kArmVdivF64, m.code[2]->arch_opcode()); - CHECK_EQ(2, m.code[2]->InputCount()); - CHECK_EQ(1, m.code[2]->OutputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[2]->InputAt(0)); - CheckSameVreg(m.code[1]->Output(), m.code[2]->InputAt(1)); - CHECK_EQ(kArmVcvtU32F64, m.code[3]->arch_opcode()); - CHECK_EQ(1, m.code[3]->InputCount()); - CheckSameVreg(m.code[2]->Output(), m.code[3]->InputAt(0)); - CHECK_EQ(kArmMul, m.code[4]->arch_opcode()); - CHECK_EQ(1, m.code[4]->OutputCount()); - CHECK_EQ(2, m.code[4]->InputCount()); - CheckSameVreg(m.code[3]->Output(), m.code[4]->InputAt(0)); - CheckSameVreg(m.code[1]->InputAt(0), m.code[4]->InputAt(1)); - CHECK_EQ(kArmSub, m.code[5]->arch_opcode()); - CHECK_EQ(1, m.code[5]->OutputCount()); - CHECK_EQ(2, m.code[5]->InputCount()); - CheckSameVreg(m.code[0]->InputAt(0), m.code[5]->InputAt(0)); - CheckSameVreg(m.code[4]->Output(), m.code[5]->InputAt(1)); -} - - -TEST(InstructionSelectorInt32UModP_SUDIV) { - InstructionSelectorTester m; - m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(SUDIV); - CHECK_EQ(3, m.code.size()); - CHECK_EQ(kArmUdiv, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(kArmMul, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(2, m.code[1]->InputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[1]->InputAt(0)); - CheckSameVreg(m.code[0]->InputAt(1), m.code[1]->InputAt(1)); - CHECK_EQ(kArmSub, m.code[2]->arch_opcode()); - CHECK_EQ(1, m.code[2]->OutputCount()); - CHECK_EQ(2, m.code[2]->InputCount()); - CheckSameVreg(m.code[0]->InputAt(0), m.code[2]->InputAt(0)); - CheckSameVreg(m.code[1]->Output(), m.code[2]->InputAt(1)); -} - - -TEST(InstructionSelectorInt32UModP_MLS_SUDIV) { - InstructionSelectorTester m; - m.Return(m.Int32UMod(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(MLS, SUDIV); - CHECK_EQ(2, m.code.size()); - CHECK_EQ(kArmUdiv, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(kArmMls, m.code[1]->arch_opcode()); - CHECK_EQ(1, m.code[1]->OutputCount()); - CHECK_EQ(3, m.code[1]->InputCount()); - CheckSameVreg(m.code[0]->Output(), m.code[1]->InputAt(0)); - CheckSameVreg(m.code[0]->InputAt(1), m.code[1]->InputAt(1)); - CheckSameVreg(m.code[0]->InputAt(0), m.code[1]->InputAt(2)); -} - - -TEST(InstructionSelectorWord32EqualP) { - InstructionSelectorTester m; - m.Return(m.Word32Equal(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); -} - - -TEST(InstructionSelectorWord32EqualImm) { - Immediates immediates; - for (Immediates::const_iterator i = immediates.begin(); i != immediates.end(); - ++i) { - int32_t imm = *i; - { - InstructionSelectorTester m; - m.Return(m.Word32Equal(m.Parameter(0), m.Int32Constant(imm))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - if (imm == 0) { - CHECK_EQ(kArmTst, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CheckSameVreg(m.code[0]->InputAt(0), m.code[0]->InputAt(1)); - } else { - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - } - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Equal(m.Int32Constant(imm), m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - if (imm == 0) { - CHECK_EQ(kArmTst, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CheckSameVreg(m.code[0]->InputAt(0), m.code[0]->InputAt(1)); - } else { - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - } - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - } -} - - -TEST(InstructionSelectorWord32EqualAndDPIP) { - DPIs dpis; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - { - InstructionSelectorTester m; - m.Return(m.Word32Equal(m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1)), - m.Int32Constant(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - m.Return( - m.Word32Equal(m.Int32Constant(0), - m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - } -} - - -TEST(InstructionSelectorWord32EqualAndDPIImm) { - DPIs dpis; - Immediates immediates; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - for (Immediates::const_iterator j = immediates.begin(); - j != immediates.end(); ++j) { - int32_t imm = *j; - { - InstructionSelectorTester m; - m.Return(m.Word32Equal( - m.NewNode(dpi.op, m.Parameter(0), m.Int32Constant(imm)), - m.Int32Constant(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Equal( - m.NewNode(dpi.op, m.Int32Constant(imm), m.Parameter(0)), - m.Int32Constant(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Equal( - m.Int32Constant(0), - m.NewNode(dpi.op, m.Parameter(0), m.Int32Constant(imm)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Equal( - m.Int32Constant(0), - m.NewNode(dpi.op, m.Int32Constant(imm), m.Parameter(0)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - } - } -} - - -TEST(InstructionSelectorWord32EqualAndShiftP) { - Shifts shifts; - for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) { - Shift shift = *i; - { - InstructionSelectorTester m; - m.Return(m.Word32Equal( - m.Parameter(0), m.NewNode(shift.op, m.Parameter(1), m.Parameter(2)))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - m.Return(m.Word32Equal( - m.NewNode(shift.op, m.Parameter(0), m.Parameter(1)), m.Parameter(2))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_set, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - } -} - - -TEST(InstructionSelectorBranchWithWord32EqualAndShiftP) { - Shifts shifts; - for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) { - Shift shift = *i; - { - InstructionSelectorTester m; - MLabel blocka, blockb; - m.Branch(m.Word32Equal(m.Parameter(0), m.NewNode(shift.op, m.Parameter(1), - m.Parameter(2))), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - m.Branch( - m.Word32Equal(m.NewNode(shift.op, m.Parameter(1), m.Parameter(2)), - m.Parameter(0)), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(shift.r_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - } -} - - -TEST(InstructionSelectorBranchWithWord32EqualAndShiftImm) { - Shifts shifts; - for (Shifts::const_iterator i = shifts.begin(); i != shifts.end(); ++i) { - Shift shift = *i; - for (int32_t imm = shift.i_low; imm <= shift.i_high; ++imm) { - { - InstructionSelectorTester m; - MLabel blocka, blockb; - m.Branch( - m.Word32Equal(m.Parameter(0), m.NewNode(shift.op, m.Parameter(1), - m.Int32Constant(imm))), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - m.Branch(m.Word32Equal( - m.NewNode(shift.op, m.Parameter(1), m.Int32Constant(imm)), - m.Parameter(0)), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(shift.i_mode, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - } - } -} - - -TEST(InstructionSelectorBranchWithWord32EqualAndRotateRightP) { - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = - m.Word32Or(m.Word32Shr(value, shift), - m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift))); - m.Branch(m.Word32Equal(input, ror), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = - m.Word32Or(m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift)), - m.Word32Shr(value, shift)); - m.Branch(m.Word32Equal(input, ror), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = - m.Word32Or(m.Word32Shr(value, shift), - m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift))); - m.Branch(m.Word32Equal(ror, input), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* shift = m.Parameter(2); - Node* ror = - m.Word32Or(m.Word32Shl(value, m.Int32Sub(m.Int32Constant(32), shift)), - m.Word32Shr(value, shift)); - m.Branch(m.Word32Equal(ror, input), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } -} - - -TEST(InstructionSelectorBranchWithWord32EqualAndRotateRightImm) { - FOR_INPUTS(uint32_t, ror, i) { - uint32_t shift = *i; - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* ror = m.Word32Or(m.Word32Shr(value, m.Int32Constant(shift)), - m.Word32Shl(value, m.Int32Constant(32 - shift))); - m.Branch(m.Word32Equal(input, ror), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - CHECK_LE(3, m.code[0]->InputCount()); - CHECK_EQ(shift, m.ToInt32(m.code[0]->InputAt(2))); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* ror = m.Word32Or(m.Word32Shl(value, m.Int32Constant(32 - shift)), - m.Word32Shr(value, m.Int32Constant(shift))); - m.Branch(m.Word32Equal(input, ror), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - CHECK_LE(3, m.code[0]->InputCount()); - CHECK_EQ(shift, m.ToInt32(m.code[0]->InputAt(2))); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* ror = m.Word32Or(m.Word32Shr(value, m.Int32Constant(shift)), - m.Word32Shl(value, m.Int32Constant(32 - shift))); - m.Branch(m.Word32Equal(ror, input), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - CHECK_LE(3, m.code[0]->InputCount()); - CHECK_EQ(shift, m.ToInt32(m.code[0]->InputAt(2))); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* input = m.Parameter(0); - Node* value = m.Parameter(1); - Node* ror = m.Word32Or(m.Word32Shl(value, m.Int32Constant(32 - shift)), - m.Word32Shr(value, m.Int32Constant(shift))); - m.Branch(m.Word32Equal(ror, input), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kArmCmp, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R_ROR_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - CHECK_LE(3, m.code[0]->InputCount()); - CHECK_EQ(shift, m.ToInt32(m.code[0]->InputAt(2))); - } - } -} - - -TEST(InstructionSelectorBranchWithDPIP) { - DPIs dpis; - for (DPIs::const_iterator i = dpis.begin(); i != dpis.end(); ++i) { - DPI dpi = *i; - { - InstructionSelectorTester m; - MLabel blocka, blockb; - m.Branch(m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1)), &blocka, - &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kNotEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - m.Branch(m.Word32Equal(m.Int32Constant(0), - m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1))), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - m.Branch(m.Word32Equal(m.NewNode(dpi.op, m.Parameter(0), m.Parameter(1)), - m.Int32Constant(0)), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(1)); - m.Bind(&blockb); - m.Return(m.Int32Constant(0)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(dpi.test_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kEqual, m.code[0]->flags_condition()); - } - } -} - - -TEST(InstructionSelectorBranchWithODPIP) { - ODPIs odpis; - for (ODPIs::const_iterator i = odpis.begin(); i != odpis.end(); ++i) { - ODPI odpi = *i; - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* node = m.NewNode(odpi.op, m.Parameter(0), m.Parameter(1)); - m.Branch(m.Projection(1, node), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(0)); - m.Bind(&blockb); - m.Return(m.Projection(0, node)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* node = m.NewNode(odpi.op, m.Parameter(0), m.Parameter(1)); - m.Branch(m.Word32Equal(m.Projection(1, node), m.Int32Constant(0)), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(0)); - m.Bind(&blockb); - m.Return(m.Projection(0, node)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kNotOverflow, m.code[0]->flags_condition()); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* node = m.NewNode(odpi.op, m.Parameter(0), m.Parameter(1)); - m.Branch(m.Word32Equal(m.Int32Constant(0), m.Projection(1, node)), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(0)); - m.Bind(&blockb); - m.Return(m.Projection(0, node)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_R, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kNotOverflow, m.code[0]->flags_condition()); - } - } -} - - -TEST(InstructionSelectorBranchWithODPIImm) { - ODPIs odpis; - Immediates immediates; - for (ODPIs::const_iterator i = odpis.begin(); i != odpis.end(); ++i) { - ODPI odpi = *i; - for (Immediates::const_iterator j = immediates.begin(); - j != immediates.end(); ++j) { - int32_t imm = *j; - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* node = m.NewNode(odpi.op, m.Parameter(0), m.Int32Constant(imm)); - m.Branch(m.Projection(1, node), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(0)); - m.Bind(&blockb); - m.Return(m.Projection(0, node)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_LE(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* node = m.NewNode(odpi.op, m.Int32Constant(imm), m.Parameter(0)); - m.Branch(m.Projection(1, node), &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(0)); - m.Bind(&blockb); - m.Return(m.Projection(0, node)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kOverflow, m.code[0]->flags_condition()); - CHECK_LE(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* node = m.NewNode(odpi.op, m.Parameter(0), m.Int32Constant(imm)); - m.Branch(m.Word32Equal(m.Projection(1, node), m.Int32Constant(0)), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(0)); - m.Bind(&blockb); - m.Return(m.Projection(0, node)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kNotOverflow, m.code[0]->flags_condition()); - CHECK_LE(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } - { - InstructionSelectorTester m; - MLabel blocka, blockb; - Node* node = m.NewNode(odpi.op, m.Int32Constant(imm), m.Parameter(0)); - m.Branch(m.Word32Equal(m.Projection(1, node), m.Int32Constant(0)), - &blocka, &blockb); - m.Bind(&blocka); - m.Return(m.Int32Constant(0)); - m.Bind(&blockb); - m.Return(m.Projection(0, node)); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(odpi.reverse_arch_opcode, m.code[0]->arch_opcode()); - CHECK_EQ(kMode_Operand2_I, m.code[0]->addressing_mode()); - CHECK_EQ(kFlags_branch, m.code[0]->flags_mode()); - CHECK_EQ(kNotOverflow, m.code[0]->flags_condition()); - CHECK_LE(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } - } - } -} diff --git a/deps/v8/test/cctest/compiler/test-instruction-selector-ia32.cc b/deps/v8/test/cctest/compiler/test-instruction-selector-ia32.cc deleted file mode 100644 index b6509584e0..0000000000 --- a/deps/v8/test/cctest/compiler/test-instruction-selector-ia32.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "test/cctest/compiler/instruction-selector-tester.h" -#include "test/cctest/compiler/value-helper.h" - -using namespace v8::internal; -using namespace v8::internal::compiler; - -TEST(InstructionSelectorInt32AddP) { - InstructionSelectorTester m; - m.Return(m.Int32Add(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kIA32Add, m.code[0]->arch_opcode()); -} - - -TEST(InstructionSelectorInt32AddImm) { - FOR_INT32_INPUTS(i) { - int32_t imm = *i; - { - InstructionSelectorTester m; - m.Return(m.Int32Add(m.Parameter(0), m.Int32Constant(imm))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kIA32Add, m.code[0]->arch_opcode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } - { - InstructionSelectorTester m; - m.Return(m.Int32Add(m.Int32Constant(imm), m.Parameter(0))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kIA32Add, m.code[0]->arch_opcode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } - } -} - - -TEST(InstructionSelectorInt32SubP) { - InstructionSelectorTester m; - m.Return(m.Int32Sub(m.Parameter(0), m.Parameter(1))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kIA32Sub, m.code[0]->arch_opcode()); - CHECK_EQ(1, m.code[0]->OutputCount()); -} - - -TEST(InstructionSelectorInt32SubImm) { - FOR_INT32_INPUTS(i) { - int32_t imm = *i; - InstructionSelectorTester m; - m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(imm))); - m.SelectInstructions(); - CHECK_EQ(1, m.code.size()); - CHECK_EQ(kIA32Sub, m.code[0]->arch_opcode()); - CHECK_EQ(2, m.code[0]->InputCount()); - CHECK_EQ(imm, m.ToInt32(m.code[0]->InputAt(1))); - } -} diff --git a/deps/v8/test/cctest/compiler/test-instruction-selector.cc b/deps/v8/test/cctest/compiler/test-instruction-selector.cc deleted file mode 100644 index e59406426e..0000000000 --- a/deps/v8/test/cctest/compiler/test-instruction-selector.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "test/cctest/compiler/instruction-selector-tester.h" - -using namespace v8::internal; -using namespace v8::internal::compiler; - -#if V8_TURBOFAN_TARGET - -TEST(InstructionSelectionReturnZero) { - InstructionSelectorTester m; - m.Return(m.Int32Constant(0)); - m.SelectInstructions(InstructionSelectorTester::kInternalMode); - CHECK_EQ(2, static_cast<int>(m.code.size())); - CHECK_EQ(kArchNop, m.code[0]->opcode()); - CHECK_EQ(kArchRet, m.code[1]->opcode()); - CHECK_EQ(1, static_cast<int>(m.code[1]->InputCount())); -} - -#endif // !V8_TURBOFAN_TARGET diff --git a/deps/v8/test/cctest/compiler/test-instruction.cc b/deps/v8/test/cctest/compiler/test-instruction.cc index bc9f4c7723..a9feaac2c8 100644 --- a/deps/v8/test/cctest/compiler/test-instruction.cc +++ b/deps/v8/test/cctest/compiler/test-instruction.cc @@ -9,6 +9,7 @@ #include "src/compiler/common-operator.h" #include "src/compiler/graph.h" #include "src/compiler/instruction.h" +#include "src/compiler/linkage.h" #include "src/compiler/machine-operator.h" #include "src/compiler/node.h" #include "src/compiler/operator.h" @@ -32,7 +33,6 @@ class InstructionTester : public HandleAndZoneScope { info(static_cast<HydrogenCodeStub*>(NULL), main_isolate()), linkage(&info), common(zone()), - machine(zone(), kMachineWord32), code(NULL) {} ~InstructionTester() { delete code; } @@ -59,19 +59,19 @@ class InstructionTester : public HandleAndZoneScope { Node* Int32Constant(int32_t val) { Node* node = graph.NewNode(common.Int32Constant(val)); - schedule.AddNode(schedule.entry(), node); + schedule.AddNode(schedule.start(), node); return node; } Node* Float64Constant(double val) { Node* node = graph.NewNode(common.Float64Constant(val)); - schedule.AddNode(schedule.entry(), node); + schedule.AddNode(schedule.start(), node); return node; } Node* Parameter(int32_t which) { Node* node = graph.NewNode(common.Parameter(which)); - schedule.AddNode(schedule.entry(), node); + schedule.AddNode(schedule.start(), node); return node; } @@ -103,7 +103,7 @@ TEST(InstructionBasic) { R.Int32Constant(i); // Add some nodes to the graph. } - BasicBlock* last = R.schedule.entry(); + BasicBlock* last = R.schedule.start(); for (int i = 0; i < 5; i++) { BasicBlock* block = R.schedule.NewBasicBlock(); R.schedule.AddGoto(last, block); @@ -130,10 +130,10 @@ TEST(InstructionBasic) { TEST(InstructionGetBasicBlock) { InstructionTester R; - BasicBlock* b0 = R.schedule.entry(); + BasicBlock* b0 = R.schedule.start(); BasicBlock* b1 = R.schedule.NewBasicBlock(); BasicBlock* b2 = R.schedule.NewBasicBlock(); - BasicBlock* b3 = R.schedule.exit(); + BasicBlock* b3 = R.schedule.end(); R.schedule.AddGoto(b0, b1); R.schedule.AddGoto(b1, b2); @@ -188,7 +188,7 @@ TEST(InstructionGetBasicBlock) { TEST(InstructionIsGapAt) { InstructionTester R; - BasicBlock* b0 = R.schedule.entry(); + BasicBlock* b0 = R.schedule.start(); R.schedule.AddReturn(b0, R.Int32Constant(1)); R.allocCode(); @@ -213,8 +213,8 @@ TEST(InstructionIsGapAt) { TEST(InstructionIsGapAt2) { InstructionTester R; - BasicBlock* b0 = R.schedule.entry(); - BasicBlock* b1 = R.schedule.exit(); + BasicBlock* b0 = R.schedule.start(); + BasicBlock* b1 = R.schedule.end(); R.schedule.AddGoto(b0, b1); R.schedule.AddReturn(b1, R.Int32Constant(1)); @@ -256,7 +256,7 @@ TEST(InstructionIsGapAt2) { TEST(InstructionAddGapMove) { InstructionTester R; - BasicBlock* b0 = R.schedule.entry(); + BasicBlock* b0 = R.schedule.start(); R.schedule.AddReturn(b0, R.Int32Constant(1)); R.allocCode(); @@ -324,9 +324,9 @@ TEST(InstructionOperands) { new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER), new (&zone) UnallocatedOperand(UnallocatedOperand::MUST_HAVE_REGISTER)}; - for (size_t i = 0; i < ARRAY_SIZE(outputs); i++) { - for (size_t j = 0; j < ARRAY_SIZE(inputs); j++) { - for (size_t k = 0; k < ARRAY_SIZE(temps); k++) { + for (size_t i = 0; i < arraysize(outputs); i++) { + for (size_t j = 0; j < arraysize(inputs); j++) { + for (size_t k = 0; k < arraysize(temps); k++) { TestInstr* m = TestInstr::New(&zone, 101, i, outputs, j, inputs, k, temps); CHECK(i == m->OutputCount()); diff --git a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc index 42a606d23c..eb0975ef45 100644 --- a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc +++ b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc @@ -17,10 +17,16 @@ using namespace v8::internal::compiler; class JSCacheTesterHelper { protected: explicit JSCacheTesterHelper(Zone* zone) - : main_graph_(zone), main_common_(zone), main_typer_(zone) {} + : main_graph_(zone), + main_common_(zone), + main_javascript_(zone), + main_typer_(zone), + main_machine_() {} Graph main_graph_; CommonOperatorBuilder main_common_; + JSOperatorBuilder main_javascript_; Typer main_typer_; + MachineOperatorBuilder main_machine_; }; @@ -30,13 +36,14 @@ class JSConstantCacheTester : public HandleAndZoneScope, public: JSConstantCacheTester() : JSCacheTesterHelper(main_zone()), - JSGraph(&main_graph_, &main_common_, &main_typer_) {} + JSGraph(&main_graph_, &main_common_, &main_javascript_, &main_typer_, + &main_machine_) {} Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; } Handle<Object> handle(Node* node) { CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); - return ValueOf<Handle<Object> >(node->op()); + return OpParameter<Unique<Object> >(node).handle(); } Factory* factory() { return main_isolate()->factory(); } @@ -87,8 +94,8 @@ TEST(MinusZeroConstant) { CHECK(!t->Is(Type::SignedSmall())); CHECK(!t->Is(Type::UnsignedSmall())); - double zero_value = ValueOf<double>(zero->op()); - double minus_zero_value = ValueOf<double>(minus_zero->op()); + double zero_value = OpParameter<double>(zero); + double minus_zero_value = OpParameter<double>(minus_zero); CHECK_EQ(0.0, zero_value); CHECK_NE(-0.0, zero_value); @@ -194,8 +201,8 @@ TEST(NoAliasing) { T.OneConstant(), T.NaNConstant(), T.Constant(21), T.Constant(22.2)}; - for (size_t i = 0; i < ARRAY_SIZE(nodes); i++) { - for (size_t j = 0; j < ARRAY_SIZE(nodes); j++) { + for (size_t i = 0; i < arraysize(nodes); i++) { + for (size_t j = 0; j < arraysize(nodes); j++) { if (i != j) CHECK_NE(nodes[i], nodes[j]); } } diff --git a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc index 740d9f3d49..47c660ae0d 100644 --- a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc +++ b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc @@ -6,7 +6,6 @@ #include "src/compiler/js-operator.h" #include "src/compiler/node-matchers.h" #include "src/compiler/node-properties-inl.h" -#include "src/compiler/simplified-node-factory.h" #include "src/compiler/source-position.h" #include "src/compiler/typer.h" #include "test/cctest/cctest.h" @@ -16,18 +15,17 @@ using namespace v8::internal; using namespace v8::internal::compiler; -class ContextSpecializationTester - : public HandleAndZoneScope, - public DirectGraphBuilder, - public SimplifiedNodeFactory<ContextSpecializationTester> { +class ContextSpecializationTester : public HandleAndZoneScope, + public DirectGraphBuilder { public: ContextSpecializationTester() : DirectGraphBuilder(new (main_zone()) Graph(main_zone())), common_(main_zone()), javascript_(main_zone()), + machine_(), simplified_(main_zone()), typer_(main_zone()), - jsgraph_(graph(), common(), &typer_), + jsgraph_(graph(), common(), &javascript_, &typer_, &machine_), info_(main_isolate(), main_zone()) {} Factory* factory() { return main_isolate()->factory(); } @@ -40,6 +38,7 @@ class ContextSpecializationTester private: CommonOperatorBuilder common_; JSOperatorBuilder javascript_; + MachineOperatorBuilder machine_; SimplifiedOperatorBuilder simplified_; Typer typer_; JSGraph jsgraph_; @@ -93,10 +92,9 @@ TEST(ReduceJSLoadContext) { CHECK(r.Changed()); Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); - ValueMatcher<Handle<Context> > match(new_context_input); - CHECK_EQ(*native, *match.Value()); - ContextAccess access = static_cast<Operator1<ContextAccess>*>( - r.replacement()->op())->parameter(); + HeapObjectMatcher<Context> match(new_context_input); + CHECK_EQ(*native, *match.Value().handle()); + ContextAccess access = OpParameter<ContextAccess>(r.replacement()); CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); CHECK_EQ(0, access.depth()); CHECK_EQ(false, access.immutable()); @@ -110,9 +108,9 @@ TEST(ReduceJSLoadContext) { CHECK(r.Changed()); CHECK(r.replacement() != load); - ValueMatcher<Handle<Object> > match(r.replacement()); + HeapObjectMatcher<Object> match(r.replacement()); CHECK(match.HasValue()); - CHECK_EQ(*expected, *match.Value()); + CHECK_EQ(*expected, *match.Value().handle()); } // TODO(titzer): test with other kinds of contexts, e.g. a function context. @@ -174,10 +172,9 @@ TEST(ReduceJSStoreContext) { CHECK(r.Changed()); Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); - ValueMatcher<Handle<Context> > match(new_context_input); - CHECK_EQ(*native, *match.Value()); - ContextAccess access = static_cast<Operator1<ContextAccess>*>( - r.replacement()->op())->parameter(); + HeapObjectMatcher<Context> match(new_context_input); + CHECK_EQ(*native, *match.Value().handle()); + ContextAccess access = OpParameter<ContextAccess>(r.replacement()); CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); CHECK_EQ(0, access.depth()); CHECK_EQ(false, access.immutable()); @@ -216,11 +213,12 @@ TEST(SpecializeToContext) { const_context, const_context, effect_in); - Node* value_use = t.ChangeTaggedToInt32(load); + Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load); Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true), param_context, param_context, load); Node* effect_use = other_load; - Node* other_use = t.ChangeTaggedToInt32(other_load); + Node* other_use = + t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load); Node* add = t.NewNode(t.javascript()->Add(), value_use, other_use, param_context, other_load, start); @@ -244,9 +242,9 @@ TEST(SpecializeToContext) { CHECK_EQ(other_load, other_use->InputAt(0)); Node* replacement = value_use->InputAt(0); - ValueMatcher<Handle<Object> > match(replacement); + HeapObjectMatcher<Object> match(replacement); CHECK(match.HasValue()); - CHECK_EQ(*expected, *match.Value()); + CHECK_EQ(*expected, *match.Value().handle()); } // TODO(titzer): clean up above test and test more complicated effects. } diff --git a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc index b6aa6d9582..cf126c2c54 100644 --- a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc @@ -21,12 +21,10 @@ class JSTypedLoweringTester : public HandleAndZoneScope { binop(NULL), unop(NULL), javascript(main_zone()), - machine(main_zone()), simplified(main_zone()), common(main_zone()), graph(main_zone()), typer(main_zone()), - source_positions(&graph), context_node(NULL) { typer.DecorateGraph(&graph); Node* s = graph.NewNode(common.Start(num_parameters)); @@ -34,15 +32,14 @@ class JSTypedLoweringTester : public HandleAndZoneScope { } Isolate* isolate; - Operator* binop; - Operator* unop; + const Operator* binop; + const Operator* unop; JSOperatorBuilder javascript; MachineOperatorBuilder machine; SimplifiedOperatorBuilder simplified; CommonOperatorBuilder common; Graph graph; Typer typer; - SourcePositionTable source_positions; Node* context_node; Node* Parameter(Type* t, int32_t index = 0) { @@ -51,9 +48,32 @@ class JSTypedLoweringTester : public HandleAndZoneScope { return n; } + Node* UndefinedConstant() { + Unique<Object> unique = + Unique<Object>::CreateImmovable(isolate->factory()->undefined_value()); + return graph.NewNode(common.HeapConstant(unique)); + } + + Node* HeapConstant(Handle<Object> constant) { + Unique<Object> unique = Unique<Object>::CreateUninitialized(constant); + return graph.NewNode(common.HeapConstant(unique)); + } + + Node* EmptyFrameState(Node* context) { + Node* parameters = graph.NewNode(common.StateValues(0)); + Node* locals = graph.NewNode(common.StateValues(0)); + Node* stack = graph.NewNode(common.StateValues(0)); + + Node* state_node = + graph.NewNode(common.FrameState(JS_FRAME, BailoutId(0), kIgnoreOutput), + parameters, locals, stack, context, UndefinedConstant()); + + return state_node; + } + Node* reduce(Node* node) { - JSGraph jsgraph(&graph, &common, &typer); - JSTypedLowering reducer(&jsgraph, &source_positions); + JSGraph jsgraph(&graph, &common, &javascript, &typer, &machine); + JSTypedLowering reducer(&jsgraph); Reduction reduction = reducer.Reduce(node); if (reduction.Changed()) return reduction.replacement(); return node; @@ -75,25 +95,25 @@ class JSTypedLoweringTester : public HandleAndZoneScope { CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc. } - void CheckPureBinop(Operator* expected, Node* node) { + void CheckPureBinop(const Operator* expected, Node* node) { CHECK_EQ(expected->opcode(), node->op()->opcode()); CHECK_EQ(2, node->InputCount()); // should not have context, effect, etc. } - Node* ReduceUnop(Operator* op, Type* input_type) { + Node* ReduceUnop(const Operator* op, Type* input_type) { return reduce(Unop(op, Parameter(input_type))); } - Node* ReduceBinop(Operator* op, Type* left_type, Type* right_type) { + Node* ReduceBinop(const Operator* op, Type* left_type, Type* right_type) { return reduce(Binop(op, Parameter(left_type, 0), Parameter(right_type, 1))); } - Node* Binop(Operator* op, Node* left, Node* right) { + Node* Binop(const Operator* op, Node* left, Node* right) { // JS binops also require context, effect, and control return graph.NewNode(op, left, right, context(), start(), control()); } - Node* Unop(Operator* op, Node* input) { + Node* Unop(const Operator* op, Node* input) { // JS unops also require context, effect, and control return graph.NewNode(op, input, context(), start(), control()); } @@ -110,17 +130,17 @@ class JSTypedLoweringTester : public HandleAndZoneScope { void CheckInt32Constant(int32_t expected, Node* result) { CHECK_EQ(IrOpcode::kInt32Constant, result->opcode()); - CHECK_EQ(expected, ValueOf<int32_t>(result->op())); + CHECK_EQ(expected, OpParameter<int32_t>(result)); } void CheckNumberConstant(double expected, Node* result) { CHECK_EQ(IrOpcode::kNumberConstant, result->opcode()); - CHECK_EQ(expected, ValueOf<double>(result->op())); + CHECK_EQ(expected, OpParameter<double>(result)); } void CheckNaN(Node* result) { CHECK_EQ(IrOpcode::kNumberConstant, result->opcode()); - double value = ValueOf<double>(result->op()); + double value = OpParameter<double>(result); CHECK(std::isnan(value)); } @@ -134,7 +154,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { void CheckHandle(Handle<Object> expected, Node* result) { CHECK_EQ(IrOpcode::kHeapConstant, result->opcode()); - Handle<Object> value = ValueOf<Handle<Object> >(result->op()); + Handle<Object> value = OpParameter<Unique<Object> >(result).handle(); CHECK_EQ(*expected, *value); } }; @@ -154,7 +174,7 @@ static Type* kNumberTypes[] = { Type::OtherUnsigned32(), Type::OtherSigned32(), Type::SignedSmall(), Type::Signed32(), Type::Unsigned32(), Type::Integral32(), Type::MinusZero(), Type::NaN(), Type::OtherNumber(), - Type::Number()}; + Type::OrderedNumber(), Type::Number()}; static Type* kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(), @@ -171,13 +191,15 @@ static IrOpcode::Value NumberToI32(bool is_signed) { } +// TODO(turbofan): Lowering of StringAdd is disabled for now. +#if 0 TEST(StringBinops) { JSTypedLoweringTester R; - for (size_t i = 0; i < ARRAY_SIZE(kStringTypes); ++i) { + for (size_t i = 0; i < arraysize(kStringTypes); ++i) { Node* p0 = R.Parameter(kStringTypes[i], 0); - for (size_t j = 0; j < ARRAY_SIZE(kStringTypes); ++j) { + for (size_t j = 0; j < arraysize(kStringTypes); ++j) { Node* p1 = R.Parameter(kStringTypes[j], 1); Node* add = R.Binop(R.javascript.Add(), p0, p1); @@ -189,11 +211,12 @@ TEST(StringBinops) { } } } +#endif TEST(AddNumber1) { JSTypedLoweringTester R; - for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); ++i) { + for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { Node* p0 = R.Parameter(kNumberTypes[i], 0); Node* p1 = R.Parameter(kNumberTypes[i], 1); Node* add = R.Binop(R.javascript.Add(), p0, p1); @@ -208,7 +231,7 @@ TEST(AddNumber1) { TEST(NumberBinops) { JSTypedLoweringTester R; - Operator* ops[] = { + const Operator* ops[] = { R.javascript.Add(), R.simplified.NumberAdd(), R.javascript.Subtract(), R.simplified.NumberSubtract(), R.javascript.Multiply(), R.simplified.NumberMultiply(), @@ -216,13 +239,13 @@ TEST(NumberBinops) { R.javascript.Modulus(), R.simplified.NumberModulus(), }; - for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); ++i) { + for (size_t i = 0; i < arraysize(kNumberTypes); ++i) { Node* p0 = R.Parameter(kNumberTypes[i], 0); - for (size_t j = 0; j < ARRAY_SIZE(kNumberTypes); ++j) { + for (size_t j = 0; j < arraysize(kNumberTypes); ++j) { Node* p1 = R.Parameter(kNumberTypes[j], 1); - for (size_t k = 0; k < ARRAY_SIZE(ops); k += 2) { + for (size_t k = 0; k < arraysize(ops); k += 2) { Node* add = R.Binop(ops[k], p0, p1); Node* r = R.reduce(add); @@ -242,7 +265,7 @@ static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) { CHECK_EQ(old_input, new_input); } else if (new_input->opcode() == IrOpcode::kNumberConstant) { CHECK(NodeProperties::GetBounds(new_input).upper->Is(expected_type)); - double v = ValueOf<double>(new_input->op()); + double v = OpParameter<double>(new_input); double e = static_cast<double>(is_signed ? FastD2I(v) : FastD2UI(v)); CHECK_EQ(e, v); } else { @@ -255,7 +278,7 @@ static void CheckToI32(Node* old_input, Node* new_input, bool is_signed) { class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { public: static const int kNumberOps = 6; - Operator* ops[kNumberOps]; + const Operator* ops[kNumberOps]; bool signedness[kNumberOps]; JSBitwiseShiftTypedLoweringTester() { @@ -269,7 +292,7 @@ class JSBitwiseShiftTypedLoweringTester : public JSTypedLoweringTester { } private: - void set(int idx, Operator* op, bool s) { + void set(int idx, const Operator* op, bool s) { ops[idx] = op; signedness[idx] = s; } @@ -286,10 +309,10 @@ TEST(Int32BitwiseShifts) { Type::Null(), Type::Boolean(), Type::Number(), Type::String(), Type::Object()}; - for (size_t i = 0; i < ARRAY_SIZE(types); ++i) { + for (size_t i = 0; i < arraysize(types); ++i) { Node* p0 = R.Parameter(types[i], 0); - for (size_t j = 0; j < ARRAY_SIZE(types); ++j) { + for (size_t j = 0; j < arraysize(types); ++j) { Node* p1 = R.Parameter(types[j], 1); for (int k = 0; k < R.kNumberOps; k += 2) { @@ -315,7 +338,7 @@ TEST(Int32BitwiseShifts) { class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { public: static const int kNumberOps = 6; - Operator* ops[kNumberOps]; + const Operator* ops[kNumberOps]; bool signedness[kNumberOps]; JSBitwiseTypedLoweringTester() { @@ -329,7 +352,7 @@ class JSBitwiseTypedLoweringTester : public JSTypedLoweringTester { } private: - void set(int idx, Operator* op, bool s) { + void set(int idx, const Operator* op, bool s) { ops[idx] = op; signedness[idx] = s; } @@ -346,10 +369,10 @@ TEST(Int32BitwiseBinops) { Type::Null(), Type::Boolean(), Type::Number(), Type::String(), Type::Object()}; - for (size_t i = 0; i < ARRAY_SIZE(types); ++i) { + for (size_t i = 0; i < arraysize(types); ++i) { Node* p0 = R.Parameter(types[i], 0); - for (size_t j = 0; j < ARRAY_SIZE(types); ++j) { + for (size_t j = 0; j < arraysize(types); ++j) { Node* p1 = R.Parameter(types[j], 1); for (int k = 0; k < R.kNumberOps; k += 2) { @@ -368,9 +391,9 @@ TEST(Int32BitwiseBinops) { TEST(JSToNumber1) { JSTypedLoweringTester R; - Operator* ton = R.javascript.ToNumber(); + const Operator* ton = R.javascript.ToNumber(); - for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); i++) { // ToNumber(number) + for (size_t i = 0; i < arraysize(kNumberTypes); i++) { // ToNumber(number) Node* r = R.ReduceUnop(ton, kNumberTypes[i]); CHECK_EQ(IrOpcode::kParameter, r->opcode()); } @@ -392,7 +415,7 @@ TEST(JSToNumber_replacement) { Type* types[] = {Type::Null(), Type::Undefined(), Type::Number()}; - for (size_t i = 0; i < ARRAY_SIZE(types); i++) { + for (size_t i = 0; i < arraysize(types); i++) { Node* n = R.Parameter(types[i]); Node* c = R.graph.NewNode(R.javascript.ToNumber(), n, R.context(), R.start(), R.start()); @@ -418,11 +441,12 @@ TEST(JSToNumber_replacement) { TEST(JSToNumberOfConstant) { JSTypedLoweringTester R; - Operator* ops[] = {R.common.NumberConstant(0), R.common.NumberConstant(-1), - R.common.NumberConstant(0.1), R.common.Int32Constant(1177), - R.common.Float64Constant(0.99)}; + const Operator* ops[] = { + R.common.NumberConstant(0), R.common.NumberConstant(-1), + R.common.NumberConstant(0.1), R.common.Int32Constant(1177), + R.common.Float64Constant(0.99)}; - for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { + for (size_t i = 0; i < arraysize(ops); i++) { Node* n = R.graph.NewNode(ops[i]); Node* convert = R.Unop(R.javascript.ToNumber(), n); Node* r = R.reduce(convert); @@ -447,7 +471,7 @@ TEST(JSToNumberOfNumberOrOtherPrimitive) { Type* others[] = {Type::Undefined(), Type::Null(), Type::Boolean(), Type::String()}; - for (size_t i = 0; i < ARRAY_SIZE(others); i++) { + for (size_t i = 0; i < arraysize(others); i++) { Type* t = Type::Union(Type::Number(), others[i], R.main_zone()); Node* r = R.ReduceUnop(R.javascript.ToNumber(), t); CHECK_EQ(IrOpcode::kJSToNumber, r->opcode()); @@ -457,7 +481,7 @@ TEST(JSToNumberOfNumberOrOtherPrimitive) { TEST(JSToBoolean) { JSTypedLoweringTester R; - Operator* op = R.javascript.ToBoolean(); + const Operator* op = R.javascript.ToBoolean(); { // ToBoolean(undefined) Node* r = R.ReduceUnop(op, Type::Undefined()); @@ -474,12 +498,12 @@ TEST(JSToBoolean) { CHECK_EQ(IrOpcode::kParameter, r->opcode()); } - { // ToBoolean(number) - Node* r = R.ReduceUnop(op, Type::Number()); + { // ToBoolean(ordered-number) + Node* r = R.ReduceUnop(op, Type::OrderedNumber()); CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); Node* i = r->InputAt(0); CHECK_EQ(IrOpcode::kNumberEqual, i->opcode()); - // ToBoolean(number) => BooleanNot(NumberEqual(x, #0)) + // ToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x, #0)) } { // ToBoolean(string) @@ -508,10 +532,11 @@ TEST(JSToBoolean) { TEST(JSToBoolean_replacement) { JSTypedLoweringTester R; - Type* types[] = {Type::Null(), Type::Undefined(), Type::Boolean(), + Type* types[] = {Type::Null(), Type::Undefined(), + Type::Boolean(), Type::OrderedNumber(), Type::DetectableObject(), Type::Undetectable()}; - for (size_t i = 0; i < ARRAY_SIZE(types); i++) { + for (size_t i = 0; i < arraysize(types); i++) { Node* n = R.Parameter(types[i]); Node* c = R.graph.NewNode(R.javascript.ToBoolean(), n, R.context(), R.start(), R.start()); @@ -523,6 +548,8 @@ TEST(JSToBoolean_replacement) { if (types[i]->Is(Type::Boolean())) { CHECK_EQ(n, r); + } else if (types[i]->Is(Type::OrderedNumber())) { + CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); } else { CHECK_EQ(IrOpcode::kHeapConstant, r->opcode()); } @@ -537,12 +564,12 @@ TEST(JSToBoolean_replacement) { TEST(JSToString1) { JSTypedLoweringTester R; - for (size_t i = 0; i < ARRAY_SIZE(kStringTypes); i++) { + for (size_t i = 0; i < arraysize(kStringTypes); i++) { Node* r = R.ReduceUnop(R.javascript.ToString(), kStringTypes[i]); CHECK_EQ(IrOpcode::kParameter, r->opcode()); } - Operator* op = R.javascript.ToString(); + const Operator* op = R.javascript.ToString(); { // ToString(undefined) => "undefined" Node* r = R.ReduceUnop(op, Type::Undefined()); @@ -583,7 +610,7 @@ TEST(JSToString_replacement) { Type* types[] = {Type::Null(), Type::Undefined(), Type::String()}; - for (size_t i = 0; i < ARRAY_SIZE(types); i++) { + for (size_t i = 0; i < arraysize(types); i++) { Node* n = R.Parameter(types[i]); Node* c = R.graph.NewNode(R.javascript.ToString(), n, R.context(), R.start(), R.start()); @@ -609,18 +636,18 @@ TEST(JSToString_replacement) { TEST(StringComparison) { JSTypedLoweringTester R; - Operator* ops[] = { + const Operator* ops[] = { R.javascript.LessThan(), R.simplified.StringLessThan(), R.javascript.LessThanOrEqual(), R.simplified.StringLessThanOrEqual(), R.javascript.GreaterThan(), R.simplified.StringLessThan(), R.javascript.GreaterThanOrEqual(), R.simplified.StringLessThanOrEqual()}; - for (size_t i = 0; i < ARRAY_SIZE(kStringTypes); i++) { + for (size_t i = 0; i < arraysize(kStringTypes); i++) { Node* p0 = R.Parameter(kStringTypes[i], 0); - for (size_t j = 0; j < ARRAY_SIZE(kStringTypes); j++) { + for (size_t j = 0; j < arraysize(kStringTypes); j++) { Node* p1 = R.Parameter(kStringTypes[j], 1); - for (size_t k = 0; k < ARRAY_SIZE(ops); k += 2) { + for (size_t k = 0; k < arraysize(ops); k += 2) { Node* cmp = R.Binop(ops[k], p0, p1); Node* r = R.reduce(cmp); @@ -643,6 +670,9 @@ TEST(StringComparison) { static void CheckIsConvertedToNumber(Node* val, Node* converted) { if (NodeProperties::GetBounds(val).upper->Is(Type::Number())) { CHECK_EQ(val, converted); + } else if (NodeProperties::GetBounds(val).upper->Is(Type::Boolean())) { + CHECK_EQ(IrOpcode::kBooleanToNumber, converted->opcode()); + CHECK_EQ(val, converted->InputAt(0)); } else { if (converted->opcode() == IrOpcode::kNumberConstant) return; CHECK_EQ(IrOpcode::kJSToNumber, converted->opcode()); @@ -654,23 +684,25 @@ static void CheckIsConvertedToNumber(Node* val, Node* converted) { TEST(NumberComparison) { JSTypedLoweringTester R; - Operator* ops[] = { + const Operator* ops[] = { R.javascript.LessThan(), R.simplified.NumberLessThan(), R.javascript.LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), R.javascript.GreaterThan(), R.simplified.NumberLessThan(), R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual()}; - for (size_t i = 0; i < ARRAY_SIZE(kJSTypes); i++) { + for (size_t i = 0; i < arraysize(kJSTypes); i++) { Type* t0 = kJSTypes[i]; - if (t0->Is(Type::String())) continue; // skip Type::String + // Skip Type::String and Type::Receiver which might coerce into a string. + if (t0->Is(Type::String()) || t0->Is(Type::Receiver())) continue; Node* p0 = R.Parameter(t0, 0); - for (size_t j = 0; j < ARRAY_SIZE(kJSTypes); j++) { + for (size_t j = 0; j < arraysize(kJSTypes); j++) { Type* t1 = kJSTypes[j]; - if (t1->Is(Type::String())) continue; // skip Type::String + // Skip Type::String and Type::Receiver which might coerce into a string. + if (t1->Is(Type::String()) || t0->Is(Type::Receiver())) continue; Node* p1 = R.Parameter(t1, 1); - for (size_t k = 0; k < ARRAY_SIZE(ops); k += 2) { + for (size_t k = 0; k < arraysize(ops); k += 2) { Node* cmp = R.Binop(ops[k], p0, p1); Node* r = R.reduce(cmp); @@ -696,10 +728,10 @@ TEST(MixedComparison1) { Type* types[] = {Type::Number(), Type::String(), Type::Union(Type::Number(), Type::String(), R.main_zone())}; - for (size_t i = 0; i < ARRAY_SIZE(types); i++) { + for (size_t i = 0; i < arraysize(types); i++) { Node* p0 = R.Parameter(types[i], 0); - for (size_t j = 0; j < ARRAY_SIZE(types); j++) { + for (size_t j = 0; j < arraysize(types); j++) { Node* p1 = R.Parameter(types[j], 1); { Node* cmp = R.Binop(R.javascript.LessThan(), p0, p1); @@ -724,7 +756,7 @@ TEST(MixedComparison1) { TEST(ObjectComparison) { JSTypedLoweringTester R; - Node* p0 = R.Parameter(Type::Object(), 0); + Node* p0 = R.Parameter(Type::Number(), 0); Node* p1 = R.Parameter(Type::Object(), 1); Node* cmp = R.Binop(R.javascript.LessThan(), p0, p1); @@ -740,37 +772,48 @@ TEST(ObjectComparison) { Node* i0 = r->InputAt(0); Node* i1 = r->InputAt(1); - CHECK_NE(p0, i0); + CHECK_EQ(p0, i0); CHECK_NE(p1, i1); - CHECK_EQ(IrOpcode::kJSToNumber, i0->opcode()); + CHECK_EQ(IrOpcode::kParameter, i0->opcode()); CHECK_EQ(IrOpcode::kJSToNumber, i1->opcode()); // Check effect chain is correct. - R.CheckEffectInput(R.start(), i0); - R.CheckEffectInput(i0, i1); + R.CheckEffectInput(R.start(), i1); R.CheckEffectInput(i1, effect_use); } TEST(UnaryNot) { JSTypedLoweringTester R; - Operator* opnot = R.javascript.UnaryNot(); + const Operator* opnot = R.javascript.UnaryNot(); - for (size_t i = 0; i < ARRAY_SIZE(kJSTypes); i++) { - Node* r = R.ReduceUnop(opnot, kJSTypes[i]); + for (size_t i = 0; i < arraysize(kJSTypes); i++) { + Node* orig = R.Unop(opnot, R.Parameter(kJSTypes[i])); + Node* use = R.graph.NewNode(R.common.Return(), orig); + Node* r = R.reduce(orig); // TODO(titzer): test will break if/when js-typed-lowering constant folds. - CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); + CHECK_EQ(IrOpcode::kBooleanNot, use->InputAt(0)->opcode()); + + if (r == orig && orig->opcode() == IrOpcode::kJSToBoolean) { + // The original node was turned into a ToBoolean. + CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode()); + } else { + CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); + } } } TEST(RemoveToNumberEffects) { + FLAG_turbo_deoptimization = true; + JSTypedLoweringTester R; Node* effect_use = NULL; for (int i = 0; i < 10; i++) { Node* p0 = R.Parameter(Type::Number()); Node* ton = R.Unop(R.javascript.ToNumber(), p0); + Node* frame_state = R.EmptyFrameState(R.context()); effect_use = NULL; switch (i) { @@ -786,11 +829,11 @@ TEST(RemoveToNumberEffects) { effect_use = R.graph.NewNode(R.common.EffectPhi(1), ton, R.start()); case 3: effect_use = R.graph.NewNode(R.javascript.Add(), ton, ton, R.context(), - ton, R.start()); + frame_state, ton, R.start()); break; case 4: effect_use = R.graph.NewNode(R.javascript.Add(), p0, p0, R.context(), - ton, R.start()); + frame_state, ton, R.start()); break; case 5: effect_use = R.graph.NewNode(R.common.Return(), p0, ton, R.start()); @@ -822,7 +865,7 @@ TEST(RemoveToNumberEffects) { // Helper class for testing the reduction of a single binop. class BinopEffectsTester { public: - explicit BinopEffectsTester(Operator* op, Type* t0, Type* t1) + explicit BinopEffectsTester(const Operator* op, Type* t0, Type* t1) : R(), p0(R.Parameter(t0, 0)), p1(R.Parameter(t1, 1)), @@ -910,10 +953,10 @@ TEST(EqualityForNumbers) { Type::Number()}; - for (size_t i = 0; i < ARRAY_SIZE(simple_number_types); ++i) { + for (size_t i = 0; i < arraysize(simple_number_types); ++i) { Node* p0 = R.Parameter(simple_number_types[i], 0); - for (size_t j = 0; j < ARRAY_SIZE(simple_number_types); ++j) { + for (size_t j = 0; j < arraysize(simple_number_types); ++j) { Node* p1 = R.Parameter(simple_number_types[j], 1); CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kNumberEqual); @@ -930,7 +973,7 @@ TEST(StrictEqualityForRefEqualTypes) { Type::Object(), Type::Receiver()}; Node* p0 = R.Parameter(Type::Any()); - for (size_t i = 0; i < ARRAY_SIZE(types); i++) { + for (size_t i = 0; i < arraysize(types); i++) { Node* p1 = R.Parameter(types[i]); CheckEqualityReduction(&R, true, p0, p1, IrOpcode::kReferenceEqual); } @@ -951,7 +994,7 @@ TEST(StringEquality) { TEST(RemovePureNumberBinopEffects) { JSTypedLoweringTester R; - Operator* ops[] = { + const Operator* ops[] = { R.javascript.Equal(), R.simplified.NumberEqual(), R.javascript.Add(), R.simplified.NumberAdd(), R.javascript.Subtract(), R.simplified.NumberSubtract(), @@ -962,7 +1005,7 @@ TEST(RemovePureNumberBinopEffects) { R.javascript.LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), }; - for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) { + for (size_t j = 0; j < arraysize(ops); j += 2) { BinopEffectsTester B(ops[j], Type::Number(), Type::Number()); CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); @@ -979,14 +1022,14 @@ TEST(RemovePureNumberBinopEffects) { TEST(OrderNumberBinopEffects1) { JSTypedLoweringTester R; - Operator* ops[] = { + const Operator* ops[] = { R.javascript.Subtract(), R.simplified.NumberSubtract(), R.javascript.Multiply(), R.simplified.NumberMultiply(), R.javascript.Divide(), R.simplified.NumberDivide(), R.javascript.Modulus(), R.simplified.NumberModulus(), }; - for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) { + for (size_t j = 0; j < arraysize(ops); j += 2) { BinopEffectsTester B(ops[j], Type::Object(), Type::String()); CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); @@ -1005,7 +1048,7 @@ TEST(OrderNumberBinopEffects1) { TEST(OrderNumberBinopEffects2) { JSTypedLoweringTester R; - Operator* ops[] = { + const Operator* ops[] = { R.javascript.Add(), R.simplified.NumberAdd(), R.javascript.Subtract(), R.simplified.NumberSubtract(), R.javascript.Multiply(), R.simplified.NumberMultiply(), @@ -1013,8 +1056,8 @@ TEST(OrderNumberBinopEffects2) { R.javascript.Modulus(), R.simplified.NumberModulus(), }; - for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) { - BinopEffectsTester B(ops[j], Type::Number(), Type::Object()); + for (size_t j = 0; j < arraysize(ops); j += 2) { + BinopEffectsTester B(ops[j], Type::Number(), Type::Symbol()); Node* i0 = B.CheckNoOp(0); Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); @@ -1026,8 +1069,8 @@ TEST(OrderNumberBinopEffects2) { B.CheckEffectOrdering(i1); } - for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) { - BinopEffectsTester B(ops[j], Type::Object(), Type::Number()); + for (size_t j = 0; j < arraysize(ops); j += 2) { + BinopEffectsTester B(ops[j], Type::Symbol(), Type::Number()); Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); Node* i1 = B.CheckNoOp(1); @@ -1044,13 +1087,13 @@ TEST(OrderNumberBinopEffects2) { TEST(OrderCompareEffects) { JSTypedLoweringTester R; - Operator* ops[] = { + const Operator* ops[] = { R.javascript.GreaterThan(), R.simplified.NumberLessThan(), R.javascript.GreaterThanOrEqual(), R.simplified.NumberLessThanOrEqual(), }; - for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) { - BinopEffectsTester B(ops[j], Type::Object(), Type::String()); + for (size_t j = 0; j < arraysize(ops); j += 2) { + BinopEffectsTester B(ops[j], Type::Symbol(), Type::String()); CHECK_EQ(ops[j + 1]->opcode(), B.result->op()->opcode()); Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); @@ -1064,8 +1107,8 @@ TEST(OrderCompareEffects) { B.CheckEffectOrdering(i1, i0); } - for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) { - BinopEffectsTester B(ops[j], Type::Number(), Type::Object()); + for (size_t j = 0; j < arraysize(ops); j += 2) { + BinopEffectsTester B(ops[j], Type::Number(), Type::Symbol()); Node* i0 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 0, true); Node* i1 = B.result->InputAt(1); @@ -1077,8 +1120,8 @@ TEST(OrderCompareEffects) { B.CheckEffectOrdering(i0); } - for (size_t j = 0; j < ARRAY_SIZE(ops); j += 2) { - BinopEffectsTester B(ops[j], Type::Object(), Type::Number()); + for (size_t j = 0; j < arraysize(ops); j += 2) { + BinopEffectsTester B(ops[j], Type::Symbol(), Type::Number()); Node* i0 = B.result->InputAt(0); Node* i1 = B.CheckConvertedInput(IrOpcode::kJSToNumber, 1, true); @@ -1177,25 +1220,25 @@ TEST(Int32BinopEffects) { TEST(UnaryNotEffects) { JSTypedLoweringTester R; - Operator* opnot = R.javascript.UnaryNot(); + const Operator* opnot = R.javascript.UnaryNot(); - for (size_t i = 0; i < ARRAY_SIZE(kJSTypes); i++) { + for (size_t i = 0; i < arraysize(kJSTypes); i++) { Node* p0 = R.Parameter(kJSTypes[i], 0); Node* orig = R.Unop(opnot, p0); Node* effect_use = R.UseForEffect(orig); Node* value_use = R.graph.NewNode(R.common.Return(), orig); Node* r = R.reduce(orig); // TODO(titzer): test will break if/when js-typed-lowering constant folds. - CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); - - CHECK_EQ(r, value_use->InputAt(0)); + CHECK_EQ(IrOpcode::kBooleanNot, value_use->InputAt(0)->opcode()); - if (r->InputAt(0) == orig && orig->opcode() == IrOpcode::kJSToBoolean) { + if (r == orig && orig->opcode() == IrOpcode::kJSToBoolean) { // The original node was turned into a ToBoolean, which has an effect. + CHECK_EQ(IrOpcode::kJSToBoolean, r->opcode()); R.CheckEffectInput(R.start(), orig); R.CheckEffectInput(orig, effect_use); } else { // effect should have been removed from this node. + CHECK_EQ(IrOpcode::kBooleanNot, r->opcode()); R.CheckEffectInput(R.start(), effect_use); } } @@ -1207,9 +1250,9 @@ TEST(Int32AddNarrowing) { JSBitwiseTypedLoweringTester R; for (int o = 0; o < R.kNumberOps; o += 2) { - for (size_t i = 0; i < ARRAY_SIZE(kInt32Types); i++) { + for (size_t i = 0; i < arraysize(kInt32Types); i++) { Node* n0 = R.Parameter(kInt32Types[i]); - for (size_t j = 0; j < ARRAY_SIZE(kInt32Types); j++) { + for (size_t j = 0; j < arraysize(kInt32Types); j++) { Node* n1 = R.Parameter(kInt32Types[j]); Node* one = R.graph.NewNode(R.common.NumberConstant(1)); @@ -1234,9 +1277,9 @@ TEST(Int32AddNarrowing) { JSBitwiseShiftTypedLoweringTester R; for (int o = 0; o < R.kNumberOps; o += 2) { - for (size_t i = 0; i < ARRAY_SIZE(kInt32Types); i++) { + for (size_t i = 0; i < arraysize(kInt32Types); i++) { Node* n0 = R.Parameter(kInt32Types[i]); - for (size_t j = 0; j < ARRAY_SIZE(kInt32Types); j++) { + for (size_t j = 0; j < arraysize(kInt32Types); j++) { Node* n1 = R.Parameter(kInt32Types[j]); Node* one = R.graph.NewNode(R.common.NumberConstant(1)); @@ -1289,10 +1332,10 @@ TEST(Int32Comparisons) { JSTypedLoweringTester R; struct Entry { - Operator* js_op; - Operator* uint_op; - Operator* int_op; - Operator* num_op; + const Operator* js_op; + const Operator* uint_op; + const Operator* int_op; + const Operator* num_op; bool commute; }; @@ -1308,19 +1351,19 @@ TEST(Int32Comparisons) { R.machine.Int32LessThanOrEqual(), R.simplified.NumberLessThanOrEqual(), true}}; - for (size_t o = 0; o < ARRAY_SIZE(ops); o++) { - for (size_t i = 0; i < ARRAY_SIZE(kNumberTypes); i++) { + for (size_t o = 0; o < arraysize(ops); o++) { + for (size_t i = 0; i < arraysize(kNumberTypes); i++) { Type* t0 = kNumberTypes[i]; Node* p0 = R.Parameter(t0, 0); - for (size_t j = 0; j < ARRAY_SIZE(kNumberTypes); j++) { + for (size_t j = 0; j < arraysize(kNumberTypes); j++) { Type* t1 = kNumberTypes[j]; Node* p1 = R.Parameter(t1, 1); Node* cmp = R.Binop(ops[o].js_op, p0, p1); Node* r = R.reduce(cmp); - Operator* expected; + const Operator* expected; if (t0->Is(Type::Unsigned32()) && t1->Is(Type::Unsigned32())) { expected = ops[o].uint_op; } else if (t0->Is(Type::Signed32()) && t1->Is(Type::Signed32())) { diff --git a/deps/v8/test/cctest/compiler/test-linkage.cc b/deps/v8/test/cctest/compiler/test-linkage.cc index 6d9453f7c4..ff65d6e4d6 100644 --- a/deps/v8/test/cctest/compiler/test-linkage.cc +++ b/deps/v8/test/cctest/compiler/test-linkage.cc @@ -65,7 +65,7 @@ TEST(TestLinkageJSFunctionIncoming) { CallDescriptor* descriptor = linkage.GetIncomingDescriptor(); CHECK_NE(NULL, descriptor); - CHECK_EQ(1 + i, descriptor->ParameterCount()); + CHECK_EQ(1 + i, descriptor->JSParameterCount()); CHECK_EQ(1, descriptor->ReturnCount()); CHECK_EQ(Operator::kNoProperties, descriptor->properties()); CHECK_EQ(true, descriptor->IsJSFunctionCall()); @@ -92,7 +92,7 @@ TEST(TestLinkageJSCall) { for (int i = 0; i < 32; i++) { CallDescriptor* descriptor = linkage.GetJSCallDescriptor(i); CHECK_NE(NULL, descriptor); - CHECK_EQ(i, descriptor->ParameterCount()); + CHECK_EQ(i, descriptor->JSParameterCount()); CHECK_EQ(1, descriptor->ReturnCount()); CHECK_EQ(Operator::kNoProperties, descriptor->properties()); CHECK_EQ(true, descriptor->IsJSFunctionCall()); diff --git a/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc b/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc index c79a96a094..9a41bc5e44 100644 --- a/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc +++ b/deps/v8/test/cctest/compiler/test-machine-operator-reducer.cc @@ -6,48 +6,72 @@ #include "src/base/utils/random-number-generator.h" #include "src/compiler/graph-inl.h" +#include "src/compiler/js-graph.h" #include "src/compiler/machine-operator-reducer.h" +#include "src/compiler/typer.h" #include "test/cctest/compiler/value-helper.h" using namespace v8::internal; using namespace v8::internal::compiler; template <typename T> -Operator* NewConstantOperator(CommonOperatorBuilder* common, volatile T value); +const Operator* NewConstantOperator(CommonOperatorBuilder* common, + volatile T value); template <> -Operator* NewConstantOperator<int32_t>(CommonOperatorBuilder* common, - volatile int32_t value) { +const Operator* NewConstantOperator<int32_t>(CommonOperatorBuilder* common, + volatile int32_t value) { return common->Int32Constant(value); } template <> -Operator* NewConstantOperator<double>(CommonOperatorBuilder* common, - volatile double value) { +const Operator* NewConstantOperator<double>(CommonOperatorBuilder* common, + volatile double value) { return common->Float64Constant(value); } +template <typename T> +T ValueOfOperator(const Operator* op); + +template <> +int32_t ValueOfOperator<int32_t>(const Operator* op) { + CHECK_EQ(IrOpcode::kInt32Constant, op->opcode()); + return OpParameter<int32_t>(op); +} + +template <> +double ValueOfOperator<double>(const Operator* op) { + CHECK_EQ(IrOpcode::kFloat64Constant, op->opcode()); + return OpParameter<double>(op); +} + + class ReducerTester : public HandleAndZoneScope { public: explicit ReducerTester(int num_parameters = 0) : isolate(main_isolate()), binop(NULL), unop(NULL), - machine(main_zone()), common(main_zone()), graph(main_zone()), + javascript(main_zone()), + typer(main_zone()), + jsgraph(&graph, &common, &javascript, &typer, &machine), maxuint32(Constant<int32_t>(kMaxUInt32)) { Node* s = graph.NewNode(common.Start(num_parameters)); graph.SetStart(s); } Isolate* isolate; - Operator* binop; - Operator* unop; + const Operator* binop; + const Operator* unop; MachineOperatorBuilder machine; CommonOperatorBuilder common; Graph graph; + JSOperatorBuilder javascript; + Typer typer; + JSGraph jsgraph; Node* maxuint32; template <typename T> @@ -55,6 +79,11 @@ class ReducerTester : public HandleAndZoneScope { return graph.NewNode(NewConstantOperator<T>(&common, value)); } + template <typename T> + const T ValueOf(const Operator* op) { + return ValueOfOperator<T>(op); + } + // Check that the reduction of this binop applied to constants {a} and {b} // yields the {expect} value. template <typename T> @@ -68,7 +97,7 @@ class ReducerTester : public HandleAndZoneScope { void CheckFoldBinop(volatile T expect, Node* a, Node* b) { CHECK_NE(NULL, binop); Node* n = graph.NewNode(binop, a, b); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction reduction = reducer.Reduce(n); CHECK(reduction.Changed()); CHECK_NE(n, reduction.replacement()); @@ -80,7 +109,7 @@ class ReducerTester : public HandleAndZoneScope { void CheckBinop(Node* expect, Node* a, Node* b) { CHECK_NE(NULL, binop); Node* n = graph.NewNode(binop, a, b); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction reduction = reducer.Reduce(n); CHECK(reduction.Changed()); CHECK_EQ(expect, reduction.replacement()); @@ -92,7 +121,7 @@ class ReducerTester : public HandleAndZoneScope { Node* right) { CHECK_NE(NULL, binop); Node* n = graph.NewNode(binop, left, right); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction reduction = reducer.Reduce(n); CHECK(reduction.Changed()); CHECK_EQ(binop, reduction.replacement()->op()); @@ -103,11 +132,11 @@ class ReducerTester : public HandleAndZoneScope { // Check that the reduction of this binop applied to {left} and {right} yields // the {op_expect} applied to {left_expect} and {right_expect}. template <typename T> - void CheckFoldBinop(volatile T left_expect, Operator* op_expect, + void CheckFoldBinop(volatile T left_expect, const Operator* op_expect, Node* right_expect, Node* left, Node* right) { CHECK_NE(NULL, binop); Node* n = graph.NewNode(binop, left, right); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction r = reducer.Reduce(n); CHECK(r.Changed()); CHECK_EQ(op_expect->opcode(), r.replacement()->op()->opcode()); @@ -118,11 +147,11 @@ class ReducerTester : public HandleAndZoneScope { // Check that the reduction of this binop applied to {left} and {right} yields // the {op_expect} applied to {left_expect} and {right_expect}. template <typename T> - void CheckFoldBinop(Node* left_expect, Operator* op_expect, + void CheckFoldBinop(Node* left_expect, const Operator* op_expect, volatile T right_expect, Node* left, Node* right) { CHECK_NE(NULL, binop); Node* n = graph.NewNode(binop, left, right); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction r = reducer.Reduce(n); CHECK(r.Changed()); CHECK_EQ(op_expect->opcode(), r.replacement()->op()->opcode()); @@ -139,7 +168,7 @@ class ReducerTester : public HandleAndZoneScope { Node* k = Constant<T>(constant); { Node* n = graph.NewNode(binop, k, p); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction reduction = reducer.Reduce(n); CHECK(!reduction.Changed() || reduction.replacement() == n); CHECK_EQ(p, n->InputAt(0)); @@ -147,7 +176,7 @@ class ReducerTester : public HandleAndZoneScope { } { Node* n = graph.NewNode(binop, p, k); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction reduction = reducer.Reduce(n); CHECK(!reduction.Changed()); CHECK_EQ(p, n->InputAt(0)); @@ -163,7 +192,7 @@ class ReducerTester : public HandleAndZoneScope { Node* p = Parameter(); Node* k = Constant<T>(constant); Node* n = graph.NewNode(binop, k, p); - MachineOperatorReducer reducer(&graph); + MachineOperatorReducer reducer(&jsgraph); Reduction reduction = reducer.Reduce(n); CHECK(!reduction.Changed()); CHECK_EQ(k, n->InputAt(0)); @@ -630,18 +659,19 @@ TEST(ReduceLoadStore) { Node* base = R.Constant<int32_t>(11); Node* index = R.Constant<int32_t>(4); - Node* load = R.graph.NewNode(R.machine.Load(kMachineWord32), base, index); + Node* load = R.graph.NewNode(R.machine.Load(kMachInt32), base, index); { - MachineOperatorReducer reducer(&R.graph); + MachineOperatorReducer reducer(&R.jsgraph); Reduction reduction = reducer.Reduce(load); CHECK(!reduction.Changed()); // loads should not be reduced. } { Node* store = R.graph.NewNode( - R.machine.Store(kMachineWord32, kNoWriteBarrier), base, index, load); - MachineOperatorReducer reducer(&R.graph); + R.machine.Store(StoreRepresentation(kMachInt32, kNoWriteBarrier)), base, + index, load); + MachineOperatorReducer reducer(&R.jsgraph); Reduction reduction = reducer.Reduce(store); CHECK(!reduction.Changed()); // stores should not be reduced. } @@ -657,9 +687,9 @@ static void CheckNans(ReducerTester* R) { pr != nans.end(); ++pr) { Node* nan1 = R->Constant<double>(*pl); Node* nan2 = R->Constant<double>(*pr); - R->CheckBinop(nan1, x, nan1); // x % NaN => NaN - R->CheckBinop(nan1, nan1, x); // NaN % x => NaN - R->CheckBinop(nan1, nan2, nan1); // NaN % NaN => NaN + R->CheckBinop(nan1, x, nan1); // x op NaN => NaN + R->CheckBinop(nan1, nan1, x); // NaN op x => NaN + R->CheckBinop(nan1, nan2, nan1); // NaN op NaN => NaN } } } @@ -676,8 +706,15 @@ TEST(ReduceFloat64Add) { } } - FOR_FLOAT64_INPUTS(i) { R.CheckPutConstantOnRight(*i); } - // TODO(titzer): CheckNans(&R); + FOR_FLOAT64_INPUTS(i) { + Double tmp(*i); + if (!tmp.IsSpecial() || tmp.IsInfinite()) { + // Don't check NaNs as they are reduced more. + R.CheckPutConstantOnRight(*i); + } + } + + CheckNans(&R); } @@ -691,7 +728,13 @@ TEST(ReduceFloat64Sub) { R.CheckFoldBinop<double>(x - y, x, y); } } - // TODO(titzer): CheckNans(&R); + + Node* zero = R.Constant<double>(0.0); + Node* x = R.Parameter(); + + R.CheckBinop(x, x, zero); // x - 0.0 => x + + CheckNans(&R); } @@ -753,6 +796,11 @@ TEST(ReduceFloat64Mod) { } } + Node* x = R.Parameter(); + Node* zero = R.Constant<double>(0.0); + + R.CheckFoldBinop<double>(v8::base::OS::nan_value(), x, zero); + CheckNans(&R); } diff --git a/deps/v8/test/cctest/compiler/test-node-cache.cc b/deps/v8/test/cctest/compiler/test-node-cache.cc index 23909a5f5a..3569386c85 100644 --- a/deps/v8/test/cctest/compiler/test-node-cache.cc +++ b/deps/v8/test/cctest/compiler/test-node-cache.cc @@ -33,15 +33,15 @@ TEST(Int32Constant_five) { int32_t constants[] = {static_cast<int32_t>(0x80000000), -77, 0, 1, -1}; - Node* nodes[ARRAY_SIZE(constants)]; + Node* nodes[arraysize(constants)]; - for (size_t i = 0; i < ARRAY_SIZE(constants); i++) { + for (size_t i = 0; i < arraysize(constants); i++) { int32_t k = constants[i]; Node* node = graph.NewNode(common.Int32Constant(k)); *cache.Find(graph.zone(), k) = nodes[i] = node; } - for (size_t i = 0; i < ARRAY_SIZE(constants); i++) { + for (size_t i = 0; i < arraysize(constants); i++) { int32_t k = constants[i]; CHECK_EQ(nodes[i], *cache.Find(graph.zone(), k)); } @@ -121,7 +121,7 @@ TEST(PtrConstant_back_to_back) { int32_t buffer[50]; for (int32_t* p = buffer; - (p - buffer) < static_cast<ptrdiff_t>(ARRAY_SIZE(buffer)); p++) { + (p - buffer) < static_cast<ptrdiff_t>(arraysize(buffer)); p++) { Node** pos = cache.Find(graph.zone(), p); CHECK_NE(NULL, pos); for (int j = 0; j < 3; j++) { @@ -140,7 +140,7 @@ TEST(PtrConstant_hits) { Node* nodes[kSize]; CommonOperatorBuilder common(graph.zone()); - for (size_t i = 0; i < ARRAY_SIZE(buffer); i++) { + for (size_t i = 0; i < arraysize(buffer); i++) { int k = static_cast<int>(i); int32_t* p = &buffer[i]; nodes[i] = graph.NewNode(common.Int32Constant(k)); @@ -148,7 +148,7 @@ TEST(PtrConstant_hits) { } int hits = 0; - for (size_t i = 0; i < ARRAY_SIZE(buffer); i++) { + for (size_t i = 0; i < arraysize(buffer); i++) { int32_t* p = &buffer[i]; Node** pos = cache.Find(graph.zone(), p); if (*pos != NULL) { diff --git a/deps/v8/test/cctest/compiler/test-node.cc b/deps/v8/test/cctest/compiler/test-node.cc index 6fe8573a2f..28d807e4a7 100644 --- a/deps/v8/test/cctest/compiler/test-node.cc +++ b/deps/v8/test/cctest/compiler/test-node.cc @@ -118,9 +118,14 @@ TEST(NodeUseIteratorOne) { TEST(NodeUseIteratorReplaceNoUses) { GraphTester graph; Node* n0 = graph.NewNode(&dummy_operator); - Node* n3 = graph.NewNode(&dummy_operator); - n0->ReplaceUses(n3); + Node* n1 = graph.NewNode(&dummy_operator); + Node* n2 = graph.NewNode(&dummy_operator); + Node* n3 = graph.NewNode(&dummy_operator, n2); + n0->ReplaceUses(n1); + CHECK(n0->uses().begin() == n0->uses().end()); + n0->ReplaceUses(n2); CHECK(n0->uses().begin() == n0->uses().end()); + USE(n3); } @@ -333,6 +338,27 @@ TEST(Inputs) { } +TEST(RemoveInput) { + GraphTester graph; + + Node* n0 = graph.NewNode(&dummy_operator); + Node* n1 = graph.NewNode(&dummy_operator, n0); + Node* n2 = graph.NewNode(&dummy_operator, n0, n1); + + n1->RemoveInput(0); + CHECK_EQ(0, n1->InputCount()); + CHECK_EQ(1, n0->UseCount()); + + n2->RemoveInput(0); + CHECK_EQ(1, n2->InputCount()); + CHECK_EQ(0, n0->UseCount()); + CHECK_EQ(1, n1->UseCount()); + + n2->RemoveInput(0); + CHECK_EQ(0, n2->InputCount()); +} + + TEST(AppendInputsAndIterator) { GraphTester graph; diff --git a/deps/v8/test/cctest/compiler/test-operator.cc b/deps/v8/test/cctest/compiler/test-operator.cc index 0bf8cb755b..af75d67663 100644 --- a/deps/v8/test/cctest/compiler/test-operator.cc +++ b/deps/v8/test/cctest/compiler/test-operator.cc @@ -14,40 +14,40 @@ using namespace v8::internal::compiler; #define Infinity (std::numeric_limits<double>::infinity()) TEST(TestOperatorMnemonic) { - SimpleOperator op1(10, 0, 0, 0, "ThisOne"); + SimpleOperator op1(10, Operator::kNoProperties, 0, 0, "ThisOne"); CHECK_EQ(0, strcmp(op1.mnemonic(), "ThisOne")); - SimpleOperator op2(11, 0, 0, 0, "ThatOne"); + SimpleOperator op2(11, Operator::kNoProperties, 0, 0, "ThatOne"); CHECK_EQ(0, strcmp(op2.mnemonic(), "ThatOne")); - Operator1<int> op3(12, 0, 0, 1, "Mnemonic1", 12333); + Operator1<int> op3(12, Operator::kNoProperties, 0, 1, "Mnemonic1", 12333); CHECK_EQ(0, strcmp(op3.mnemonic(), "Mnemonic1")); - Operator1<double> op4(13, 0, 0, 1, "TheOther", 99.9); + Operator1<double> op4(13, Operator::kNoProperties, 0, 1, "TheOther", 99.9); CHECK_EQ(0, strcmp(op4.mnemonic(), "TheOther")); } TEST(TestSimpleOperatorHash) { - SimpleOperator op1(17, 0, 0, 0, "Another"); + SimpleOperator op1(17, Operator::kNoProperties, 0, 0, "Another"); CHECK_EQ(17, op1.HashCode()); - SimpleOperator op2(18, 0, 0, 0, "Falsch"); + SimpleOperator op2(18, Operator::kNoProperties, 0, 0, "Falsch"); CHECK_EQ(18, op2.HashCode()); } TEST(TestSimpleOperatorEquals) { - SimpleOperator op1a(19, 0, 0, 0, "Another1"); - SimpleOperator op1b(19, 2, 2, 2, "Another2"); + SimpleOperator op1a(19, Operator::kNoProperties, 0, 0, "Another1"); + SimpleOperator op1b(19, Operator::kFoldable, 2, 2, "Another2"); CHECK(op1a.Equals(&op1a)); CHECK(op1a.Equals(&op1b)); CHECK(op1b.Equals(&op1a)); CHECK(op1b.Equals(&op1b)); - SimpleOperator op2a(20, 0, 0, 0, "Falsch1"); - SimpleOperator op2b(20, 1, 1, 1, "Falsch2"); + SimpleOperator op2a(20, Operator::kNoProperties, 0, 0, "Falsch1"); + SimpleOperator op2b(20, Operator::kFoldable, 1, 1, "Falsch2"); CHECK(op2a.Equals(&op2a)); CHECK(op2a.Equals(&op2b)); @@ -74,14 +74,14 @@ static SmartArrayPointer<const char> OperatorToString(Operator* op) { TEST(TestSimpleOperatorPrint) { - SimpleOperator op1a(19, 0, 0, 0, "Another1"); - SimpleOperator op1b(19, 2, 2, 2, "Another2"); + SimpleOperator op1a(19, Operator::kNoProperties, 0, 0, "Another1"); + SimpleOperator op1b(19, Operator::kFoldable, 2, 2, "Another2"); CHECK_EQ("Another1", OperatorToString(&op1a).get()); CHECK_EQ("Another2", OperatorToString(&op1b).get()); - SimpleOperator op2a(20, 0, 0, 0, "Flog1"); - SimpleOperator op2b(20, 1, 1, 1, "Flog2"); + SimpleOperator op2a(20, Operator::kNoProperties, 0, 0, "Flog1"); + SimpleOperator op2b(20, Operator::kFoldable, 1, 1, "Flog2"); CHECK_EQ("Flog1", OperatorToString(&op2a).get()); CHECK_EQ("Flog2", OperatorToString(&op2b).get()); @@ -89,13 +89,13 @@ TEST(TestSimpleOperatorPrint) { TEST(TestOperator1intHash) { - Operator1<int> op1a(23, 0, 0, 0, "Wolfie", 11); - Operator1<int> op1b(23, 2, 2, 2, "Doggie", 11); + Operator1<int> op1a(23, Operator::kNoProperties, 0, 0, "Wolfie", 11); + Operator1<int> op1b(23, Operator::kFoldable, 2, 2, "Doggie", 11); CHECK_EQ(op1a.HashCode(), op1b.HashCode()); - Operator1<int> op2a(24, 0, 0, 0, "Arfie", 3); - Operator1<int> op2b(24, 0, 0, 0, "Arfie", 4); + Operator1<int> op2a(24, Operator::kNoProperties, 0, 0, "Arfie", 3); + Operator1<int> op2b(24, Operator::kNoProperties, 0, 0, "Arfie", 4); CHECK_NE(op1a.HashCode(), op2a.HashCode()); CHECK_NE(op2a.HashCode(), op2b.HashCode()); @@ -103,16 +103,16 @@ TEST(TestOperator1intHash) { TEST(TestOperator1intEquals) { - Operator1<int> op1a(23, 0, 0, 0, "Scratchy", 11); - Operator1<int> op1b(23, 2, 2, 2, "Scratchy", 11); + Operator1<int> op1a(23, Operator::kNoProperties, 0, 0, "Scratchy", 11); + Operator1<int> op1b(23, Operator::kFoldable, 2, 2, "Scratchy", 11); CHECK(op1a.Equals(&op1a)); CHECK(op1a.Equals(&op1b)); CHECK(op1b.Equals(&op1a)); CHECK(op1b.Equals(&op1b)); - Operator1<int> op2a(24, 0, 0, 0, "Im", 3); - Operator1<int> op2b(24, 0, 0, 0, "Im", 4); + Operator1<int> op2a(24, Operator::kNoProperties, 0, 0, "Im", 3); + Operator1<int> op2b(24, Operator::kNoProperties, 0, 0, "Im", 4); CHECK(op2a.Equals(&op2a)); CHECK(!op2a.Equals(&op2b)); @@ -129,7 +129,7 @@ TEST(TestOperator1intEquals) { CHECK(!op2b.Equals(&op1a)); CHECK(!op2b.Equals(&op1b)); - SimpleOperator op3(25, 0, 0, 0, "Weepy"); + SimpleOperator op3(25, Operator::kNoProperties, 0, 0, "Weepy"); CHECK(!op1a.Equals(&op3)); CHECK(!op1b.Equals(&op3)); @@ -144,28 +144,28 @@ TEST(TestOperator1intEquals) { TEST(TestOperator1intPrint) { - Operator1<int> op1(12, 0, 0, 1, "Op1Test", 0); + Operator1<int> op1(12, Operator::kNoProperties, 0, 1, "Op1Test", 0); CHECK_EQ("Op1Test[0]", OperatorToString(&op1).get()); - Operator1<int> op2(12, 0, 0, 1, "Op1Test", 66666666); + Operator1<int> op2(12, Operator::kNoProperties, 0, 1, "Op1Test", 66666666); CHECK_EQ("Op1Test[66666666]", OperatorToString(&op2).get()); - Operator1<int> op3(12, 0, 0, 1, "FooBar", 2347); + Operator1<int> op3(12, Operator::kNoProperties, 0, 1, "FooBar", 2347); CHECK_EQ("FooBar[2347]", OperatorToString(&op3).get()); - Operator1<int> op4(12, 0, 0, 1, "BarFoo", -879); + Operator1<int> op4(12, Operator::kNoProperties, 0, 1, "BarFoo", -879); CHECK_EQ("BarFoo[-879]", OperatorToString(&op4).get()); } TEST(TestOperator1doubleHash) { - Operator1<double> op1a(23, 0, 0, 0, "Wolfie", 11.77); - Operator1<double> op1b(23, 2, 2, 2, "Doggie", 11.77); + Operator1<double> op1a(23, Operator::kNoProperties, 0, 0, "Wolfie", 11.77); + Operator1<double> op1b(23, Operator::kFoldable, 2, 2, "Doggie", 11.77); CHECK_EQ(op1a.HashCode(), op1b.HashCode()); - Operator1<double> op2a(24, 0, 0, 0, "Arfie", -6.7); - Operator1<double> op2b(24, 0, 0, 0, "Arfie", -6.8); + Operator1<double> op2a(24, Operator::kNoProperties, 0, 0, "Arfie", -6.7); + Operator1<double> op2b(24, Operator::kNoProperties, 0, 0, "Arfie", -6.8); CHECK_NE(op1a.HashCode(), op2a.HashCode()); CHECK_NE(op2a.HashCode(), op2b.HashCode()); @@ -173,16 +173,16 @@ TEST(TestOperator1doubleHash) { TEST(TestOperator1doubleEquals) { - Operator1<double> op1a(23, 0, 0, 0, "Scratchy", 11.77); - Operator1<double> op1b(23, 2, 2, 2, "Scratchy", 11.77); + Operator1<double> op1a(23, Operator::kNoProperties, 0, 0, "Scratchy", 11.77); + Operator1<double> op1b(23, Operator::kFoldable, 2, 2, "Scratchy", 11.77); CHECK(op1a.Equals(&op1a)); CHECK(op1a.Equals(&op1b)); CHECK(op1b.Equals(&op1a)); CHECK(op1b.Equals(&op1b)); - Operator1<double> op2a(24, 0, 0, 0, "Im", 3.1); - Operator1<double> op2b(24, 0, 0, 0, "Im", 3.2); + Operator1<double> op2a(24, Operator::kNoProperties, 0, 0, "Im", 3.1); + Operator1<double> op2b(24, Operator::kNoProperties, 0, 0, "Im", 3.2); CHECK(op2a.Equals(&op2a)); CHECK(!op2a.Equals(&op2b)); @@ -199,7 +199,7 @@ TEST(TestOperator1doubleEquals) { CHECK(!op2b.Equals(&op1a)); CHECK(!op2b.Equals(&op1b)); - SimpleOperator op3(25, 0, 0, 0, "Weepy"); + SimpleOperator op3(25, Operator::kNoProperties, 0, 0, "Weepy"); CHECK(!op1a.Equals(&op3)); CHECK(!op1b.Equals(&op3)); @@ -211,8 +211,8 @@ TEST(TestOperator1doubleEquals) { CHECK(!op3.Equals(&op2a)); CHECK(!op3.Equals(&op2b)); - Operator1<double> op4a(24, 0, 0, 0, "Bashful", NaN); - Operator1<double> op4b(24, 0, 0, 0, "Bashful", NaN); + Operator1<double> op4a(24, Operator::kNoProperties, 0, 0, "Bashful", NaN); + Operator1<double> op4b(24, Operator::kNoProperties, 0, 0, "Bashful", NaN); CHECK(op4a.Equals(&op4a)); CHECK(op4a.Equals(&op4b)); @@ -227,18 +227,18 @@ TEST(TestOperator1doubleEquals) { TEST(TestOperator1doublePrint) { - Operator1<double> op1(12, 0, 0, 1, "Op1Test", 0); + Operator1<double> op1(12, Operator::kNoProperties, 0, 1, "Op1Test", 0); CHECK_EQ("Op1Test[0]", OperatorToString(&op1).get()); - Operator1<double> op2(12, 0, 0, 1, "Op1Test", 7.3); + Operator1<double> op2(12, Operator::kNoProperties, 0, 1, "Op1Test", 7.3); CHECK_EQ("Op1Test[7.3]", OperatorToString(&op2).get()); - Operator1<double> op3(12, 0, 0, 1, "FooBar", 2e+123); + Operator1<double> op3(12, Operator::kNoProperties, 0, 1, "FooBar", 2e+123); CHECK_EQ("FooBar[2e+123]", OperatorToString(&op3).get()); - Operator1<double> op4(12, 0, 0, 1, "BarFoo", Infinity); + Operator1<double> op4(12, Operator::kNoProperties, 0, 1, "BarFoo", Infinity); CHECK_EQ("BarFoo[inf]", OperatorToString(&op4).get()); - Operator1<double> op5(12, 0, 0, 1, "BarFoo", NaN); + Operator1<double> op5(12, Operator::kNoProperties, 0, 1, "BarFoo", NaN); CHECK_EQ("BarFoo[nan]", OperatorToString(&op5).get()); } diff --git a/deps/v8/test/cctest/compiler/test-phi-reducer.cc b/deps/v8/test/cctest/compiler/test-phi-reducer.cc index 00e250d8a2..7d2fab6727 100644 --- a/deps/v8/test/cctest/compiler/test-phi-reducer.cc +++ b/deps/v8/test/cctest/compiler/test-phi-reducer.cc @@ -53,27 +53,32 @@ class PhiReducerTester : HandleAndZoneScope { } Node* Phi(Node* a) { - return SetSelfReferences(graph.NewNode(common.Phi(1), a)); + return SetSelfReferences(graph.NewNode(common.Phi(kMachAnyTagged, 1), a)); } Node* Phi(Node* a, Node* b) { - return SetSelfReferences(graph.NewNode(common.Phi(2), a, b)); + return SetSelfReferences( + graph.NewNode(common.Phi(kMachAnyTagged, 2), a, b)); } Node* Phi(Node* a, Node* b, Node* c) { - return SetSelfReferences(graph.NewNode(common.Phi(3), a, b, c)); + return SetSelfReferences( + graph.NewNode(common.Phi(kMachAnyTagged, 3), a, b, c)); } Node* Phi(Node* a, Node* b, Node* c, Node* d) { - return SetSelfReferences(graph.NewNode(common.Phi(4), a, b, c, d)); + return SetSelfReferences( + graph.NewNode(common.Phi(kMachAnyTagged, 4), a, b, c, d)); } Node* PhiWithControl(Node* a, Node* control) { - return SetSelfReferences(graph.NewNode(common.Phi(1), a, control)); + return SetSelfReferences( + graph.NewNode(common.Phi(kMachAnyTagged, 1), a, control)); } Node* PhiWithControl(Node* a, Node* b, Node* control) { - return SetSelfReferences(graph.NewNode(common.Phi(2), a, b, control)); + return SetSelfReferences( + graph.NewNode(common.Phi(kMachAnyTagged, 2), a, b, control)); } Node* SetSelfReferences(Node* node) { @@ -96,7 +101,7 @@ TEST(PhiReduce1) { Node* param = R.Parameter(); Node* singles[] = {zero, one, oneish, param}; - for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 0; i < arraysize(singles); i++) { R.CheckReduce(singles[i], R.Phi(singles[i])); } } @@ -110,18 +115,18 @@ TEST(PhiReduce2) { Node* param = R.Parameter(); Node* singles[] = {zero, one, oneish, param}; - for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 0; i < arraysize(singles); i++) { Node* a = singles[i]; R.CheckReduce(a, R.Phi(a, a)); } - for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 0; i < arraysize(singles); i++) { Node* a = singles[i]; R.CheckReduce(a, R.Phi(R.self, a)); R.CheckReduce(a, R.Phi(a, R.self)); } - for (size_t i = 1; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 1; i < arraysize(singles); i++) { Node* a = singles[i], *b = singles[0]; Node* phi1 = R.Phi(b, a); R.CheckReduce(phi1, phi1); @@ -140,19 +145,19 @@ TEST(PhiReduce3) { Node* param = R.Parameter(); Node* singles[] = {zero, one, oneish, param}; - for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 0; i < arraysize(singles); i++) { Node* a = singles[i]; R.CheckReduce(a, R.Phi(a, a, a)); } - for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 0; i < arraysize(singles); i++) { Node* a = singles[i]; R.CheckReduce(a, R.Phi(R.self, a, a)); R.CheckReduce(a, R.Phi(a, R.self, a)); R.CheckReduce(a, R.Phi(a, a, R.self)); } - for (size_t i = 1; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 1; i < arraysize(singles); i++) { Node* a = singles[i], *b = singles[0]; Node* phi1 = R.Phi(b, a, a); R.CheckReduce(phi1, phi1); @@ -174,12 +179,12 @@ TEST(PhiReduce4) { Node* param = R.Parameter(); Node* singles[] = {zero, one, oneish, param}; - for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 0; i < arraysize(singles); i++) { Node* a = singles[i]; R.CheckReduce(a, R.Phi(a, a, a, a)); } - for (size_t i = 0; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 0; i < arraysize(singles); i++) { Node* a = singles[i]; R.CheckReduce(a, R.Phi(R.self, a, a, a)); R.CheckReduce(a, R.Phi(a, R.self, a, a)); @@ -192,7 +197,7 @@ TEST(PhiReduce4) { R.CheckReduce(a, R.Phi(R.self, a, a, R.self)); } - for (size_t i = 1; i < ARRAY_SIZE(singles); i++) { + for (size_t i = 1; i < arraysize(singles); i++) { Node* a = singles[i], *b = singles[0]; Node* phi1 = R.Phi(b, a, a, a); R.CheckReduce(phi1, phi1); @@ -217,7 +222,7 @@ TEST(PhiReduceShouldIgnoreControlNodes) { Node* param = R.Parameter(); Node* singles[] = {zero, one, oneish, param}; - for (size_t i = 0; i < ARRAY_SIZE(singles); ++i) { + for (size_t i = 0; i < arraysize(singles); ++i) { R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.dead)); R.CheckReduce(singles[i], R.PhiWithControl(R.self, singles[i], R.dead)); R.CheckReduce(singles[i], R.PhiWithControl(singles[i], R.self, R.dead)); diff --git a/deps/v8/test/cctest/compiler/test-pipeline.cc b/deps/v8/test/cctest/compiler/test-pipeline.cc index 7efedeeea2..f0b750a0cc 100644 --- a/deps/v8/test/cctest/compiler/test-pipeline.cc +++ b/deps/v8/test/cctest/compiler/test-pipeline.cc @@ -23,8 +23,6 @@ TEST(PipelineAdd) { CompilationInfoWithZone info(function); CHECK(Parser::Parse(&info)); - StrictMode strict_mode = info.function()->strict_mode(); - info.SetStrictMode(strict_mode); CHECK(Rewriter::Rewrite(&info)); CHECK(Scope::Analyze(&info)); CHECK_NE(NULL, info.scope()); diff --git a/deps/v8/test/cctest/compiler/test-representation-change.cc b/deps/v8/test/cctest/compiler/test-representation-change.cc index 092a5f7d90..9bf3b371f9 100644 --- a/deps/v8/test/cctest/compiler/test-representation-change.cc +++ b/deps/v8/test/cctest/compiler/test-representation-change.cc @@ -7,6 +7,7 @@ #include "src/v8.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/graph-builder-tester.h" +#include "test/cctest/compiler/value-helper.h" #include "src/compiler/node-matchers.h" #include "src/compiler/representation-change.h" @@ -25,13 +26,16 @@ class RepresentationChangerTester : public HandleAndZoneScope, explicit RepresentationChangerTester(int num_parameters = 0) : GraphAndBuilders(main_zone()), typer_(main_zone()), - jsgraph_(main_graph_, &main_common_, &typer_), - changer_(&jsgraph_, &main_simplified_, &main_machine_, main_isolate()) { + javascript_(main_zone()), + jsgraph_(main_graph_, &main_common_, &javascript_, &typer_, + &main_machine_), + changer_(&jsgraph_, &main_simplified_, main_isolate()) { Node* s = graph()->NewNode(common()->Start(num_parameters)); graph()->SetStart(s); } Typer typer_; + JSOperatorBuilder javascript_; JSGraph jsgraph_; RepresentationChanger changer_; @@ -43,19 +47,37 @@ class RepresentationChangerTester : public HandleAndZoneScope, // TODO(titzer): use ValueChecker / ValueUtil void CheckInt32Constant(Node* n, int32_t expected) { - ValueMatcher<int32_t> m(n); + Int32Matcher m(n); CHECK(m.HasValue()); CHECK_EQ(expected, m.Value()); } - void CheckHeapConstant(Node* n, Object* expected) { - ValueMatcher<Handle<Object> > m(n); + void CheckUint32Constant(Node* n, uint32_t expected) { + Uint32Matcher m(n); CHECK(m.HasValue()); - CHECK_EQ(expected, *m.Value()); + CHECK_EQ(static_cast<int>(expected), static_cast<int>(m.Value())); + } + + void CheckFloat64Constant(Node* n, double expected) { + Float64Matcher m(n); + CHECK(m.HasValue()); + CHECK_EQ(expected, m.Value()); + } + + void CheckFloat32Constant(Node* n, float expected) { + CHECK_EQ(IrOpcode::kFloat32Constant, n->opcode()); + float fval = OpParameter<float>(n->op()); + CHECK_EQ(expected, fval); + } + + void CheckHeapConstant(Node* n, HeapObject* expected) { + HeapObjectMatcher<HeapObject> m(n); + CHECK(m.HasValue()); + CHECK_EQ(expected, *m.Value().handle()); } void CheckNumberConstant(Node* n, double expected) { - ValueMatcher<double> m(n); + NumberMatcher m(n); CHECK_EQ(IrOpcode::kNumberConstant, n->opcode()); CHECK(m.HasValue()); CHECK_EQ(expected, m.Value()); @@ -65,16 +87,16 @@ class RepresentationChangerTester : public HandleAndZoneScope, return graph()->NewNode(common()->Parameter(index), graph()->start()); } - void CheckTypeError(RepTypeUnion from, RepTypeUnion to) { + void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) { changer()->testing_type_errors_ = true; changer()->type_error_ = false; Node* n = Parameter(0); Node* c = changer()->GetRepresentationFor(n, from, to); - CHECK_EQ(n, c); CHECK(changer()->type_error_); + CHECK_EQ(n, c); } - void CheckNop(RepTypeUnion from, RepTypeUnion to) { + void CheckNop(MachineTypeUnion from, MachineTypeUnion to) { Node* n = Parameter(0); Node* c = changer()->GetRepresentationFor(n, from, to); CHECK_EQ(n, c); @@ -85,38 +107,21 @@ class RepresentationChangerTester : public HandleAndZoneScope, } // namespace v8::internal::compiler -static const RepType all_reps[] = {rBit, rWord32, rWord64, rFloat64, rTagged}; - - -// TODO(titzer): lift this to ValueHelper -static const double double_inputs[] = { - 0.0, -0.0, 1.0, -1.0, 0.1, 1.4, -1.7, - 2, 5, 6, 982983, 888, -999.8, 3.1e7, - -2e66, 2.3e124, -12e73, V8_INFINITY, -V8_INFINITY}; - - -static const int32_t int32_inputs[] = { - 0, 1, -1, - 2, 5, 6, - 982983, 888, -999, - 65535, static_cast<int32_t>(0xFFFFFFFF), static_cast<int32_t>(0x80000000)}; - - -static const uint32_t uint32_inputs[] = { - 0, 1, static_cast<uint32_t>(-1), 2, 5, 6, - 982983, 888, static_cast<uint32_t>(-999), 65535, 0xFFFFFFFF, 0x80000000}; +static const MachineType all_reps[] = {kRepBit, kRepWord32, kRepWord64, + kRepFloat32, kRepFloat64, kRepTagged}; TEST(BoolToBit_constant) { RepresentationChangerTester r; Node* true_node = r.jsgraph()->TrueConstant(); - Node* true_bit = r.changer()->GetRepresentationFor(true_node, rTagged, rBit); + Node* true_bit = + r.changer()->GetRepresentationFor(true_node, kRepTagged, kRepBit); r.CheckInt32Constant(true_bit, 1); Node* false_node = r.jsgraph()->FalseConstant(); Node* false_bit = - r.changer()->GetRepresentationFor(false_node, rTagged, rBit); + r.changer()->GetRepresentationFor(false_node, kRepTagged, kRepBit); r.CheckInt32Constant(false_bit, 0); } @@ -126,7 +131,7 @@ TEST(BitToBool_constant) { for (int i = -5; i < 5; i++) { Node* node = r.jsgraph()->Int32Constant(i); - Node* val = r.changer()->GetRepresentationFor(node, rBit, rTagged); + Node* val = r.changer()->GetRepresentationFor(node, kRepBit, kRepTagged); r.CheckHeapConstant(val, i == 0 ? r.isolate()->heap()->false_value() : r.isolate()->heap()->true_value()); } @@ -136,28 +141,240 @@ TEST(BitToBool_constant) { TEST(ToTagged_constant) { RepresentationChangerTester r; - for (size_t i = 0; i < ARRAY_SIZE(double_inputs); i++) { - Node* n = r.jsgraph()->Float64Constant(double_inputs[i]); - Node* c = r.changer()->GetRepresentationFor(n, rFloat64, rTagged); - r.CheckNumberConstant(c, double_inputs[i]); + { + FOR_FLOAT64_INPUTS(i) { + Node* n = r.jsgraph()->Float64Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged); + r.CheckNumberConstant(c, *i); + } + } + + { + FOR_FLOAT64_INPUTS(i) { + Node* n = r.jsgraph()->Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged); + r.CheckNumberConstant(c, *i); + } + } + + { + FOR_FLOAT32_INPUTS(i) { + Node* n = r.jsgraph()->Float32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepTagged); + r.CheckNumberConstant(c, *i); + } } - for (size_t i = 0; i < ARRAY_SIZE(int32_inputs); i++) { - Node* n = r.jsgraph()->Int32Constant(int32_inputs[i]); - Node* c = r.changer()->GetRepresentationFor(n, rWord32 | tInt32, rTagged); - r.CheckNumberConstant(c, static_cast<double>(int32_inputs[i])); + { + FOR_INT32_INPUTS(i) { + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, + kRepTagged); + r.CheckNumberConstant(c, *i); + } } - for (size_t i = 0; i < ARRAY_SIZE(uint32_inputs); i++) { - Node* n = r.jsgraph()->Int32Constant(uint32_inputs[i]); - Node* c = r.changer()->GetRepresentationFor(n, rWord32 | tUint32, rTagged); - r.CheckNumberConstant(c, static_cast<double>(uint32_inputs[i])); + { + FOR_UINT32_INPUTS(i) { + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, + kRepTagged); + r.CheckNumberConstant(c, *i); + } } } -static void CheckChange(IrOpcode::Value expected, RepTypeUnion from, - RepTypeUnion to) { +TEST(ToFloat64_constant) { + RepresentationChangerTester r; + + { + FOR_FLOAT64_INPUTS(i) { + Node* n = r.jsgraph()->Float64Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepFloat64); + CHECK_EQ(n, c); + } + } + + { + FOR_FLOAT64_INPUTS(i) { + Node* n = r.jsgraph()->Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepTagged, kRepFloat64); + r.CheckFloat64Constant(c, *i); + } + } + + { + FOR_FLOAT32_INPUTS(i) { + Node* n = r.jsgraph()->Float32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepFloat64); + r.CheckFloat64Constant(c, *i); + } + } + + { + FOR_INT32_INPUTS(i) { + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, + kRepFloat64); + r.CheckFloat64Constant(c, *i); + } + } + + { + FOR_UINT32_INPUTS(i) { + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, + kRepFloat64); + r.CheckFloat64Constant(c, *i); + } + } +} + + +static bool IsFloat32Int32(int32_t val) { + return val >= -(1 << 23) && val <= (1 << 23); +} + + +static bool IsFloat32Uint32(uint32_t val) { return val <= (1 << 23); } + + +TEST(ToFloat32_constant) { + RepresentationChangerTester r; + + { + FOR_FLOAT32_INPUTS(i) { + Node* n = r.jsgraph()->Float32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32, kRepFloat32); + CHECK_EQ(n, c); + } + } + + { + FOR_FLOAT32_INPUTS(i) { + Node* n = r.jsgraph()->Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepTagged, kRepFloat32); + r.CheckFloat32Constant(c, *i); + } + } + + { + FOR_FLOAT32_INPUTS(i) { + Node* n = r.jsgraph()->Float64Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepFloat32); + r.CheckFloat32Constant(c, *i); + } + } + + { + FOR_INT32_INPUTS(i) { + if (!IsFloat32Int32(*i)) continue; + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, + kRepFloat32); + r.CheckFloat32Constant(c, static_cast<float>(*i)); + } + } + + { + FOR_UINT32_INPUTS(i) { + if (!IsFloat32Uint32(*i)) continue; + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, + kRepFloat32); + r.CheckFloat32Constant(c, static_cast<float>(*i)); + } + } +} + + +TEST(ToInt32_constant) { + RepresentationChangerTester r; + + { + FOR_INT32_INPUTS(i) { + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, + kRepWord32); + r.CheckInt32Constant(c, *i); + } + } + + { + FOR_INT32_INPUTS(i) { + if (!IsFloat32Int32(*i)) continue; + Node* n = r.jsgraph()->Float32Constant(static_cast<float>(*i)); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeInt32, + kRepWord32); + r.CheckInt32Constant(c, *i); + } + } + + { + FOR_INT32_INPUTS(i) { + Node* n = r.jsgraph()->Float64Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeInt32, + kRepWord32); + r.CheckInt32Constant(c, *i); + } + } + + { + FOR_INT32_INPUTS(i) { + Node* n = r.jsgraph()->Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepTagged | kTypeInt32, + kRepWord32); + r.CheckInt32Constant(c, *i); + } + } +} + + +TEST(ToUint32_constant) { + RepresentationChangerTester r; + + { + FOR_UINT32_INPUTS(i) { + Node* n = r.jsgraph()->Int32Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, + kRepWord32); + r.CheckUint32Constant(c, *i); + } + } + + { + FOR_UINT32_INPUTS(i) { + if (!IsFloat32Uint32(*i)) continue; + Node* n = r.jsgraph()->Float32Constant(static_cast<float>(*i)); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeUint32, + kRepWord32); + r.CheckUint32Constant(c, *i); + } + } + + { + FOR_UINT32_INPUTS(i) { + Node* n = r.jsgraph()->Float64Constant(*i); + Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeUint32, + kRepWord32); + r.CheckUint32Constant(c, *i); + } + } + + { + FOR_UINT32_INPUTS(i) { + Node* n = r.jsgraph()->Constant(static_cast<double>(*i)); + Node* c = r.changer()->GetRepresentationFor(n, kRepTagged | kTypeUint32, + kRepWord32); + r.CheckUint32Constant(c, *i); + } + } +} + + +static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from, + MachineTypeUnion to) { RepresentationChangerTester r; Node* n = r.Parameter(); @@ -169,34 +386,86 @@ static void CheckChange(IrOpcode::Value expected, RepTypeUnion from, } +static void CheckTwoChanges(IrOpcode::Value expected2, + IrOpcode::Value expected1, MachineTypeUnion from, + MachineTypeUnion to) { + RepresentationChangerTester r; + + Node* n = r.Parameter(); + Node* c1 = r.changer()->GetRepresentationFor(n, from, to); + + CHECK_NE(c1, n); + CHECK_EQ(expected1, c1->opcode()); + Node* c2 = c1->InputAt(0); + CHECK_NE(c2, n); + CHECK_EQ(expected2, c2->opcode()); + CHECK_EQ(n, c2->InputAt(0)); +} + + TEST(SingleChanges) { - CheckChange(IrOpcode::kChangeBoolToBit, rTagged, rBit); - CheckChange(IrOpcode::kChangeBitToBool, rBit, rTagged); + CheckChange(IrOpcode::kChangeBoolToBit, kRepTagged, kRepBit); + CheckChange(IrOpcode::kChangeBitToBool, kRepBit, kRepTagged); - CheckChange(IrOpcode::kChangeInt32ToTagged, rWord32 | tInt32, rTagged); - CheckChange(IrOpcode::kChangeUint32ToTagged, rWord32 | tUint32, rTagged); - CheckChange(IrOpcode::kChangeFloat64ToTagged, rFloat64, rTagged); + CheckChange(IrOpcode::kChangeInt32ToTagged, kRepWord32 | kTypeInt32, + kRepTagged); + CheckChange(IrOpcode::kChangeUint32ToTagged, kRepWord32 | kTypeUint32, + kRepTagged); + CheckChange(IrOpcode::kChangeFloat64ToTagged, kRepFloat64, kRepTagged); - CheckChange(IrOpcode::kChangeTaggedToInt32, rTagged | tInt32, rWord32); - CheckChange(IrOpcode::kChangeTaggedToUint32, rTagged | tUint32, rWord32); - CheckChange(IrOpcode::kChangeTaggedToFloat64, rTagged, rFloat64); + CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged | kTypeInt32, + kRepWord32); + CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged | kTypeUint32, + kRepWord32); + CheckChange(IrOpcode::kChangeTaggedToFloat64, kRepTagged, kRepFloat64); // Int32,Uint32 <-> Float64 are actually machine conversions. - CheckChange(IrOpcode::kChangeInt32ToFloat64, rWord32 | tInt32, rFloat64); - CheckChange(IrOpcode::kChangeUint32ToFloat64, rWord32 | tUint32, rFloat64); - CheckChange(IrOpcode::kChangeFloat64ToInt32, rFloat64 | tInt32, rWord32); - CheckChange(IrOpcode::kChangeFloat64ToUint32, rFloat64 | tUint32, rWord32); + CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32 | kTypeInt32, + kRepFloat64); + CheckChange(IrOpcode::kChangeUint32ToFloat64, kRepWord32 | kTypeUint32, + kRepFloat64); + CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64 | kTypeInt32, + kRepWord32); + CheckChange(IrOpcode::kChangeFloat64ToUint32, kRepFloat64 | kTypeUint32, + kRepWord32); + + // Int32,Uint32 <-> Float32 require two changes. + CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, + IrOpcode::kTruncateFloat64ToFloat32, kRepWord32 | kTypeInt32, + kRepFloat32); + CheckTwoChanges(IrOpcode::kChangeUint32ToFloat64, + IrOpcode::kTruncateFloat64ToFloat32, kRepWord32 | kTypeUint32, + kRepFloat32); + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToInt32, kRepFloat32 | kTypeInt32, + kRepWord32); + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToUint32, kRepFloat32 | kTypeUint32, + kRepWord32); + + // Float32 <-> Tagged require two changes. + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToTagged, kRepFloat32, kRepTagged); + CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64, + IrOpcode::kTruncateFloat64ToFloat32, kRepTagged, kRepFloat32); } TEST(SignednessInWord32) { RepresentationChangerTester r; - // TODO(titzer): assume that uses of a word32 without a sign mean tInt32. - CheckChange(IrOpcode::kChangeTaggedToInt32, rTagged, rWord32 | tInt32); - CheckChange(IrOpcode::kChangeTaggedToUint32, rTagged, rWord32 | tUint32); - CheckChange(IrOpcode::kChangeInt32ToFloat64, rWord32, rFloat64); - CheckChange(IrOpcode::kChangeFloat64ToInt32, rFloat64, rWord32); + // TODO(titzer): assume that uses of a word32 without a sign mean kTypeInt32. + CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged, + kRepWord32 | kTypeInt32); + CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged, + kRepWord32 | kTypeUint32); + CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64); + CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64, kRepWord32); + + CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, + IrOpcode::kTruncateFloat64ToFloat32, kRepWord32, kRepFloat32); + CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, + IrOpcode::kChangeFloat64ToInt32, kRepFloat32, kRepWord32); } @@ -204,21 +473,39 @@ TEST(Nops) { RepresentationChangerTester r; // X -> X is always a nop for any single representation X. - for (size_t i = 0; i < ARRAY_SIZE(all_reps); i++) { + for (size_t i = 0; i < arraysize(all_reps); i++) { r.CheckNop(all_reps[i], all_reps[i]); } - // 32-bit or 64-bit words can be used as branch conditions (rBit). - r.CheckNop(rWord32, rBit); - r.CheckNop(rWord32, rBit | tBool); - r.CheckNop(rWord64, rBit); - r.CheckNop(rWord64, rBit | tBool); - - // rBit (result of comparison) is implicitly a wordish thing. - r.CheckNop(rBit, rWord32); - r.CheckNop(rBit | tBool, rWord32); - r.CheckNop(rBit, rWord64); - r.CheckNop(rBit | tBool, rWord64); + // 32-bit floats. + r.CheckNop(kRepFloat32, kRepFloat32); + r.CheckNop(kRepFloat32 | kTypeNumber, kRepFloat32); + r.CheckNop(kRepFloat32, kRepFloat32 | kTypeNumber); + + // 32-bit or 64-bit words can be used as branch conditions (kRepBit). + r.CheckNop(kRepWord32, kRepBit); + r.CheckNop(kRepWord32, kRepBit | kTypeBool); + r.CheckNop(kRepWord64, kRepBit); + r.CheckNop(kRepWord64, kRepBit | kTypeBool); + + // 32-bit words can be used as smaller word sizes and vice versa, because + // loads from memory implicitly sign or zero extend the value to the + // full machine word size, and stores implicitly truncate. + r.CheckNop(kRepWord32, kRepWord8); + r.CheckNop(kRepWord32, kRepWord16); + r.CheckNop(kRepWord32, kRepWord32); + r.CheckNop(kRepWord8, kRepWord32); + r.CheckNop(kRepWord16, kRepWord32); + + // kRepBit (result of comparison) is implicitly a wordish thing. + r.CheckNop(kRepBit, kRepWord8); + r.CheckNop(kRepBit | kTypeBool, kRepWord8); + r.CheckNop(kRepBit, kRepWord16); + r.CheckNop(kRepBit | kTypeBool, kRepWord16); + r.CheckNop(kRepBit, kRepWord32); + r.CheckNop(kRepBit | kTypeBool, kRepWord32); + r.CheckNop(kRepBit, kRepWord64); + r.CheckNop(kRepBit | kTypeBool, kRepWord64); } @@ -226,51 +513,37 @@ TEST(TypeErrors) { RepresentationChangerTester r; // Floats cannot be implicitly converted to/from comparison conditions. - r.CheckTypeError(rFloat64, rBit); - r.CheckTypeError(rFloat64, rBit | tBool); - r.CheckTypeError(rBit, rFloat64); - r.CheckTypeError(rBit | tBool, rFloat64); + r.CheckTypeError(kRepFloat64, kRepBit); + r.CheckTypeError(kRepFloat64, kRepBit | kTypeBool); + r.CheckTypeError(kRepBit, kRepFloat64); + r.CheckTypeError(kRepBit | kTypeBool, kRepFloat64); + + // Floats cannot be implicitly converted to/from comparison conditions. + r.CheckTypeError(kRepFloat32, kRepBit); + r.CheckTypeError(kRepFloat32, kRepBit | kTypeBool); + r.CheckTypeError(kRepBit, kRepFloat32); + r.CheckTypeError(kRepBit | kTypeBool, kRepFloat32); // Word64 is internal and shouldn't be implicitly converted. - r.CheckTypeError(rWord64, rTagged | tBool); - r.CheckTypeError(rWord64, rTagged); - r.CheckTypeError(rWord64, rTagged | tBool); - r.CheckTypeError(rTagged, rWord64); - r.CheckTypeError(rTagged | tBool, rWord64); + r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool); + r.CheckTypeError(kRepWord64, kRepTagged); + r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool); + r.CheckTypeError(kRepTagged, kRepWord64); + r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64); // Word64 / Word32 shouldn't be implicitly converted. - r.CheckTypeError(rWord64, rWord32); - r.CheckTypeError(rWord32, rWord64); - r.CheckTypeError(rWord64, rWord32 | tInt32); - r.CheckTypeError(rWord32 | tInt32, rWord64); - r.CheckTypeError(rWord64, rWord32 | tUint32); - r.CheckTypeError(rWord32 | tUint32, rWord64); - - for (size_t i = 0; i < ARRAY_SIZE(all_reps); i++) { - for (size_t j = 0; j < ARRAY_SIZE(all_reps); j++) { + r.CheckTypeError(kRepWord64, kRepWord32); + r.CheckTypeError(kRepWord32, kRepWord64); + r.CheckTypeError(kRepWord64, kRepWord32 | kTypeInt32); + r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64); + r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32); + r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); + + for (size_t i = 0; i < arraysize(all_reps); i++) { + for (size_t j = 0; j < arraysize(all_reps); j++) { if (i == j) continue; // Only a single from representation is allowed. - r.CheckTypeError(all_reps[i] | all_reps[j], rTagged); + r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); } } } - - -TEST(CompleteMatrix) { - // TODO(titzer): test all variants in the matrix. - // rB - // tBrB - // tBrT - // rW32 - // tIrW32 - // tUrW32 - // rW64 - // tIrW64 - // tUrW64 - // rF64 - // tIrF64 - // tUrF64 - // tArF64 - // rT - // tArT -} diff --git a/deps/v8/test/cctest/compiler/test-run-deopt.cc b/deps/v8/test/cctest/compiler/test-run-deopt.cc index af173d6be6..14c024cdbc 100644 --- a/deps/v8/test/cctest/compiler/test-run-deopt.cc +++ b/deps/v8/test/cctest/compiler/test-run-deopt.cc @@ -4,13 +4,29 @@ #include "src/v8.h" +#include "test/cctest/cctest.h" #include "test/cctest/compiler/function-tester.h" +using namespace v8; using namespace v8::internal; using namespace v8::internal::compiler; #if V8_TURBOFAN_TARGET +static void IsOptimized(const FunctionCallbackInfo<v8::Value>& args) { + JavaScriptFrameIterator it(CcTest::i_isolate()); + JavaScriptFrame* frame = it.frame(); + return args.GetReturnValue().Set(frame->is_optimized()); +} + + +static void InstallIsOptimizedHelper(v8::Isolate* isolate) { + Local<v8::Context> context = isolate->GetCurrentContext(); + Local<v8::FunctionTemplate> t = FunctionTemplate::New(isolate, IsOptimized); + context->Global()->Set(v8_str("IsOptimized"), t->GetFunction()); +} + + TEST(TurboSimpleDeopt) { FLAG_allow_natives_syntax = true; FLAG_turbo_deoptimization = true; @@ -18,11 +34,12 @@ TEST(TurboSimpleDeopt) { FunctionTester T( "(function f(a) {" "var b = 1;" - "if (!%IsOptimized()) return 0;" + "if (!IsOptimized()) return 0;" "%DeoptimizeFunction(f);" - "if (%IsOptimized()) return 0;" + "if (IsOptimized()) return 0;" "return a + b; })"); + InstallIsOptimizedHelper(CcTest::isolate()); T.CheckCall(T.Val(2), T.Val(1)); } @@ -35,11 +52,12 @@ TEST(TurboSimpleDeoptInExpr) { "(function f(a) {" "var b = 1;" "var c = 2;" - "if (!%IsOptimized()) return 0;" + "if (!IsOptimized()) return 0;" "var d = b + (%DeoptimizeFunction(f), c);" - "if (%IsOptimized()) return 0;" + "if (IsOptimized()) return 0;" "return d + a; })"); + InstallIsOptimizedHelper(CcTest::isolate()); T.CheckCall(T.Val(6), T.Val(3)); } diff --git a/deps/v8/test/cctest/compiler/test-run-inlining.cc b/deps/v8/test/cctest/compiler/test-run-inlining.cc new file mode 100644 index 0000000000..ad82fecaa2 --- /dev/null +++ b/deps/v8/test/cctest/compiler/test-run-inlining.cc @@ -0,0 +1,353 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/v8.h" + +#include "test/cctest/compiler/function-tester.h" + +#if V8_TURBOFAN_TARGET + +using namespace v8::internal; +using namespace v8::internal::compiler; + +// Helper to determine inline count via JavaScriptFrame::GetInlineCount. +// Note that a count of 1 indicates that no inlining has occured. +static void AssertInlineCount(const v8::FunctionCallbackInfo<v8::Value>& args) { + StackTraceFrameIterator it(CcTest::i_isolate()); + int frames_seen = 0; + JavaScriptFrame* topmost = it.frame(); + while (!it.done()) { + JavaScriptFrame* frame = it.frame(); + PrintF("%d %s, inline count: %d\n", frames_seen, + frame->function()->shared()->DebugName()->ToCString().get(), + frame->GetInlineCount()); + frames_seen++; + it.Advance(); + } + CHECK_EQ(args[0]->ToInt32()->Value(), topmost->GetInlineCount()); +} + + +static void InstallAssertInlineCountHelper(v8::Isolate* isolate) { + v8::Local<v8::Context> context = isolate->GetCurrentContext(); + v8::Local<v8::FunctionTemplate> t = + v8::FunctionTemplate::New(isolate, AssertInlineCount); + context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); +} + + +TEST(SimpleInlining) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function(){" + "function foo(s) { AssertInlineCount(2); return s; };" + "function bar(s, t) { return foo(s); };" + "return bar;})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); +} + + +TEST(SimpleInliningDeopt) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function(){" + "function foo(s) { %DeoptimizeFunction(bar); return " + "s; };" + "function bar(s, t) { return foo(s); };" + "return bar;})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); +} + + +TEST(SimpleInliningContext) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "function foo(s) { AssertInlineCount(2); var x = 12; return s + x; };" + "function bar(s, t) { return foo(s); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); +} + + +TEST(SimpleInliningContextDeopt) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "function foo(s) { " + " AssertInlineCount(2); %DeoptimizeFunction(bar); var x = 12;" + " return s + x;" + "};" + "function bar(s, t) { return foo(s); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); +} + + +TEST(CaptureContext) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "var f = (function () {" + "var x = 42;" + "function bar(s) { return x + s; };" + "return (function (s) { return bar(s); });" + "})();" + "(function (s) { return f(s)})", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); +} + + +// TODO(sigurds) For now we do not inline any native functions. If we do at +// some point, change this test. +TEST(DontInlineEval) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "var x = 42;" + "(function () {" + "function bar(s, t) { return eval(\"AssertInlineCount(1); x\") };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); +} + + +TEST(InlineOmitArguments) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = 42;" + "function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };" + "return (function (s,t) { return bar(s); });" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); +} + + +TEST(InlineOmitArgumentsDeopt) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "function foo(s,t,u,v) { AssertInlineCount(2); %DeoptimizeFunction(bar); " + "return baz(); };" + "function bar() { return foo(11); };" + "function baz() { return foo.arguments.length == 1 && " + " foo.arguments[0] == 11 ; }" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); +} + + +TEST(InlineSurplusArguments) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = 42;" + "function foo(s) { AssertInlineCount(2); return x + s; };" + "function bar(s,t) { return foo(s,t,13); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); +} + + +TEST(InlineSurplusArgumentsDeopt) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar); " + "return baz(); };" + "function bar() { return foo(13, 14, 15); };" + "function baz() { return foo.arguments.length == 3 && " + " foo.arguments[0] == 13 && " + " foo.arguments[1] == 14 && " + " foo.arguments[2] == 15; }" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); +} + + +TEST(InlineTwice) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = 42;" + "function bar(s) { AssertInlineCount(2); return x + s; };" + "return (function (s,t) { return bar(s) + bar(t); });" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4)); +} + + +TEST(InlineTwiceDependent) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = 42;" + "function foo(s) { AssertInlineCount(2); return x + s; };" + "function bar(s,t) { return foo(foo(s)); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4)); +} + + +TEST(InlineTwiceDependentDiamond) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = 41;" + "function foo(s) { AssertInlineCount(2); if (s % 2 == 0) {" + " return x - s } else { return x + s; } };" + "function bar(s,t) { return foo(foo(s)); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(-11), T.Val(11), T.Val(4)); +} + + +TEST(InlineTwiceDependentDiamondDifferent) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = 41;" + "function foo(s,t) { AssertInlineCount(2); if (s % 2 == 0) {" + " return x - s * t } else { return x + s * t; } };" + "function bar(s,t) { return foo(foo(s, 3), 5); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(-329), T.Val(11), T.Val(4)); +} + + +TEST(InlineLoop) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = 41;" + "function foo(s) { AssertInlineCount(2); while (s > 0) {" + " s = s - 1; }; return s; };" + "function bar(s,t) { return foo(foo(s)); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4)); +} + + +TEST(InlineStrictIntoNonStrict) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = Object.create({}, { y: { value:42, writable:false } });" + "function foo(s) { 'use strict';" + " x.y = 9; };" + "function bar(s,t) { return foo(s); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckThrows(T.undefined(), T.undefined()); +} + + +TEST(InlineNonStrictIntoStrict) { + FLAG_turbo_deoptimization = true; + FunctionTester T( + "(function () {" + "var x = Object.create({}, { y: { value:42, writable:false } });" + "function foo(s) { x.y = 9; return x.y; };" + "function bar(s,t) { \'use strict\'; return foo(s); };" + "return bar;" + "})();", + CompilationInfo::kInliningEnabled | + CompilationInfo::kContextSpecializing | + CompilationInfo::kTypingEnabled); + + InstallAssertInlineCountHelper(CcTest::isolate()); + T.CheckCall(T.Val(42), T.undefined(), T.undefined()); +} + + +#endif // V8_TURBOFAN_TARGET diff --git a/deps/v8/test/cctest/compiler/test-run-jsbranches.cc b/deps/v8/test/cctest/compiler/test-run-jsbranches.cc index 2eb4fa6d0f..df2fcdcb6d 100644 --- a/deps/v8/test/cctest/compiler/test-run-jsbranches.cc +++ b/deps/v8/test/cctest/compiler/test-run-jsbranches.cc @@ -148,6 +148,26 @@ TEST(ForInStatement) { } +TEST(ForInContinueStatement) { + const char* src = + "(function(a,b) {" + " var r = '-';" + " for (var x in a) {" + " r += 'A-';" + " if (b) continue;" + " r += 'B-';" + " }" + " return r;" + "})"; + FunctionTester T(src); + + T.CheckCall(T.Val("-A-B-"), T.NewObject("({x:1})"), T.false_value()); + T.CheckCall(T.Val("-A-B-A-B-"), T.NewObject("({x:1,y:2})"), T.false_value()); + T.CheckCall(T.Val("-A-"), T.NewObject("({x:1})"), T.true_value()); + T.CheckCall(T.Val("-A-A-"), T.NewObject("({x:1,y:2})"), T.true_value()); +} + + TEST(SwitchStatement) { const char* src = "(function(a,b) {" diff --git a/deps/v8/test/cctest/compiler/test-run-jscalls.cc b/deps/v8/test/cctest/compiler/test-run-jscalls.cc index 2ad7e50467..dec7194c4a 100644 --- a/deps/v8/test/cctest/compiler/test-run-jscalls.cc +++ b/deps/v8/test/cctest/compiler/test-run-jscalls.cc @@ -233,3 +233,57 @@ TEST(ReceiverPatching) { Handle<JSObject> g(T.function->context()->global_object()->global_proxy()); T.CheckCall(g, T.undefined()); } + + +TEST(CallEval) { + FunctionTester T( + "var x = 42;" + "(function () {" + "function bar() { return eval('x') };" + "return bar;" + "})();"); + + T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); +} + + +TEST(ContextLoadedFromActivation) { + const char* script = + "var x = 42;" + "(function() {" + " return function () { return x };" + "})()"; + + // Disable context specialization. + FunctionTester T(script); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope scope(context); + v8::Local<v8::Value> value = CompileRun(script); + i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); + i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); + jsfun->set_code(T.function->code()); + context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); + CompileRun("var x = 24;"); + ExpectInt32("foo();", 24); +} + + +TEST(BuiltinLoadedFromActivation) { + const char* script = + "var x = 42;" + "(function() {" + " return function () { return this; };" + "})()"; + + // Disable context specialization. + FunctionTester T(script); + v8::Local<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope scope(context); + v8::Local<v8::Value> value = CompileRun(script); + i::Handle<i::Object> ofun = v8::Utils::OpenHandle(*value); + i::Handle<i::JSFunction> jsfun = Handle<JSFunction>::cast(ofun); + jsfun->set_code(T.function->code()); + context->Global()->Set(v8_str("foo"), v8::Utils::ToLocal(jsfun)); + CompileRun("var x = 24;"); + ExpectObject("foo()", context->Global()); +} diff --git a/deps/v8/test/cctest/compiler/test-run-machops.cc b/deps/v8/test/cctest/compiler/test-run-machops.cc index 6786f38741..5606126e06 100644 --- a/deps/v8/test/cctest/compiler/test-run-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-machops.cc @@ -5,12 +5,19 @@ #include <functional> #include <limits> +#include "src/base/bits.h" +#include "src/compiler/generic-node-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/codegen-tester.h" #include "test/cctest/compiler/value-helper.h" #if V8_TURBOFAN_TARGET +using namespace v8::base; + +#define CHECK_UINT32_EQ(x, y) \ + CHECK_EQ(static_cast<int32_t>(x), static_cast<int32_t>(y)) + using namespace v8::internal; using namespace v8::internal::compiler; @@ -41,7 +48,7 @@ static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { case 6: return m->Int32Constant(0x01234567); case 7: - return m->Load(kMachineWord32, m->PointerConstant(NULL)); + return m->Load(kMachInt32, m->PointerConstant(NULL)); default: return NULL; } @@ -51,7 +58,7 @@ static Node* Int32Input(RawMachineAssemblerTester<int32_t>* m, int index) { TEST(CodeGenInt32Binop) { RawMachineAssemblerTester<void> m; - Operator* ops[] = { + const Operator* ops[] = { m.machine()->Word32And(), m.machine()->Word32Or(), m.machine()->Word32Xor(), m.machine()->Word32Shl(), m.machine()->Word32Shr(), m.machine()->Word32Sar(), @@ -66,7 +73,7 @@ TEST(CodeGenInt32Binop) { for (int i = 0; ops[i] != NULL; i++) { for (int j = 0; j < 8; j++) { for (int k = 0; k < 8; k++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); Node* a = Int32Input(&m, j); Node* b = Int32Input(&m, k); m.Return(m.NewNode(ops[i], a, b)); @@ -95,7 +102,7 @@ TEST(RunGotoMultiple) { int constant = 9999977; MLabel labels[10]; - for (size_t i = 0; i < ARRAY_SIZE(labels); i++) { + for (size_t i = 0; i < arraysize(labels); i++) { m.Goto(&labels[i]); m.Bind(&labels[i]); } @@ -202,7 +209,8 @@ TEST(RunLoop) { template <typename R> static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, - Node* true_node, Node* false_node) { + MachineType type, Node* true_node, + Node* false_node) { MLabel blocka, blockb; MLabel* end = m->Exit(); m->Branch(cond_node, &blocka, &blockb); @@ -212,51 +220,51 @@ static void BuildDiamondPhi(RawMachineAssemblerTester<R>* m, Node* cond_node, m->Goto(end); m->Bind(end); - Node* phi = m->Phi(true_node, false_node); + Node* phi = m->Phi(type, true_node, false_node); m->Return(phi); } TEST(RunDiamondPhiConst) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); int false_val = 0xFF666; int true_val = 0x00DDD; Node* true_node = m.Int32Constant(true_val); Node* false_node = m.Int32Constant(false_val); - BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); + BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, true_node, false_node); CHECK_EQ(false_val, m.Call(0)); CHECK_EQ(true_val, m.Call(1)); } TEST(RunDiamondPhiNumber) { - RawMachineAssemblerTester<Object*> m(kMachineWord32); + RawMachineAssemblerTester<Object*> m(kMachInt32); double false_val = -11.1; double true_val = 200.1; Node* true_node = m.NumberConstant(true_val); Node* false_node = m.NumberConstant(false_val); - BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); + BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); m.CheckNumber(false_val, m.Call(0)); m.CheckNumber(true_val, m.Call(1)); } TEST(RunDiamondPhiString) { - RawMachineAssemblerTester<Object*> m(kMachineWord32); + RawMachineAssemblerTester<Object*> m(kMachInt32); const char* false_val = "false"; const char* true_val = "true"; Node* true_node = m.StringConstant(true_val); Node* false_node = m.StringConstant(false_val); - BuildDiamondPhi(&m, m.Parameter(0), true_node, false_node); + BuildDiamondPhi(&m, m.Parameter(0), kMachAnyTagged, true_node, false_node); m.CheckString(false_val, m.Call(0)); m.CheckString(true_val, m.Call(1)); } TEST(RunDiamondPhiParam) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); - BuildDiamondPhi(&m, m.Parameter(0), m.Parameter(1), m.Parameter(2)); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); + BuildDiamondPhi(&m, m.Parameter(0), kMachInt32, m.Parameter(1), + m.Parameter(2)); int32_t c1 = 0x260cb75a; int32_t c2 = 0xcd3e9c8b; int result = m.Call(0, c1, c2); @@ -281,7 +289,7 @@ TEST(RunLoopPhiConst) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(false_node, true_node); + Node* phi = m.Phi(kMachInt32, false_node, true_node); m.Branch(cond_node, &body, end); m.Bind(&body); m.Goto(&header); @@ -293,8 +301,7 @@ TEST(RunLoopPhiConst) { TEST(RunLoopPhiParam) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); MLabel blocka, blockb; MLabel* end = m.Exit(); @@ -302,8 +309,8 @@ TEST(RunLoopPhiParam) { m.Goto(&blocka); m.Bind(&blocka); - Node* phi = m.Phi(m.Parameter(1), m.Parameter(2)); - Node* cond = m.Phi(m.Parameter(0), m.Int32Constant(0)); + Node* phi = m.Phi(kMachInt32, m.Parameter(1), m.Parameter(2)); + Node* cond = m.Phi(kMachInt32, m.Parameter(0), m.Int32Constant(0)); m.Branch(cond, &blockb, end); m.Bind(&blockb); @@ -334,7 +341,7 @@ TEST(RunLoopPhiInduction) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(false_node, false_node); + Node* phi = m.Phi(kMachInt32, false_node, false_node); m.Branch(m.Int32Constant(0), &body, end); m.Bind(&body); @@ -361,7 +368,7 @@ TEST(RunLoopIncrement) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(zero, zero); + Node* phi = m.Phi(kMachInt32, zero, zero); m.Branch(m.WordXor(phi, bt.param0), &body, end); m.Bind(&body); @@ -389,7 +396,7 @@ TEST(RunLoopIncrement2) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(zero, zero); + Node* phi = m.Phi(kMachInt32, zero, zero); m.Branch(m.Int32LessThan(phi, bt.param0), &body, end); m.Bind(&body); @@ -418,7 +425,7 @@ TEST(RunLoopIncrement3) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(zero, zero); + Node* phi = m.Phi(kMachInt32, zero, zero); m.Branch(m.Uint32LessThan(phi, bt.param0), &body, end); m.Bind(&body); @@ -446,7 +453,7 @@ TEST(RunLoopDecrement) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(bt.param0, m.Int32Constant(0)); + Node* phi = m.Phi(kMachInt32, bt.param0, m.Int32Constant(0)); m.Branch(phi, &body, end); m.Bind(&body); @@ -474,7 +481,7 @@ TEST(RunLoopIncrementFloat64) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(minus_3, ten); + Node* phi = m.Phi(kMachFloat64, minus_3, ten); m.Branch(m.Float64LessThan(phi, ten), &body, end); m.Bind(&body); @@ -492,7 +499,7 @@ TEST(RunLoadInt32) { RawMachineAssemblerTester<int32_t> m; int32_t p1 = 0; // loads directly from this location. - m.Return(m.LoadFromPointer(&p1, kMachineWord32)); + m.Return(m.LoadFromPointer(&p1, kMachInt32)); FOR_INT32_INPUTS(i) { p1 = *i; @@ -507,12 +514,12 @@ TEST(RunLoadInt32Offset) { int32_t offsets[] = {-2000000, -100, -101, 1, 3, 7, 120, 2000, 2000000000, 0xff}; - for (size_t i = 0; i < ARRAY_SIZE(offsets); i++) { + for (size_t i = 0; i < arraysize(offsets); i++) { RawMachineAssemblerTester<int32_t> m; int32_t offset = offsets[i]; byte* pointer = reinterpret_cast<byte*>(&p1) - offset; // generate load [#base + #index] - m.Return(m.LoadFromPointer(pointer, kMachineWord32, offset)); + m.Return(m.LoadFromPointer(pointer, kMachInt32, offset)); FOR_INT32_INPUTS(j) { p1 = *j; @@ -533,10 +540,9 @@ TEST(RunLoadStoreFloat64Offset) { byte* from = reinterpret_cast<byte*>(&p1) - offset; byte* to = reinterpret_cast<byte*>(&p2) - offset; // generate load [#base + #index] - Node* load = m.Load(kMachineFloat64, m.PointerConstant(from), - m.Int32Constant(offset)); - m.Store(kMachineFloat64, m.PointerConstant(to), m.Int32Constant(offset), - load); + Node* load = + m.Load(kMachFloat64, m.PointerConstant(from), m.Int32Constant(offset)); + m.Store(kMachFloat64, m.PointerConstant(to), m.Int32Constant(offset), load); m.Return(m.Int32Constant(magic)); FOR_FLOAT64_INPUTS(j) { @@ -567,14 +573,12 @@ TEST(RunInt32AddP) { TEST(RunInt32AddAndWord32SarP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); m.Return(m.Int32Add(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. int32_t expected = *i + (*j >> shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); @@ -583,14 +587,12 @@ TEST(RunInt32AddAndWord32SarP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); m.Return(m.Int32Add(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i >> shift) + *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); @@ -603,14 +605,12 @@ TEST(RunInt32AddAndWord32SarP) { TEST(RunInt32AddAndWord32ShlP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); m.Return(m.Int32Add(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. int32_t expected = *i + (*j << shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); @@ -619,14 +619,12 @@ TEST(RunInt32AddAndWord32ShlP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); m.Return(m.Int32Add(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i << shift) + *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); @@ -639,14 +637,12 @@ TEST(RunInt32AddAndWord32ShlP) { TEST(RunInt32AddAndWord32ShrP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); m.Return(m.Int32Add(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. int32_t expected = *i + (*j >> shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); @@ -655,14 +651,12 @@ TEST(RunInt32AddAndWord32ShrP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); m.Return(m.Int32Add(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i >> shift) + *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); @@ -677,7 +671,7 @@ TEST(RunInt32AddInBranch) { static const int32_t constant = 987654321; { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), @@ -695,7 +689,7 @@ TEST(RunInt32AddInBranch) { } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0)), @@ -713,7 +707,7 @@ TEST(RunInt32AddInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -723,14 +717,14 @@ TEST(RunInt32AddInBranch) { m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i + *j) == 0 ? constant : 0 - constant; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i + *j) == 0 ? constant : 0 - constant; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -740,18 +734,19 @@ TEST(RunInt32AddInBranch) { m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i + *j) != 0 ? constant : 0 - constant; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i + *j) != 0 ? constant : 0 - constant; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; - Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), - m.machine()->Word32Shr()}; - for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + const Operator* shops[] = {m.machine()->Word32Sar(), + m.machine()->Word32Shl(), + m.machine()->Word32Shr()}; + for (size_t n = 0; n < arraysize(shops); n++) { + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, + kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Add(m.Parameter(0), m.NewNode(shops[n], m.Parameter(1), @@ -764,8 +759,7 @@ TEST(RunInt32AddInBranch) { m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: @@ -793,65 +787,65 @@ TEST(RunInt32AddInBranch) { TEST(RunInt32AddInComparison) { { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Add(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i + *j) == 0; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i + *j) == 0; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Int32Add(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i + *j) == 0; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i + *j) == 0; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Int32Add(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i + *j) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i + *j) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Int32Add(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*j + *i) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*j + *i) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; - Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), - m.machine()->Word32Shr()}; - for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + const Operator* shops[] = {m.machine()->Word32Sar(), + m.machine()->Word32Shl(), + m.machine()->Word32Shr()}; + for (size_t n = 0; n < arraysize(shops); n++) { + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, + kMachUint32); m.Return(m.Word32Equal( m.Int32Add(m.Parameter(0), m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: @@ -878,15 +872,14 @@ TEST(RunInt32AddInComparison) { TEST(RunInt32SubP) { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); m.Return(m.Int32Sub(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - // Use uint32_t because signed overflow is UB in C. - int expected = static_cast<int32_t>(*i - *j); - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = static_cast<int32_t>(*i - *j); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } @@ -895,23 +888,21 @@ TEST(RunInt32SubP) { TEST(RunInt32SubImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { - // Use uint32_t because signed overflow is UB in C. - int32_t expected = static_cast<int32_t>(*i - *j); - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = *i - *j; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i))); FOR_UINT32_INPUTS(j) { - // Use uint32_t because signed overflow is UB in C. - int32_t expected = static_cast<int32_t>(*j - *i); - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = *j - *i; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } @@ -920,15 +911,12 @@ TEST(RunInt32SubImm) { TEST(RunInt32SubAndWord32SarP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; - // Use uint32_t because signed overflow is UB in C. + FOR_UINT32_SHIFTS(shift) { int32_t expected = *i - (*j >> shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } @@ -936,15 +924,12 @@ TEST(RunInt32SubAndWord32SarP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); m.Return(m.Int32Sub(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; - // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i >> shift) - *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); } @@ -956,15 +941,12 @@ TEST(RunInt32SubAndWord32SarP) { TEST(RunInt32SubAndWord32ShlP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachUint32); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; - // Use uint32_t because signed overflow is UB in C. + FOR_UINT32_SHIFTS(shift) { int32_t expected = *i - (*j << shift); CHECK_EQ(expected, m.Call(*i, *j, shift)); } @@ -972,14 +954,12 @@ TEST(RunInt32SubAndWord32ShlP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachUint32); m.Return(m.Int32Sub(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i << shift) - *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); @@ -992,30 +972,28 @@ TEST(RunInt32SubAndWord32ShlP) { TEST(RunInt32SubAndWord32ShrP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, + kMachUint32); m.Return(m.Int32Sub(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { // Use uint32_t because signed overflow is UB in C. int32_t expected = *i - (*j >> shift); - CHECK_EQ(expected, m.Call(*i, *j, shift)); + CHECK_UINT32_EQ(expected, m.Call(*i, *j, shift)); } } } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32, kMachUint32, + kMachUint32); m.Return(m.Int32Sub(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; // Use uint32_t because signed overflow is UB in C. int32_t expected = (*i >> shift) - *k; CHECK_EQ(expected, m.Call(*i, shift, *k)); @@ -1030,7 +1008,7 @@ TEST(RunInt32SubInBranch) { static const int constant = 987654321; { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), @@ -1048,7 +1026,7 @@ TEST(RunInt32SubInBranch) { } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0)), @@ -1066,7 +1044,7 @@ TEST(RunInt32SubInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1083,7 +1061,7 @@ TEST(RunInt32SubInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1100,11 +1078,12 @@ TEST(RunInt32SubInBranch) { } { RawMachineAssemblerTester<void> m; - Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), - m.machine()->Word32Shr()}; - for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + const Operator* shops[] = {m.machine()->Word32Sar(), + m.machine()->Word32Shl(), + m.machine()->Word32Shr()}; + for (size_t n = 0; n < arraysize(shops); n++) { + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, + kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.NewNode(shops[n], m.Parameter(1), @@ -1117,8 +1096,7 @@ TEST(RunInt32SubInBranch) { m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: @@ -1146,65 +1124,65 @@ TEST(RunInt32SubInBranch) { TEST(RunInt32SubInComparison) { { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Sub(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i - *j) == 0; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i - *j) == 0; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Int32Sub(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i - *j) == 0; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i - *j) == 0; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Int32Sub(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i - *j) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i - *j) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Int32Sub(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*j - *i) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*j - *i) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; - Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), - m.machine()->Word32Shr()}; - for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + const Operator* shops[] = {m.machine()->Word32Sar(), + m.machine()->Word32Shl(), + m.machine()->Word32Shr()}; + for (size_t n = 0; n < arraysize(shops); n++) { + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, + kMachUint32); m.Return(m.Word32Equal( m.Int32Sub(m.Parameter(0), m.NewNode(shops[n], m.Parameter(1), m.Parameter(2))), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: @@ -1243,12 +1221,12 @@ TEST(RunInt32MulP) { } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn(m.Int32Mul(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int expected = static_cast<int32_t>(*i * *j); - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = *i * *j; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } @@ -1258,21 +1236,21 @@ TEST(RunInt32MulP) { TEST(RunInt32MulImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Int32Mul(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = static_cast<int32_t>(*i * *j); - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = *i * *j; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant(*i))); FOR_UINT32_INPUTS(j) { - int32_t expected = static_cast<int32_t>(*j * *i); - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = *j * *i; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } @@ -1281,8 +1259,7 @@ TEST(RunInt32MulImm) { TEST(RunInt32MulAndInt32AddP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); m.Return( m.Int32Add(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { @@ -1298,8 +1275,7 @@ TEST(RunInt32MulAndInt32AddP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); m.Return( m.Int32Add(m.Int32Mul(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { @@ -1335,8 +1311,7 @@ TEST(RunInt32MulAndInt32AddP) { TEST(RunInt32MulAndInt32SubP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, kMachInt32); m.Return( m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { @@ -1548,25 +1523,25 @@ TEST(RunWord32AndP) { TEST(RunWord32AndAndWord32ShlP) { { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shl(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i << (*j & 0x1f); - CHECK_EQ(expected, bt.call(*i, *j)); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shl(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i << (0x1f & *j); - CHECK_EQ(expected, bt.call(*i, *j)); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } @@ -1576,25 +1551,25 @@ TEST(RunWord32AndAndWord32ShlP) { TEST(RunWord32AndAndWord32ShrP) { { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shr(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i >> (*j & 0x1f); - CHECK_EQ(expected, bt.call(*i, *j)); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Shr(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i >> (0x1f & *j); - CHECK_EQ(expected, bt.call(*i, *j)); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } @@ -1608,8 +1583,8 @@ TEST(RunWord32AndAndWord32SarP) { bt.AddReturn( m.Word32Sar(bt.param0, m.Word32And(bt.param1, m.Int32Constant(0x1f)))); FOR_INT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { - uint32_t expected = *i >> (*j & 0x1f); + FOR_INT32_INPUTS(j) { + int32_t expected = *i >> (*j & 0x1f); CHECK_EQ(expected, bt.call(*i, *j)); } } @@ -1620,7 +1595,7 @@ TEST(RunWord32AndAndWord32SarP) { bt.AddReturn( m.Word32Sar(bt.param0, m.Word32And(m.Int32Constant(0x1f), bt.param1))); FOR_INT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_INT32_INPUTS(j) { uint32_t expected = *i >> (0x1f & *j); CHECK_EQ(expected, bt.call(*i, *j)); } @@ -1632,21 +1607,21 @@ TEST(RunWord32AndAndWord32SarP) { TEST(RunWord32AndImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32And(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i & *j; - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i & ~(*j); - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } @@ -1657,7 +1632,7 @@ TEST(RunWord32AndInBranch) { static const int constant = 987654321; { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), @@ -1675,7 +1650,7 @@ TEST(RunWord32AndInBranch) { } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0)), @@ -1693,7 +1668,7 @@ TEST(RunWord32AndInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1710,7 +1685,7 @@ TEST(RunWord32AndInBranch) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), @@ -1728,11 +1703,12 @@ TEST(RunWord32AndInBranch) { } { RawMachineAssemblerTester<void> m; - Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), - m.machine()->Word32Shr()}; - for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + const Operator* shops[] = {m.machine()->Word32Sar(), + m.machine()->Word32Shl(), + m.machine()->Word32Shr()}; + for (size_t n = 0; n < arraysize(shops); n++) { + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, + kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32And(m.Parameter(0), m.NewNode(shops[n], m.Parameter(1), @@ -1745,8 +1721,7 @@ TEST(RunWord32AndInBranch) { m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: @@ -1774,47 +1749,47 @@ TEST(RunWord32AndInBranch) { TEST(RunWord32AndInComparison) { { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32And(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i & *j) == 0; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i & *j) == 0; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32And(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i & *j) == 0; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i & *j) == 0; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Word32And(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i & *j) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i & *j) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Word32And(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*j & *i) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*j & *i) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } @@ -1824,34 +1799,34 @@ TEST(RunWord32AndInComparison) { TEST(RunWord32OrP) { { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Or(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i | *j; - CHECK_EQ(expected, bt.call(*i, *j)); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i | ~(*j); - CHECK_EQ(expected, bt.call(*i, *j)); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = ~(*i) | *j; - CHECK_EQ(expected, bt.call(*i, *j)); + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } @@ -1861,21 +1836,21 @@ TEST(RunWord32OrP) { TEST(RunWord32OrImm) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Or(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i | *j; - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i | ~(*j); - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } @@ -1895,8 +1870,8 @@ TEST(RunWord32OrInBranch) { bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); - FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_INT32_INPUTS(i) { + FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } @@ -1913,16 +1888,16 @@ TEST(RunWord32OrInBranch) { bt.AddReturn(m.Int32Constant(constant)); m.Bind(&blockb); bt.AddReturn(m.Int32Constant(0 - constant)); - FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_INT32_INPUTS(i) { + FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } { - FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + FOR_INT32_INPUTS(i) { + RawMachineAssemblerTester<int32_t> m(kMachInt32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1931,15 +1906,15 @@ TEST(RunWord32OrInBranch) { m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); - FOR_UINT32_INPUTS(j) { + FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) == 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } } } { - FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + FOR_INT32_INPUTS(i) { + RawMachineAssemblerTester<int32_t> m(kMachInt32); MLabel blocka, blockb; m.Branch(m.Word32NotEqual(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -1948,7 +1923,7 @@ TEST(RunWord32OrInBranch) { m.Return(m.Int32Constant(constant)); m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); - FOR_UINT32_INPUTS(j) { + FOR_INT32_INPUTS(j) { int32_t expected = (*i | *j) != 0 ? constant : 0 - constant; CHECK_EQ(expected, m.Call(*j)); } @@ -1956,11 +1931,12 @@ TEST(RunWord32OrInBranch) { } { RawMachineAssemblerTester<void> m; - Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), - m.machine()->Word32Shr()}; - for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + const Operator* shops[] = {m.machine()->Word32Sar(), + m.machine()->Word32Shl(), + m.machine()->Word32Shr()}; + for (size_t n = 0; n < arraysize(shops); n++) { + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, + kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Or(m.Parameter(0), m.NewNode(shops[n], m.Parameter(1), @@ -1973,8 +1949,7 @@ TEST(RunWord32OrInBranch) { m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: @@ -2002,7 +1977,7 @@ TEST(RunWord32OrInBranch) { TEST(RunWord32OrInComparison) { { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Word32Or(bt.param0, bt.param1), m.Int32Constant(0))); FOR_UINT32_INPUTS(i) { @@ -2014,7 +1989,7 @@ TEST(RunWord32OrInComparison) { } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn( m.Word32Equal(m.Int32Constant(0), m.Word32Or(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { @@ -2026,23 +2001,23 @@ TEST(RunWord32OrInComparison) { } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Word32Or(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i | *j) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i | *j) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Equal(m.Word32Or(m.Parameter(0), m.Int32Constant(*i)), m.Int32Constant(0))); FOR_UINT32_INPUTS(j) { - int32_t expected = (*j | *i) == 0; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*j | *i) == 0; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } @@ -2052,22 +2027,22 @@ TEST(RunWord32OrInComparison) { TEST(RunWord32XorP) { { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32); m.Return(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ *j; - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Xor(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - uint32_t expected = *i ^ *j; - CHECK_EQ(expected, bt.call(*i, *j)); + int32_t expected = *i ^ *j; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } @@ -2075,9 +2050,9 @@ TEST(RunWord32XorP) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1))); - FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { - uint32_t expected = *i ^ ~(*j); + FOR_INT32_INPUTS(i) { + FOR_INT32_INPUTS(j) { + int32_t expected = *i ^ ~(*j); CHECK_EQ(expected, bt.call(*i, *j)); } } @@ -2086,20 +2061,20 @@ TEST(RunWord32XorP) { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1)); - FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { - uint32_t expected = ~(*i) ^ *j; + FOR_INT32_INPUTS(i) { + FOR_INT32_INPUTS(j) { + int32_t expected = ~(*i) ^ *j; CHECK_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ ~(*j); - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } @@ -2107,10 +2082,10 @@ TEST(RunWord32XorP) { TEST(RunWord32XorInBranch) { - static const int constant = 987654321; + static const uint32_t constant = 987654321; { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32Equal(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), @@ -2121,14 +2096,14 @@ TEST(RunWord32XorInBranch) { bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); MLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32Xor(bt.param0, bt.param1), m.Int32Constant(0)), @@ -2139,14 +2114,14 @@ TEST(RunWord32XorInBranch) { bt.AddReturn(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - int32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; - CHECK_EQ(expected, bt.call(*i, *j)); + uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; + CHECK_UINT32_EQ(expected, bt.call(*i, *j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), m.Int32Constant(0)), @@ -2156,14 +2131,14 @@ TEST(RunWord32XorInBranch) { m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i ^ *j) == 0 ? constant : 0 - constant; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { FOR_UINT32_INPUTS(i) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<uint32_t> m(kMachUint32); MLabel blocka, blockb; m.Branch( m.Word32NotEqual(m.Word32Xor(m.Int32Constant(*i), m.Parameter(0)), @@ -2174,18 +2149,19 @@ TEST(RunWord32XorInBranch) { m.Bind(&blockb); m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(j) { - int32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; - CHECK_EQ(expected, m.Call(*j)); + uint32_t expected = (*i ^ *j) != 0 ? constant : 0 - constant; + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<void> m; - Operator* shops[] = {m.machine()->Word32Sar(), m.machine()->Word32Shl(), - m.machine()->Word32Shr()}; - for (size_t n = 0; n < ARRAY_SIZE(shops); n++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + const Operator* shops[] = {m.machine()->Word32Sar(), + m.machine()->Word32Shl(), + m.machine()->Word32Shr()}; + for (size_t n = 0; n < arraysize(shops); n++) { + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachInt32, + kMachUint32); MLabel blocka, blockb; m.Branch(m.Word32Equal(m.Word32Xor(m.Parameter(0), m.NewNode(shops[n], m.Parameter(1), @@ -2198,8 +2174,7 @@ TEST(RunWord32XorInBranch) { m.Return(m.Int32Constant(0 - constant)); FOR_UINT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t right; switch (shops[n]->opcode()) { default: @@ -2226,52 +2201,100 @@ TEST(RunWord32XorInBranch) { TEST(RunWord32ShlP) { { - FOR_UINT32_INPUTS(i) { - uint32_t shift = *i & 0x1F; - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j << shift; - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Shl(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { - uint32_t shift = *j & 0x1F; + FOR_UINT32_SHIFTS(shift) { uint32_t expected = *i << shift; - CHECK_EQ(expected, bt.call(*i, shift)); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); } } } } -TEST(RunWord32ShrP) { +TEST(RunWord32ShlInComparison) { + { + RawMachineAssemblerTester<int32_t> m; + Uint32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Word32Shl(bt.param0, bt.param1), m.Int32Constant(0))); + FOR_UINT32_INPUTS(i) { + FOR_UINT32_SHIFTS(shift) { + uint32_t expected = 0 == (*i << shift); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); + } + } + } { + RawMachineAssemblerTester<int32_t> m; + Uint32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Int32Constant(0), m.Word32Shl(bt.param0, bt.param1))); FOR_UINT32_INPUTS(i) { - uint32_t shift = *i & 0x1F; - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + FOR_UINT32_SHIFTS(shift) { + uint32_t expected = 0 == (*i << shift); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); + } + } + } + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return( + m.Word32Equal(m.Int32Constant(0), + m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)))); + FOR_UINT32_INPUTS(i) { + uint32_t expected = 0 == (*i << shift); + CHECK_UINT32_EQ(expected, m.Call(*i)); + } + } + } + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return( + m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Int32Constant(shift)), + m.Int32Constant(0))); + FOR_UINT32_INPUTS(i) { + uint32_t expected = 0 == (*i << shift); + CHECK_UINT32_EQ(expected, m.Call(*i)); + } + } + } +} + + +TEST(RunWord32ShrP) { + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<uint32_t> m(kMachUint32); m.Return(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift))); FOR_UINT32_INPUTS(j) { uint32_t expected = *j >> shift; - CHECK_EQ(expected, m.Call(*j)); + CHECK_UINT32_EQ(expected, m.Call(*j)); } } } { RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); + Uint32BinopTester bt(&m); bt.AddReturn(m.Word32Shr(bt.param0, bt.param1)); FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { - uint32_t shift = *j & 0x1F; + FOR_UINT32_SHIFTS(shift) { uint32_t expected = *i >> shift; - CHECK_EQ(expected, bt.call(*i, shift)); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); } } CHECK_EQ(0x00010000, bt.call(0x80000000, 15)); @@ -2279,11 +2302,62 @@ TEST(RunWord32ShrP) { } +TEST(RunWord32ShrInComparison) { + { + RawMachineAssemblerTester<int32_t> m; + Uint32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Word32Shr(bt.param0, bt.param1), m.Int32Constant(0))); + FOR_UINT32_INPUTS(i) { + FOR_UINT32_SHIFTS(shift) { + uint32_t expected = 0 == (*i >> shift); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); + } + } + } + { + RawMachineAssemblerTester<int32_t> m; + Uint32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Int32Constant(0), m.Word32Shr(bt.param0, bt.param1))); + FOR_UINT32_INPUTS(i) { + FOR_UINT32_SHIFTS(shift) { + uint32_t expected = 0 == (*i >> shift); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); + } + } + } + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return( + m.Word32Equal(m.Int32Constant(0), + m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)))); + FOR_UINT32_INPUTS(i) { + uint32_t expected = 0 == (*i >> shift); + CHECK_UINT32_EQ(expected, m.Call(*i)); + } + } + } + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return( + m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Int32Constant(shift)), + m.Int32Constant(0))); + FOR_UINT32_INPUTS(i) { + uint32_t expected = 0 == (*i >> shift); + CHECK_UINT32_EQ(expected, m.Call(*i)); + } + } + } +} + + TEST(RunWord32SarP) { { - FOR_INT32_INPUTS(i) { - int32_t shift = *i & 0x1F; - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + FOR_INT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachInt32); m.Return(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift))); FOR_INT32_INPUTS(j) { int32_t expected = *j >> shift; @@ -2296,8 +2370,7 @@ TEST(RunWord32SarP) { Int32BinopTester bt(&m); bt.AddReturn(m.Word32Sar(bt.param0, bt.param1)); FOR_INT32_INPUTS(i) { - FOR_INT32_INPUTS(j) { - int32_t shift = *j & 0x1F; + FOR_INT32_SHIFTS(shift) { int32_t expected = *i >> shift; CHECK_EQ(expected, bt.call(*i, shift)); } @@ -2307,10 +2380,139 @@ TEST(RunWord32SarP) { } +TEST(RunWord32SarInComparison) { + { + RawMachineAssemblerTester<int32_t> m; + Int32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Word32Sar(bt.param0, bt.param1), m.Int32Constant(0))); + FOR_INT32_INPUTS(i) { + FOR_INT32_SHIFTS(shift) { + int32_t expected = 0 == (*i >> shift); + CHECK_EQ(expected, bt.call(*i, shift)); + } + } + } + { + RawMachineAssemblerTester<int32_t> m; + Int32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Int32Constant(0), m.Word32Sar(bt.param0, bt.param1))); + FOR_INT32_INPUTS(i) { + FOR_INT32_SHIFTS(shift) { + int32_t expected = 0 == (*i >> shift); + CHECK_EQ(expected, bt.call(*i, shift)); + } + } + } + { + FOR_INT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachInt32); + m.Return( + m.Word32Equal(m.Int32Constant(0), + m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)))); + FOR_INT32_INPUTS(i) { + int32_t expected = 0 == (*i >> shift); + CHECK_EQ(expected, m.Call(*i)); + } + } + } + { + FOR_INT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachInt32); + m.Return( + m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Int32Constant(shift)), + m.Int32Constant(0))); + FOR_INT32_INPUTS(i) { + uint32_t expected = 0 == (*i >> shift); + CHECK_EQ(expected, m.Call(*i)); + } + } + } +} + + +TEST(RunWord32RorP) { + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift))); + FOR_UINT32_INPUTS(j) { + int32_t expected = bits::RotateRight32(*j, shift); + CHECK_EQ(expected, m.Call(*j)); + } + } + } + { + RawMachineAssemblerTester<int32_t> m; + Uint32BinopTester bt(&m); + bt.AddReturn(m.Word32Ror(bt.param0, bt.param1)); + FOR_UINT32_INPUTS(i) { + FOR_UINT32_SHIFTS(shift) { + uint32_t expected = bits::RotateRight32(*i, shift); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); + } + } + } +} + + +TEST(RunWord32RorInComparison) { + { + RawMachineAssemblerTester<int32_t> m; + Uint32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Word32Ror(bt.param0, bt.param1), m.Int32Constant(0))); + FOR_UINT32_INPUTS(i) { + FOR_UINT32_SHIFTS(shift) { + uint32_t expected = 0 == bits::RotateRight32(*i, shift); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); + } + } + } + { + RawMachineAssemblerTester<int32_t> m; + Uint32BinopTester bt(&m); + bt.AddReturn( + m.Word32Equal(m.Int32Constant(0), m.Word32Ror(bt.param0, bt.param1))); + FOR_UINT32_INPUTS(i) { + FOR_UINT32_SHIFTS(shift) { + uint32_t expected = 0 == bits::RotateRight32(*i, shift); + CHECK_UINT32_EQ(expected, bt.call(*i, shift)); + } + } + } + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return( + m.Word32Equal(m.Int32Constant(0), + m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)))); + FOR_UINT32_INPUTS(i) { + uint32_t expected = 0 == bits::RotateRight32(*i, shift); + CHECK_UINT32_EQ(expected, m.Call(*i)); + } + } + } + { + FOR_UINT32_SHIFTS(shift) { + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.Return( + m.Word32Equal(m.Word32Ror(m.Parameter(0), m.Int32Constant(shift)), + m.Int32Constant(0))); + FOR_UINT32_INPUTS(i) { + uint32_t expected = 0 == bits::RotateRight32(*i, shift); + CHECK_UINT32_EQ(expected, m.Call(*i)); + } + } + } +} + + TEST(RunWord32NotP) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); m.Return(m.Word32Not(m.Parameter(0))); - FOR_UINT32_INPUTS(i) { + FOR_INT32_INPUTS(i) { int expected = ~(*i); CHECK_EQ(expected, m.Call(*i)); } @@ -2318,7 +2520,7 @@ TEST(RunWord32NotP) { TEST(RunInt32NegP) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); m.Return(m.Int32Neg(m.Parameter(0))); FOR_INT32_INPUTS(i) { int expected = -*i; @@ -2329,14 +2531,12 @@ TEST(RunInt32NegP) { TEST(RunWord32EqualAndWord32SarP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachUint32); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Sar(m.Parameter(1), m.Parameter(2)))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t expected = (*i == (*j >> shift)); CHECK_EQ(expected, m.Call(*i, *j, shift)); } @@ -2344,14 +2544,12 @@ TEST(RunWord32EqualAndWord32SarP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachUint32, kMachInt32); m.Return(m.Word32Equal(m.Word32Sar(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_INT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_INT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; int32_t expected = ((*i >> shift) == *k); CHECK_EQ(expected, m.Call(*i, shift, *k)); } @@ -2363,14 +2561,12 @@ TEST(RunWord32EqualAndWord32SarP) { TEST(RunWord32EqualAndWord32ShlP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Shl(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t expected = (*i == (*j << shift)); CHECK_EQ(expected, m.Call(*i, *j, shift)); } @@ -2378,14 +2574,12 @@ TEST(RunWord32EqualAndWord32ShlP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); m.Return(m.Word32Equal(m.Word32Shl(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; int32_t expected = ((*i << shift) == *k); CHECK_EQ(expected, m.Call(*i, shift, *k)); } @@ -2397,14 +2591,12 @@ TEST(RunWord32EqualAndWord32ShlP) { TEST(RunWord32EqualAndWord32ShrP) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); m.Return(m.Word32Equal(m.Parameter(0), m.Word32Shr(m.Parameter(1), m.Parameter(2)))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { - FOR_UINT32_INPUTS(k) { - uint32_t shift = *k & 0x1F; + FOR_UINT32_SHIFTS(shift) { int32_t expected = (*i == (*j >> shift)); CHECK_EQ(expected, m.Call(*i, *j, shift)); } @@ -2412,14 +2604,12 @@ TEST(RunWord32EqualAndWord32ShrP) { } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, - kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32, kMachUint32, kMachUint32); m.Return(m.Word32Equal(m.Word32Shr(m.Parameter(0), m.Parameter(1)), m.Parameter(2))); FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_UINT32_SHIFTS(shift) { FOR_UINT32_INPUTS(k) { - uint32_t shift = *j & 0x1F; int32_t expected = ((*i >> shift) == *k); CHECK_EQ(expected, m.Call(*i, shift, *k)); } @@ -2431,8 +2621,7 @@ TEST(RunWord32EqualAndWord32ShrP) { TEST(RunDeadNodes) { for (int i = 0; true; i++) { - RawMachineAssemblerTester<int32_t> m(i == 5 ? kMachineWord32 - : kMachineLast); + RawMachineAssemblerTester<int32_t> m(i == 5 ? kMachInt32 : kMachNone); int constant = 0x55 + i; switch (i) { case 0: @@ -2448,7 +2637,7 @@ TEST(RunDeadNodes) { m.PointerConstant(&constant); break; case 4: - m.LoadFromPointer(&constant, kMachineWord32); + m.LoadFromPointer(&constant, kMachInt32); break; case 5: m.Parameter(0); @@ -2469,20 +2658,20 @@ TEST(RunDeadNodes) { TEST(RunDeadInt32Binops) { RawMachineAssemblerTester<int32_t> m; - Operator* ops[] = { - m.machine()->Word32And(), m.machine()->Word32Or(), - m.machine()->Word32Xor(), m.machine()->Word32Shl(), - m.machine()->Word32Shr(), m.machine()->Word32Sar(), - m.machine()->Word32Equal(), m.machine()->Int32Add(), - m.machine()->Int32Sub(), m.machine()->Int32Mul(), - m.machine()->Int32Div(), m.machine()->Int32UDiv(), - m.machine()->Int32Mod(), m.machine()->Int32UMod(), - m.machine()->Int32LessThan(), m.machine()->Int32LessThanOrEqual(), - m.machine()->Uint32LessThan(), m.machine()->Uint32LessThanOrEqual(), - NULL}; + const Operator* ops[] = { + m.machine()->Word32And(), m.machine()->Word32Or(), + m.machine()->Word32Xor(), m.machine()->Word32Shl(), + m.machine()->Word32Shr(), m.machine()->Word32Sar(), + m.machine()->Word32Ror(), m.machine()->Word32Equal(), + m.machine()->Int32Add(), m.machine()->Int32Sub(), + m.machine()->Int32Mul(), m.machine()->Int32Div(), + m.machine()->Int32UDiv(), m.machine()->Int32Mod(), + m.machine()->Int32UMod(), m.machine()->Int32LessThan(), + m.machine()->Int32LessThanOrEqual(), m.machine()->Uint32LessThan(), + m.machine()->Uint32LessThanOrEqual(), NULL}; for (int i = 0; ops[i] != NULL; i++) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); int constant = 0x55555 + i; m.NewNode(ops[i], m.Parameter(0), m.Parameter(1)); m.Return(m.Int32Constant(constant)); @@ -2492,10 +2681,10 @@ TEST(RunDeadInt32Binops) { } -template <typename Type, typename CType> +template <typename Type> static void RunLoadImmIndex(MachineType rep) { const int kNumElems = 3; - CType buffer[kNumElems]; + Type buffer[kNumElems]; // initialize the buffer with raw data. byte* raw = reinterpret_cast<byte*>(buffer); @@ -2512,21 +2701,24 @@ static void RunLoadImmIndex(MachineType rep) { m.Return(m.Load(rep, base, index)); Type expected = buffer[i]; - Type actual = static_cast<CType>(m.Call()); - CHECK_EQ(expected, actual); - printf("XXX\n"); + Type actual = m.Call(); + CHECK(expected == actual); } } } TEST(RunLoadImmIndex) { - RunLoadImmIndex<int8_t, uint8_t>(kMachineWord8); - RunLoadImmIndex<int16_t, uint16_t>(kMachineWord16); - RunLoadImmIndex<int32_t, uint32_t>(kMachineWord32); - RunLoadImmIndex<int32_t*, int32_t*>(kMachineTagged); - - // TODO(titzer): test kMachineFloat64 loads + RunLoadImmIndex<int8_t>(kMachInt8); + RunLoadImmIndex<uint8_t>(kMachUint8); + RunLoadImmIndex<int16_t>(kMachInt16); + RunLoadImmIndex<uint16_t>(kMachUint16); + RunLoadImmIndex<int32_t>(kMachInt32); + RunLoadImmIndex<uint32_t>(kMachUint32); + RunLoadImmIndex<int32_t*>(kMachAnyTagged); + + // TODO(titzer): test kRepBit loads + // TODO(titzer): test kMachFloat64 loads // TODO(titzer): test various indexing modes. } @@ -2553,19 +2745,23 @@ static void RunLoadStore(MachineType rep) { m.Store(rep, base, index1, load); m.Return(m.Int32Constant(OK)); - CHECK_NE(buffer[x], buffer[y]); + CHECK(buffer[x] != buffer[y]); CHECK_EQ(OK, m.Call()); - CHECK_EQ(buffer[x], buffer[y]); + CHECK(buffer[x] == buffer[y]); } } TEST(RunLoadStore) { - RunLoadStore<int8_t>(kMachineWord8); - RunLoadStore<int16_t>(kMachineWord16); - RunLoadStore<int32_t>(kMachineWord32); - RunLoadStore<void*>(kMachineTagged); - RunLoadStore<double>(kMachineFloat64); + RunLoadStore<int8_t>(kMachInt8); + RunLoadStore<uint8_t>(kMachUint8); + RunLoadStore<int16_t>(kMachInt16); + RunLoadStore<uint16_t>(kMachUint16); + RunLoadStore<int32_t>(kMachInt32); + RunLoadStore<uint32_t>(kMachUint32); + RunLoadStore<void*>(kMachAnyTagged); + RunLoadStore<float>(kMachFloat32); + RunLoadStore<double>(kMachFloat64); } @@ -2573,12 +2769,12 @@ TEST(RunFloat64Binop) { RawMachineAssemblerTester<int32_t> m; double result; - Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), - m.machine()->Float64Mul(), m.machine()->Float64Div(), - m.machine()->Float64Mod(), NULL}; + const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), + m.machine()->Float64Mul(), m.machine()->Float64Div(), + m.machine()->Float64Mod(), NULL}; double inf = V8_INFINITY; - Operator* inputs[] = { + const Operator* inputs[] = { m.common()->Float64Constant(0), m.common()->Float64Constant(1), m.common()->Float64Constant(1), m.common()->Float64Constant(0), m.common()->Float64Constant(0), m.common()->Float64Constant(-1), @@ -2597,7 +2793,7 @@ TEST(RunFloat64Binop) { Node* binop = m.NewNode(ops[i], a, b); Node* base = m.PointerConstant(&result); Node* zero = m.Int32Constant(0); - m.Store(kMachineFloat64, base, zero, binop); + m.Store(kMachFloat64, base, zero, binop); m.Return(m.Int32Constant(i + j)); CHECK_EQ(i + j, m.Call()); } @@ -2608,9 +2804,9 @@ TEST(RunFloat64Binop) { TEST(RunDeadFloat64Binops) { RawMachineAssemblerTester<int32_t> m; - Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), - m.machine()->Float64Mul(), m.machine()->Float64Div(), - m.machine()->Float64Mod(), NULL}; + const Operator* ops[] = {m.machine()->Float64Add(), m.machine()->Float64Sub(), + m.machine()->Float64Mul(), m.machine()->Float64Div(), + m.machine()->Float64Mod(), NULL}; for (int i = 0; ops[i] != NULL; i++) { RawMachineAssemblerTester<int32_t> m; @@ -2658,9 +2854,9 @@ TEST(RunFloat64SubImm1) { FOR_FLOAT64_INPUTS(i) { RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); + Node* t0 = m.LoadFromPointer(&input, kMachFloat64); Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0); - m.StoreToPointer(&output, kMachineFloat64, t1); + m.StoreToPointer(&output, kMachFloat64, t1); m.Return(m.Int32Constant(0)); FOR_FLOAT64_INPUTS(j) { input = *j; @@ -2678,9 +2874,9 @@ TEST(RunFloat64SubImm2) { FOR_FLOAT64_INPUTS(i) { RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); + Node* t0 = m.LoadFromPointer(&input, kMachFloat64); Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i)); - m.StoreToPointer(&output, kMachineFloat64, t1); + m.StoreToPointer(&output, kMachFloat64, t1); m.Return(m.Int32Constant(0)); FOR_FLOAT64_INPUTS(j) { input = *j; @@ -2715,10 +2911,10 @@ TEST(RunFloat64MulAndFloat64AddP) { { RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); - Node* c = m.LoadFromPointer(&input_c, kMachineFloat64); - m.StoreToPointer(&output, kMachineFloat64, + Node* a = m.LoadFromPointer(&input_a, kMachFloat64); + Node* b = m.LoadFromPointer(&input_b, kMachFloat64); + Node* c = m.LoadFromPointer(&input_c, kMachFloat64); + m.StoreToPointer(&output, kMachFloat64, m.Float64Add(m.Float64Mul(a, b), c)); m.Return(m.Int32Constant(0)); FOR_FLOAT64_INPUTS(i) { @@ -2737,10 +2933,10 @@ TEST(RunFloat64MulAndFloat64AddP) { } { RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); - Node* c = m.LoadFromPointer(&input_c, kMachineFloat64); - m.StoreToPointer(&output, kMachineFloat64, + Node* a = m.LoadFromPointer(&input_a, kMachFloat64); + Node* b = m.LoadFromPointer(&input_b, kMachFloat64); + Node* c = m.LoadFromPointer(&input_c, kMachFloat64); + m.StoreToPointer(&output, kMachFloat64, m.Float64Add(a, m.Float64Mul(b, c))); m.Return(m.Int32Constant(0)); FOR_FLOAT64_INPUTS(i) { @@ -2767,11 +2963,10 @@ TEST(RunFloat64MulAndFloat64SubP) { double output = 0.0; RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); - Node* c = m.LoadFromPointer(&input_c, kMachineFloat64); - m.StoreToPointer(&output, kMachineFloat64, - m.Float64Sub(a, m.Float64Mul(b, c))); + Node* a = m.LoadFromPointer(&input_a, kMachFloat64); + Node* b = m.LoadFromPointer(&input_b, kMachFloat64); + Node* c = m.LoadFromPointer(&input_c, kMachFloat64); + m.StoreToPointer(&output, kMachFloat64, m.Float64Sub(a, m.Float64Mul(b, c))); m.Return(m.Int32Constant(0)); FOR_FLOAT64_INPUTS(i) { @@ -2797,9 +2992,9 @@ TEST(RunFloat64MulImm) { { FOR_FLOAT64_INPUTS(i) { RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); + Node* t0 = m.LoadFromPointer(&input, kMachFloat64); Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0); - m.StoreToPointer(&output, kMachineFloat64, t1); + m.StoreToPointer(&output, kMachFloat64, t1); m.Return(m.Int32Constant(0)); FOR_FLOAT64_INPUTS(j) { input = *j; @@ -2812,9 +3007,9 @@ TEST(RunFloat64MulImm) { { FOR_FLOAT64_INPUTS(i) { RawMachineAssemblerTester<int32_t> m; - Node* t0 = m.LoadFromPointer(&input, kMachineFloat64); + Node* t0 = m.LoadFromPointer(&input, kMachFloat64); Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i)); - m.StoreToPointer(&output, kMachineFloat64, t1); + m.StoreToPointer(&output, kMachFloat64, t1); m.Return(m.Int32Constant(0)); FOR_FLOAT64_INPUTS(j) { input = *j; @@ -2864,7 +3059,7 @@ TEST(RunChangeInt32ToFloat64_A) { double result = 0; Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic)); - m.Store(kMachineFloat64, m.PointerConstant(&result), m.Int32Constant(0), + m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(0), convert); m.Return(m.Int32Constant(magic)); @@ -2874,11 +3069,11 @@ TEST(RunChangeInt32ToFloat64_A) { TEST(RunChangeInt32ToFloat64_B) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); double output = 0; Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0)); - m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0), + m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), convert); m.Return(m.Parameter(0)); @@ -2891,11 +3086,11 @@ TEST(RunChangeInt32ToFloat64_B) { TEST(RunChangeUint32ToFloat64_B) { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachUint32); double output = 0; Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0)); - m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0), + m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), convert); m.Return(m.Parameter(0)); @@ -2913,7 +3108,7 @@ TEST(RunChangeFloat64ToInt32_A) { double input = 11.1; int32_t result = 0; - m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(0), + m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(0), m.ChangeFloat64ToInt32(m.Float64Constant(input))); m.Return(m.Int32Constant(magic)); @@ -2928,10 +3123,9 @@ TEST(RunChangeFloat64ToInt32_B) { int32_t output = 0; Node* load = - m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0)); + m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); Node* convert = m.ChangeFloat64ToInt32(load); - m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0), - convert); + m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert); m.Return(convert); { @@ -2970,10 +3164,9 @@ TEST(RunChangeFloat64ToUint32_B) { int32_t output = 0; Node* load = - m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0)); + m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); Node* convert = m.ChangeFloat64ToUint32(load); - m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0), - convert); + m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert); m.Return(convert); { @@ -3016,12 +3209,12 @@ TEST(RunChangeFloat64ToInt32_spilled) { Node* input_node[kNumInputs]; for (int i = 0; i < kNumInputs; i++) { - input_node[i] = m.Load(kMachineFloat64, m.PointerConstant(&input), - m.Int32Constant(i * 8)); + input_node[i] = + m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); } for (int i = 0; i < kNumInputs; i++) { - m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(i * 4), + m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(i * 4), m.ChangeFloat64ToInt32(input_node[i])); } @@ -3039,6 +3232,46 @@ TEST(RunChangeFloat64ToInt32_spilled) { } +TEST(RunChangeFloat64ToUint32_spilled) { + RawMachineAssemblerTester<uint32_t> m; + const int kNumInputs = 32; + int32_t magic = 0x786234; + double input[kNumInputs]; + uint32_t result[kNumInputs]; + Node* input_node[kNumInputs]; + + for (int i = 0; i < kNumInputs; i++) { + input_node[i] = + m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); + } + + for (int i = 0; i < kNumInputs; i++) { + m.Store(kMachUint32, m.PointerConstant(&result), m.Int32Constant(i * 4), + m.ChangeFloat64ToUint32(input_node[i])); + } + + m.Return(m.Int32Constant(magic)); + + for (int i = 0; i < kNumInputs; i++) { + if (i % 2) { + input[i] = 100 + i + 2147483648u; + } else { + input[i] = 100 + i; + } + } + + CHECK_EQ(magic, m.Call()); + + for (int i = 0; i < kNumInputs; i++) { + if (i % 2) { + CHECK_UINT32_EQ(result[i], static_cast<uint32_t>(100 + i + 2147483648u)); + } else { + CHECK_UINT32_EQ(result[i], static_cast<uint32_t>(100 + i)); + } + } +} + + TEST(RunDeadChangeFloat64ToInt32) { RawMachineAssemblerTester<int32_t> m; const int magic = 0x88abcda4; @@ -3067,7 +3300,7 @@ TEST(RunLoopPhiInduction2) { Node* false_node = m.Int32Constant(false_val); m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(false_node, false_node); + Node* phi = m.Phi(kMachInt32, false_node, false_node); m.Branch(m.Int32Constant(0), &body, &end); m.Bind(&body); Node* add = m.Int32Add(phi, m.Int32Constant(1)); @@ -3096,8 +3329,8 @@ TEST(RunDoubleDiamond) { m.Bind(&blockb); m.Goto(&end); m.Bind(&end); - Node* phi = m.Phi(k2, k1); - m.Store(kMachineFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); + Node* phi = m.Phi(kMachFloat64, k2, k1); + m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -3122,8 +3355,8 @@ TEST(RunRefDiamond) { m.Bind(&blockb); m.Goto(&end); m.Bind(&end); - Node* phi = m.Phi(k2, k1); - m.Store(kMachineTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi); + Node* phi = m.Phi(kMachAnyTagged, k2, k1); + m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -3152,11 +3385,10 @@ TEST(RunDoubleRefDiamond) { m.Bind(&blockb); m.Goto(&end); m.Bind(&end); - Node* dphi = m.Phi(d2, d1); - Node* rphi = m.Phi(r2, r1); - m.Store(kMachineFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), - dphi); - m.Store(kMachineTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), + Node* dphi = m.Phi(kMachFloat64, d2, d1); + Node* rphi = m.Phi(kMachAnyTagged, r2, r1); + m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi); + m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi); m.Return(m.Int32Constant(magic)); @@ -3187,8 +3419,8 @@ TEST(RunDoubleRefDoubleDiamond) { m.Bind(&blockb); m.Goto(&mid); m.Bind(&mid); - Node* dphi1 = m.Phi(d2, d1); - Node* rphi1 = m.Phi(r2, r1); + Node* dphi1 = m.Phi(kMachFloat64, d2, d1); + Node* rphi1 = m.Phi(kMachAnyTagged, r2, r1); m.Branch(m.Int32Constant(0), &blockd, &blocke); m.Bind(&blockd); @@ -3196,12 +3428,11 @@ TEST(RunDoubleRefDoubleDiamond) { m.Bind(&blocke); m.Goto(&end); m.Bind(&end); - Node* dphi2 = m.Phi(d1, dphi1); - Node* rphi2 = m.Phi(r1, rphi1); + Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1); + Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1); - m.Store(kMachineFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), - dphi2); - m.Store(kMachineTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), + m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2); + m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), rphi2); m.Return(m.Int32Constant(magic)); @@ -3224,13 +3455,13 @@ TEST(RunDoubleLoopPhi) { m.Goto(&header); m.Bind(&header); - Node* phi = m.Phi(dk, dk); + Node* phi = m.Phi(kMachFloat64, dk, dk); phi->ReplaceInput(1, phi); m.Branch(zero, &body, &end); m.Bind(&body); m.Goto(&header); m.Bind(&end); - m.Store(kMachineFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); + m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); m.Return(m.Int32Constant(magic)); CHECK_EQ(magic, m.Call()); @@ -3249,8 +3480,8 @@ TEST(RunCountToTenAccRaw) { m.Goto(&header); m.Bind(&header); - Node* i = m.Phi(zero, zero); - Node* j = m.Phi(zero, zero); + Node* i = m.Phi(kMachInt32, zero, zero); + Node* j = m.Phi(kMachInt32, zero, zero); m.Goto(&body); m.Bind(&body); @@ -3282,9 +3513,9 @@ TEST(RunCountToTenAccRaw2) { m.Goto(&header); m.Bind(&header); - Node* i = m.Phi(zero, zero); - Node* j = m.Phi(zero, zero); - Node* k = m.Phi(zero, zero); + Node* i = m.Phi(kMachInt32, zero, zero); + Node* j = m.Phi(kMachInt32, zero, zero); + Node* k = m.Phi(kMachInt32, zero, zero); m.Goto(&body); m.Bind(&body); @@ -3311,14 +3542,14 @@ TEST(RunAddTree) { int32_t inputs[] = {11, 12, 13, 14, 15, 16, 17, 18}; Node* base = m.PointerConstant(inputs); - Node* n0 = m.Load(kMachineWord32, base, m.Int32Constant(0 * sizeof(int32_t))); - Node* n1 = m.Load(kMachineWord32, base, m.Int32Constant(1 * sizeof(int32_t))); - Node* n2 = m.Load(kMachineWord32, base, m.Int32Constant(2 * sizeof(int32_t))); - Node* n3 = m.Load(kMachineWord32, base, m.Int32Constant(3 * sizeof(int32_t))); - Node* n4 = m.Load(kMachineWord32, base, m.Int32Constant(4 * sizeof(int32_t))); - Node* n5 = m.Load(kMachineWord32, base, m.Int32Constant(5 * sizeof(int32_t))); - Node* n6 = m.Load(kMachineWord32, base, m.Int32Constant(6 * sizeof(int32_t))); - Node* n7 = m.Load(kMachineWord32, base, m.Int32Constant(7 * sizeof(int32_t))); + Node* n0 = m.Load(kMachInt32, base, m.Int32Constant(0 * sizeof(int32_t))); + Node* n1 = m.Load(kMachInt32, base, m.Int32Constant(1 * sizeof(int32_t))); + Node* n2 = m.Load(kMachInt32, base, m.Int32Constant(2 * sizeof(int32_t))); + Node* n3 = m.Load(kMachInt32, base, m.Int32Constant(3 * sizeof(int32_t))); + Node* n4 = m.Load(kMachInt32, base, m.Int32Constant(4 * sizeof(int32_t))); + Node* n5 = m.Load(kMachInt32, base, m.Int32Constant(5 * sizeof(int32_t))); + Node* n6 = m.Load(kMachInt32, base, m.Int32Constant(6 * sizeof(int32_t))); + Node* n7 = m.Load(kMachInt32, base, m.Int32Constant(7 * sizeof(int32_t))); Node* i1 = m.Int32Add(n0, n1); Node* i2 = m.Int32Add(n2, n3); @@ -3336,85 +3567,6 @@ TEST(RunAddTree) { } -#if MACHINE_ASSEMBLER_SUPPORTS_CALL_C - -static int Seven() { return 7; } -static int UnaryMinus(int a) { return -a; } -static int APlusTwoB(int a, int b) { return a + 2 * b; } - - -TEST(RunCallSeven) { - for (int i = 0; i < 2; i++) { - bool call_direct = i == 0; - void* function_address = - reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven)); - - RawMachineAssemblerTester<int32_t> m; - Node** args = NULL; - MachineType* arg_types = NULL; - Node* function = - call_direct ? m.PointerConstant(function_address) - : m.LoadFromPointer(&function_address, - MachineOperatorBuilder::pointer_rep()); - m.Return(m.CallC(function, kMachineWord32, arg_types, args, 0)); - - CHECK_EQ(7, m.Call()); - } -} - - -TEST(RunCallUnaryMinus) { - for (int i = 0; i < 2; i++) { - bool call_direct = i == 0; - void* function_address = - reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus)); - - RawMachineAssemblerTester<int32_t> m(kMachineWord32); - Node* args[] = {m.Parameter(0)}; - MachineType arg_types[] = {kMachineWord32}; - Node* function = - call_direct ? m.PointerConstant(function_address) - : m.LoadFromPointer(&function_address, - MachineOperatorBuilder::pointer_rep()); - m.Return(m.CallC(function, kMachineWord32, arg_types, args, 1)); - - FOR_INT32_INPUTS(i) { - int a = *i; - CHECK_EQ(-a, m.Call(a)); - } - } -} - - -TEST(RunCallAPlusTwoB) { - for (int i = 0; i < 2; i++) { - bool call_direct = i == 0; - void* function_address = - reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB)); - - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); - Node* args[] = {m.Parameter(0), m.Parameter(1)}; - MachineType arg_types[] = {kMachineWord32, kMachineWord32}; - Node* function = - call_direct ? m.PointerConstant(function_address) - : m.LoadFromPointer(&function_address, - MachineOperatorBuilder::pointer_rep()); - m.Return(m.CallC(function, kMachineWord32, arg_types, args, 2)); - - FOR_INT32_INPUTS(i) { - FOR_INT32_INPUTS(j) { - int a = *i; - int b = *j; - int result = m.Call(a, b); - CHECK_EQ(a + 2 * b, result); - } - } - } -} - -#endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C - - static const int kFloat64CompareHelperTestCases = 15; static const int kFloat64CompareHelperNodeType = 4; @@ -3429,9 +3581,9 @@ static int Float64CompareHelper(RawMachineAssemblerTester<int32_t>* m, CHECK(x < y); bool load_a = node_type / 2 == 1; bool load_b = node_type % 2 == 1; - Node* a = load_a ? m->Load(kMachineFloat64, m->PointerConstant(&buffer[0])) + Node* a = load_a ? m->Load(kMachFloat64, m->PointerConstant(&buffer[0])) : m->Float64Constant(x); - Node* b = load_b ? m->Load(kMachineFloat64, m->PointerConstant(&buffer[1])) + Node* b = load_b ? m->Load(kMachFloat64, m->PointerConstant(&buffer[1])) : m->Float64Constant(y); Node* cmp = NULL; bool expected = false; @@ -3519,7 +3671,7 @@ TEST(RunFloat64Compare) { for (int test = 0; test < kFloat64CompareHelperTestCases; test++) { for (int node_type = 0; node_type < kFloat64CompareHelperNodeType; node_type++) { - for (size_t input = 0; input < ARRAY_SIZE(inputs); input += 2) { + for (size_t input = 0; input < arraysize(inputs); input += 2) { RawMachineAssemblerTester<int32_t> m; int expected = Float64CompareHelper(&m, test, node_type, inputs[input], inputs[input + 1]); @@ -3533,14 +3685,14 @@ TEST(RunFloat64Compare) { TEST(RunFloat64UnorderedCompare) { RawMachineAssemblerTester<int32_t> m; - Operator* operators[] = {m.machine()->Float64Equal(), - m.machine()->Float64LessThan(), - m.machine()->Float64LessThanOrEqual()}; + const Operator* operators[] = {m.machine()->Float64Equal(), + m.machine()->Float64LessThan(), + m.machine()->Float64LessThanOrEqual()}; double nan = v8::base::OS::nan_value(); FOR_FLOAT64_INPUTS(i) { - for (size_t o = 0; o < ARRAY_SIZE(operators); ++o) { + for (size_t o = 0; o < arraysize(operators); ++o) { for (int j = 0; j < 2; j++) { RawMachineAssemblerTester<int32_t> m; Node* a = m.Float64Constant(*i); @@ -3559,8 +3711,8 @@ TEST(RunFloat64Equal) { double input_b = 0.0; RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); + Node* a = m.LoadFromPointer(&input_a, kMachFloat64); + Node* b = m.LoadFromPointer(&input_b, kMachFloat64); m.Return(m.Float64Equal(a, b)); CompareWrapper cmp(IrOpcode::kFloat64Equal); @@ -3580,8 +3732,8 @@ TEST(RunFloat64LessThan) { double input_b = 0.0; RawMachineAssemblerTester<int32_t> m; - Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); - Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); + Node* a = m.LoadFromPointer(&input_a, kMachFloat64); + Node* b = m.LoadFromPointer(&input_b, kMachFloat64); m.Return(m.Float64LessThan(a, b)); CompareWrapper cmp(IrOpcode::kFloat64LessThan); @@ -3616,29 +3768,28 @@ static void LoadStoreTruncation() { // Test lower bound. input = min; - CHECK_EQ(max + 2, m.Call()); + CHECK_EQ(static_cast<IntType>(max + 2), m.Call()); CHECK_EQ(min + 1, input); // Test all one byte values that are not one byte bounds. for (int i = -127; i < 127; i++) { input = i; int expected = i >= 0 ? i + 1 : max + (i - min) + 2; - CHECK_EQ(expected, m.Call()); - CHECK_EQ(i + 1, input); + CHECK_EQ(static_cast<IntType>(expected), m.Call()); + CHECK_EQ(static_cast<IntType>(i + 1), input); } } TEST(RunLoadStoreTruncation) { - LoadStoreTruncation<int8_t, kMachineWord8>(); - LoadStoreTruncation<int16_t, kMachineWord16>(); + LoadStoreTruncation<int8_t, kMachInt8>(); + LoadStoreTruncation<int16_t, kMachInt16>(); } static void IntPtrCompare(intptr_t left, intptr_t right) { for (int test = 0; test < 7; test++) { - RawMachineAssemblerTester<bool> m(MachineOperatorBuilder::pointer_rep(), - MachineOperatorBuilder::pointer_rep()); + RawMachineAssemblerTester<bool> m(kMachPtr, kMachPtr); Node* p0 = m.Parameter(0); Node* p1 = m.Parameter(1); Node* res = NULL; @@ -3688,7 +3839,7 @@ TEST(RunIntPtrCompare) { intptr_t max = std::numeric_limits<intptr_t>::max(); // An ascending chain of intptr_t intptr_t inputs[] = {min, min / 2, -1, 0, 1, max / 2, max}; - for (size_t i = 0; i < ARRAY_SIZE(inputs) - 1; i++) { + for (size_t i = 0; i < arraysize(inputs) - 1; i++) { IntPtrCompare(inputs[i], inputs[i + 1]); } } @@ -3707,7 +3858,7 @@ TEST(RunTestIntPtrArithmetic) { Node* output = m.PointerConstant(&outputs[kInputSize - 1]); Node* elem_size = m.ConvertInt32ToIntPtr(m.Int32Constant(sizeof(inputs[0]))); for (int i = 0; i < kInputSize; i++) { - m.Store(kMachineWord32, output, m.Load(kMachineWord32, input)); + m.Store(kMachInt32, output, m.Load(kMachInt32, input)); input = m.IntPtrAdd(input, elem_size); output = m.IntPtrSub(output, elem_size); } @@ -3720,53 +3871,6 @@ TEST(RunTestIntPtrArithmetic) { } -static inline uint32_t rotr32(uint32_t i, uint32_t j) { - return (i >> j) | (i << (32 - j)); -} - - -TEST(RunTestInt32RotateRightP) { - { - RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); - bt.AddReturn(m.Word32Or( - m.Word32Shr(bt.param0, bt.param1), - m.Word32Shl(bt.param0, m.Int32Sub(m.Int32Constant(32), bt.param1)))); - bt.Run(ValueHelper::uint32_vector(), ValueHelper::ror_vector(), rotr32); - } - { - RawMachineAssemblerTester<int32_t> m; - Int32BinopTester bt(&m); - bt.AddReturn(m.Word32Or( - m.Word32Shl(bt.param0, m.Int32Sub(m.Int32Constant(32), bt.param1)), - m.Word32Shr(bt.param0, bt.param1))); - bt.Run(ValueHelper::uint32_vector(), ValueHelper::ror_vector(), rotr32); - } -} - - -TEST(RunTestInt32RotateRightImm) { - FOR_INPUTS(uint32_t, ror, i) { - { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); - Node* value = m.Parameter(0); - m.Return(m.Word32Or(m.Word32Shr(value, m.Int32Constant(*i)), - m.Word32Shl(value, m.Int32Constant(32 - *i)))); - m.Run(ValueHelper::uint32_vector(), - std::bind2nd(std::ptr_fun(&rotr32), *i)); - } - { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); - Node* value = m.Parameter(0); - m.Return(m.Word32Or(m.Word32Shl(value, m.Int32Constant(32 - *i)), - m.Word32Shr(value, m.Int32Constant(*i)))); - m.Run(ValueHelper::uint32_vector(), - std::bind2nd(std::ptr_fun(&rotr32), *i)); - } - } -} - - TEST(RunSpillLotsOfThings) { static const int kInputSize = 1000; RawMachineAssemblerTester<void> m; @@ -3779,7 +3883,7 @@ TEST(RunSpillLotsOfThings) { accs[i] = acc; } for (int i = 0; i < kInputSize; i++) { - m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]); + m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); } m.Return(one); m.Call(); @@ -3792,7 +3896,7 @@ TEST(RunSpillLotsOfThings) { TEST(RunSpillConstantsAndParameters) { static const int kInputSize = 1000; static const int32_t kBase = 987; - RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); int32_t outputs[kInputSize]; Node* csts[kInputSize]; Node* accs[kInputSize]; @@ -3805,7 +3909,7 @@ TEST(RunSpillConstantsAndParameters) { accs[i] = acc; } for (int i = 0; i < kInputSize; i++) { - m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]); + m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); } m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); FOR_INT32_INPUTS(i) { @@ -3826,7 +3930,7 @@ TEST(RunSpillConstantsAndParameters) { TEST(RunNewSpaceConstantsInPhi) { - RawMachineAssemblerTester<Object*> m(kMachineWord32); + RawMachineAssemblerTester<Object*> m(kMachInt32); Isolate* isolate = CcTest::i_isolate(); Handle<HeapNumber> true_val = isolate->factory()->NewHeapNumber(11.2); @@ -3842,7 +3946,7 @@ TEST(RunNewSpaceConstantsInPhi) { m.Goto(&end); m.Bind(&end); - Node* phi = m.Phi(true_node, false_node); + Node* phi = m.Phi(kMachAnyTagged, true_node, false_node); m.Return(phi); CHECK_EQ(*false_val, m.Call(0)); @@ -3850,55 +3954,6 @@ TEST(RunNewSpaceConstantsInPhi) { } -#if MACHINE_ASSEMBLER_SUPPORTS_CALL_C - -TEST(RunSpillLotsOfThingsWithCall) { - static const int kInputSize = 1000; - RawMachineAssemblerTester<void> m; - Node* accs[kInputSize]; - int32_t outputs[kInputSize]; - Node* one = m.Int32Constant(1); - Node* acc = one; - for (int i = 0; i < kInputSize; i++) { - acc = m.Int32Add(acc, one); - accs[i] = acc; - } - // If the spill slot computation is wrong, it might load from the c frame - { - void* func = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven)); - Node** args = NULL; - MachineType* arg_types = NULL; - m.CallC(m.PointerConstant(func), kMachineWord32, arg_types, args, 0); - } - for (int i = 0; i < kInputSize; i++) { - m.StoreToPointer(&outputs[i], kMachineWord32, accs[i]); - } - m.Return(one); - m.Call(); - for (int i = 0; i < kInputSize; i++) { - CHECK_EQ(outputs[i], i + 2); - } -} - -#endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C - - -static bool sadd_overflow(int32_t x, int32_t y, int32_t* val) { - int32_t v = - static_cast<int32_t>(static_cast<uint32_t>(x) + static_cast<uint32_t>(y)); - *val = v; - return (((v ^ x) & (v ^ y)) >> 31) & 1; -} - - -static bool ssub_overflow(int32_t x, int32_t y, int32_t* val) { - int32_t v = - static_cast<int32_t>(static_cast<uint32_t>(x) - static_cast<uint32_t>(y)); - *val = v; - return (((v ^ x) & (v ^ ~y)) >> 31) & 1; -} - - TEST(RunInt32AddWithOverflowP) { int32_t actual_val = -1; RawMachineAssemblerTester<int32_t> m; @@ -3906,12 +3961,12 @@ TEST(RunInt32AddWithOverflowP) { Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); bt.AddReturn(ovf); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected_val; - int expected_ovf = sadd_overflow(*i, *j, &expected_val); + int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, bt.call(*i, *j)); CHECK_EQ(expected_val, actual_val); } @@ -3923,27 +3978,27 @@ TEST(RunInt32AddWithOverflowImm) { int32_t actual_val = -1, expected_val = 0; FOR_INT32_INPUTS(i) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { - int expected_ovf = sadd_overflow(*i, *j, &expected_val); + int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { - int expected_ovf = sadd_overflow(*i, *j, &expected_val); + int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } @@ -3954,9 +4009,9 @@ TEST(RunInt32AddWithOverflowImm) { m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); m.Return(ovf); - int expected_ovf = sadd_overflow(*i, *j, &expected_val); + int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call()); CHECK_EQ(expected_val, actual_val); } @@ -3977,10 +4032,10 @@ TEST(RunInt32AddWithOverflowInBranchP) { m.Bind(&blockb); Node* val = m.Projection(0, add); bt.AddReturn(val); - FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_INT32_INPUTS(i) { + FOR_INT32_INPUTS(j) { int32_t expected; - if (sadd_overflow(*i, *j, &expected)) expected = constant; + if (bits::SignedAddOverflow32(*i, *j, &expected)) expected = constant; CHECK_EQ(expected, bt.call(*i, *j)); } } @@ -3994,12 +4049,12 @@ TEST(RunInt32SubWithOverflowP) { Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); bt.AddReturn(ovf); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected_val; - int expected_ovf = ssub_overflow(*i, *j, &expected_val); + int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, bt.call(*i, *j)); CHECK_EQ(expected_val, actual_val); } @@ -4011,27 +4066,27 @@ TEST(RunInt32SubWithOverflowImm) { int32_t actual_val = -1, expected_val = 0; FOR_INT32_INPUTS(i) { { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { - int expected_ovf = ssub_overflow(*i, *j, &expected_val); + int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } } { - RawMachineAssemblerTester<int32_t> m(kMachineWord32); + RawMachineAssemblerTester<int32_t> m(kMachInt32); Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); m.Return(ovf); FOR_INT32_INPUTS(j) { - int expected_ovf = ssub_overflow(*j, *i, &expected_val); + int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); CHECK_EQ(expected_ovf, m.Call(*j)); CHECK_EQ(expected_val, actual_val); } @@ -4042,9 +4097,9 @@ TEST(RunInt32SubWithOverflowImm) { m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); Node* val = m.Projection(0, add); Node* ovf = m.Projection(1, add); - m.StoreToPointer(&actual_val, kMachineWord32, val); + m.StoreToPointer(&actual_val, kMachInt32, val); m.Return(ovf); - int expected_ovf = ssub_overflow(*i, *j, &expected_val); + int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); CHECK_EQ(expected_ovf, m.Call()); CHECK_EQ(expected_val, actual_val); } @@ -4065,13 +4120,172 @@ TEST(RunInt32SubWithOverflowInBranchP) { m.Bind(&blockb); Node* val = m.Projection(0, sub); bt.AddReturn(val); - FOR_UINT32_INPUTS(i) { - FOR_UINT32_INPUTS(j) { + FOR_INT32_INPUTS(i) { + FOR_INT32_INPUTS(j) { int32_t expected; - if (ssub_overflow(*i, *j, &expected)) expected = constant; + if (bits::SignedSubOverflow32(*i, *j, &expected)) expected = constant; CHECK_EQ(expected, bt.call(*i, *j)); } } } + +TEST(RunChangeInt32ToInt64P) { + if (kPointerSize < 8) return; + int64_t actual = -1; + RawMachineAssemblerTester<int32_t> m(kMachInt32); + m.StoreToPointer(&actual, kMachInt64, m.ChangeInt32ToInt64(m.Parameter(0))); + m.Return(m.Int32Constant(0)); + FOR_INT32_INPUTS(i) { + int64_t expected = *i; + CHECK_EQ(0, m.Call(*i)); + CHECK_EQ(expected, actual); + } +} + + +TEST(RunChangeUint32ToUint64P) { + if (kPointerSize < 8) return; + int64_t actual = -1; + RawMachineAssemblerTester<int32_t> m(kMachUint32); + m.StoreToPointer(&actual, kMachUint64, + m.ChangeUint32ToUint64(m.Parameter(0))); + m.Return(m.Int32Constant(0)); + FOR_UINT32_INPUTS(i) { + int64_t expected = static_cast<uint64_t>(*i); + CHECK_EQ(0, m.Call(*i)); + CHECK_EQ(expected, actual); + } +} + + +TEST(RunTruncateInt64ToInt32P) { + if (kPointerSize < 8) return; + int64_t expected = -1; + RawMachineAssemblerTester<int32_t> m; + m.Return(m.TruncateInt64ToInt32(m.LoadFromPointer(&expected, kMachInt64))); + FOR_UINT32_INPUTS(i) { + FOR_UINT32_INPUTS(j) { + expected = (static_cast<uint64_t>(*j) << 32) | *i; + CHECK_UINT32_EQ(expected, m.Call()); + } + } +} + + +TEST(RunTruncateFloat64ToInt32P) { + struct { + double from; + double raw; + } kValues[] = {{0, 0}, + {0.5, 0}, + {-0.5, 0}, + {1.5, 1}, + {-1.5, -1}, + {5.5, 5}, + {-5.0, -5}, + {v8::base::OS::nan_value(), 0}, + {std::numeric_limits<double>::infinity(), 0}, + {-v8::base::OS::nan_value(), 0}, + {-std::numeric_limits<double>::infinity(), 0}, + {4.94065645841e-324, 0}, + {-4.94065645841e-324, 0}, + {0.9999999999999999, 0}, + {-0.9999999999999999, 0}, + {4294967296.0, 0}, + {-4294967296.0, 0}, + {9223372036854775000.0, 4294966272.0}, + {-9223372036854775000.0, -4294966272.0}, + {4.5036e+15, 372629504}, + {-4.5036e+15, -372629504}, + {287524199.5377777, 0x11234567}, + {-287524199.5377777, -0x11234567}, + {2300193596.302222, 2300193596.0}, + {-2300193596.302222, -2300193596.0}, + {4600387192.604444, 305419896}, + {-4600387192.604444, -305419896}, + {4823855600872397.0, 1737075661}, + {-4823855600872397.0, -1737075661}, + {4503603922337791.0, -1}, + {-4503603922337791.0, 1}, + {4503601774854143.0, 2147483647}, + {-4503601774854143.0, -2147483647}, + {9007207844675582.0, -2}, + {-9007207844675582.0, 2}, + {2.4178527921507624e+24, -536870912}, + {-2.4178527921507624e+24, 536870912}, + {2.417853945072267e+24, -536870912}, + {-2.417853945072267e+24, 536870912}, + {4.8357055843015248e+24, -1073741824}, + {-4.8357055843015248e+24, 1073741824}, + {4.8357078901445341e+24, -1073741824}, + {-4.8357078901445341e+24, 1073741824}, + {2147483647.0, 2147483647.0}, + {-2147483648.0, -2147483648.0}, + {9.6714111686030497e+24, -2147483648.0}, + {-9.6714111686030497e+24, -2147483648.0}, + {9.6714157802890681e+24, -2147483648.0}, + {-9.6714157802890681e+24, -2147483648.0}, + {1.9342813113834065e+25, 2147483648.0}, + {-1.9342813113834065e+25, 2147483648.0}, + {3.868562622766813e+25, 0}, + {-3.868562622766813e+25, 0}, + {1.7976931348623157e+308, 0}, + {-1.7976931348623157e+308, 0}}; + double input = -1.0; + RawMachineAssemblerTester<int32_t> m; + m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); + for (size_t i = 0; i < arraysize(kValues); ++i) { + input = kValues[i].from; + uint64_t expected = static_cast<int64_t>(kValues[i].raw); + CHECK_EQ(static_cast<int>(expected), m.Call()); + } +} + + +TEST(RunChangeFloat32ToFloat64) { + double actual = 0.0f; + float expected = 0.0; + RawMachineAssemblerTester<int32_t> m; + m.StoreToPointer( + &actual, kMachFloat64, + m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32))); + m.Return(m.Int32Constant(0)); + FOR_FLOAT32_INPUTS(i) { + expected = *i; + CHECK_EQ(0, m.Call()); + CHECK_EQ(expected, actual); + } +} + + +TEST(RunTruncateFloat64ToFloat32) { + float actual = 0.0f; + double input = 0.0; + RawMachineAssemblerTester<int32_t> m; + m.StoreToPointer( + &actual, kMachFloat32, + m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); + m.Return(m.Int32Constant(0)); + FOR_FLOAT64_INPUTS(i) { + input = *i; + volatile double expected = DoubleToFloat32(input); + CHECK_EQ(0, m.Call()); + CHECK_EQ(expected, actual); + } +} + + +TEST(RunFloat32Constant) { + FOR_FLOAT32_INPUTS(i) { + float expected = *i; + float actual = *i; + RawMachineAssemblerTester<int32_t> m; + m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); + m.Return(m.Int32Constant(0)); + CHECK_EQ(0, m.Call()); + CHECK_EQ(expected, actual); + } +} + #endif // V8_TURBOFAN_TARGET diff --git a/deps/v8/test/cctest/compiler/test-run-properties.cc b/deps/v8/test/cctest/compiler/test-run-properties.cc new file mode 100644 index 0000000000..d4442f7a85 --- /dev/null +++ b/deps/v8/test/cctest/compiler/test-run-properties.cc @@ -0,0 +1,141 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/v8.h" + +#include "test/cctest/compiler/function-tester.h" + +using namespace v8::internal; +using namespace v8::internal::compiler; + +template <typename U> +static void TypedArrayLoadHelper(const char* array_type) { + static const uint32_t kValues[] = { + 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321, + 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff, + 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000}; + EmbeddedVector<char, 1024> values_buffer; + StringBuilder values_builder(values_buffer.start(), values_buffer.length()); + for (size_t i = 0; i < arraysize(kValues); ++i) { + values_builder.AddFormatted("a[%d] = 0x%08x;", i, kValues[i]); + } + + // Note that below source creates two different typed arrays with distinct + // elements kind to get coverage for both access patterns: + // - IsFixedTypedArrayElementsKind(x) + // - IsExternalArrayElementsKind(y) + const char* source = + "(function(a) {" + " var x = (a = new %sArray(%d)); %s;" + " var y = (a = new %sArray(%d)); %s; %%TypedArrayGetBuffer(y);" + " if (!%%HasFixed%sElements(x)) %%AbortJS('x');" + " if (!%%HasExternal%sElements(y)) %%AbortJS('y');" + " function f(a,b) {" + " a = a | 0; b = b | 0;" + " return x[a] + y[b];" + " }" + " return f;" + "})()"; + EmbeddedVector<char, 1024> source_buffer; + SNPrintF(source_buffer, source, array_type, arraysize(kValues), + values_buffer.start(), array_type, arraysize(kValues), + values_buffer.start(), array_type, array_type); + + FunctionTester T( + source_buffer.start(), + CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled); + for (size_t i = 0; i < arraysize(kValues); ++i) { + for (size_t j = 0; j < arraysize(kValues); ++j) { + volatile U value_a = static_cast<U>(kValues[i]); + volatile U value_b = static_cast<U>(kValues[j]); + double expected = + static_cast<double>(value_a) + static_cast<double>(value_b); + T.CheckCall(T.Val(expected), T.Val(static_cast<double>(i)), + T.Val(static_cast<double>(j))); + } + } +} + + +TEST(TypedArrayLoad) { + FLAG_typed_array_max_size_in_heap = 256; + TypedArrayLoadHelper<int8_t>("Int8"); + TypedArrayLoadHelper<uint8_t>("Uint8"); + TypedArrayLoadHelper<int16_t>("Int16"); + TypedArrayLoadHelper<uint16_t>("Uint16"); + TypedArrayLoadHelper<int32_t>("Int32"); + TypedArrayLoadHelper<uint32_t>("Uint32"); + TypedArrayLoadHelper<float>("Float32"); + TypedArrayLoadHelper<double>("Float64"); + // TODO(mstarzinger): Add tests for ClampedUint8. +} + + +template <typename U> +static void TypedArrayStoreHelper(const char* array_type) { + static const uint32_t kValues[] = { + 0x00000000, 0x00000001, 0x00000023, 0x00000042, 0x12345678, 0x87654321, + 0x0000003f, 0x0000007f, 0x00003fff, 0x00007fff, 0x3fffffff, 0x7fffffff, + 0x000000ff, 0x00000080, 0x0000ffff, 0x00008000, 0xffffffff, 0x80000000}; + EmbeddedVector<char, 1024> values_buffer; + StringBuilder values_builder(values_buffer.start(), values_buffer.length()); + for (size_t i = 0; i < arraysize(kValues); ++i) { + values_builder.AddFormatted("a[%d] = 0x%08x;", i, kValues[i]); + } + + // Note that below source creates two different typed arrays with distinct + // elements kind to get coverage for both access patterns: + // - IsFixedTypedArrayElementsKind(x) + // - IsExternalArrayElementsKind(y) + const char* source = + "(function(a) {" + " var x = (a = new %sArray(%d)); %s;" + " var y = (a = new %sArray(%d)); %s; %%TypedArrayGetBuffer(y);" + " if (!%%HasFixed%sElements(x)) %%AbortJS('x');" + " if (!%%HasExternal%sElements(y)) %%AbortJS('y');" + " function f(a,b) {" + " a = a | 0; b = b | 0;" + " var t = x[a];" + " x[a] = y[b];" + " y[b] = t;" + " t = y[b];" + " y[b] = x[a];" + " x[a] = t;" + " return x[a] + y[b];" + " }" + " return f;" + "})()"; + EmbeddedVector<char, 2048> source_buffer; + SNPrintF(source_buffer, source, array_type, arraysize(kValues), + values_buffer.start(), array_type, arraysize(kValues), + values_buffer.start(), array_type, array_type); + + FunctionTester T( + source_buffer.start(), + CompilationInfo::kContextSpecializing | CompilationInfo::kTypingEnabled); + for (size_t i = 0; i < arraysize(kValues); ++i) { + for (size_t j = 0; j < arraysize(kValues); ++j) { + volatile U value_a = static_cast<U>(kValues[i]); + volatile U value_b = static_cast<U>(kValues[j]); + double expected = + static_cast<double>(value_a) + static_cast<double>(value_b); + T.CheckCall(T.Val(expected), T.Val(static_cast<double>(i)), + T.Val(static_cast<double>(j))); + } + } +} + + +TEST(TypedArrayStore) { + FLAG_typed_array_max_size_in_heap = 256; + TypedArrayStoreHelper<int8_t>("Int8"); + TypedArrayStoreHelper<uint8_t>("Uint8"); + TypedArrayStoreHelper<int16_t>("Int16"); + TypedArrayStoreHelper<uint16_t>("Uint16"); + TypedArrayStoreHelper<int32_t>("Int32"); + TypedArrayStoreHelper<uint32_t>("Uint32"); + TypedArrayStoreHelper<float>("Float32"); + TypedArrayStoreHelper<double>("Float64"); + // TODO(mstarzinger): Add tests for ClampedUint8. +} diff --git a/deps/v8/test/cctest/compiler/test-schedule.cc b/deps/v8/test/cctest/compiler/test-schedule.cc index bfa47d872a..6c05c05916 100644 --- a/deps/v8/test/cctest/compiler/test-schedule.cc +++ b/deps/v8/test/cctest/compiler/test-schedule.cc @@ -23,8 +23,8 @@ TEST(TestScheduleAllocation) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - CHECK_NE(NULL, schedule.entry()); - CHECK_EQ(schedule.entry(), *(schedule.all_blocks().begin())); + CHECK_NE(NULL, schedule.start()); + CHECK_EQ(schedule.start(), *(schedule.all_blocks().begin())); } @@ -36,7 +36,7 @@ TEST(TestScheduleAddNode) { Schedule schedule(scope.main_zone()); - BasicBlock* entry = schedule.entry(); + BasicBlock* entry = schedule.start(); schedule.AddNode(entry, n0); schedule.AddNode(entry, n1); @@ -53,7 +53,7 @@ TEST(TestScheduleAddGoto) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* entry = schedule.entry(); + BasicBlock* entry = schedule.start(); BasicBlock* next = schedule.NewBasicBlock(); schedule.AddGoto(entry, next); @@ -72,7 +72,7 @@ TEST(TestScheduleAddBranch) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* entry = schedule.entry(); + BasicBlock* entry = schedule.start(); BasicBlock* tblock = schedule.NewBasicBlock(); BasicBlock* fblock = schedule.NewBasicBlock(); @@ -103,12 +103,12 @@ TEST(TestScheduleAddReturn) { Schedule schedule(scope.main_zone()); Graph graph(scope.main_zone()); Node* n0 = graph.NewNode(&dummy_operator); - BasicBlock* entry = schedule.entry(); + BasicBlock* entry = schedule.start(); schedule.AddReturn(entry, n0); CHECK_EQ(0, entry->PredecessorCount()); CHECK_EQ(1, entry->SuccessorCount()); - CHECK_EQ(schedule.exit(), entry->SuccessorAt(0)); + CHECK_EQ(schedule.end(), entry->SuccessorAt(0)); } @@ -117,26 +117,12 @@ TEST(TestScheduleAddThrow) { Schedule schedule(scope.main_zone()); Graph graph(scope.main_zone()); Node* n0 = graph.NewNode(&dummy_operator); - BasicBlock* entry = schedule.entry(); + BasicBlock* entry = schedule.start(); schedule.AddThrow(entry, n0); CHECK_EQ(0, entry->PredecessorCount()); CHECK_EQ(1, entry->SuccessorCount()); - CHECK_EQ(schedule.exit(), entry->SuccessorAt(0)); -} - - -TEST(TestScheduleAddDeopt) { - HandleAndZoneScope scope; - Schedule schedule(scope.main_zone()); - Graph graph(scope.main_zone()); - Node* n0 = graph.NewNode(&dummy_operator); - BasicBlock* entry = schedule.entry(); - schedule.AddDeoptimize(entry, n0); - - CHECK_EQ(0, entry->PredecessorCount()); - CHECK_EQ(1, entry->SuccessorCount()); - CHECK_EQ(schedule.exit(), entry->SuccessorAt(0)); + CHECK_EQ(schedule.end(), entry->SuccessorAt(0)); } @@ -145,7 +131,7 @@ TEST(BuildMulNodeGraph) { Schedule schedule(scope.main_zone()); Graph graph(scope.main_zone()); CommonOperatorBuilder common(scope.main_zone()); - MachineOperatorBuilder machine(scope.main_zone(), kMachineWord32); + MachineOperatorBuilder machine; Node* start = graph.NewNode(common.Start(0)); graph.SetStart(start); diff --git a/deps/v8/test/cctest/compiler/test-scheduler.cc b/deps/v8/test/cctest/compiler/test-scheduler.cc index ec4e77e111..cf3312351d 100644 --- a/deps/v8/test/cctest/compiler/test-scheduler.cc +++ b/deps/v8/test/cctest/compiler/test-scheduler.cc @@ -16,10 +16,12 @@ #include "src/compiler/operator.h" #include "src/compiler/schedule.h" #include "src/compiler/scheduler.h" +#include "src/compiler/verifier.h" using namespace v8::internal; using namespace v8::internal::compiler; +// TODO(titzer): pull RPO tests out to their own file. struct TestLoop { int count; BasicBlock** nodes; @@ -65,13 +67,49 @@ static void CheckLoopContains(BasicBlock** blocks, int body_size) { } +static int GetScheduledNodeCount(Schedule* schedule) { + int node_count = 0; + for (BasicBlockVectorIter i = schedule->rpo_order()->begin(); + i != schedule->rpo_order()->end(); ++i) { + BasicBlock* block = *i; + for (BasicBlock::const_iterator j = block->begin(); j != block->end(); + ++j) { + ++node_count; + } + BasicBlock::Control control = block->control_; + if (control != BasicBlock::kNone) { + ++node_count; + } + } + return node_count; +} + + +static Schedule* ComputeAndVerifySchedule(int expected, Graph* graph) { + if (FLAG_trace_turbo) { + OFStream os(stdout); + os << AsDOT(*graph); + } + + Schedule* schedule = Scheduler::ComputeSchedule(graph); + + if (FLAG_trace_turbo_scheduler) { + OFStream os(stdout); + os << *schedule << endl; + } + ScheduleVerifier::Run(schedule); + CHECK_EQ(expected, GetScheduledNodeCount(schedule)); + return schedule; +} + + TEST(RPODegenerate1) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); CheckRPONumbers(order, 1, false); - CHECK_EQ(schedule.entry(), order->at(0)); + CHECK_EQ(schedule.start(), order->at(0)); } @@ -79,11 +117,11 @@ TEST(RPODegenerate2) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - schedule.AddGoto(schedule.entry(), schedule.exit()); + schedule.AddGoto(schedule.start(), schedule.end()); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); CheckRPONumbers(order, 2, false); - CHECK_EQ(schedule.entry(), order->at(0)); - CHECK_EQ(schedule.exit(), order->at(1)); + CHECK_EQ(schedule.start(), order->at(0)); + CHECK_EQ(schedule.end(), order->at(1)); } @@ -93,7 +131,7 @@ TEST(RPOLine) { for (int i = 0; i < 10; i++) { Schedule schedule(scope.main_zone()); - BasicBlock* last = schedule.entry(); + BasicBlock* last = schedule.start(); for (int j = 0; j < i; j++) { BasicBlock* block = schedule.NewBasicBlock(); schedule.AddGoto(last, block); @@ -117,10 +155,10 @@ TEST(RPOLine) { TEST(RPOSelfLoop) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - schedule.AddSuccessor(schedule.entry(), schedule.entry()); + schedule.AddSuccessor(schedule.start(), schedule.start()); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); CheckRPONumbers(order, 1, true); - BasicBlock* loop[] = {schedule.entry()}; + BasicBlock* loop[] = {schedule.start()}; CheckLoopContains(loop, 1); } @@ -128,11 +166,11 @@ TEST(RPOSelfLoop) { TEST(RPOEntryLoop) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - schedule.AddSuccessor(schedule.entry(), schedule.exit()); - schedule.AddSuccessor(schedule.exit(), schedule.entry()); + schedule.AddSuccessor(schedule.start(), schedule.end()); + schedule.AddSuccessor(schedule.end(), schedule.start()); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); CheckRPONumbers(order, 2, true); - BasicBlock* loop[] = {schedule.entry(), schedule.exit()}; + BasicBlock* loop[] = {schedule.start(), schedule.end()}; CheckLoopContains(loop, 2); } @@ -141,7 +179,7 @@ TEST(RPOEndLoop) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); - schedule.AddSuccessor(schedule.entry(), loop1->header()); + schedule.AddSuccessor(schedule.start(), loop1->header()); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); CheckRPONumbers(order, 3, true); CheckLoopContains(loop1->nodes, loop1->count); @@ -152,8 +190,8 @@ TEST(RPOEndLoopNested) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 2)); - schedule.AddSuccessor(schedule.entry(), loop1->header()); - schedule.AddSuccessor(loop1->last(), schedule.entry()); + schedule.AddSuccessor(schedule.start(), loop1->header()); + schedule.AddSuccessor(loop1->last(), schedule.start()); BasicBlockVector* order = Scheduler::ComputeSpecialRPO(&schedule); CheckRPONumbers(order, 3, true); CheckLoopContains(loop1->nodes, loop1->count); @@ -164,10 +202,10 @@ TEST(RPODiamond) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); - BasicBlock* D = schedule.exit(); + BasicBlock* D = schedule.end(); schedule.AddSuccessor(A, B); schedule.AddSuccessor(A, C); @@ -188,10 +226,10 @@ TEST(RPOLoop1) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); - BasicBlock* D = schedule.exit(); + BasicBlock* D = schedule.end(); schedule.AddSuccessor(A, B); schedule.AddSuccessor(B, C); @@ -209,10 +247,10 @@ TEST(RPOLoop2) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); - BasicBlock* D = schedule.exit(); + BasicBlock* D = schedule.end(); schedule.AddSuccessor(A, B); schedule.AddSuccessor(B, C); @@ -231,13 +269,13 @@ TEST(RPOLoopN) { for (int i = 0; i < 11; i++) { Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); BasicBlock* D = schedule.NewBasicBlock(); BasicBlock* E = schedule.NewBasicBlock(); BasicBlock* F = schedule.NewBasicBlock(); - BasicBlock* G = schedule.exit(); + BasicBlock* G = schedule.end(); schedule.AddSuccessor(A, B); schedule.AddSuccessor(B, C); @@ -273,12 +311,12 @@ TEST(RPOLoopNest1) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); BasicBlock* D = schedule.NewBasicBlock(); BasicBlock* E = schedule.NewBasicBlock(); - BasicBlock* F = schedule.exit(); + BasicBlock* F = schedule.end(); schedule.AddSuccessor(A, B); schedule.AddSuccessor(B, C); @@ -302,14 +340,14 @@ TEST(RPOLoopNest2) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); BasicBlock* D = schedule.NewBasicBlock(); BasicBlock* E = schedule.NewBasicBlock(); BasicBlock* F = schedule.NewBasicBlock(); BasicBlock* G = schedule.NewBasicBlock(); - BasicBlock* H = schedule.exit(); + BasicBlock* H = schedule.end(); schedule.AddSuccessor(A, B); schedule.AddSuccessor(B, C); @@ -343,8 +381,8 @@ TEST(RPOLoopFollow1) { SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); - BasicBlock* A = schedule.entry(); - BasicBlock* E = schedule.exit(); + BasicBlock* A = schedule.start(); + BasicBlock* E = schedule.end(); schedule.AddSuccessor(A, loop1->header()); schedule.AddSuccessor(loop1->header(), loop2->header()); @@ -367,9 +405,9 @@ TEST(RPOLoopFollow2) { SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* S = schedule.NewBasicBlock(); - BasicBlock* E = schedule.exit(); + BasicBlock* E = schedule.end(); schedule.AddSuccessor(A, loop1->header()); schedule.AddSuccessor(loop1->header(), S); @@ -394,8 +432,8 @@ TEST(RPOLoopFollowN) { Schedule schedule(scope.main_zone()); SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); SmartPointer<TestLoop> loop2(CreateLoop(&schedule, size)); - BasicBlock* A = schedule.entry(); - BasicBlock* E = schedule.exit(); + BasicBlock* A = schedule.start(); + BasicBlock* E = schedule.end(); schedule.AddSuccessor(A, loop1->header()); schedule.AddSuccessor(loop1->nodes[exit], loop2->header()); @@ -418,10 +456,10 @@ TEST(RPONestedLoopFollow1) { SmartPointer<TestLoop> loop1(CreateLoop(&schedule, 1)); SmartPointer<TestLoop> loop2(CreateLoop(&schedule, 1)); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); - BasicBlock* E = schedule.exit(); + BasicBlock* E = schedule.end(); schedule.AddSuccessor(A, B); schedule.AddSuccessor(B, loop1->header()); @@ -450,8 +488,8 @@ TEST(RPOLoopBackedges1) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); - BasicBlock* E = schedule.exit(); + BasicBlock* A = schedule.start(); + BasicBlock* E = schedule.end(); SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); schedule.AddSuccessor(A, loop1->header()); @@ -475,9 +513,9 @@ TEST(RPOLoopOutedges1) { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* D = schedule.NewBasicBlock(); - BasicBlock* E = schedule.exit(); + BasicBlock* E = schedule.end(); SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); schedule.AddSuccessor(A, loop1->header()); @@ -501,8 +539,8 @@ TEST(RPOLoopOutedges2) { int size = 8; for (int i = 0; i < size; i++) { Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); - BasicBlock* E = schedule.exit(); + BasicBlock* A = schedule.start(); + BasicBlock* E = schedule.end(); SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); schedule.AddSuccessor(A, loop1->header()); @@ -527,8 +565,8 @@ TEST(RPOLoopOutloops1) { int size = 8; for (int i = 0; i < size; i++) { Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); - BasicBlock* E = schedule.exit(); + BasicBlock* A = schedule.start(); + BasicBlock* E = schedule.end(); SmartPointer<TestLoop> loop1(CreateLoop(&schedule, size)); schedule.AddSuccessor(A, loop1->header()); schedule.AddSuccessor(loop1->last(), E); @@ -557,10 +595,10 @@ TEST(RPOLoopMultibackedge) { HandleAndZoneScope scope; Schedule schedule(scope.main_zone()); - BasicBlock* A = schedule.entry(); + BasicBlock* A = schedule.start(); BasicBlock* B = schedule.NewBasicBlock(); BasicBlock* C = schedule.NewBasicBlock(); - BasicBlock* D = schedule.exit(); + BasicBlock* D = schedule.end(); BasicBlock* E = schedule.NewBasicBlock(); schedule.AddSuccessor(A, B); @@ -605,36 +643,6 @@ TEST(BuildScheduleOneParameter) { } -static int GetScheduledNodeCount(Schedule* schedule) { - int node_count = 0; - for (BasicBlockVectorIter i = schedule->rpo_order()->begin(); - i != schedule->rpo_order()->end(); ++i) { - BasicBlock* block = *i; - for (BasicBlock::const_iterator j = block->begin(); j != block->end(); - ++j) { - ++node_count; - } - BasicBlock::Control control = block->control_; - if (control != BasicBlock::kNone) { - ++node_count; - } - } - return node_count; -} - - -static void PrintGraph(Graph* graph) { - OFStream os(stdout); - os << AsDOT(*graph); -} - - -static void PrintSchedule(Schedule* schedule) { - OFStream os(stdout); - os << *schedule << endl; -} - - TEST(BuildScheduleIfSplit) { HandleAndZoneScope scope; Graph graph(scope.main_zone()); @@ -658,14 +666,7 @@ TEST(BuildScheduleIfSplit) { Node* merge = graph.NewNode(builder.Merge(2), ret1, ret2); graph.SetEnd(graph.NewNode(builder.End(), merge)); - PrintGraph(&graph); - - Schedule* schedule = Scheduler::ComputeSchedule(&graph); - - PrintSchedule(schedule); - - - CHECK_EQ(13, GetScheduledNodeCount(schedule)); + ComputeAndVerifySchedule(13, &graph); } @@ -675,12 +676,11 @@ TEST(BuildScheduleIfSplitWithEffects) { Graph graph(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone()); - Operator* op; + const Operator* op; Handle<Object> object = Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> unique_constant = - PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object); + Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object); // Manually transcripted code for: // function turbo_fan_test(a, b, c, y) { @@ -811,13 +811,7 @@ TEST(BuildScheduleIfSplitWithEffects) { graph.SetStart(n0); graph.SetEnd(n23); - PrintGraph(&graph); - - Schedule* schedule = Scheduler::ComputeSchedule(&graph); - - PrintSchedule(schedule); - - CHECK_EQ(20, GetScheduledNodeCount(schedule)); + ComputeAndVerifySchedule(20, &graph); } @@ -827,12 +821,11 @@ TEST(BuildScheduleSimpleLoop) { Graph graph(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone()); - Operator* op; + const Operator* op; Handle<Object> object = Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> unique_constant = - PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object); + Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object); // Manually transcripted code for: // function turbo_fan_test(a, b) { @@ -851,7 +844,7 @@ TEST(BuildScheduleSimpleLoop) { op = common_builder.Return(); Node* n19 = graph.NewNode(op, nil, nil, nil); USE(n19); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n8 = graph.NewNode(op, nil, nil, nil); USE(n8); op = common_builder.Parameter(0); @@ -873,7 +866,7 @@ TEST(BuildScheduleSimpleLoop) { Node* n12 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n12); n12->ReplaceInput(0, n8); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n9 = graph.NewNode(op, nil, nil, nil); USE(n9); op = common_builder.Parameter(0); @@ -898,7 +891,7 @@ TEST(BuildScheduleSimpleLoop) { n9->ReplaceInput(2, n6); n12->ReplaceInput(1, n9); n12->ReplaceInput(2, n5); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n10 = graph.NewNode(op, nil, nil, nil); USE(n10); n10->ReplaceInput(0, n0); @@ -930,13 +923,7 @@ TEST(BuildScheduleSimpleLoop) { graph.SetStart(n0); graph.SetEnd(n20); - PrintGraph(&graph); - - Schedule* schedule = Scheduler::ComputeSchedule(&graph); - - PrintSchedule(schedule); - - CHECK_EQ(19, GetScheduledNodeCount(schedule)); + ComputeAndVerifySchedule(19, &graph); } @@ -946,12 +933,11 @@ TEST(BuildScheduleComplexLoops) { Graph graph(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone()); - Operator* op; + const Operator* op; Handle<Object> object = Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> unique_constant = - PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object); + Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object); // Manually transcripted code for: // function turbo_fan_test(a, b, c) { @@ -976,17 +962,17 @@ TEST(BuildScheduleComplexLoops) { op = common_builder.Return(); Node* n45 = graph.NewNode(op, nil, nil, nil); USE(n45); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n35 = graph.NewNode(op, nil, nil, nil); USE(n35); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n9 = graph.NewNode(op, nil, nil, nil); USE(n9); op = common_builder.Parameter(0); Node* n2 = graph.NewNode(op, n0); USE(n2); n9->ReplaceInput(0, n2); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n23 = graph.NewNode(op, nil, nil, nil); USE(n23); op = js_builder.Add(); @@ -1004,14 +990,14 @@ TEST(BuildScheduleComplexLoops) { Node* n14 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n14); n14->ReplaceInput(0, n9); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n10 = graph.NewNode(op, nil, nil, nil); USE(n10); op = common_builder.Parameter(0); Node* n3 = graph.NewNode(op, n0); USE(n3); n10->ReplaceInput(0, n3); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n24 = graph.NewNode(op, nil, nil, nil); USE(n24); n24->ReplaceInput(0, n10); @@ -1039,10 +1025,10 @@ TEST(BuildScheduleComplexLoops) { op = js_builder.LessThan(); Node* n27 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n27); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n25 = graph.NewNode(op, nil, nil, nil); USE(n25); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n11 = graph.NewNode(op, nil, nil, nil); USE(n11); op = common_builder.Parameter(0); @@ -1079,7 +1065,7 @@ TEST(BuildScheduleComplexLoops) { n27->ReplaceInput(0, n25); n27->ReplaceInput(1, n24); n27->ReplaceInput(2, n6); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n26 = graph.NewNode(op, nil, nil, nil); USE(n26); n26->ReplaceInput(0, n20); @@ -1100,7 +1086,7 @@ TEST(BuildScheduleComplexLoops) { n10->ReplaceInput(2, n7); n14->ReplaceInput(1, n10); n14->ReplaceInput(2, n6); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n12 = graph.NewNode(op, nil, nil, nil); USE(n12); n12->ReplaceInput(0, n0); @@ -1134,7 +1120,7 @@ TEST(BuildScheduleComplexLoops) { Node* n39 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n39); n39->ReplaceInput(0, n35); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n36 = graph.NewNode(op, nil, nil, nil); USE(n36); n36->ReplaceInput(0, n10); @@ -1160,7 +1146,7 @@ TEST(BuildScheduleComplexLoops) { n36->ReplaceInput(2, n33); n39->ReplaceInput(1, n36); n39->ReplaceInput(2, n6); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n38 = graph.NewNode(op, nil, nil, nil); USE(n38); n38->ReplaceInput(0, n14); @@ -1184,13 +1170,7 @@ TEST(BuildScheduleComplexLoops) { graph.SetStart(n0); graph.SetEnd(n46); - PrintGraph(&graph); - - Schedule* schedule = Scheduler::ComputeSchedule(&graph); - - PrintSchedule(schedule); - - CHECK_EQ(46, GetScheduledNodeCount(schedule)); + ComputeAndVerifySchedule(46, &graph); } @@ -1200,12 +1180,11 @@ TEST(BuildScheduleBreakAndContinue) { Graph graph(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone()); - Operator* op; + const Operator* op; Handle<Object> object = Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> unique_constant = - PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object); + Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object); // Manually transcripted code for: // function turbo_fan_test(a, b, c) { @@ -1235,14 +1214,14 @@ TEST(BuildScheduleBreakAndContinue) { op = js_builder.Add(); Node* n56 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n56); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n10 = graph.NewNode(op, nil, nil, nil); USE(n10); op = common_builder.Parameter(0); Node* n2 = graph.NewNode(op, n0); USE(n2); n10->ReplaceInput(0, n2); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n25 = graph.NewNode(op, nil, nil, nil); USE(n25); op = js_builder.Add(); @@ -1260,14 +1239,14 @@ TEST(BuildScheduleBreakAndContinue) { Node* n16 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n16); n16->ReplaceInput(0, n10); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n11 = graph.NewNode(op, nil, nil, nil); USE(n11); op = common_builder.Parameter(0); Node* n3 = graph.NewNode(op, n0); USE(n3); n11->ReplaceInput(0, n3); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n26 = graph.NewNode(op, nil, nil, nil); USE(n26); n26->ReplaceInput(0, n11); @@ -1304,23 +1283,23 @@ TEST(BuildScheduleBreakAndContinue) { USE(n46); n47->ReplaceInput(1, n46); n47->ReplaceInput(2, n6); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n42 = graph.NewNode(op, nil, nil, nil); USE(n42); op = js_builder.LessThan(); Node* n30 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n30); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n27 = graph.NewNode(op, nil, nil, nil); USE(n27); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n12 = graph.NewNode(op, nil, nil, nil); USE(n12); op = common_builder.Parameter(0); Node* n4 = graph.NewNode(op, n0); USE(n4); n12->ReplaceInput(0, n4); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n41 = graph.NewNode(op, nil, nil, nil); USE(n41); n41->ReplaceInput(0, n27); @@ -1369,17 +1348,17 @@ TEST(BuildScheduleBreakAndContinue) { op = js_builder.Equal(); Node* n37 = graph.NewNode(op, nil, nil, nil, nil, nil); USE(n37); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n28 = graph.NewNode(op, nil, nil, nil); USE(n28); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n13 = graph.NewNode(op, nil, nil, nil); USE(n13); op = common_builder.NumberConstant(0); Node* n7 = graph.NewNode(op); USE(n7); n13->ReplaceInput(0, n7); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n54 = graph.NewNode(op, nil, nil, nil); USE(n54); n54->ReplaceInput(0, n28); @@ -1430,7 +1409,7 @@ TEST(BuildScheduleBreakAndContinue) { n30->ReplaceInput(0, n27); n30->ReplaceInput(1, n26); n30->ReplaceInput(2, n6); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n29 = graph.NewNode(op, nil, nil, nil); USE(n29); n29->ReplaceInput(0, n22); @@ -1477,11 +1456,11 @@ TEST(BuildScheduleBreakAndContinue) { n11->ReplaceInput(2, n8); n16->ReplaceInput(1, n11); n16->ReplaceInput(2, n6); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n14 = graph.NewNode(op, nil, nil, nil); USE(n14); n14->ReplaceInput(0, n0); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n55 = graph.NewNode(op, nil, nil, nil); USE(n55); n55->ReplaceInput(0, n47); @@ -1520,13 +1499,7 @@ TEST(BuildScheduleBreakAndContinue) { graph.SetStart(n0); graph.SetEnd(n58); - PrintGraph(&graph); - - Schedule* schedule = Scheduler::ComputeSchedule(&graph); - - PrintSchedule(schedule); - - CHECK_EQ(62, GetScheduledNodeCount(schedule)); + ComputeAndVerifySchedule(62, &graph); } @@ -1536,13 +1509,12 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { Graph graph(scope.main_zone()); CommonOperatorBuilder common_builder(scope.main_zone()); JSOperatorBuilder js_builder(scope.main_zone()); - MachineOperatorBuilder machine_builder(scope.main_zone(), kMachineWord32); - Operator* op; + MachineOperatorBuilder machine_builder; + const Operator* op; Handle<Object> object = Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> unique_constant = - PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), object); + Unique<Object> unique_constant = Unique<Object>::CreateUninitialized(object); // Manually transcripted code for: // function turbo_fan_test(a, b, c) { @@ -1561,7 +1533,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { op = common_builder.Return(); Node* n21 = graph.NewNode(op, nil, nil, nil); USE(n21); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n9 = graph.NewNode(op, nil, nil, nil); USE(n9); op = common_builder.Parameter(0); @@ -1575,7 +1547,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { op = machine_builder.Int32Add(); Node* n19 = graph.NewNode(op, nil, nil); USE(n19); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n10 = graph.NewNode(op, nil, nil, nil); USE(n10); op = common_builder.Parameter(0); @@ -1605,7 +1577,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { Node* n6 = graph.NewNode(op); USE(n6); n14->ReplaceInput(2, n6); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n12 = graph.NewNode(op, nil, nil, nil); USE(n12); n12->ReplaceInput(0, n0); @@ -1623,7 +1595,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { n7->ReplaceInput(1, n17); n10->ReplaceInput(2, n7); n19->ReplaceInput(0, n2); - op = common_builder.Phi(2); + op = common_builder.Phi(kMachAnyTagged, 2); Node* n11 = graph.NewNode(op, nil, nil, nil); USE(n11); op = common_builder.Parameter(0); @@ -1651,14 +1623,7 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { graph.SetStart(n0); graph.SetEnd(n22); - PrintGraph(&graph); - - Schedule* schedule = Scheduler::ComputeSchedule(&graph); - - PrintSchedule(schedule); - - CHECK_EQ(19, GetScheduledNodeCount(schedule)); - + Schedule* schedule = ComputeAndVerifySchedule(19, &graph); // Make sure the integer-only add gets hoisted to a different block that the // JSAdd. CHECK(schedule->block(n19) != schedule->block(n20)); @@ -1667,143 +1632,82 @@ TEST(BuildScheduleSimpleLoopWithCodeMotion) { #if V8_TURBOFAN_TARGET -// So we can get a real JS function. -static Handle<JSFunction> Compile(const char* source) { - Isolate* isolate = CcTest::i_isolate(); - Handle<String> source_code = isolate->factory() - ->NewStringFromUtf8(CStrVector(source)) - .ToHandleChecked(); - Handle<SharedFunctionInfo> shared_function = Compiler::CompileScript( - source_code, Handle<String>(), 0, 0, false, - Handle<Context>(isolate->native_context()), NULL, NULL, - v8::ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE); - return isolate->factory()->NewFunctionFromSharedFunctionInfo( - shared_function, isolate->native_context()); +static Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, + Node* cond) { + Node* tv = graph->NewNode(common->Int32Constant(6)); + Node* fv = graph->NewNode(common->Int32Constant(7)); + Node* br = graph->NewNode(common->Branch(), cond, graph->start()); + Node* t = graph->NewNode(common->IfTrue(), br); + Node* f = graph->NewNode(common->IfFalse(), br); + Node* m = graph->NewNode(common->Merge(2), t, f); + Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); + return phi; } -TEST(BuildScheduleTrivialLazyDeoptCall) { - FLAG_turbo_deoptimization = true; +TEST(FloatingDiamond1) { + HandleAndZoneScope scope; + Graph graph(scope.main_zone()); + CommonOperatorBuilder common(scope.main_zone()); + + Node* start = graph.NewNode(common.Start(1)); + graph.SetStart(start); + + Node* p0 = graph.NewNode(common.Parameter(0), start); + Node* d1 = CreateDiamond(&graph, &common, p0); + Node* ret = graph.NewNode(common.Return(), d1, start, start); + Node* end = graph.NewNode(common.End(), ret, start); + + graph.SetEnd(end); + + ComputeAndVerifySchedule(13, &graph); +} + +TEST(FloatingDiamond2) { HandleAndZoneScope scope; - Isolate* isolate = scope.main_isolate(); Graph graph(scope.main_zone()); CommonOperatorBuilder common(scope.main_zone()); - JSOperatorBuilder js_builder(scope.main_zone()); + MachineOperatorBuilder machine; - InitializedHandleScope handles; - Handle<JSFunction> function = Compile("m()"); - CompilationInfoWithZone info(function); - Linkage linkage(&info); + Node* start = graph.NewNode(common.Start(2)); + graph.SetStart(start); - // Manually transcribed code for: - // function turbo_fan_test() { - // m(); - // } - // where m can lazy deopt (so it has a deopt block associated with it). - - - // Start // - // ^ // - // | (EC) // - // | // - // /------> Call <--------------\ // - // / ^ ^ \ // - // / | | \ undef // - // / / \ \ ^ // - // (E) | (C) / \ (C) \ (E) | // - // | Continuation LazyDeoptimization | | // - // \___ ^ ^ / | // - // \ | | ______/ Framestate // - // undef \ | (VC) | (C) / ^ // - // \ \ | | / / // - // Return Deoptimization ----------/ // - // ^ ^ // - // \ / // - // (C) \ / (C) // - // \ / // - // Merge // - // ^ // - // | // - // End // - - Handle<Object> undef_object = - Handle<Object>(isolate->heap()->undefined_value(), isolate); - PrintableUnique<Object> undef_constant = - PrintableUnique<Object>::CreateUninitialized(scope.main_zone(), - undef_object); - - Node* undef_node = graph.NewNode(common.HeapConstant(undef_constant)); - - Node* start_node = graph.NewNode(common.Start(0)); - - CallDescriptor* descriptor = linkage.GetJSCallDescriptor(0); - Node* call_node = graph.NewNode(common.Call(descriptor), - undef_node, // function - undef_node, // context - start_node, // effect - start_node); // control - - Node* cont_node = graph.NewNode(common.Continuation(), call_node); - Node* lazy_deopt_node = graph.NewNode(common.LazyDeoptimization(), call_node); - - Node* parameters = graph.NewNode(common.StateValues(1), undef_node); - Node* locals = graph.NewNode(common.StateValues(0)); - Node* stack = graph.NewNode(common.StateValues(0)); - - Node* state_node = graph.NewNode(common.FrameState(BailoutId(1234)), - parameters, locals, stack); - - Node* return_node = graph.NewNode(common.Return(), - undef_node, // return value - call_node, // effect - cont_node); // control - Node* deoptimization_node = graph.NewNode(common.Deoptimize(), - state_node, // deopt environment - call_node, // effect - lazy_deopt_node); // control - - Node* merge_node = - graph.NewNode(common.Merge(2), return_node, deoptimization_node); - - Node* end_node = graph.NewNode(common.End(), merge_node); - - graph.SetStart(start_node); - graph.SetEnd(end_node); - - PrintGraph(&graph); - - Schedule* schedule = Scheduler::ComputeSchedule(&graph); - - PrintSchedule(schedule); - - // Tests: - // Continuation and deopt have basic blocks. - BasicBlock* cont_block = schedule->block(cont_node); - BasicBlock* deopt_block = schedule->block(lazy_deopt_node); - BasicBlock* call_block = schedule->block(call_node); - CHECK_NE(NULL, cont_block); - CHECK_NE(NULL, deopt_block); - CHECK_NE(NULL, call_block); - // The basic blocks are different. - CHECK_NE(cont_block, deopt_block); - CHECK_NE(cont_block, call_block); - CHECK_NE(deopt_block, call_block); - // The call node finishes its own basic block. - CHECK_EQ(BasicBlock::kCall, call_block->control_); - CHECK_EQ(call_node, call_block->control_input_); - // The lazy deopt block is deferred. - CHECK(deopt_block->deferred_); - CHECK(!call_block->deferred_); - CHECK(!cont_block->deferred_); - // The lazy deopt block contains framestate + bailout (and nothing else). - CHECK_EQ(deoptimization_node, deopt_block->control_input_); - CHECK_EQ(5, static_cast<int>(deopt_block->nodes_.size())); - CHECK_EQ(lazy_deopt_node, deopt_block->nodes_[0]); - CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[1]->op()->opcode()); - CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[2]->op()->opcode()); - CHECK_EQ(IrOpcode::kStateValues, deopt_block->nodes_[3]->op()->opcode()); - CHECK_EQ(state_node, deopt_block->nodes_[4]); + Node* p0 = graph.NewNode(common.Parameter(0), start); + Node* p1 = graph.NewNode(common.Parameter(1), start); + Node* d1 = CreateDiamond(&graph, &common, p0); + Node* d2 = CreateDiamond(&graph, &common, p1); + Node* add = graph.NewNode(machine.Int32Add(), d1, d2); + Node* ret = graph.NewNode(common.Return(), add, start, start); + Node* end = graph.NewNode(common.End(), ret, start); + + graph.SetEnd(end); + + ComputeAndVerifySchedule(24, &graph); +} + + +TEST(FloatingDiamond3) { + HandleAndZoneScope scope; + Graph graph(scope.main_zone()); + CommonOperatorBuilder common(scope.main_zone()); + MachineOperatorBuilder machine; + + Node* start = graph.NewNode(common.Start(2)); + graph.SetStart(start); + + Node* p0 = graph.NewNode(common.Parameter(0), start); + Node* p1 = graph.NewNode(common.Parameter(1), start); + Node* d1 = CreateDiamond(&graph, &common, p0); + Node* d2 = CreateDiamond(&graph, &common, p1); + Node* add = graph.NewNode(machine.Int32Add(), d1, d2); + Node* d3 = CreateDiamond(&graph, &common, add); + Node* ret = graph.NewNode(common.Return(), d3, start, start); + Node* end = graph.NewNode(common.End(), ret, start); + + graph.SetEnd(end); + + ComputeAndVerifySchedule(33, &graph); } #endif diff --git a/deps/v8/test/cctest/compiler/test-simplified-lowering.cc b/deps/v8/test/cctest/compiler/test-simplified-lowering.cc index 18f4136b90..bafa2d88f4 100644 --- a/deps/v8/test/cctest/compiler/test-simplified-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-simplified-lowering.cc @@ -4,6 +4,7 @@ #include <limits> +#include "src/compiler/access-builder.h" #include "src/compiler/control-builders.h" #include "src/compiler/generic-node-inl.h" #include "src/compiler/graph-visualizer.h" @@ -11,7 +12,6 @@ #include "src/compiler/pipeline.h" #include "src/compiler/representation-change.h" #include "src/compiler/simplified-lowering.h" -#include "src/compiler/simplified-node-factory.h" #include "src/compiler/typer.h" #include "src/compiler/verifier.h" #include "src/execution.h" @@ -29,19 +29,20 @@ using namespace v8::internal::compiler; template <typename ReturnType> class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { public: - SimplifiedLoweringTester(MachineType p0 = kMachineLast, - MachineType p1 = kMachineLast, - MachineType p2 = kMachineLast, - MachineType p3 = kMachineLast, - MachineType p4 = kMachineLast) + SimplifiedLoweringTester(MachineType p0 = kMachNone, + MachineType p1 = kMachNone, + MachineType p2 = kMachNone, + MachineType p3 = kMachNone, + MachineType p4 = kMachNone) : GraphBuilderTester<ReturnType>(p0, p1, p2, p3, p4), typer(this->zone()), - source_positions(this->graph()), - jsgraph(this->graph(), this->common(), &typer), - lowering(&jsgraph, &source_positions) {} + javascript(this->zone()), + jsgraph(this->graph(), this->common(), &javascript, &typer, + this->machine()), + lowering(&jsgraph) {} Typer typer; - SourcePositionTable source_positions; + JSOperatorBuilder javascript; JSGraph jsgraph; SimplifiedLowering lowering; @@ -55,47 +56,64 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> { }; -// TODO(dcarney): find a home for these functions. -namespace { - -FieldAccess ForJSObjectMap() { - FieldAccess access = {kTaggedBase, JSObject::kMapOffset, Handle<Name>(), - Type::Any(), kMachineTagged}; - return access; -} - - -FieldAccess ForJSObjectProperties() { - FieldAccess access = {kTaggedBase, JSObject::kPropertiesOffset, - Handle<Name>(), Type::Any(), kMachineTagged}; - return access; -} - +#ifndef V8_TARGET_ARCH_ARM64 +// TODO(titzer): these result in a stub call that doesn't work on ARM64. +// TODO(titzer): factor these tests out to test-run-simplifiedops.cc. +// TODO(titzer): test tagged representation for input to NumberToInt32. +TEST(RunNumberToInt32_float64) { + // TODO(titzer): explicit load/stores here are only because of representations + double input; + int32_t result; + SimplifiedLoweringTester<Object*> t; + FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(), + kMachFloat64}; + Node* loaded = t.LoadField(load, t.PointerConstant(&input)); + Node* convert = t.NumberToInt32(loaded); + FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Signed32(), + kMachInt32}; + t.StoreField(store, t.PointerConstant(&result), convert); + t.Return(t.jsgraph.TrueConstant()); + t.LowerAllNodes(); + t.GenerateCode(); -FieldAccess ForArrayBufferBackingStore() { - FieldAccess access = { - kTaggedBase, JSArrayBuffer::kBackingStoreOffset, - Handle<Name>(), Type::UntaggedPtr(), - MachineOperatorBuilder::pointer_rep(), - }; - return access; + if (Pipeline::SupportedTarget()) { + FOR_FLOAT64_INPUTS(i) { + input = *i; + int32_t expected = DoubleToInt32(*i); + t.Call(); + CHECK_EQ(expected, result); + } + } } -ElementAccess ForFixedArrayElement() { - ElementAccess access = {kTaggedBase, FixedArray::kHeaderSize, Type::Any(), - kMachineTagged}; - return access; -} - +// TODO(titzer): test tagged representation for input to NumberToUint32. +TEST(RunNumberToUint32_float64) { + // TODO(titzer): explicit load/stores here are only because of representations + double input; + uint32_t result; + SimplifiedLoweringTester<Object*> t; + FieldAccess load = {kUntaggedBase, 0, Handle<Name>(), Type::Number(), + kMachFloat64}; + Node* loaded = t.LoadField(load, t.PointerConstant(&input)); + Node* convert = t.NumberToUint32(loaded); + FieldAccess store = {kUntaggedBase, 0, Handle<Name>(), Type::Unsigned32(), + kMachUint32}; + t.StoreField(store, t.PointerConstant(&result), convert); + t.Return(t.jsgraph.TrueConstant()); + t.LowerAllNodes(); + t.GenerateCode(); -ElementAccess ForBackingStoreElement(MachineType rep) { - ElementAccess access = {kUntaggedBase, - kNonHeapObjectHeaderSize - kHeapObjectTag, - Type::Any(), rep}; - return access; -} + if (Pipeline::SupportedTarget()) { + FOR_FLOAT64_INPUTS(i) { + input = *i; + uint32_t expected = DoubleToUint32(*i); + t.Call(); + CHECK_EQ(static_cast<int32_t>(expected), static_cast<int32_t>(result)); + } + } } +#endif // Create a simple JSObject with a unique map. @@ -108,8 +126,8 @@ static Handle<JSObject> TestObject() { TEST(RunLoadMap) { - SimplifiedLoweringTester<Object*> t(kMachineTagged); - FieldAccess access = ForJSObjectMap(); + SimplifiedLoweringTester<Object*> t(kMachAnyTagged); + FieldAccess access = AccessBuilder::ForMap(); Node* load = t.LoadField(access, t.Parameter(0)); t.Return(load); @@ -126,8 +144,8 @@ TEST(RunLoadMap) { TEST(RunStoreMap) { - SimplifiedLoweringTester<int32_t> t(kMachineTagged, kMachineTagged); - FieldAccess access = ForJSObjectMap(); + SimplifiedLoweringTester<int32_t> t(kMachAnyTagged, kMachAnyTagged); + FieldAccess access = AccessBuilder::ForMap(); t.StoreField(access, t.Parameter(1), t.Parameter(0)); t.Return(t.jsgraph.TrueConstant()); @@ -146,8 +164,8 @@ TEST(RunStoreMap) { TEST(RunLoadProperties) { - SimplifiedLoweringTester<Object*> t(kMachineTagged); - FieldAccess access = ForJSObjectProperties(); + SimplifiedLoweringTester<Object*> t(kMachAnyTagged); + FieldAccess access = AccessBuilder::ForJSObjectProperties(); Node* load = t.LoadField(access, t.Parameter(0)); t.Return(load); @@ -164,8 +182,8 @@ TEST(RunLoadProperties) { TEST(RunLoadStoreMap) { - SimplifiedLoweringTester<Object*> t(kMachineTagged, kMachineTagged); - FieldAccess access = ForJSObjectMap(); + SimplifiedLoweringTester<Object*> t(kMachAnyTagged, kMachAnyTagged); + FieldAccess access = AccessBuilder::ForMap(); Node* load = t.LoadField(access, t.Parameter(0)); t.StoreField(access, t.Parameter(1), load); t.Return(load); @@ -187,10 +205,12 @@ TEST(RunLoadStoreMap) { TEST(RunLoadStoreFixedArrayIndex) { - SimplifiedLoweringTester<Object*> t(kMachineTagged); - ElementAccess access = ForFixedArrayElement(); - Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0)); - t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), load); + SimplifiedLoweringTester<Object*> t(kMachAnyTagged); + ElementAccess access = AccessBuilder::ForFixedArrayElement(); + Node* load = t.LoadElement(access, t.Parameter(0), t.Int32Constant(0), + t.Int32Constant(2)); + t.StoreElement(access, t.Parameter(0), t.Int32Constant(1), t.Int32Constant(2), + load); t.Return(load); t.LowerAllNodes(); @@ -211,15 +231,18 @@ TEST(RunLoadStoreFixedArrayIndex) { TEST(RunLoadStoreArrayBuffer) { - SimplifiedLoweringTester<Object*> t(kMachineTagged); + SimplifiedLoweringTester<Object*> t(kMachAnyTagged); const int index = 12; - ElementAccess buffer_access = ForBackingStoreElement(kMachineWord8); - Node* backing_store = - t.LoadField(ForArrayBufferBackingStore(), t.Parameter(0)); + const int array_length = 2 * index; + ElementAccess buffer_access = + AccessBuilder::ForTypedArrayElement(v8::kExternalInt8Array, true); + Node* backing_store = t.LoadField( + AccessBuilder::ForJSArrayBufferBackingStore(), t.Parameter(0)); Node* load = - t.LoadElement(buffer_access, backing_store, t.Int32Constant(index)); + t.LoadElement(buffer_access, backing_store, t.Int32Constant(index), + t.Int32Constant(array_length)); t.StoreElement(buffer_access, backing_store, t.Int32Constant(index + 1), - load); + t.Int32Constant(array_length), load); t.Return(t.jsgraph.TrueConstant()); t.LowerAllNodes(); @@ -227,7 +250,6 @@ TEST(RunLoadStoreArrayBuffer) { if (Pipeline::SupportedTarget()) { Handle<JSArrayBuffer> array = t.factory()->NewJSArrayBuffer(); - const int array_length = 2 * index; Runtime::SetupArrayBufferAllocatingData(t.isolate(), array, array_length); uint8_t* data = reinterpret_cast<uint8_t*>(array->backing_store()); for (int i = 0; i < array_length; i++) { @@ -249,10 +271,10 @@ TEST(RunLoadStoreArrayBuffer) { TEST(RunLoadFieldFromUntaggedBase) { Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; - for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { + for (size_t i = 0; i < arraysize(smis); i++) { int offset = static_cast<int>(i * sizeof(Smi*)); FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), - Type::Integral32(), kMachineTagged}; + Type::Integral32(), kMachAnyTagged}; SimplifiedLoweringTester<Object*> t; Node* load = t.LoadField(access, t.PointerConstant(smis)); @@ -273,12 +295,12 @@ TEST(RunLoadFieldFromUntaggedBase) { TEST(RunStoreFieldToUntaggedBase) { Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3)}; - for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { + for (size_t i = 0; i < arraysize(smis); i++) { int offset = static_cast<int>(i * sizeof(Smi*)); FieldAccess access = {kUntaggedBase, offset, Handle<Name>(), - Type::Integral32(), kMachineTagged}; + Type::Integral32(), kMachAnyTagged}; - SimplifiedLoweringTester<Object*> t(kMachineTagged); + SimplifiedLoweringTester<Object*> t(kMachAnyTagged); Node* p0 = t.Parameter(0); t.StoreField(access, t.PointerConstant(smis), p0); t.Return(p0); @@ -300,15 +322,16 @@ TEST(RunLoadElementFromUntaggedBase) { Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), Smi::FromInt(4), Smi::FromInt(5)}; - for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes - for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index + for (size_t i = 0; i < arraysize(smis); i++) { // for header sizes + for (size_t j = 0; (i + j) < arraysize(smis); j++) { // for element index int offset = static_cast<int>(i * sizeof(Smi*)); ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), - kMachineTagged}; + kMachAnyTagged}; SimplifiedLoweringTester<Object*> t; - Node* load = t.LoadElement(access, t.PointerConstant(smis), - t.Int32Constant(static_cast<int>(j))); + Node* load = t.LoadElement( + access, t.PointerConstant(smis), t.Int32Constant(static_cast<int>(j)), + t.Int32Constant(static_cast<int>(arraysize(smis)))); t.Return(load); t.LowerAllNodes(); @@ -328,16 +351,17 @@ TEST(RunStoreElementFromUntaggedBase) { Smi* smis[] = {Smi::FromInt(1), Smi::FromInt(2), Smi::FromInt(3), Smi::FromInt(4), Smi::FromInt(5)}; - for (size_t i = 0; i < ARRAY_SIZE(smis); i++) { // for header sizes - for (size_t j = 0; (i + j) < ARRAY_SIZE(smis); j++) { // for element index + for (size_t i = 0; i < arraysize(smis); i++) { // for header sizes + for (size_t j = 0; (i + j) < arraysize(smis); j++) { // for element index int offset = static_cast<int>(i * sizeof(Smi*)); ElementAccess access = {kUntaggedBase, offset, Type::Integral32(), - kMachineTagged}; + kMachAnyTagged}; - SimplifiedLoweringTester<Object*> t(kMachineTagged); + SimplifiedLoweringTester<Object*> t(kMachAnyTagged); Node* p0 = t.Parameter(0); t.StoreElement(access, t.PointerConstant(smis), - t.Int32Constant(static_cast<int>(j)), p0); + t.Int32Constant(static_cast<int>(j)), + t.Int32Constant(static_cast<int>(arraysize(smis))), p0); t.Return(p0); t.LowerAllNodes(); @@ -403,8 +427,10 @@ class AccessTester : public HandleAndZoneScope { SimplifiedLoweringTester<Object*> t; Node* ptr = GetBaseNode(&t); - Node* load = t.LoadElement(access, ptr, t.Int32Constant(from_index)); - t.StoreElement(access, ptr, t.Int32Constant(to_index), load); + Node* load = t.LoadElement(access, ptr, t.Int32Constant(from_index), + t.Int32Constant(static_cast<int>(num_elements))); + t.StoreElement(access, ptr, t.Int32Constant(to_index), + t.Int32Constant(static_cast<int>(num_elements)), load); t.Return(t.jsgraph.TrueConstant()); t.LowerAllNodes(); t.GenerateCode(); @@ -439,6 +465,8 @@ class AccessTester : public HandleAndZoneScope { // Create and run code that copies the elements from {this} to {that}. void RunCopyElements(AccessTester<E>* that) { +// TODO(titzer): Rewrite this test without StructuredGraphBuilder support. +#if 0 SimplifiedLoweringTester<Object*> t; Node* one = t.Int32Constant(1); @@ -474,6 +502,7 @@ class AccessTester : public HandleAndZoneScope { Object* result = t.Call(); CHECK_EQ(t.isolate()->heap()->true_value(), result); } +#endif } E GetElement(int index) { @@ -559,19 +588,19 @@ static void RunAccessTest(MachineType rep, E* original_elements, size_t num) { TEST(RunAccessTests_uint8) { uint8_t data[] = {0x07, 0x16, 0x25, 0x34, 0x43, 0x99, 0xab, 0x78, 0x89, 0x19, 0x2b, 0x38}; - RunAccessTest<uint8_t>(kMachineWord8, data, ARRAY_SIZE(data)); + RunAccessTest<uint8_t>(kMachInt8, data, arraysize(data)); } TEST(RunAccessTests_uint16) { uint16_t data[] = {0x071a, 0x162b, 0x253c, 0x344d, 0x435e, 0x7777}; - RunAccessTest<uint16_t>(kMachineWord16, data, ARRAY_SIZE(data)); + RunAccessTest<uint16_t>(kMachInt16, data, arraysize(data)); } TEST(RunAccessTests_int32) { int32_t data[] = {-211, 211, 628347, 2000000000, -2000000000, -1, -100000034}; - RunAccessTest<int32_t>(kMachineWord32, data, ARRAY_SIZE(data)); + RunAccessTest<int32_t>(kMachInt32, data, arraysize(data)); } @@ -585,13 +614,13 @@ TEST(RunAccessTests_int64) { V8_2PART_INT64(0x30313233, 34353637), V8_2PART_INT64(0xa0a1a2a3, a4a5a6a7), V8_2PART_INT64(0xf0f1f2f3, f4f5f6f7)}; - RunAccessTest<int64_t>(kMachineWord64, data, ARRAY_SIZE(data)); + RunAccessTest<int64_t>(kMachInt64, data, arraysize(data)); } TEST(RunAccessTests_float64) { double data[] = {1.25, -1.25, 2.75, 11.0, 11100.8}; - RunAccessTest<double>(kMachineFloat64, data, ARRAY_SIZE(data)); + RunAccessTest<double>(kMachFloat64, data, arraysize(data)); } @@ -599,7 +628,7 @@ TEST(RunAccessTests_Smi) { Smi* data[] = {Smi::FromInt(-1), Smi::FromInt(-9), Smi::FromInt(0), Smi::FromInt(666), Smi::FromInt(77777), Smi::FromInt(Smi::kMaxValue)}; - RunAccessTest<Smi*>(kMachineTagged, data, ARRAY_SIZE(data)); + RunAccessTest<Smi*>(kMachAnyTagged, data, arraysize(data)); } @@ -607,17 +636,21 @@ TEST(RunAccessTests_Smi) { class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { public: Typer typer; + JSOperatorBuilder javascript; JSGraph jsgraph; Node* p0; Node* p1; + Node* p2; Node* start; Node* end; Node* ret; - explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None()) + explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(), + Type* p2_type = Type::None()) : GraphAndBuilders(main_zone()), typer(main_zone()), - jsgraph(graph(), common(), &typer) { + javascript(main_zone()), + jsgraph(graph(), common(), &javascript, &typer, machine()) { start = graph()->NewNode(common()->Start(2)); graph()->SetStart(start); ret = @@ -626,18 +659,20 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { graph()->SetEnd(end); p0 = graph()->NewNode(common()->Parameter(0), start); p1 = graph()->NewNode(common()->Parameter(1), start); + p2 = graph()->NewNode(common()->Parameter(2), start); NodeProperties::SetBounds(p0, Bounds(p0_type)); NodeProperties::SetBounds(p1, Bounds(p1_type)); + NodeProperties::SetBounds(p2, Bounds(p2_type)); } - void CheckLoweringBinop(IrOpcode::Value expected, Operator* op) { + void CheckLoweringBinop(IrOpcode::Value expected, const Operator* op) { Node* node = Return(graph()->NewNode(op, p0, p1)); Lower(); CHECK_EQ(expected, node->opcode()); } - void CheckLoweringTruncatedBinop(IrOpcode::Value expected, Operator* op, - Operator* trunc) { + void CheckLoweringTruncatedBinop(IrOpcode::Value expected, const Operator* op, + const Operator* trunc) { Node* node = graph()->NewNode(op, p0, p1); Return(graph()->NewNode(trunc, node)); Lower(); @@ -645,7 +680,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { } void Lower() { - SimplifiedLowering lowering(&jsgraph, NULL); + SimplifiedLowering lowering(&jsgraph); lowering.LowerAllNodes(); } @@ -658,42 +693,42 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { // Inserts the node as the effect input to the return of the graph. void Effect(Node* node) { ret->ReplaceInput(1, node); } - Node* ExampleWithOutput(RepType type) { + Node* ExampleWithOutput(MachineType type) { // TODO(titzer): use parameters with guaranteed representations. - if (type & tInt32) { + if (type & kTypeInt32) { return graph()->NewNode(machine()->Int32Add(), jsgraph.Int32Constant(1), jsgraph.Int32Constant(1)); - } else if (type & tUint32) { + } else if (type & kTypeUint32) { return graph()->NewNode(machine()->Word32Shr(), jsgraph.Int32Constant(1), jsgraph.Int32Constant(1)); - } else if (type & rFloat64) { + } else if (type & kRepFloat64) { return graph()->NewNode(machine()->Float64Add(), jsgraph.Float64Constant(1), jsgraph.Float64Constant(1)); - } else if (type & rBit) { + } else if (type & kRepBit) { return graph()->NewNode(machine()->Word32Equal(), jsgraph.Int32Constant(1), jsgraph.Int32Constant(1)); - } else if (type & rWord64) { + } else if (type & kRepWord64) { return graph()->NewNode(machine()->Int64Add(), Int64Constant(1), Int64Constant(1)); } else { - CHECK(type & rTagged); + CHECK(type & kRepTagged); return p0; } } - Node* Use(Node* node, RepType type) { - if (type & tInt32) { + Node* Use(Node* node, MachineType type) { + if (type & kTypeInt32) { return graph()->NewNode(machine()->Int32LessThan(), node, jsgraph.Int32Constant(1)); - } else if (type & tUint32) { + } else if (type & kTypeUint32) { return graph()->NewNode(machine()->Uint32LessThan(), node, jsgraph.Int32Constant(1)); - } else if (type & rFloat64) { + } else if (type & kRepFloat64) { return graph()->NewNode(machine()->Float64Add(), node, jsgraph.Float64Constant(1)); - } else if (type & rWord64) { + } else if (type & kRepWord64) { return graph()->NewNode(machine()->Int64LessThan(), node, Int64Constant(1)); } else { @@ -723,9 +758,9 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders { TEST(LowerBooleanNot_bit_bit) { - // BooleanNot(x: rBit) used as rBit + // BooleanNot(x: kRepBit) used as kRepBit TestingGraph t(Type::Boolean()); - Node* b = t.ExampleWithOutput(rBit); + Node* b = t.ExampleWithOutput(kRepBit); Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); Node* use = t.Branch(inv); t.Lower(); @@ -738,11 +773,11 @@ TEST(LowerBooleanNot_bit_bit) { TEST(LowerBooleanNot_bit_tagged) { - // BooleanNot(x: rBit) used as rTagged + // BooleanNot(x: kRepBit) used as kRepTagged TestingGraph t(Type::Boolean()); - Node* b = t.ExampleWithOutput(rBit); + Node* b = t.ExampleWithOutput(kRepBit); Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); - Node* use = t.Use(inv, rTagged); + Node* use = t.Use(inv, kRepTagged); t.Return(use); t.Lower(); CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); @@ -755,7 +790,7 @@ TEST(LowerBooleanNot_bit_tagged) { TEST(LowerBooleanNot_tagged_bit) { - // BooleanNot(x: rTagged) used as rBit + // BooleanNot(x: kRepTagged) used as kRepBit TestingGraph t(Type::Boolean()); Node* b = t.p0; Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); @@ -770,11 +805,11 @@ TEST(LowerBooleanNot_tagged_bit) { TEST(LowerBooleanNot_tagged_tagged) { - // BooleanNot(x: rTagged) used as rTagged + // BooleanNot(x: kRepTagged) used as kRepTagged TestingGraph t(Type::Boolean()); Node* b = t.p0; Node* inv = t.graph()->NewNode(t.simplified()->BooleanNot(), b); - Node* use = t.Use(inv, rTagged); + Node* use = t.Use(inv, kRepTagged); t.Return(use); t.Lower(); CHECK_EQ(IrOpcode::kChangeBitToBool, use->InputAt(0)->opcode()); @@ -786,6 +821,63 @@ TEST(LowerBooleanNot_tagged_tagged) { } +TEST(LowerBooleanToNumber_bit_int32) { + // BooleanToNumber(x: kRepBit) used as kMachInt32 + TestingGraph t(Type::Boolean()); + Node* b = t.ExampleWithOutput(kRepBit); + Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); + Node* use = t.Use(cnv, kMachInt32); + t.Return(use); + t.Lower(); + CHECK_EQ(b, use->InputAt(0)); +} + + +TEST(LowerBooleanToNumber_tagged_int32) { + // BooleanToNumber(x: kRepTagged) used as kMachInt32 + TestingGraph t(Type::Boolean()); + Node* b = t.p0; + Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); + Node* use = t.Use(cnv, kMachInt32); + t.Return(use); + t.Lower(); + CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); + CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); + Node* c = t.jsgraph.TrueConstant(); + CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); +} + + +TEST(LowerBooleanToNumber_bit_tagged) { + // BooleanToNumber(x: kRepBit) used as kMachAnyTagged + TestingGraph t(Type::Boolean()); + Node* b = t.ExampleWithOutput(kRepBit); + Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); + Node* use = t.Use(cnv, kMachAnyTagged); + t.Return(use); + t.Lower(); + CHECK_EQ(b, use->InputAt(0)->InputAt(0)); + CHECK_EQ(IrOpcode::kChangeInt32ToTagged, use->InputAt(0)->opcode()); +} + + +TEST(LowerBooleanToNumber_tagged_tagged) { + // BooleanToNumber(x: kRepTagged) used as kMachAnyTagged + TestingGraph t(Type::Boolean()); + Node* b = t.p0; + Node* cnv = t.graph()->NewNode(t.simplified()->BooleanToNumber(), b); + Node* use = t.Use(cnv, kMachAnyTagged); + t.Return(use); + t.Lower(); + CHECK_EQ(cnv, use->InputAt(0)->InputAt(0)); + CHECK_EQ(IrOpcode::kChangeInt32ToTagged, use->InputAt(0)->opcode()); + CHECK_EQ(t.machine()->WordEqual()->opcode(), cnv->opcode()); + CHECK(b == cnv->InputAt(0) || b == cnv->InputAt(1)); + Node* c = t.jsgraph.TrueConstant(); + CHECK(c == cnv->InputAt(0) || c == cnv->InputAt(1)); +} + + static Type* test_types[] = {Type::Signed32(), Type::Unsigned32(), Type::Number(), Type::Any()}; @@ -815,7 +907,7 @@ TEST(LowerNumberCmp_to_uint32) { TEST(LowerNumberCmp_to_float64) { static Type* types[] = {Type::Number(), Type::Any()}; - for (size_t i = 0; i < ARRAY_SIZE(types); i++) { + for (size_t i = 0; i < arraysize(types); i++) { TestingGraph t(types[i], types[i]); t.CheckLoweringBinop(IrOpcode::kFloat64Equal, @@ -851,7 +943,7 @@ TEST(LowerNumberAddSub_to_uint32) { TEST(LowerNumberAddSub_to_float64) { - for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) { + for (size_t i = 0; i < arraysize(test_types); i++) { TestingGraph t(test_types[i], test_types[i]); t.CheckLoweringBinop(IrOpcode::kFloat64Add, t.simplified()->NumberAdd()); @@ -862,7 +954,7 @@ TEST(LowerNumberAddSub_to_float64) { TEST(LowerNumberDivMod_to_float64) { - for (size_t i = 0; i < ARRAY_SIZE(test_types); i++) { + for (size_t i = 0; i < arraysize(test_types); i++) { TestingGraph t(test_types[i], test_types[i]); t.CheckLoweringBinop(IrOpcode::kFloat64Div, t.simplified()->NumberDivide()); @@ -879,10 +971,10 @@ static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) { TEST(LowerNumberToInt32_to_nop) { - // NumberToInt32(x: rTagged | tInt32) used as rTagged + // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepTagged TestingGraph t(Type::Signed32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); - Node* use = t.Use(trunc, rTagged); + Node* use = t.Use(trunc, kRepTagged); t.Return(use); t.Lower(); CHECK_EQ(t.p0, use->InputAt(0)); @@ -890,10 +982,10 @@ TEST(LowerNumberToInt32_to_nop) { TEST(LowerNumberToInt32_to_ChangeTaggedToFloat64) { - // NumberToInt32(x: rTagged | tInt32) used as rFloat64 + // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepFloat64 TestingGraph t(Type::Signed32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); - Node* use = t.Use(trunc, rFloat64); + Node* use = t.Use(trunc, kRepFloat64); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0)); @@ -901,36 +993,59 @@ TEST(LowerNumberToInt32_to_ChangeTaggedToFloat64) { TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) { - // NumberToInt32(x: rTagged | tInt32) used as rWord32 + // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepWord32 TestingGraph t(Type::Signed32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); - Node* use = t.Use(trunc, tInt32); + Node* use = t.Use(trunc, kTypeInt32); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p0, use->InputAt(0)); } -TEST(LowerNumberToInt32_to_ChangeFloat64ToTagged) { - // TODO(titzer): NumberToInt32(x: rFloat64 | tInt32) used as rTagged +TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) { + // NumberToInt32(x: kRepFloat64) used as kMachInt32 + TestingGraph t(Type::Number()); + Node* p0 = t.ExampleWithOutput(kMachFloat64); + Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), p0); + Node* use = t.Use(trunc, kMachInt32); + t.Return(use); + t.Lower(); + CheckChangeOf(IrOpcode::kTruncateFloat64ToInt32, p0, use->InputAt(0)); } -TEST(LowerNumberToInt32_to_ChangeFloat64ToInt32) { - // TODO(titzer): NumberToInt32(x: rFloat64 | tInt32) used as rWord32 | tInt32 +TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32_with_change) { + // NumberToInt32(x: kTypeNumber | kRepTagged) used as kMachInt32 + TestingGraph t(Type::Number()); + Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); + Node* use = t.Use(trunc, kMachInt32); + t.Return(use); + t.Lower(); + Node* node = use->InputAt(0); + CHECK_EQ(IrOpcode::kTruncateFloat64ToInt32, node->opcode()); + Node* of = node->InputAt(0); + CHECK_EQ(IrOpcode::kChangeTaggedToFloat64, of->opcode()); + CHECK_EQ(t.p0, of->InputAt(0)); } -TEST(LowerNumberToInt32_to_TruncateFloat64ToInt32) { - // TODO(titzer): NumberToInt32(x: rFloat64) used as rWord32 | tUint32 +TEST(LowerNumberToInt32_to_ChangeFloat64ToTagged) { + // TODO(titzer): NumberToInt32(x: kRepFloat64 | kTypeInt32) used as kRepTagged +} + + +TEST(LowerNumberToInt32_to_ChangeFloat64ToInt32) { + // TODO(titzer): NumberToInt32(x: kRepFloat64 | kTypeInt32) used as kRepWord32 + // | kTypeInt32 } TEST(LowerNumberToUint32_to_nop) { - // NumberToUint32(x: rTagged | tUint32) used as rTagged + // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepTagged TestingGraph t(Type::Unsigned32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); - Node* use = t.Use(trunc, rTagged); + Node* use = t.Use(trunc, kRepTagged); t.Return(use); t.Lower(); CHECK_EQ(t.p0, use->InputAt(0)); @@ -938,10 +1053,10 @@ TEST(LowerNumberToUint32_to_nop) { TEST(LowerNumberToUint32_to_ChangeTaggedToFloat64) { - // NumberToUint32(x: rTagged | tUint32) used as rWord32 + // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32 TestingGraph t(Type::Unsigned32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); - Node* use = t.Use(trunc, rFloat64); + Node* use = t.Use(trunc, kRepFloat64); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0)); @@ -949,28 +1064,57 @@ TEST(LowerNumberToUint32_to_ChangeTaggedToFloat64) { TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) { - // NumberToUint32(x: rTagged | tUint32) used as rWord32 + // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32 TestingGraph t(Type::Unsigned32()); Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); - Node* use = t.Use(trunc, tUint32); + Node* use = t.Use(trunc, kTypeUint32); t.Return(use); t.Lower(); CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0)); } +TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32) { + // NumberToUint32(x: kRepFloat64) used as kMachUint32 + TestingGraph t(Type::Number()); + Node* p0 = t.ExampleWithOutput(kMachFloat64); + Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), p0); + Node* use = t.Use(trunc, kMachUint32); + t.Return(use); + t.Lower(); + CheckChangeOf(IrOpcode::kTruncateFloat64ToInt32, p0, use->InputAt(0)); +} + + +TEST(LowerNumberToUint32_to_TruncateFloat64ToInt32_with_change) { + // NumberToInt32(x: kTypeNumber | kRepTagged) used as kMachUint32 + TestingGraph t(Type::Number()); + Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); + Node* use = t.Use(trunc, kMachUint32); + t.Return(use); + t.Lower(); + Node* node = use->InputAt(0); + CHECK_EQ(IrOpcode::kTruncateFloat64ToInt32, node->opcode()); + Node* of = node->InputAt(0); + CHECK_EQ(IrOpcode::kChangeTaggedToFloat64, of->opcode()); + CHECK_EQ(t.p0, of->InputAt(0)); +} + + TEST(LowerNumberToUint32_to_ChangeFloat64ToTagged) { - // TODO(titzer): NumberToUint32(x: rFloat64 | tUint32) used as rTagged + // TODO(titzer): NumberToUint32(x: kRepFloat64 | kTypeUint32) used as + // kRepTagged } TEST(LowerNumberToUint32_to_ChangeFloat64ToUint32) { - // TODO(titzer): NumberToUint32(x: rFloat64 | tUint32) used as rWord32 + // TODO(titzer): NumberToUint32(x: kRepFloat64 | kTypeUint32) used as + // kRepWord32 } TEST(LowerNumberToUint32_to_TruncateFloat64ToUint32) { - // TODO(titzer): NumberToUint32(x: rFloat64) used as rWord32 + // TODO(titzer): NumberToUint32(x: kRepFloat64) used as kRepWord32 } @@ -982,19 +1126,26 @@ TEST(LowerReferenceEqual_to_wordeq) { } -TEST(LowerStringOps_to_rtcalls) { - if (false) { // TODO(titzer): lower StringOps to runtime calls +TEST(LowerStringOps_to_call_and_compare) { + if (Pipeline::SupportedTarget()) { + // These tests need linkage for the calls. TestingGraph t(Type::String(), Type::String()); - t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringEqual()); - t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringLessThan()); - t.CheckLoweringBinop(IrOpcode::kCall, - t.simplified()->StringLessThanOrEqual()); + IrOpcode::Value compare_eq = + static_cast<IrOpcode::Value>(t.machine()->WordEqual()->opcode()); + IrOpcode::Value compare_lt = + static_cast<IrOpcode::Value>(t.machine()->IntLessThan()->opcode()); + IrOpcode::Value compare_le = static_cast<IrOpcode::Value>( + t.machine()->IntLessThanOrEqual()->opcode()); + t.CheckLoweringBinop(compare_eq, t.simplified()->StringEqual()); + t.CheckLoweringBinop(compare_lt, t.simplified()->StringLessThan()); + t.CheckLoweringBinop(compare_le, t.simplified()->StringLessThanOrEqual()); t.CheckLoweringBinop(IrOpcode::kCall, t.simplified()->StringAdd()); } } -void CheckChangeInsertion(IrOpcode::Value expected, RepType from, RepType to) { +void CheckChangeInsertion(IrOpcode::Value expected, MachineType from, + MachineType to) { TestingGraph t(Type::Any()); Node* in = t.ExampleWithOutput(from); Node* use = t.Use(in, to); @@ -1006,26 +1157,31 @@ void CheckChangeInsertion(IrOpcode::Value expected, RepType from, RepType to) { TEST(InsertBasicChanges) { - if (false) { - // TODO(titzer): these changes need the output to have the right type. - CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, rFloat64, tInt32); - CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, rFloat64, tUint32); - CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, rTagged, tInt32); - CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, rTagged, tUint32); - } + CheckChangeInsertion(IrOpcode::kChangeFloat64ToInt32, kRepFloat64, + kTypeInt32); + CheckChangeInsertion(IrOpcode::kChangeFloat64ToUint32, kRepFloat64, + kTypeUint32); + CheckChangeInsertion(IrOpcode::kChangeTaggedToInt32, kRepTagged, kTypeInt32); + CheckChangeInsertion(IrOpcode::kChangeTaggedToUint32, kRepTagged, + kTypeUint32); - CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, rFloat64, rTagged); - CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, rTagged, rFloat64); + CheckChangeInsertion(IrOpcode::kChangeFloat64ToTagged, kRepFloat64, + kRepTagged); + CheckChangeInsertion(IrOpcode::kChangeTaggedToFloat64, kRepTagged, + kRepFloat64); - CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, tInt32, rFloat64); - CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, tInt32, rTagged); + CheckChangeInsertion(IrOpcode::kChangeInt32ToFloat64, kTypeInt32, + kRepFloat64); + CheckChangeInsertion(IrOpcode::kChangeInt32ToTagged, kTypeInt32, kRepTagged); - CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, tUint32, rFloat64); - CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, tUint32, rTagged); + CheckChangeInsertion(IrOpcode::kChangeUint32ToFloat64, kTypeUint32, + kRepFloat64); + CheckChangeInsertion(IrOpcode::kChangeUint32ToTagged, kTypeUint32, + kRepTagged); } -static void CheckChangesAroundBinop(TestingGraph* t, Operator* op, +static void CheckChangesAroundBinop(TestingGraph* t, const Operator* op, IrOpcode::Value input_change, IrOpcode::Value output_change) { Node* binop = t->graph()->NewNode(op, t->p0, t->p1); @@ -1043,13 +1199,13 @@ static void CheckChangesAroundBinop(TestingGraph* t, Operator* op, TEST(InsertChangesAroundInt32Binops) { TestingGraph t(Type::Signed32(), Type::Signed32()); - Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), - t.machine()->Int32Mul(), t.machine()->Int32Div(), - t.machine()->Int32Mod(), t.machine()->Word32And(), - t.machine()->Word32Or(), t.machine()->Word32Xor(), - t.machine()->Word32Shl(), t.machine()->Word32Sar()}; + const Operator* ops[] = {t.machine()->Int32Add(), t.machine()->Int32Sub(), + t.machine()->Int32Mul(), t.machine()->Int32Div(), + t.machine()->Int32Mod(), t.machine()->Word32And(), + t.machine()->Word32Or(), t.machine()->Word32Xor(), + t.machine()->Word32Shl(), t.machine()->Word32Sar()}; - for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { + for (size_t i = 0; i < arraysize(ops); i++) { CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, IrOpcode::kChangeInt32ToTagged); } @@ -1059,10 +1215,10 @@ TEST(InsertChangesAroundInt32Binops) { TEST(InsertChangesAroundInt32Cmp) { TestingGraph t(Type::Signed32(), Type::Signed32()); - Operator* ops[] = {t.machine()->Int32LessThan(), - t.machine()->Int32LessThanOrEqual()}; + const Operator* ops[] = {t.machine()->Int32LessThan(), + t.machine()->Int32LessThanOrEqual()}; - for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { + for (size_t i = 0; i < arraysize(ops); i++) { CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToInt32, IrOpcode::kChangeBitToBool); } @@ -1072,10 +1228,10 @@ TEST(InsertChangesAroundInt32Cmp) { TEST(InsertChangesAroundUint32Cmp) { TestingGraph t(Type::Unsigned32(), Type::Unsigned32()); - Operator* ops[] = {t.machine()->Uint32LessThan(), - t.machine()->Uint32LessThanOrEqual()}; + const Operator* ops[] = {t.machine()->Uint32LessThan(), + t.machine()->Uint32LessThanOrEqual()}; - for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { + for (size_t i = 0; i < arraysize(ops); i++) { CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToUint32, IrOpcode::kChangeBitToBool); } @@ -1085,13 +1241,13 @@ TEST(InsertChangesAroundUint32Cmp) { TEST(InsertChangesAroundFloat64Binops) { TestingGraph t(Type::Number(), Type::Number()); - Operator* ops[] = { + const Operator* ops[] = { t.machine()->Float64Add(), t.machine()->Float64Sub(), t.machine()->Float64Mul(), t.machine()->Float64Div(), t.machine()->Float64Mod(), }; - for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { + for (size_t i = 0; i < arraysize(ops); i++) { CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, IrOpcode::kChangeFloat64ToTagged); } @@ -1101,11 +1257,11 @@ TEST(InsertChangesAroundFloat64Binops) { TEST(InsertChangesAroundFloat64Cmp) { TestingGraph t(Type::Number(), Type::Number()); - Operator* ops[] = {t.machine()->Float64Equal(), - t.machine()->Float64LessThan(), - t.machine()->Float64LessThanOrEqual()}; + const Operator* ops[] = {t.machine()->Float64Equal(), + t.machine()->Float64LessThan(), + t.machine()->Float64LessThanOrEqual()}; - for (size_t i = 0; i < ARRAY_SIZE(ops); i++) { + for (size_t i = 0; i < arraysize(ops); i++) { CheckChangesAroundBinop(&t, ops[i], IrOpcode::kChangeTaggedToFloat64, IrOpcode::kChangeBitToBool); } @@ -1123,28 +1279,7 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) { CHECK_EQ(IrOpcode::kInt32Add, index.node()->opcode()); CHECK(index.right().Is(access.header_size - access.tag())); - int element_size = 0; - switch (access.representation) { - case kMachineTagged: - element_size = kPointerSize; - break; - case kMachineWord8: - element_size = 1; - break; - case kMachineWord16: - element_size = 2; - break; - case kMachineWord32: - element_size = 4; - break; - case kMachineWord64: - case kMachineFloat64: - element_size = 8; - break; - case kMachineLast: - UNREACHABLE(); - break; - } + int element_size = ElementSizeOf(access.machine_type); if (element_size != 1) { Int32BinopMatcher mul(index.left().node()); @@ -1157,30 +1292,21 @@ Node* CheckElementAccessArithmetic(ElementAccess access, Node* load_or_store) { } -static const MachineType machine_reps[] = {kMachineWord8, kMachineWord16, - kMachineWord32, kMachineWord64, - kMachineFloat64, kMachineTagged}; - - -// Representation types corresponding to those above. -static const RepType rep_types[] = {static_cast<RepType>(rWord32 | tUint32), - static_cast<RepType>(rWord32 | tUint32), - static_cast<RepType>(rWord32 | tInt32), - static_cast<RepType>(rWord64), - static_cast<RepType>(rFloat64 | tNumber), - static_cast<RepType>(rTagged | tAny)}; +static const MachineType machine_reps[] = { + kRepBit, kMachInt8, kMachInt16, kMachInt32, + kMachInt64, kMachFloat64, kMachAnyTagged}; TEST(LowerLoadField_to_load) { TestingGraph t(Type::Any(), Type::Signed32()); - for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { + for (size_t i = 0; i < arraysize(machine_reps); i++) { FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(), Type::Any(), machine_reps[i]}; Node* load = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); - Node* use = t.Use(load, rep_types[i]); + Node* use = t.Use(load, machine_reps[i]); t.Return(use); t.Lower(); CHECK_EQ(IrOpcode::kLoad, load->opcode()); @@ -1196,12 +1322,12 @@ TEST(LowerLoadField_to_load) { TEST(LowerStoreField_to_store) { TestingGraph t(Type::Any(), Type::Signed32()); - for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { + for (size_t i = 0; i < arraysize(machine_reps); i++) { FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(), Type::Any(), machine_reps[i]}; - Node* val = t.ExampleWithOutput(rep_types[i]); + Node* val = t.ExampleWithOutput(machine_reps[i]); Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, val, t.start, t.start); t.Effect(store); @@ -1211,10 +1337,10 @@ TEST(LowerStoreField_to_store) { CheckFieldAccessArithmetic(access, store); StoreRepresentation rep = OpParameter<StoreRepresentation>(store); - if (rep_types[i] & rTagged) { - CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind); + if (machine_reps[i] & kRepTagged) { + CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); } - CHECK_EQ(machine_reps[i], rep.rep); + CHECK_EQ(machine_reps[i], rep.machine_type()); } } @@ -1222,13 +1348,14 @@ TEST(LowerStoreField_to_store) { TEST(LowerLoadElement_to_load) { TestingGraph t(Type::Any(), Type::Signed32()); - for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { + for (size_t i = 0; i < arraysize(machine_reps); i++) { ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), machine_reps[i]}; - Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, - t.p1, t.start); - Node* use = t.Use(load, rep_types[i]); + Node* load = + t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, t.p1, + t.jsgraph.Int32Constant(1024), t.start); + Node* use = t.Use(load, machine_reps[i]); t.Return(use); t.Lower(); CHECK_EQ(IrOpcode::kLoad, load->opcode()); @@ -1244,13 +1371,14 @@ TEST(LowerLoadElement_to_load) { TEST(LowerStoreElement_to_store) { TestingGraph t(Type::Any(), Type::Signed32()); - for (size_t i = 0; i < ARRAY_SIZE(machine_reps); i++) { + for (size_t i = 0; i < arraysize(machine_reps); i++) { ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), machine_reps[i]}; - Node* val = t.ExampleWithOutput(rep_types[i]); + Node* val = t.ExampleWithOutput(machine_reps[i]); Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, - t.p1, val, t.start, t.start); + t.p1, t.jsgraph.Int32Constant(1024), val, + t.start, t.start); t.Effect(store); t.Lower(); CHECK_EQ(IrOpcode::kStore, store->opcode()); @@ -1258,23 +1386,23 @@ TEST(LowerStoreElement_to_store) { CheckElementAccessArithmetic(access, store); StoreRepresentation rep = OpParameter<StoreRepresentation>(store); - if (rep_types[i] & rTagged) { - CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind); + if (machine_reps[i] & kRepTagged) { + CHECK_EQ(kFullWriteBarrier, rep.write_barrier_kind()); } - CHECK_EQ(machine_reps[i], rep.rep); + CHECK_EQ(machine_reps[i], rep.machine_type()); } } TEST(InsertChangeForLoadElementIndex) { - // LoadElement(obj: Tagged, index: tInt32 | rTagged) => + // LoadElement(obj: Tagged, index: kTypeInt32 | kRepTagged, length) => // Load(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k)) - TestingGraph t(Type::Any(), Type::Signed32()); + TestingGraph t(Type::Any(), Type::Signed32(), Type::Any()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachineTagged}; + kMachAnyTagged}; Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, - t.p1, t.start); + t.p1, t.p2, t.start); t.Return(load); t.Lower(); CHECK_EQ(IrOpcode::kLoad, load->opcode()); @@ -1286,14 +1414,14 @@ TEST(InsertChangeForLoadElementIndex) { TEST(InsertChangeForStoreElementIndex) { - // StoreElement(obj: Tagged, index: tInt32 | rTagged, val) => + // StoreElement(obj: Tagged, index: kTypeInt32 | kRepTagged, length, val) => // Store(obj, Int32Add(Int32Mul(ChangeTaggedToInt32(index), #k), #k), val) - TestingGraph t(Type::Any(), Type::Signed32()); + TestingGraph t(Type::Any(), Type::Signed32(), Type::Any()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachineTagged}; + kMachAnyTagged}; Node* store = - t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, t.p1, + t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, t.p1, t.p2, t.jsgraph.TrueConstant(), t.start, t.start); t.Effect(store); t.Lower(); @@ -1307,12 +1435,12 @@ TEST(InsertChangeForStoreElementIndex) { TEST(InsertChangeForLoadElement) { // TODO(titzer): test all load/store representation change insertions. - TestingGraph t(Type::Any(), Type::Signed32()); + TestingGraph t(Type::Any(), Type::Signed32(), Type::Any()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachineFloat64}; + kMachFloat64}; Node* load = t.graph()->NewNode(t.simplified()->LoadElement(access), t.p0, - t.p1, t.start); + t.p1, t.p1, t.start); t.Return(load); t.Lower(); CHECK_EQ(IrOpcode::kLoad, load->opcode()); @@ -1325,7 +1453,7 @@ TEST(InsertChangeForLoadField) { // TODO(titzer): test all load/store representation change insertions. TestingGraph t(Type::Any(), Type::Signed32()); FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle<Name>::null(), Type::Any(), kMachineFloat64}; + Handle<Name>::null(), Type::Any(), kMachFloat64}; Node* load = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); @@ -1339,13 +1467,13 @@ TEST(InsertChangeForLoadField) { TEST(InsertChangeForStoreElement) { // TODO(titzer): test all load/store representation change insertions. - TestingGraph t(Type::Any(), Type::Signed32()); + TestingGraph t(Type::Any(), Type::Signed32(), Type::Any()); ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(), - kMachineFloat64}; + kMachFloat64}; - Node* store = - t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, - t.jsgraph.Int32Constant(0), t.p1, t.start, t.start); + Node* store = t.graph()->NewNode(t.simplified()->StoreElement(access), t.p0, + t.jsgraph.Int32Constant(0), t.p2, t.p1, + t.start, t.start); t.Effect(store); t.Lower(); @@ -1359,7 +1487,7 @@ TEST(InsertChangeForStoreField) { // TODO(titzer): test all load/store representation change insertions. TestingGraph t(Type::Any(), Type::Signed32()); FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, - Handle<Name>::null(), Type::Any(), kMachineFloat64}; + Handle<Name>::null(), Type::Any(), kMachFloat64}; Node* store = t.graph()->NewNode(t.simplified()->StoreField(access), t.p0, t.p1, t.start, t.start); @@ -1370,3 +1498,28 @@ TEST(InsertChangeForStoreField) { CHECK_EQ(t.p0, store->InputAt(0)); CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p1, store->InputAt(2)); } + + +TEST(UpdatePhi) { + TestingGraph t(Type::Any(), Type::Signed32()); + static const MachineType kMachineTypes[] = {kMachInt32, kMachUint32, + kMachFloat64}; + + for (size_t i = 0; i < arraysize(kMachineTypes); i++) { + FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, + Handle<Name>::null(), Type::Any(), kMachineTypes[i]}; + + Node* load0 = + t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start); + Node* load1 = + t.graph()->NewNode(t.simplified()->LoadField(access), t.p1, t.start); + Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0, + load1, t.start); + t.Return(t.Use(phi, kMachineTypes[i])); + t.Lower(); + + CHECK_EQ(IrOpcode::kPhi, phi->opcode()); + CHECK_EQ(RepresentationOf(kMachineTypes[i]), + RepresentationOf(OpParameter<MachineType>(phi))); + } +} diff --git a/deps/v8/test/cctest/compiler/test-structured-ifbuilder-fuzzer.cc b/deps/v8/test/cctest/compiler/test-structured-ifbuilder-fuzzer.cc deleted file mode 100644 index 02232264d9..0000000000 --- a/deps/v8/test/cctest/compiler/test-structured-ifbuilder-fuzzer.cc +++ /dev/null @@ -1,667 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <string> - -#include "src/v8.h" -#include "test/cctest/cctest.h" - -#include "src/base/utils/random-number-generator.h" -#include "test/cctest/compiler/codegen-tester.h" - -#if V8_TURBOFAN_TARGET - -using namespace v8::internal; -using namespace v8::internal::compiler; - -typedef StructuredMachineAssembler::IfBuilder IfBuilder; -typedef StructuredMachineAssembler::LoopBuilder Loop; - -static const int32_t kUninitializedVariableOffset = -1; -static const int32_t kUninitializedOutput = -1; -static const int32_t kVerifiedOutput = -2; - -static const int32_t kInitalVar = 1013; -static const int32_t kConjunctionInc = 1069; -static const int32_t kDisjunctionInc = 1151; -static const int32_t kThenInc = 1223; -static const int32_t kElseInc = 1291; -static const int32_t kIfInc = 1373; - -class IfBuilderModel { - public: - explicit IfBuilderModel(Zone* zone) - : zone_(zone), - variable_offset_(0), - root_(new (zone_) Node(NULL)), - current_node_(root_), - current_expression_(NULL) {} - - void If() { - if (current_node_->else_node != NULL) { - current_node_ = current_node_->else_node; - } else if (current_node_->then_node != NULL) { - current_node_ = current_node_->then_node; - } - DCHECK(current_expression_ == NULL); - current_expression_ = new (zone_) Expression(zone_, NULL); - current_node_->condition = current_expression_; - } - void IfNode() { LastChild()->variable_offset = variable_offset_++; } - - void OpenParen() { current_expression_ = LastChild(); } - void CloseParen() { current_expression_ = current_expression_->parent; } - - void And() { NewChild()->conjunction = true; } - void Or() { NewChild()->disjunction = true; } - - void Then() { - DCHECK(current_expression_ == NULL || current_expression_->parent == NULL); - current_expression_ = NULL; - DCHECK(current_node_->then_node == NULL); - current_node_->then_node = new (zone_) Node(current_node_); - } - void Else() { - DCHECK(current_expression_ == NULL || current_expression_->parent == NULL); - current_expression_ = NULL; - DCHECK(current_node_->else_node == NULL); - current_node_->else_node = new (zone_) Node(current_node_); - } - void Return() { - if (current_node_->else_node != NULL) { - current_node_->else_node->returns = true; - } else if (current_node_->then_node != NULL) { - current_node_->then_node->returns = true; - } else { - CHECK(false); - } - } - void End() {} - - void Print(std::vector<char>* v) { PrintRecursive(v, root_); } - - struct VerificationState { - int32_t* inputs; - int32_t* outputs; - int32_t var; - }; - - int32_t Verify(int length, int32_t* inputs, int32_t* outputs) { - CHECK_EQ(variable_offset_, length); - // Input/Output verification. - for (int i = 0; i < length; ++i) { - CHECK(inputs[i] == 0 || inputs[i] == 1); - CHECK(outputs[i] == kUninitializedOutput || outputs[i] >= 0); - } - // Do verification. - VerificationState state; - state.inputs = inputs; - state.outputs = outputs; - state.var = kInitalVar; - VerifyRecursive(root_, &state); - // Verify all outputs marked. - for (int i = 0; i < length; ++i) { - CHECK(outputs[i] == kUninitializedOutput || - outputs[i] == kVerifiedOutput); - } - return state.var; - } - - private: - struct Expression; - typedef std::vector<Expression*, zone_allocator<Expression*> > Expressions; - - struct Expression : public ZoneObject { - Expression(Zone* zone, Expression* p) - : variable_offset(kUninitializedVariableOffset), - disjunction(false), - conjunction(false), - parent(p), - children(Expressions::allocator_type(zone)) {} - int variable_offset; - bool disjunction; - bool conjunction; - Expression* parent; - Expressions children; - - private: - DISALLOW_COPY_AND_ASSIGN(Expression); - }; - - struct Node : public ZoneObject { - explicit Node(Node* p) - : parent(p), - condition(NULL), - then_node(NULL), - else_node(NULL), - returns(false) {} - Node* parent; - Expression* condition; - Node* then_node; - Node* else_node; - bool returns; - - private: - DISALLOW_COPY_AND_ASSIGN(Node); - }; - - Expression* LastChild() { - if (current_expression_->children.empty()) { - current_expression_->children.push_back( - new (zone_) Expression(zone_, current_expression_)); - } - return current_expression_->children.back(); - } - - Expression* NewChild() { - Expression* child = new (zone_) Expression(zone_, current_expression_); - current_expression_->children.push_back(child); - return child; - } - - static void PrintRecursive(std::vector<char>* v, Expression* expression) { - CHECK(expression != NULL); - if (expression->conjunction) { - DCHECK(!expression->disjunction); - v->push_back('&'); - } else if (expression->disjunction) { - v->push_back('|'); - } - if (expression->variable_offset != kUninitializedVariableOffset) { - v->push_back('v'); - } - Expressions& children = expression->children; - if (children.empty()) return; - v->push_back('('); - for (Expressions::iterator i = children.begin(); i != children.end(); ++i) { - PrintRecursive(v, *i); - } - v->push_back(')'); - } - - static void PrintRecursive(std::vector<char>* v, Node* node) { - // Termination condition. - if (node->condition == NULL) { - CHECK(node->then_node == NULL && node->else_node == NULL); - if (node->returns) v->push_back('r'); - return; - } - CHECK(!node->returns); - v->push_back('i'); - PrintRecursive(v, node->condition); - if (node->then_node != NULL) { - v->push_back('t'); - PrintRecursive(v, node->then_node); - } - if (node->else_node != NULL) { - v->push_back('e'); - PrintRecursive(v, node->else_node); - } - } - - static bool VerifyRecursive(Expression* expression, - VerificationState* state) { - bool result = false; - bool first_iteration = true; - Expressions& children = expression->children; - CHECK(!children.empty()); - for (Expressions::iterator i = children.begin(); i != children.end(); ++i) { - Expression* child = *i; - // Short circuit evaluation, - // but mixes of &&s and ||s have weird semantics. - if ((child->conjunction && !result) || (child->disjunction && result)) { - continue; - } - if (child->conjunction) state->var += kConjunctionInc; - if (child->disjunction) state->var += kDisjunctionInc; - bool child_result; - if (child->variable_offset != kUninitializedVariableOffset) { - // Verify output - CHECK_EQ(state->var, state->outputs[child->variable_offset]); - state->outputs[child->variable_offset] = kVerifiedOutput; // Mark seen. - child_result = state->inputs[child->variable_offset]; - CHECK(child->children.empty()); - state->var += kIfInc; - } else { - child_result = VerifyRecursive(child, state); - } - if (child->conjunction) { - result &= child_result; - } else if (child->disjunction) { - result |= child_result; - } else { - CHECK(first_iteration); - result = child_result; - } - first_iteration = false; - } - return result; - } - - static void VerifyRecursive(Node* node, VerificationState* state) { - if (node->condition == NULL) return; - bool result = VerifyRecursive(node->condition, state); - if (result) { - if (node->then_node) { - state->var += kThenInc; - return VerifyRecursive(node->then_node, state); - } - } else { - if (node->else_node) { - state->var += kElseInc; - return VerifyRecursive(node->else_node, state); - } - } - } - - Zone* zone_; - int variable_offset_; - Node* root_; - Node* current_node_; - Expression* current_expression_; - DISALLOW_COPY_AND_ASSIGN(IfBuilderModel); -}; - - -class IfBuilderGenerator : public StructuredMachineAssemblerTester<int32_t> { - public: - IfBuilderGenerator() - : StructuredMachineAssemblerTester<int32_t>( - MachineOperatorBuilder::pointer_rep(), - MachineOperatorBuilder::pointer_rep()), - var_(NewVariable(Int32Constant(kInitalVar))), - c_(this), - m_(this->zone()), - one_(Int32Constant(1)), - offset_(0) {} - - static void GenerateExpression(v8::base::RandomNumberGenerator* rng, - std::vector<char>* v, int n_vars) { - int depth = 1; - v->push_back('('); - bool need_if = true; - bool populated = false; - while (n_vars != 0) { - if (need_if) { - // can nest a paren or do a variable - if (rng->NextBool()) { - v->push_back('v'); - n_vars--; - need_if = false; - populated = true; - } else { - v->push_back('('); - depth++; - populated = false; - } - } else { - // can pop, do && or do || - int options = 3; - if (depth == 1 || !populated) { - options--; - } - switch (rng->NextInt(options)) { - case 0: - v->push_back('&'); - need_if = true; - break; - case 1: - v->push_back('|'); - need_if = true; - break; - case 2: - v->push_back(')'); - depth--; - break; - } - } - } - CHECK(!need_if); - while (depth != 0) { - v->push_back(')'); - depth--; - } - } - - static void GenerateIfThenElse(v8::base::RandomNumberGenerator* rng, - std::vector<char>* v, int n_ifs, - int max_exp_length) { - CHECK_GT(n_ifs, 0); - CHECK_GT(max_exp_length, 0); - bool have_env = true; - bool then_done = false; - bool else_done = false; - bool first_iteration = true; - while (n_ifs != 0) { - if (have_env) { - int options = 3; - if (else_done || first_iteration) { // Don't do else or return - options -= 2; - first_iteration = false; - } - switch (rng->NextInt(options)) { - case 0: - v->push_back('i'); - n_ifs--; - have_env = false; - GenerateExpression(rng, v, rng->NextInt(max_exp_length) + 1); - break; - case 1: - v->push_back('r'); - have_env = false; - break; - case 2: - v->push_back('e'); - else_done = true; - then_done = false; - break; - default: - CHECK(false); - } - } else { // Can only do then or else - int options = 2; - if (then_done) options--; - switch (rng->NextInt(options)) { - case 0: - v->push_back('e'); - else_done = true; - then_done = false; - break; - case 1: - v->push_back('t'); - then_done = true; - else_done = false; - break; - default: - CHECK(false); - } - have_env = true; - } - } - // Last instruction must have been an if, can complete it in several ways. - int options = 2; - if (then_done && !else_done) options++; - switch (rng->NextInt(3)) { - case 0: - // Do nothing. - break; - case 1: - v->push_back('t'); - switch (rng->NextInt(3)) { - case 0: - v->push_back('r'); - break; - case 1: - v->push_back('e'); - break; - case 2: - v->push_back('e'); - v->push_back('r'); - break; - default: - CHECK(false); - } - break; - case 2: - v->push_back('e'); - if (rng->NextBool()) v->push_back('r'); - break; - default: - CHECK(false); - } - } - - std::string::const_iterator ParseExpression(std::string::const_iterator it, - std::string::const_iterator end) { - // Prepare for expression. - m_.If(); - c_.If(); - int depth = 0; - for (; it != end; ++it) { - switch (*it) { - case 'v': - m_.IfNode(); - { - Node* offset = Int32Constant(offset_ * 4); - Store(kMachineWord32, Parameter(1), offset, var_.Get()); - var_.Set(Int32Add(var_.Get(), Int32Constant(kIfInc))); - c_.If(Load(kMachineWord32, Parameter(0), offset)); - offset_++; - } - break; - case '&': - m_.And(); - c_.And(); - var_.Set(Int32Add(var_.Get(), Int32Constant(kConjunctionInc))); - break; - case '|': - m_.Or(); - c_.Or(); - var_.Set(Int32Add(var_.Get(), Int32Constant(kDisjunctionInc))); - break; - case '(': - if (depth != 0) { - m_.OpenParen(); - c_.OpenParen(); - } - depth++; - break; - case ')': - depth--; - if (depth == 0) return it; - m_.CloseParen(); - c_.CloseParen(); - break; - default: - CHECK(false); - } - } - CHECK(false); - return it; - } - - void ParseIfThenElse(const std::string& str) { - int n_vars = 0; - for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) { - if (*it == 'v') n_vars++; - } - InitializeConstants(n_vars); - for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) { - switch (*it) { - case 'i': { - it++; - CHECK(it != str.end()); - CHECK_EQ('(', *it); - it = ParseExpression(it, str.end()); - CHECK_EQ(')', *it); - break; - } - case 't': - m_.Then(); - c_.Then(); - var_.Set(Int32Add(var_.Get(), Int32Constant(kThenInc))); - break; - case 'e': - m_.Else(); - c_.Else(); - var_.Set(Int32Add(var_.Get(), Int32Constant(kElseInc))); - break; - case 'r': - m_.Return(); - Return(var_.Get()); - break; - default: - CHECK(false); - } - } - m_.End(); - c_.End(); - Return(var_.Get()); - // Compare generated model to parsed version. - { - std::vector<char> v; - m_.Print(&v); - std::string m_str(v.begin(), v.end()); - CHECK(m_str == str); - } - } - - void ParseExpression(const std::string& str) { - CHECK(inputs_.is_empty()); - std::string wrapped = "i(" + str + ")te"; - ParseIfThenElse(wrapped); - } - - void ParseRandomIfThenElse(v8::base::RandomNumberGenerator* rng, int n_ifs, - int n_vars) { - std::vector<char> v; - GenerateIfThenElse(rng, &v, n_ifs, n_vars); - std::string str(v.begin(), v.end()); - ParseIfThenElse(str); - } - - void RunRandom(v8::base::RandomNumberGenerator* rng) { - // TODO(dcarney): permute inputs via model. - // TODO(dcarney): compute test_cases from n_ifs and n_vars. - int test_cases = 100; - for (int test = 0; test < test_cases; test++) { - Initialize(); - for (int i = 0; i < offset_; i++) { - inputs_[i] = rng->NextBool(); - } - DoCall(); - } - } - - void Run(const std::string& str, int32_t expected) { - Initialize(); - int offset = 0; - for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) { - switch (*it) { - case 't': - inputs_[offset++] = 1; - break; - case 'f': - inputs_[offset++] = 0; - break; - default: - CHECK(false); - } - } - CHECK_EQ(offset_, offset); - // Call. - int32_t result = DoCall(); - CHECK_EQ(result, expected); - } - - private: - typedef std::vector<int32_t, zone_allocator<int32_t> > IOVector; - - void InitializeConstants(int n_vars) { - CHECK(inputs_.is_empty()); - inputs_.Reset(new int32_t[n_vars]); - outputs_.Reset(new int32_t[n_vars]); - } - - void Initialize() { - for (int i = 0; i < offset_; i++) { - inputs_[i] = 0; - outputs_[i] = kUninitializedOutput; - } - } - - int32_t DoCall() { - int32_t result = Call(inputs_.get(), outputs_.get()); - int32_t expected = m_.Verify(offset_, inputs_.get(), outputs_.get()); - CHECK_EQ(result, expected); - return result; - } - - const v8::internal::compiler::Variable var_; - IfBuilder c_; - IfBuilderModel m_; - Node* one_; - int32_t offset_; - SmartArrayPointer<int32_t> inputs_; - SmartArrayPointer<int32_t> outputs_; -}; - - -TEST(RunExpressionString) { - IfBuilderGenerator m; - m.ParseExpression("((v|v)|v)"); - m.Run("ttt", kInitalVar + 1 * kIfInc + kThenInc); - m.Run("ftt", kInitalVar + 2 * kIfInc + kDisjunctionInc + kThenInc); - m.Run("fft", kInitalVar + 3 * kIfInc + 2 * kDisjunctionInc + kThenInc); - m.Run("fff", kInitalVar + 3 * kIfInc + 2 * kDisjunctionInc + kElseInc); -} - - -TEST(RunExpressionStrings) { - const char* strings[] = { - "v", "(v)", "((v))", "v|v", - "(v|v)", "((v|v))", "v&v", "(v&v)", - "((v&v))", "v&(v)", "v&(v|v)", "v&(v|v)&v", - "v|(v)", "v|(v&v)", "v|(v&v)|v", "v|(((v)|(v&v)|(v)|v)&(v))|v", - }; - v8::base::RandomNumberGenerator rng; - for (size_t i = 0; i < ARRAY_SIZE(strings); i++) { - IfBuilderGenerator m; - m.ParseExpression(strings[i]); - m.RunRandom(&rng); - } -} - - -TEST(RunSimpleIfElseTester) { - const char* tests[] = { - "i(v)", "i(v)t", "i(v)te", - "i(v)er", "i(v)ter", "i(v)ti(v)trei(v)ei(v)ei(v)ei(v)ei(v)ei(v)ei(v)e"}; - v8::base::RandomNumberGenerator rng; - for (size_t i = 0; i < ARRAY_SIZE(tests); ++i) { - IfBuilderGenerator m; - m.ParseIfThenElse(tests[i]); - m.RunRandom(&rng); - } -} - - -TEST(RunRandomExpressions) { - v8::base::RandomNumberGenerator rng; - for (int n_vars = 1; n_vars < 12; n_vars++) { - for (int i = 0; i < n_vars * n_vars + 10; i++) { - IfBuilderGenerator m; - m.ParseRandomIfThenElse(&rng, 1, n_vars); - m.RunRandom(&rng); - } - } -} - - -TEST(RunRandomIfElse) { - v8::base::RandomNumberGenerator rng; - for (int n_ifs = 1; n_ifs < 12; n_ifs++) { - for (int i = 0; i < n_ifs * n_ifs + 10; i++) { - IfBuilderGenerator m; - m.ParseRandomIfThenElse(&rng, n_ifs, 1); - m.RunRandom(&rng); - } - } -} - - -TEST(RunRandomIfElseExpressions) { - v8::base::RandomNumberGenerator rng; - for (int n_vars = 2; n_vars < 6; n_vars++) { - for (int n_ifs = 2; n_ifs < 7; n_ifs++) { - for (int i = 0; i < n_ifs * n_vars + 10; i++) { - IfBuilderGenerator m; - m.ParseRandomIfThenElse(&rng, n_ifs, n_vars); - m.RunRandom(&rng); - } - } - } -} - -#endif diff --git a/deps/v8/test/cctest/compiler/test-structured-machine-assembler.cc b/deps/v8/test/cctest/compiler/test-structured-machine-assembler.cc deleted file mode 100644 index 6d8020baf4..0000000000 --- a/deps/v8/test/cctest/compiler/test-structured-machine-assembler.cc +++ /dev/null @@ -1,1055 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/v8.h" -#include "test/cctest/cctest.h" - -#include "src/base/utils/random-number-generator.h" -#include "src/compiler/structured-machine-assembler.h" -#include "test/cctest/compiler/codegen-tester.h" -#include "test/cctest/compiler/value-helper.h" - -#if V8_TURBOFAN_TARGET - -using namespace v8::internal::compiler; - -typedef StructuredMachineAssembler::IfBuilder IfBuilder; -typedef StructuredMachineAssembler::LoopBuilder Loop; - -namespace v8 { -namespace internal { -namespace compiler { - -class StructuredMachineAssemblerFriend { - public: - static bool VariableAlive(StructuredMachineAssembler* m, - const Variable& var) { - CHECK(m->current_environment_ != NULL); - int offset = var.offset_; - return offset < static_cast<int>(m->CurrentVars()->size()) && - m->CurrentVars()->at(offset) != NULL; - } -}; -} -} -} // namespace v8::internal::compiler - - -TEST(RunVariable) { - StructuredMachineAssemblerTester<int32_t> m; - - int32_t constant = 0x86c2bb16; - - Variable v1 = m.NewVariable(m.Int32Constant(constant)); - Variable v2 = m.NewVariable(v1.Get()); - m.Return(v2.Get()); - - CHECK_EQ(constant, m.Call()); -} - - -TEST(RunSimpleIf) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0xc4a3e3a6; - { - IfBuilder cond(&m); - cond.If(m.Parameter(0)).Then(); - m.Return(m.Int32Constant(constant)); - } - m.Return(m.Word32Not(m.Int32Constant(constant))); - - CHECK_EQ(~constant, m.Call(0)); - CHECK_EQ(constant, m.Call(1)); -} - - -TEST(RunSimpleIfVariable) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0xdb6f20c2; - Variable var = m.NewVariable(m.Int32Constant(constant)); - { - IfBuilder cond(&m); - cond.If(m.Parameter(0)).Then(); - var.Set(m.Word32Not(var.Get())); - } - m.Return(var.Get()); - - CHECK_EQ(constant, m.Call(0)); - CHECK_EQ(~constant, m.Call(1)); -} - - -TEST(RunSimpleElse) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0xfc5eadf4; - { - IfBuilder cond(&m); - cond.If(m.Parameter(0)).Else(); - m.Return(m.Int32Constant(constant)); - } - m.Return(m.Word32Not(m.Int32Constant(constant))); - - CHECK_EQ(constant, m.Call(0)); - CHECK_EQ(~constant, m.Call(1)); -} - - -TEST(RunSimpleIfElse) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0xaa9c8cd3; - { - IfBuilder cond(&m); - cond.If(m.Parameter(0)).Then(); - m.Return(m.Int32Constant(constant)); - cond.Else(); - m.Return(m.Word32Not(m.Int32Constant(constant))); - } - - CHECK_EQ(~constant, m.Call(0)); - CHECK_EQ(constant, m.Call(1)); -} - - -TEST(RunSimpleIfElseVariable) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0x67b6f39c; - Variable var = m.NewVariable(m.Int32Constant(constant)); - { - IfBuilder cond(&m); - cond.If(m.Parameter(0)).Then(); - var.Set(m.Word32Not(m.Word32Not(var.Get()))); - cond.Else(); - var.Set(m.Word32Not(var.Get())); - } - m.Return(var.Get()); - - CHECK_EQ(~constant, m.Call(0)); - CHECK_EQ(constant, m.Call(1)); -} - - -TEST(RunSimpleIfNoThenElse) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0xd5e550ed; - { - IfBuilder cond(&m); - cond.If(m.Parameter(0)); - } - m.Return(m.Int32Constant(constant)); - - CHECK_EQ(constant, m.Call(0)); - CHECK_EQ(constant, m.Call(1)); -} - - -TEST(RunSimpleConjunctionVariable) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0xf8fb9ec6; - Variable var = m.NewVariable(m.Int32Constant(constant)); - { - IfBuilder cond(&m); - cond.If(m.Int32Constant(1)).And(); - var.Set(m.Word32Not(var.Get())); - cond.If(m.Parameter(0)).Then(); - var.Set(m.Word32Not(m.Word32Not(var.Get()))); - cond.Else(); - var.Set(m.Word32Not(var.Get())); - } - m.Return(var.Get()); - - CHECK_EQ(constant, m.Call(0)); - CHECK_EQ(~constant, m.Call(1)); -} - - -TEST(RunSimpleDisjunctionVariable) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0x118f6ffc; - Variable var = m.NewVariable(m.Int32Constant(constant)); - { - IfBuilder cond(&m); - cond.If(m.Int32Constant(0)).Or(); - var.Set(m.Word32Not(var.Get())); - cond.If(m.Parameter(0)).Then(); - var.Set(m.Word32Not(m.Word32Not(var.Get()))); - cond.Else(); - var.Set(m.Word32Not(var.Get())); - } - m.Return(var.Get()); - - CHECK_EQ(constant, m.Call(0)); - CHECK_EQ(~constant, m.Call(1)); -} - - -TEST(RunIfElse) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - { - IfBuilder cond(&m); - bool first = true; - FOR_INT32_INPUTS(i) { - Node* c = m.Int32Constant(*i); - if (first) { - cond.If(m.Word32Equal(m.Parameter(0), c)).Then(); - m.Return(c); - first = false; - } else { - cond.Else(); - cond.If(m.Word32Equal(m.Parameter(0), c)).Then(); - m.Return(c); - } - } - } - m.Return(m.Int32Constant(333)); - - FOR_INT32_INPUTS(i) { CHECK_EQ(*i, m.Call(*i)); } -} - - -enum IfBuilderBranchType { kSkipBranch, kBranchFallsThrough, kBranchReturns }; - - -static IfBuilderBranchType all_branch_types[] = { - kSkipBranch, kBranchFallsThrough, kBranchReturns}; - - -static void RunIfBuilderDisjunction(size_t max, IfBuilderBranchType then_type, - IfBuilderBranchType else_type) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - std::vector<int32_t> inputs = ValueHelper::int32_vector(); - std::vector<int32_t>::const_iterator i = inputs.begin(); - int32_t hit = 0x8c723c9a; - int32_t miss = 0x88a6b9f3; - { - Node* p0 = m.Parameter(0); - IfBuilder cond(&m); - for (size_t j = 0; j < max; j++, ++i) { - CHECK(i != inputs.end()); // Thank you STL. - if (j > 0) cond.Or(); - cond.If(m.Word32Equal(p0, m.Int32Constant(*i))); - } - switch (then_type) { - case kSkipBranch: - break; - case kBranchFallsThrough: - cond.Then(); - break; - case kBranchReturns: - cond.Then(); - m.Return(m.Int32Constant(hit)); - break; - } - switch (else_type) { - case kSkipBranch: - break; - case kBranchFallsThrough: - cond.Else(); - break; - case kBranchReturns: - cond.Else(); - m.Return(m.Int32Constant(miss)); - break; - } - } - if (then_type != kBranchReturns || else_type != kBranchReturns) { - m.Return(m.Int32Constant(miss)); - } - - if (then_type != kBranchReturns) hit = miss; - - i = inputs.begin(); - for (size_t j = 0; i != inputs.end(); j++, ++i) { - int32_t result = m.Call(*i); - CHECK_EQ(j < max ? hit : miss, result); - } -} - - -TEST(RunIfBuilderDisjunction) { - size_t len = ValueHelper::int32_vector().size() - 1; - size_t max = len > 10 ? 10 : len - 1; - for (size_t i = 0; i < ARRAY_SIZE(all_branch_types); i++) { - for (size_t j = 0; j < ARRAY_SIZE(all_branch_types); j++) { - for (size_t size = 1; size < max; size++) { - RunIfBuilderDisjunction(size, all_branch_types[i], all_branch_types[j]); - } - RunIfBuilderDisjunction(len, all_branch_types[i], all_branch_types[j]); - } - } -} - - -static void RunIfBuilderConjunction(size_t max, IfBuilderBranchType then_type, - IfBuilderBranchType else_type) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - std::vector<int32_t> inputs = ValueHelper::int32_vector(); - std::vector<int32_t>::const_iterator i = inputs.begin(); - int32_t hit = 0xa0ceb9ca; - int32_t miss = 0x226cafaa; - { - IfBuilder cond(&m); - Node* p0 = m.Parameter(0); - for (size_t j = 0; j < max; j++, ++i) { - if (j > 0) cond.And(); - cond.If(m.Word32NotEqual(p0, m.Int32Constant(*i))); - } - switch (then_type) { - case kSkipBranch: - break; - case kBranchFallsThrough: - cond.Then(); - break; - case kBranchReturns: - cond.Then(); - m.Return(m.Int32Constant(hit)); - break; - } - switch (else_type) { - case kSkipBranch: - break; - case kBranchFallsThrough: - cond.Else(); - break; - case kBranchReturns: - cond.Else(); - m.Return(m.Int32Constant(miss)); - break; - } - } - if (then_type != kBranchReturns || else_type != kBranchReturns) { - m.Return(m.Int32Constant(miss)); - } - - if (then_type != kBranchReturns) hit = miss; - - i = inputs.begin(); - for (size_t j = 0; i != inputs.end(); j++, ++i) { - int32_t result = m.Call(*i); - CHECK_EQ(j >= max ? hit : miss, result); - } -} - - -TEST(RunIfBuilderConjunction) { - size_t len = ValueHelper::int32_vector().size() - 1; - size_t max = len > 10 ? 10 : len - 1; - for (size_t i = 0; i < ARRAY_SIZE(all_branch_types); i++) { - for (size_t j = 0; j < ARRAY_SIZE(all_branch_types); j++) { - for (size_t size = 1; size < max; size++) { - RunIfBuilderConjunction(size, all_branch_types[i], all_branch_types[j]); - } - RunIfBuilderConjunction(len, all_branch_types[i], all_branch_types[j]); - } - } -} - - -static void RunDisjunctionVariables(int disjunctions, bool explicit_then, - bool explicit_else) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0x65a09535; - - Node* cmp_val = m.Int32Constant(constant); - Node* one = m.Int32Constant(1); - Variable var = m.NewVariable(m.Parameter(0)); - { - IfBuilder cond(&m); - cond.If(m.Word32Equal(var.Get(), cmp_val)); - for (int i = 0; i < disjunctions; i++) { - cond.Or(); - var.Set(m.Int32Add(var.Get(), one)); - cond.If(m.Word32Equal(var.Get(), cmp_val)); - } - if (explicit_then) { - cond.Then(); - } - if (explicit_else) { - cond.Else(); - var.Set(m.Int32Add(var.Get(), one)); - } - } - m.Return(var.Get()); - - int adds = disjunctions + (explicit_else ? 1 : 0); - int32_t input = constant - 2 * adds; - for (int i = 0; i < adds; i++) { - CHECK_EQ(input + adds, m.Call(input)); - input++; - } - for (int i = 0; i < adds + 1; i++) { - CHECK_EQ(constant, m.Call(input)); - input++; - } - for (int i = 0; i < adds; i++) { - CHECK_EQ(input + adds, m.Call(input)); - input++; - } -} - - -TEST(RunDisjunctionVariables) { - for (int disjunctions = 0; disjunctions < 10; disjunctions++) { - RunDisjunctionVariables(disjunctions, false, false); - RunDisjunctionVariables(disjunctions, false, true); - RunDisjunctionVariables(disjunctions, true, false); - RunDisjunctionVariables(disjunctions, true, true); - } -} - - -static void RunConjunctionVariables(int conjunctions, bool explicit_then, - bool explicit_else) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - int32_t constant = 0x2c7f4b45; - Node* cmp_val = m.Int32Constant(constant); - Node* one = m.Int32Constant(1); - Variable var = m.NewVariable(m.Parameter(0)); - { - IfBuilder cond(&m); - cond.If(m.Word32NotEqual(var.Get(), cmp_val)); - for (int i = 0; i < conjunctions; i++) { - cond.And(); - var.Set(m.Int32Add(var.Get(), one)); - cond.If(m.Word32NotEqual(var.Get(), cmp_val)); - } - if (explicit_then) { - cond.Then(); - var.Set(m.Int32Add(var.Get(), one)); - } - if (explicit_else) { - cond.Else(); - } - } - m.Return(var.Get()); - - int adds = conjunctions + (explicit_then ? 1 : 0); - int32_t input = constant - 2 * adds; - for (int i = 0; i < adds; i++) { - CHECK_EQ(input + adds, m.Call(input)); - input++; - } - for (int i = 0; i < adds + 1; i++) { - CHECK_EQ(constant, m.Call(input)); - input++; - } - for (int i = 0; i < adds; i++) { - CHECK_EQ(input + adds, m.Call(input)); - input++; - } -} - - -TEST(RunConjunctionVariables) { - for (int conjunctions = 0; conjunctions < 10; conjunctions++) { - RunConjunctionVariables(conjunctions, false, false); - RunConjunctionVariables(conjunctions, false, true); - RunConjunctionVariables(conjunctions, true, false); - RunConjunctionVariables(conjunctions, true, true); - } -} - - -TEST(RunSimpleNestedIf) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); - const size_t NUM_VALUES = 7; - std::vector<int32_t> inputs = ValueHelper::int32_vector(); - CHECK(inputs.size() >= NUM_VALUES); - Node* values[NUM_VALUES]; - for (size_t j = 0; j < NUM_VALUES; j++) { - values[j] = m.Int32Constant(inputs[j]); - } - { - IfBuilder if_0(&m); - if_0.If(m.Word32Equal(m.Parameter(0), values[0])).Then(); - { - IfBuilder if_1(&m); - if_1.If(m.Word32Equal(m.Parameter(1), values[1])).Then(); - { m.Return(values[3]); } - if_1.Else(); - { m.Return(values[4]); } - } - if_0.Else(); - { - IfBuilder if_1(&m); - if_1.If(m.Word32Equal(m.Parameter(1), values[2])).Then(); - { m.Return(values[5]); } - if_1.Else(); - { m.Return(values[6]); } - } - } - - int32_t result = m.Call(inputs[0], inputs[1]); - CHECK_EQ(inputs[3], result); - - result = m.Call(inputs[0], inputs[1] + 1); - CHECK_EQ(inputs[4], result); - - result = m.Call(inputs[0] + 1, inputs[2]); - CHECK_EQ(inputs[5], result); - - result = m.Call(inputs[0] + 1, inputs[2] + 1); - CHECK_EQ(inputs[6], result); -} - - -TEST(RunUnreachableBlockAfterIf) { - StructuredMachineAssemblerTester<int32_t> m; - { - IfBuilder cond(&m); - cond.If(m.Int32Constant(0)).Then(); - m.Return(m.Int32Constant(1)); - cond.Else(); - m.Return(m.Int32Constant(2)); - } - // This is unreachable. - m.Return(m.Int32Constant(3)); - CHECK_EQ(2, m.Call()); -} - - -TEST(RunUnreachableBlockAfterLoop) { - StructuredMachineAssemblerTester<int32_t> m; - { - Loop loop(&m); - m.Return(m.Int32Constant(1)); - } - // This is unreachable. - m.Return(m.Int32Constant(3)); - CHECK_EQ(1, m.Call()); -} - - -TEST(RunSimpleLoop) { - StructuredMachineAssemblerTester<int32_t> m; - int32_t constant = 0x120c1f85; - { - Loop loop(&m); - m.Return(m.Int32Constant(constant)); - } - CHECK_EQ(constant, m.Call()); -} - - -TEST(RunSimpleLoopBreak) { - StructuredMachineAssemblerTester<int32_t> m; - int32_t constant = 0x10ddb0a6; - { - Loop loop(&m); - loop.Break(); - } - m.Return(m.Int32Constant(constant)); - CHECK_EQ(constant, m.Call()); -} - - -TEST(RunCountToTen) { - StructuredMachineAssemblerTester<int32_t> m; - Variable i = m.NewVariable(m.Int32Constant(0)); - Node* ten = m.Int32Constant(10); - Node* one = m.Int32Constant(1); - { - Loop loop(&m); - { - IfBuilder cond(&m); - cond.If(m.Word32Equal(i.Get(), ten)).Then(); - loop.Break(); - } - i.Set(m.Int32Add(i.Get(), one)); - } - m.Return(i.Get()); - CHECK_EQ(10, m.Call()); -} - - -TEST(RunCountToTenAcc) { - StructuredMachineAssemblerTester<int32_t> m; - int32_t constant = 0xf27aed64; - Variable i = m.NewVariable(m.Int32Constant(0)); - Variable var = m.NewVariable(m.Int32Constant(constant)); - Node* ten = m.Int32Constant(10); - Node* one = m.Int32Constant(1); - { - Loop loop(&m); - { - IfBuilder cond(&m); - cond.If(m.Word32Equal(i.Get(), ten)).Then(); - loop.Break(); - } - i.Set(m.Int32Add(i.Get(), one)); - var.Set(m.Int32Add(var.Get(), i.Get())); - } - m.Return(var.Get()); - - CHECK_EQ(constant + 10 + 9 * 5, m.Call()); -} - - -TEST(RunSimpleNestedLoop) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - Node* zero = m.Int32Constant(0); - Node* one = m.Int32Constant(1); - Node* two = m.Int32Constant(2); - Node* three = m.Int32Constant(3); - { - Loop l1(&m); - { - Loop l2(&m); - { - IfBuilder cond(&m); - cond.If(m.Word32Equal(m.Parameter(0), one)).Then(); - l1.Break(); - } - { - Loop l3(&m); - { - IfBuilder cond(&m); - cond.If(m.Word32Equal(m.Parameter(0), two)).Then(); - l2.Break(); - cond.Else(); - cond.If(m.Word32Equal(m.Parameter(0), three)).Then(); - l3.Break(); - } - m.Return(three); - } - m.Return(two); - } - m.Return(one); - } - m.Return(zero); - - CHECK_EQ(0, m.Call(1)); - CHECK_EQ(1, m.Call(2)); - CHECK_EQ(2, m.Call(3)); - CHECK_EQ(3, m.Call(4)); -} - - -TEST(RunFib) { - StructuredMachineAssemblerTester<int32_t> m(kMachineWord32); - - // Constants. - Node* zero = m.Int32Constant(0); - Node* one = m.Int32Constant(1); - Node* two = m.Int32Constant(2); - // Variables. - // cnt = input - Variable cnt = m.NewVariable(m.Parameter(0)); - // if (cnt < 2) return i - { - IfBuilder lt2(&m); - lt2.If(m.Int32LessThan(cnt.Get(), two)).Then(); - m.Return(cnt.Get()); - } - // cnt -= 2 - cnt.Set(m.Int32Sub(cnt.Get(), two)); - // res = 1 - Variable res = m.NewVariable(one); - { - // prv_0 = 1 - // prv_1 = 1 - Variable prv_0 = m.NewVariable(one); - Variable prv_1 = m.NewVariable(one); - // while (cnt != 0) { - Loop main(&m); - { - IfBuilder nz(&m); - nz.If(m.Word32Equal(cnt.Get(), zero)).Then(); - main.Break(); - } - // res = prv_0 + prv_1 - // prv_0 = prv_1 - // prv_1 = res - res.Set(m.Int32Add(prv_0.Get(), prv_1.Get())); - prv_0.Set(prv_1.Get()); - prv_1.Set(res.Get()); - // cnt-- - cnt.Set(m.Int32Sub(cnt.Get(), one)); - } - m.Return(res.Get()); - - int32_t values[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144}; - for (size_t i = 0; i < ARRAY_SIZE(values); i++) { - CHECK_EQ(values[i], m.Call(static_cast<int32_t>(i))); - } -} - - -static int VariableIntroduction() { - while (true) { - int ret = 0; - for (int i = 0; i < 10; i++) { - for (int j = i; j < 10; j++) { - for (int k = j; k < 10; k++) { - ret++; - } - ret++; - } - ret++; - } - return ret; - } -} - - -TEST(RunVariableIntroduction) { - StructuredMachineAssemblerTester<int32_t> m; - Node* zero = m.Int32Constant(0); - Node* one = m.Int32Constant(1); - // Use an IfBuilder to get out of start block. - { - IfBuilder i0(&m); - i0.If(zero).Then(); - m.Return(one); - } - Node* ten = m.Int32Constant(10); - Variable v0 = - m.NewVariable(zero); // Introduce variable outside of start block. - { - Loop l0(&m); - Variable ret = m.NewVariable(zero); // Introduce loop variable. - { - Loop l1(&m); - { - IfBuilder i1(&m); - i1.If(m.Word32Equal(v0.Get(), ten)).Then(); - l1.Break(); - } - Variable v1 = m.NewVariable(v0.Get()); // Introduce loop variable. - { - Loop l2(&m); - { - IfBuilder i2(&m); - i2.If(m.Word32Equal(v1.Get(), ten)).Then(); - l2.Break(); - } - Variable v2 = m.NewVariable(v1.Get()); // Introduce loop variable. - { - Loop l3(&m); - { - IfBuilder i3(&m); - i3.If(m.Word32Equal(v2.Get(), ten)).Then(); - l3.Break(); - } - ret.Set(m.Int32Add(ret.Get(), one)); - v2.Set(m.Int32Add(v2.Get(), one)); - } - ret.Set(m.Int32Add(ret.Get(), one)); - v1.Set(m.Int32Add(v1.Get(), one)); - } - ret.Set(m.Int32Add(ret.Get(), one)); - v0.Set(m.Int32Add(v0.Get(), one)); - } - m.Return(ret.Get()); // Return loop variable. - } - CHECK_EQ(VariableIntroduction(), m.Call()); -} - - -TEST(RunIfBuilderVariableLiveness) { - StructuredMachineAssemblerTester<int32_t> m; - typedef i::compiler::StructuredMachineAssemblerFriend F; - Node* zero = m.Int32Constant(0); - Variable v_outer = m.NewVariable(zero); - IfBuilder cond(&m); - cond.If(zero).Then(); - Variable v_then = m.NewVariable(zero); - CHECK(F::VariableAlive(&m, v_outer)); - CHECK(F::VariableAlive(&m, v_then)); - cond.Else(); - Variable v_else = m.NewVariable(zero); - CHECK(F::VariableAlive(&m, v_outer)); - CHECK(F::VariableAlive(&m, v_else)); - CHECK(!F::VariableAlive(&m, v_then)); - cond.End(); - CHECK(F::VariableAlive(&m, v_outer)); - CHECK(!F::VariableAlive(&m, v_then)); - CHECK(!F::VariableAlive(&m, v_else)); -} - - -TEST(RunSimpleExpression1) { - StructuredMachineAssemblerTester<int32_t> m; - - int32_t constant = 0x0c2974ef; - Node* zero = m.Int32Constant(0); - Node* one = m.Int32Constant(1); - { - // if (((1 && 1) && 1) && 1) return constant; return 0; - IfBuilder cond(&m); - cond.OpenParen(); - cond.OpenParen().If(one).And(); - cond.If(one).CloseParen().And(); - cond.If(one).CloseParen().And(); - cond.If(one).Then(); - m.Return(m.Int32Constant(constant)); - } - m.Return(zero); - - CHECK_EQ(constant, m.Call()); -} - - -TEST(RunSimpleExpression2) { - StructuredMachineAssemblerTester<int32_t> m; - - int32_t constant = 0x2eddc11b; - Node* zero = m.Int32Constant(0); - Node* one = m.Int32Constant(1); - { - // if (((0 || 1) && 1) && 1) return constant; return 0; - IfBuilder cond(&m); - cond.OpenParen(); - cond.OpenParen().If(zero).Or(); - cond.If(one).CloseParen().And(); - cond.If(one).CloseParen().And(); - cond.If(one).Then(); - m.Return(m.Int32Constant(constant)); - } - m.Return(zero); - - CHECK_EQ(constant, m.Call()); -} - - -TEST(RunSimpleExpression3) { - StructuredMachineAssemblerTester<int32_t> m; - - int32_t constant = 0x9ed5e9ef; - Node* zero = m.Int32Constant(0); - Node* one = m.Int32Constant(1); - { - // if (1 && ((0 || 1) && 1) && 1) return constant; return 0; - IfBuilder cond(&m); - cond.If(one).And(); - cond.OpenParen(); - cond.OpenParen().If(zero).Or(); - cond.If(one).CloseParen().And(); - cond.If(one).CloseParen().And(); - cond.If(one).Then(); - m.Return(m.Int32Constant(constant)); - } - m.Return(zero); - - CHECK_EQ(constant, m.Call()); -} - - -TEST(RunSimpleExpressionVariable1) { - StructuredMachineAssemblerTester<int32_t> m; - - int32_t constant = 0x4b40a986; - Node* one = m.Int32Constant(1); - Variable var = m.NewVariable(m.Int32Constant(constant)); - { - // if (var.Get() && ((!var || var) && var) && var) {} return var; - // incrementing var in each environment. - IfBuilder cond(&m); - cond.If(var.Get()).And(); - var.Set(m.Int32Add(var.Get(), one)); - cond.OpenParen().OpenParen().If(m.Word32BinaryNot(var.Get())).Or(); - var.Set(m.Int32Add(var.Get(), one)); - cond.If(var.Get()).CloseParen().And(); - var.Set(m.Int32Add(var.Get(), one)); - cond.If(var.Get()).CloseParen().And(); - var.Set(m.Int32Add(var.Get(), one)); - cond.If(var.Get()); - } - m.Return(var.Get()); - - CHECK_EQ(constant + 4, m.Call()); -} - - -class QuicksortHelper : public StructuredMachineAssemblerTester<int32_t> { - public: - QuicksortHelper() - : StructuredMachineAssemblerTester<int32_t>( - MachineOperatorBuilder::pointer_rep(), kMachineWord32, - MachineOperatorBuilder::pointer_rep(), kMachineWord32), - input_(NULL), - stack_limit_(NULL), - one_(Int32Constant(1)), - stack_frame_size_(Int32Constant(kFrameVariables * 4)), - left_offset_(Int32Constant(0 * 4)), - right_offset_(Int32Constant(1 * 4)) { - Build(); - } - - int32_t DoCall(int32_t* input, int32_t input_length) { - int32_t stack_space[20]; - // Do call. - int32_t return_val = Call(input, input_length, stack_space, - static_cast<int32_t>(ARRAY_SIZE(stack_space))); - // Ran out of stack space. - if (return_val != 0) return return_val; - // Check sorted. - int32_t last = input[0]; - for (int32_t i = 0; i < input_length; i++) { - CHECK(last <= input[i]); - last = input[i]; - } - return return_val; - } - - private: - void Inc32(const Variable& var) { var.Set(Int32Add(var.Get(), one_)); } - Node* Index(Node* index) { return Word32Shl(index, Int32Constant(2)); } - Node* ArrayLoad(Node* index) { - return Load(kMachineWord32, input_, Index(index)); - } - void Swap(Node* a_index, Node* b_index) { - Node* a = ArrayLoad(a_index); - Node* b = ArrayLoad(b_index); - Store(kMachineWord32, input_, Index(a_index), b); - Store(kMachineWord32, input_, Index(b_index), a); - } - void AddToCallStack(const Variable& fp, Node* left, Node* right) { - { - // Stack limit check. - IfBuilder cond(this); - cond.If(IntPtrLessThanOrEqual(fp.Get(), stack_limit_)).Then(); - Return(Int32Constant(-1)); - } - Store(kMachineWord32, fp.Get(), left_offset_, left); - Store(kMachineWord32, fp.Get(), right_offset_, right); - fp.Set(IntPtrAdd(fp.Get(), ConvertInt32ToIntPtr(stack_frame_size_))); - } - void Build() { - Variable left = NewVariable(Int32Constant(0)); - Variable right = - NewVariable(Int32Sub(Parameter(kInputLengthParameter), one_)); - input_ = Parameter(kInputParameter); - Node* top_of_stack = Parameter(kStackParameter); - stack_limit_ = IntPtrSub( - top_of_stack, ConvertInt32ToIntPtr(Parameter(kStackLengthParameter))); - Variable fp = NewVariable(top_of_stack); - { - Loop outermost(this); - // Edge case - 2 element array. - { - IfBuilder cond(this); - cond.If(Word32Equal(left.Get(), Int32Sub(right.Get(), one_))).And(); - cond.If(Int32LessThanOrEqual(ArrayLoad(right.Get()), - ArrayLoad(left.Get()))).Then(); - Swap(left.Get(), right.Get()); - } - { - IfBuilder cond(this); - // Algorithm complete condition. - cond.If(WordEqual(top_of_stack, fp.Get())).And(); - cond.If(Int32LessThanOrEqual(Int32Sub(right.Get(), one_), left.Get())) - .Then(); - outermost.Break(); - // 'Recursion' exit condition. Pop frame and continue. - cond.Else(); - cond.If(Int32LessThanOrEqual(Int32Sub(right.Get(), one_), left.Get())) - .Then(); - fp.Set(IntPtrSub(fp.Get(), ConvertInt32ToIntPtr(stack_frame_size_))); - left.Set(Load(kMachineWord32, fp.Get(), left_offset_)); - right.Set(Load(kMachineWord32, fp.Get(), right_offset_)); - outermost.Continue(); - } - // Partition. - Variable store_index = NewVariable(left.Get()); - { - Node* pivot_index = - Int32Div(Int32Add(left.Get(), right.Get()), Int32Constant(2)); - Node* pivot = ArrayLoad(pivot_index); - Swap(pivot_index, right.Get()); - Variable i = NewVariable(left.Get()); - { - Loop partition(this); - { - IfBuilder cond(this); - // Parition complete. - cond.If(Word32Equal(i.Get(), right.Get())).Then(); - partition.Break(); - // Need swap. - cond.Else(); - cond.If(Int32LessThanOrEqual(ArrayLoad(i.Get()), pivot)).Then(); - Swap(i.Get(), store_index.Get()); - Inc32(store_index); - } - Inc32(i); - } // End partition loop. - Swap(store_index.Get(), right.Get()); - } - // 'Recurse' left and right halves of partition. - // Tail recurse second one. - AddToCallStack(fp, left.Get(), Int32Sub(store_index.Get(), one_)); - left.Set(Int32Add(store_index.Get(), one_)); - } // End outermost loop. - Return(Int32Constant(0)); - } - - static const int kFrameVariables = 2; // left, right - // Parameter offsets. - static const int kInputParameter = 0; - static const int kInputLengthParameter = 1; - static const int kStackParameter = 2; - static const int kStackLengthParameter = 3; - // Function inputs. - Node* input_; - Node* stack_limit_; - // Constants. - Node* const one_; - // Frame constants. - Node* const stack_frame_size_; - Node* const left_offset_; - Node* const right_offset_; -}; - - -TEST(RunSimpleQuicksort) { - QuicksortHelper m; - int32_t inputs[] = {9, 7, 1, 8, 11}; - CHECK_EQ(0, m.DoCall(inputs, ARRAY_SIZE(inputs))); -} - - -TEST(RunRandomQuicksort) { - QuicksortHelper m; - - v8::base::RandomNumberGenerator rng; - static const int kMaxLength = 40; - int32_t inputs[kMaxLength]; - - for (int length = 1; length < kMaxLength; length++) { - for (int i = 0; i < 70; i++) { - // Randomize inputs. - for (int j = 0; j < length; j++) { - inputs[j] = rng.NextInt(10) - 5; - } - CHECK_EQ(0, m.DoCall(inputs, length)); - } - } -} - - -TEST(MultipleScopes) { - StructuredMachineAssemblerTester<int32_t> m; - for (int i = 0; i < 10; i++) { - IfBuilder b(&m); - b.If(m.Int32Constant(0)).Then(); - m.NewVariable(m.Int32Constant(0)); - } - m.Return(m.Int32Constant(0)); - CHECK_EQ(0, m.Call()); -} - -#endif diff --git a/deps/v8/test/cctest/compiler/value-helper.h b/deps/v8/test/cctest/compiler/value-helper.h index 5bfd7884d0..7d7c11e4f1 100644 --- a/deps/v8/test/cctest/compiler/value-helper.h +++ b/deps/v8/test/cctest/compiler/value-helper.h @@ -27,34 +27,29 @@ class ValueHelper { ValueHelper() : isolate_(CcTest::InitIsolateOnce()) {} - template <typename T> - void CheckConstant(T expected, Node* node) { - CHECK_EQ(expected, ValueOf<T>(node->op())); - } - void CheckFloat64Constant(double expected, Node* node) { CHECK_EQ(IrOpcode::kFloat64Constant, node->opcode()); - CHECK_EQ(expected, ValueOf<double>(node->op())); + CHECK_EQ(expected, OpParameter<double>(node)); } void CheckNumberConstant(double expected, Node* node) { CHECK_EQ(IrOpcode::kNumberConstant, node->opcode()); - CHECK_EQ(expected, ValueOf<double>(node->op())); + CHECK_EQ(expected, OpParameter<double>(node)); } void CheckInt32Constant(int32_t expected, Node* node) { CHECK_EQ(IrOpcode::kInt32Constant, node->opcode()); - CHECK_EQ(expected, ValueOf<int32_t>(node->op())); + CHECK_EQ(expected, OpParameter<int32_t>(node)); } void CheckUint32Constant(int32_t expected, Node* node) { CHECK_EQ(IrOpcode::kInt32Constant, node->opcode()); - CHECK_EQ(expected, ValueOf<uint32_t>(node->op())); + CHECK_EQ(expected, OpParameter<uint32_t>(node)); } void CheckHeapConstant(Object* expected, Node* node) { CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); - CHECK_EQ(expected, *ValueOf<Handle<Object> >(node->op())); + CHECK_EQ(expected, *OpParameter<Unique<Object> >(node).handle()); } void CheckTrue(Node* node) { @@ -65,6 +60,45 @@ class ValueHelper { CheckHeapConstant(isolate_->heap()->false_value(), node); } + static std::vector<float> float32_vector() { + static const float kValues[] = { + -std::numeric_limits<float>::infinity(), -2.70497e+38f, -1.4698e+37f, + -1.22813e+35f, -1.20555e+35f, -1.34584e+34f, + -1.0079e+32f, -6.49364e+26f, -3.06077e+25f, + -1.46821e+25f, -1.17658e+23f, -1.9617e+22f, + -2.7357e+20f, -1.48708e+13f, -1.89633e+12f, + -4.66622e+11f, -2.22581e+11f, -1.45381e+10f, + -1.3956e+09f, -1.32951e+09f, -1.30721e+09f, + -1.19756e+09f, -9.26822e+08f, -6.35647e+08f, + -4.00037e+08f, -1.81227e+08f, -5.09256e+07f, + -964300.0f, -192446.0f, -28455.0f, + -27194.0f, -26401.0f, -20575.0f, + -17069.0f, -9167.0f, -960.178f, + -113.0f, -62.0f, -15.0f, + -7.0f, -0.0256635f, -4.60374e-07f, + -3.63759e-10f, -4.30175e-14f, -5.27385e-15f, + -1.48084e-15f, -1.05755e-19f, -3.2995e-21f, + -1.67354e-23f, -1.11885e-23f, -1.78506e-30f, + -5.07594e-31f, -3.65799e-31f, -1.43718e-34f, + -1.27126e-38f, -0.0f, 0.0f, + 1.17549e-38f, 1.56657e-37f, 4.08512e-29f, + 3.31357e-28f, 6.25073e-22f, 4.1723e-13f, + 1.44343e-09f, 5.27004e-08f, 9.48298e-08f, + 5.57888e-07f, 4.89988e-05f, 0.244326f, + 12.4895f, 19.0f, 47.0f, + 106.0f, 538.324f, 564.536f, + 819.124f, 7048.0f, 12611.0f, + 19878.0f, 20309.0f, 797056.0f, + 1.77219e+09f, 1.51116e+11f, 4.18193e+13f, + 3.59167e+16f, 3.38211e+19f, 2.67488e+20f, + 1.78831e+21f, 9.20914e+21f, 8.35654e+23f, + 1.4495e+24f, 5.94015e+25f, 4.43608e+30f, + 2.44502e+33f, 2.61152e+33f, 1.38178e+37f, + 1.71306e+37f, 3.31899e+38f, 3.40282e+38f, + std::numeric_limits<float>::infinity()}; + return std::vector<float>(&kValues[0], &kValues[arraysize(kValues)]); + } + static std::vector<double> float64_vector() { static const double nan = v8::base::OS::nan_value(); static const double values[] = { @@ -76,7 +110,7 @@ class ValueHelper { -V8_INFINITY, nan, 2147483647.375, 2147483647.75, 2147483648.0, 2147483648.25, 2147483649.25, -2147483647.0, -2147483647.125, -2147483647.875, -2147483648.25, -2147483649.5}; - return std::vector<double>(&values[0], &values[ARRAY_SIZE(values)]); + return std::vector<double>(&values[0], &values[arraysize(values)]); } static const std::vector<int32_t> int32_vector() { @@ -94,7 +128,7 @@ class ValueHelper { 0xeeeeeeee, 0xfffffffd, 0xf0000000, 0x007fffff, 0x003fffff, 0x001fffff, 0x000fffff, 0x0007ffff, 0x0003ffff, 0x0001ffff, 0x0000ffff, 0x00007fff, 0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff}; - return std::vector<uint32_t>(&kValues[0], &kValues[ARRAY_SIZE(kValues)]); + return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]); } static const std::vector<double> nan_vector(size_t limit = 0) { @@ -102,14 +136,14 @@ class ValueHelper { static const double values[] = {-nan, -V8_INFINITY * -0.0, -V8_INFINITY * 0.0, V8_INFINITY * -0.0, V8_INFINITY * 0.0, nan}; - return std::vector<double>(&values[0], &values[ARRAY_SIZE(values)]); + return std::vector<double>(&values[0], &values[arraysize(values)]); } static const std::vector<uint32_t> ror_vector() { static const uint32_t kValues[31] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; - return std::vector<uint32_t>(&kValues[0], &kValues[ARRAY_SIZE(kValues)]); + return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]); } }; @@ -122,8 +156,13 @@ class ValueHelper { #define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var) #define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var) +#define FOR_FLOAT32_INPUTS(var) FOR_INPUTS(float, float32, var) #define FOR_FLOAT64_INPUTS(var) FOR_INPUTS(double, float64, var) +#define FOR_INT32_SHIFTS(var) for (int32_t var = 0; var < 32; var++) + +#define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++) + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-alloc.cc b/deps/v8/test/cctest/test-alloc.cc index 314c3c1479..d647a3128e 100644 --- a/deps/v8/test/cctest/test-alloc.cc +++ b/deps/v8/test/cctest/test-alloc.cc @@ -106,7 +106,7 @@ TEST(StressHandles) { void TestGetter( - v8::Local<v8::String> name, + v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); HandleScope scope(isolate); @@ -115,7 +115,7 @@ void TestGetter( void TestSetter( - v8::Local<v8::String> name, + v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { UNREACHABLE(); @@ -124,7 +124,7 @@ void TestSetter( Handle<AccessorInfo> TestAccessorInfo( Isolate* isolate, PropertyAttributes attributes) { - Handle<String> name = isolate->factory()->NewStringFromStaticAscii("get"); + Handle<String> name = isolate->factory()->NewStringFromStaticChars("get"); return Accessors::MakeAccessor(isolate, name, &TestGetter, &TestSetter, attributes); } diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index 9ddc9db71d..0330ac892f 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -63,6 +63,7 @@ using ::v8::FunctionTemplate; using ::v8::Handle; using ::v8::HandleScope; using ::v8::Local; +using ::v8::Name; using ::v8::Message; using ::v8::MessageCallback; using ::v8::Object; @@ -71,6 +72,7 @@ using ::v8::Persistent; using ::v8::Script; using ::v8::StackTrace; using ::v8::String; +using ::v8::Symbol; using ::v8::TryCatch; using ::v8::Undefined; using ::v8::UniqueId; @@ -128,19 +130,18 @@ static void SignatureCallback( // Tests that call v8::V8::Dispose() cannot be threaded. -TEST(InitializeAndDisposeOnce) { +UNINITIALIZED_TEST(InitializeAndDisposeOnce) { CHECK(v8::V8::Initialize()); CHECK(v8::V8::Dispose()); } // Tests that call v8::V8::Dispose() cannot be threaded. -TEST(InitializeAndDisposeMultiple) { +UNINITIALIZED_TEST(InitializeAndDisposeMultiple) { for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize()); for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); - // TODO(mstarzinger): This should fail gracefully instead of asserting. - // for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize()); + for (int i = 0; i < 3; ++i) CHECK(v8::V8::Initialize()); for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); } @@ -261,7 +262,7 @@ THREADED_TEST(ReceiverSignature) { const char* test_objects[] = { "fun_instance", "sub_fun_instance", "obj", "unrel" }; unsigned bad_signature_start_offset = 2; - for (unsigned i = 0; i < ARRAY_SIZE(test_objects); i++) { + for (unsigned i = 0; i < arraysize(test_objects); i++) { i::ScopedVector<char> source(200); i::SNPrintF( source, "var test_object = %s; test_object", test_objects[i]); @@ -436,16 +437,16 @@ class TestResource: public String::ExternalStringResource { }; -class TestAsciiResource: public String::ExternalAsciiStringResource { +class TestOneByteResource : public String::ExternalOneByteStringResource { public: - explicit TestAsciiResource(const char* data, int* counter = NULL, - size_t offset = 0) + explicit TestOneByteResource(const char* data, int* counter = NULL, + size_t offset = 0) : orig_data_(data), data_(data + offset), length_(strlen(data) - offset), counter_(counter) {} - ~TestAsciiResource() { + ~TestOneByteResource() { i::DeleteArray(orig_data_); if (counter_ != NULL) ++*counter_; } @@ -495,22 +496,22 @@ THREADED_TEST(ScriptUsingStringResource) { } -THREADED_TEST(ScriptUsingAsciiStringResource) { +THREADED_TEST(ScriptUsingOneByteStringResource) { int dispose_count = 0; const char* c_source = "1 + 2 * 3"; { LocalContext env; v8::HandleScope scope(env->GetIsolate()); - TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source), - &dispose_count); + TestOneByteResource* resource = + new TestOneByteResource(i::StrDup(c_source), &dispose_count); Local<String> source = String::NewExternal(env->GetIsolate(), resource); - CHECK(source->IsExternalAscii()); + CHECK(source->IsExternalOneByte()); CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), - source->GetExternalAsciiStringResource()); + source->GetExternalOneByteStringResource()); String::Encoding encoding = String::UNKNOWN_ENCODING; CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), source->GetExternalStringResourceBase(&encoding)); - CHECK_EQ(String::ASCII_ENCODING, encoding); + CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); Local<Script> script = v8_compile(source); Local<Value> value = script->Run(); CHECK(value->IsNumber()); @@ -536,10 +537,10 @@ THREADED_TEST(ScriptMakingExternalString) { CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now CHECK_EQ(source->IsExternal(), false); - CHECK_EQ(source->IsExternalAscii(), false); + CHECK_EQ(source->IsExternalOneByte(), false); String::Encoding encoding = String::UNKNOWN_ENCODING; CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); - CHECK_EQ(String::ASCII_ENCODING, encoding); + CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); bool success = source->MakeExternal(new TestResource(two_byte_source, &dispose_count)); CHECK(success); @@ -556,7 +557,7 @@ THREADED_TEST(ScriptMakingExternalString) { } -THREADED_TEST(ScriptMakingExternalAsciiString) { +THREADED_TEST(ScriptMakingExternalOneByteString) { int dispose_count = 0; const char* c_source = "1 + 2 * 3"; { @@ -567,7 +568,7 @@ THREADED_TEST(ScriptMakingExternalAsciiString) { CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now bool success = source->MakeExternal( - new TestAsciiResource(i::StrDup(c_source), &dispose_count)); + new TestOneByteResource(i::StrDup(c_source), &dispose_count)); CHECK(success); Local<Script> script = v8_compile(source); Local<Value> value = script->Run(); @@ -630,7 +631,7 @@ TEST(MakingExternalStringConditions) { } -TEST(MakingExternalAsciiStringConditions) { +TEST(MakingExternalOneByteStringConditions) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -667,7 +668,7 @@ TEST(MakingExternalAsciiStringConditions) { } -TEST(MakingExternalUnalignedAsciiString) { +TEST(MakingExternalUnalignedOneByteString) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -687,12 +688,12 @@ TEST(MakingExternalUnalignedAsciiString) { // Turn into external string with unaligned resource data. const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; - bool success = cons->MakeExternal( - new TestAsciiResource(i::StrDup(c_cons), NULL, 1)); + bool success = + cons->MakeExternal(new TestOneByteResource(i::StrDup(c_cons), NULL, 1)); CHECK(success); const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; - success = slice->MakeExternal( - new TestAsciiResource(i::StrDup(c_slice), NULL, 1)); + success = + slice->MakeExternal(new TestOneByteResource(i::StrDup(c_slice), NULL, 1)); CHECK(success); // Trigger GCs and force evacuation. @@ -721,13 +722,13 @@ THREADED_TEST(UsingExternalString) { } -THREADED_TEST(UsingExternalAsciiString) { +THREADED_TEST(UsingExternalOneByteString) { i::Factory* factory = CcTest::i_isolate()->factory(); { v8::HandleScope scope(CcTest::isolate()); const char* one_byte_string = "test string"; Local<String> string = String::NewExternal( - CcTest::isolate(), new TestAsciiResource(i::StrDup(one_byte_string))); + CcTest::isolate(), new TestOneByteResource(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. CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now @@ -741,6 +742,53 @@ THREADED_TEST(UsingExternalAsciiString) { } +class DummyResource : public v8::String::ExternalStringResource { + public: + virtual const uint16_t* data() const { return string_; } + virtual size_t length() const { return 1 << 30; } + + private: + uint16_t string_[10]; +}; + + +class DummyOneByteResource : public v8::String::ExternalOneByteStringResource { + public: + virtual const char* data() const { return string_; } + virtual size_t length() const { return 1 << 30; } + + private: + char string_[10]; +}; + + +THREADED_TEST(NewExternalForVeryLongString) { + { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::TryCatch try_catch; + DummyOneByteResource r; + v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); + CHECK(str.IsEmpty()); + CHECK(try_catch.HasCaught()); + String::Utf8Value exception_value(try_catch.Exception()); + CHECK_EQ("RangeError: Invalid string length", *exception_value); + } + + { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::TryCatch try_catch; + DummyResource r; + v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); + CHECK(str.IsEmpty()); + CHECK(try_catch.HasCaught()); + String::Utf8Value exception_value(try_catch.Exception()); + CHECK_EQ("RangeError: Invalid string length", *exception_value); + } +} + + THREADED_TEST(ScavengeExternalString) { i::FLAG_stress_compaction = false; i::FLAG_gc_global = false; @@ -763,7 +811,7 @@ THREADED_TEST(ScavengeExternalString) { } -THREADED_TEST(ScavengeExternalAsciiString) { +THREADED_TEST(ScavengeExternalOneByteString) { i::FLAG_stress_compaction = false; i::FLAG_gc_global = false; int dispose_count = 0; @@ -773,7 +821,7 @@ THREADED_TEST(ScavengeExternalAsciiString) { const char* one_byte_string = "test string"; Local<String> string = String::NewExternal( CcTest::isolate(), - new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); + new TestOneByteResource(i::StrDup(one_byte_string), &dispose_count)); i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); CcTest::heap()->CollectGarbage(i::NEW_SPACE); in_new_space = CcTest::heap()->InNewSpace(*istring); @@ -786,15 +834,14 @@ THREADED_TEST(ScavengeExternalAsciiString) { } -class TestAsciiResourceWithDisposeControl: public TestAsciiResource { +class TestOneByteResourceWithDisposeControl : public TestOneByteResource { public: // Only used by non-threaded tests, so it can use static fields. static int dispose_calls; static int dispose_count; - TestAsciiResourceWithDisposeControl(const char* data, bool dispose) - : TestAsciiResource(data, &dispose_count), - dispose_(dispose) { } + TestOneByteResourceWithDisposeControl(const char* data, bool dispose) + : TestOneByteResource(data, &dispose_count), dispose_(dispose) {} void Dispose() { ++dispose_calls; @@ -805,17 +852,17 @@ class TestAsciiResourceWithDisposeControl: public TestAsciiResource { }; -int TestAsciiResourceWithDisposeControl::dispose_count = 0; -int TestAsciiResourceWithDisposeControl::dispose_calls = 0; +int TestOneByteResourceWithDisposeControl::dispose_count = 0; +int TestOneByteResourceWithDisposeControl::dispose_calls = 0; TEST(ExternalStringWithDisposeHandling) { const char* c_source = "1 + 2 * 3"; // Use a stack allocated external string resource allocated object. - TestAsciiResourceWithDisposeControl::dispose_count = 0; - TestAsciiResourceWithDisposeControl::dispose_calls = 0; - TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); + TestOneByteResourceWithDisposeControl::dispose_count = 0; + TestOneByteResourceWithDisposeControl::dispose_calls = 0; + TestOneByteResourceWithDisposeControl res_stack(i::StrDup(c_source), false); { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -825,18 +872,18 @@ TEST(ExternalStringWithDisposeHandling) { CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); CcTest::heap()->CollectAllAvailableGarbage(); - CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); + CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count); } CcTest::i_isolate()->compilation_cache()->Clear(); CcTest::heap()->CollectAllAvailableGarbage(); - CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); - CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); + CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_calls); + CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count); // Use a heap allocated external string resource allocated object. - TestAsciiResourceWithDisposeControl::dispose_count = 0; - TestAsciiResourceWithDisposeControl::dispose_calls = 0; - TestAsciiResource* res_heap = - new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); + TestOneByteResourceWithDisposeControl::dispose_count = 0; + TestOneByteResourceWithDisposeControl::dispose_calls = 0; + TestOneByteResource* res_heap = + new TestOneByteResourceWithDisposeControl(i::StrDup(c_source), true); { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -846,12 +893,12 @@ TEST(ExternalStringWithDisposeHandling) { CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); CcTest::heap()->CollectAllAvailableGarbage(); - CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); + CHECK_EQ(0, TestOneByteResourceWithDisposeControl::dispose_count); } CcTest::i_isolate()->compilation_cache()->Clear(); CcTest::heap()->CollectAllAvailableGarbage(); - CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); - CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); + CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_calls); + CHECK_EQ(1, TestOneByteResourceWithDisposeControl::dispose_count); } @@ -875,7 +922,8 @@ THREADED_TEST(StringConcat) { Local<String> source = String::Concat(left, right); right = String::NewExternal( - env->GetIsolate(), new TestAsciiResource(i::StrDup(one_byte_extern_1))); + env->GetIsolate(), + new TestOneByteResource(i::StrDup(one_byte_extern_1))); source = String::Concat(source, right); right = String::NewExternal( env->GetIsolate(), @@ -1187,7 +1235,7 @@ THREADED_PROFILED_TEST(FastReturnValues) { 0, 234, -723, i::Smi::kMinValue, i::Smi::kMaxValue }; - for (size_t i = 0; i < ARRAY_SIZE(int_values); i++) { + for (size_t i = 0; i < arraysize(int_values); i++) { for (int modifier = -1; modifier <= 1; modifier++) { int int_value = int_values[i] + modifier; // check int32_t @@ -1219,7 +1267,7 @@ THREADED_PROFILED_TEST(FastReturnValues) { kUndefinedReturnValue, kEmptyStringReturnValue }; - for (size_t i = 0; i < ARRAY_SIZE(oddballs); i++) { + for (size_t i = 0; i < arraysize(oddballs); i++) { fast_return_value_void = oddballs[i]; value = TestFastReturnValues<void>(); switch (fast_return_value_void) { @@ -1541,6 +1589,83 @@ THREADED_TEST(IsNativeError) { } +THREADED_TEST(IsGeneratorFunctionOrObject) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + + CompileRun("function *gen() { yield 1; }\nfunction func() {}"); + v8::Handle<Value> gen = CompileRun("gen"); + v8::Handle<Value> genObj = CompileRun("gen()"); + v8::Handle<Value> object = CompileRun("{a:42}"); + v8::Handle<Value> func = CompileRun("func"); + + CHECK(gen->IsGeneratorFunction()); + CHECK(gen->IsFunction()); + CHECK(!gen->IsGeneratorObject()); + + CHECK(!genObj->IsGeneratorFunction()); + CHECK(!genObj->IsFunction()); + CHECK(genObj->IsGeneratorObject()); + + CHECK(!object->IsGeneratorFunction()); + CHECK(!object->IsFunction()); + CHECK(!object->IsGeneratorObject()); + + CHECK(!func->IsGeneratorFunction()); + CHECK(func->IsFunction()); + CHECK(!func->IsGeneratorObject()); +} + + +THREADED_TEST(ArgumentsObject) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::Handle<Value> arguments_object = + CompileRun("var out = 0; (function(){ out = arguments; })(1,2,3); out;"); + CHECK(arguments_object->IsArgumentsObject()); + v8::Handle<Value> array = CompileRun("[1,2,3]"); + CHECK(!array->IsArgumentsObject()); + v8::Handle<Value> object = CompileRun("{a:42}"); + CHECK(!object->IsArgumentsObject()); +} + + +THREADED_TEST(IsMapOrSet) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::Handle<Value> map = CompileRun("new Map()"); + v8::Handle<Value> set = CompileRun("new Set()"); + v8::Handle<Value> weak_map = CompileRun("new WeakMap()"); + v8::Handle<Value> weak_set = CompileRun("new WeakSet()"); + CHECK(map->IsMap()); + CHECK(set->IsSet()); + CHECK(weak_map->IsWeakMap()); + CHECK(weak_set->IsWeakSet()); + + CHECK(!map->IsSet()); + CHECK(!map->IsWeakMap()); + CHECK(!map->IsWeakSet()); + + CHECK(!set->IsMap()); + CHECK(!set->IsWeakMap()); + CHECK(!set->IsWeakSet()); + + CHECK(!weak_map->IsMap()); + CHECK(!weak_map->IsSet()); + CHECK(!weak_map->IsWeakSet()); + + CHECK(!weak_set->IsMap()); + CHECK(!weak_set->IsSet()); + CHECK(!weak_set->IsWeakMap()); + + v8::Handle<Value> object = CompileRun("{a:42}"); + CHECK(!object->IsMap()); + CHECK(!object->IsSet()); + CHECK(!object->IsWeakMap()); + CHECK(!object->IsWeakSet()); +} + + THREADED_TEST(StringObject) { LocalContext env; v8::HandleScope scope(env->GetIsolate()); @@ -1878,6 +2003,24 @@ void SimpleAccessorSetter(Local<String> name, Local<Value> value, self->Set(String::Concat(v8_str("accessor_"), name), value); } +void SymbolAccessorGetter(Local<Name> name, + const v8::PropertyCallbackInfo<v8::Value>& info) { + CHECK(name->IsSymbol()); + Local<Symbol> sym = Local<Symbol>::Cast(name); + if (sym->Name()->IsUndefined()) + return; + SimpleAccessorGetter(Local<String>::Cast(sym->Name()), info); +} + +void SymbolAccessorSetter(Local<Name> name, Local<Value> value, + const v8::PropertyCallbackInfo<void>& info) { + CHECK(name->IsSymbol()); + Local<Symbol> sym = Local<Symbol>::Cast(name); + if (sym->Name()->IsUndefined()) + return; + SimpleAccessorSetter(Local<String>::Cast(sym->Name()), value, info); +} + void EmptyInterceptorGetter(Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { } @@ -1936,6 +2079,14 @@ void AddInterceptor(Handle<FunctionTemplate> templ, } +void AddAccessor(Handle<FunctionTemplate> templ, + Handle<Name> name, + v8::AccessorNameGetterCallback getter, + v8::AccessorNameSetterCallback setter) { + templ->PrototypeTemplate()->SetAccessor(name, getter, setter); +} + + THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { v8::HandleScope scope(CcTest::isolate()); Handle<FunctionTemplate> parent = FunctionTemplate::New(CcTest::isolate()); @@ -1968,10 +2119,9 @@ THREADED_TEST(ExecutableAccessorIsPreservedOnAttributeChange) { i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); i::LookupResult lookup(i_isolate); i::Handle<i::String> name(v8::Utils::OpenHandle(*v8_str("length"))); - a->LookupOwnRealNamedProperty(name, &lookup); - CHECK(lookup.IsPropertyCallbacks()); - i::Handle<i::Object> callback(lookup.GetCallbackObject(), i_isolate); - CHECK(callback->IsExecutableAccessorInfo()); + i::LookupIterator it(a, name, i::LookupIterator::OWN_SKIP_INTERCEPTOR); + CHECK_EQ(i::LookupIterator::ACCESSOR, it.state()); + CHECK(it.GetAccessors()->IsExecutableAccessorInfo()); } @@ -2747,6 +2897,8 @@ THREADED_TEST(SymbolProperties) { v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, v8_str("my-symbol")); + v8::Local<v8::Symbol> sym3 = + v8::Symbol::New(isolate, v8_str("sym3")); CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); @@ -2802,31 +2954,62 @@ THREADED_TEST(SymbolProperties) { CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); + CHECK(obj->SetAccessor(sym3, SymbolAccessorGetter, SymbolAccessorSetter)); + CHECK(obj->Get(sym3)->IsUndefined()); + CHECK(obj->Set(sym3, v8::Integer::New(isolate, 42))); + CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); + CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( + v8::Integer::New(isolate, 42))); + // Add another property and delete it afterwards to force the object in // slow case. CHECK(obj->Set(sym2, v8::Integer::New(isolate, 2008))); CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); - CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); + CHECK_EQ(2, obj->GetOwnPropertyNames()->Length()); CHECK(obj->Has(sym1)); CHECK(obj->Has(sym2)); + CHECK(obj->Has(sym3)); + CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3"))); CHECK(obj->Delete(sym2)); CHECK(obj->Has(sym1)); CHECK(!obj->Has(sym2)); + CHECK(obj->Has(sym3)); + CHECK(obj->Has(v8::String::NewFromUtf8(isolate, "accessor_sym3"))); CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); - CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); + CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); + CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( + v8::Integer::New(isolate, 42))); + CHECK_EQ(2, obj->GetOwnPropertyNames()->Length()); // Symbol properties are inherited. v8::Local<v8::Object> child = v8::Object::New(isolate); child->SetPrototype(obj); CHECK(child->Has(sym1)); CHECK_EQ(2002, child->Get(sym1)->Int32Value()); + CHECK(obj->Get(sym3)->Equals(v8::Integer::New(isolate, 42))); + CHECK(obj->Get(v8::String::NewFromUtf8(isolate, "accessor_sym3"))->Equals( + v8::Integer::New(isolate, 42))); CHECK_EQ(0, child->GetOwnPropertyNames()->Length()); } +THREADED_TEST(SymbolTemplateProperties) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::Local<v8::FunctionTemplate> foo = v8::FunctionTemplate::New(isolate); + v8::Local<v8::Name> name = v8::Symbol::New(isolate); + CHECK(!name.IsEmpty()); + foo->PrototypeTemplate()->Set(name, v8::FunctionTemplate::New(isolate)); + v8::Local<v8::Object> new_instance = foo->InstanceTemplate()->NewInstance(); + CHECK(!new_instance.IsEmpty()); + CHECK(new_instance->Has(name)); +} + + THREADED_TEST(PrivateProperties) { LocalContext env; v8::Isolate* isolate = env->GetIsolate(); @@ -2911,6 +3094,29 @@ THREADED_TEST(GlobalSymbols) { } +static void CheckWellKnownSymbol(v8::Local<v8::Symbol>(*getter)(v8::Isolate*), + const char* name) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + + v8::Local<v8::Symbol> symbol = getter(isolate); + std::string script = std::string("var sym = ") + name; + CompileRun(script.c_str()); + v8::Local<Value> value = env->Global()->Get(v8_str("sym")); + + CHECK(!value.IsEmpty()); + CHECK(!symbol.IsEmpty()); + CHECK(value->SameValue(symbol)); +} + + +THREADED_TEST(WellKnownSymbols) { + CheckWellKnownSymbol(v8::Symbol::GetIterator, "Symbol.iterator"); + CheckWellKnownSymbol(v8::Symbol::GetUnscopables, "Symbol.unscopables"); +} + + THREADED_TEST(GlobalPrivates) { LocalContext env; v8::Isolate* isolate = env->GetIsolate(); @@ -9412,18 +9618,14 @@ TEST(AccessControlES5) { } -static bool GetOwnPropertyNamesNamedBlocker(Local<v8::Object> global, - Local<Value> name, - v8::AccessType type, - Local<Value> data) { +static bool BlockEverythingNamed(Local<v8::Object> object, Local<Value> name, + v8::AccessType type, Local<Value> data) { return false; } -static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global, - uint32_t key, - v8::AccessType type, - Local<Value> data) { +static bool BlockEverythingIndexed(Local<v8::Object> object, uint32_t key, + v8::AccessType type, Local<Value> data) { return false; } @@ -9435,8 +9637,8 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) { v8::ObjectTemplate::New(isolate); obj_template->Set(v8_str("x"), v8::Integer::New(isolate, 42)); - obj_template->SetAccessCheckCallbacks(GetOwnPropertyNamesNamedBlocker, - GetOwnPropertyNamesIndexedBlocker); + obj_template->SetAccessCheckCallbacks(BlockEverythingNamed, + BlockEverythingIndexed); // Create an environment v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template); @@ -9471,6 +9673,50 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) { } +TEST(SuperAccessControl) { + i::FLAG_harmony_classes = true; + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope handle_scope(isolate); + v8::Handle<v8::ObjectTemplate> obj_template = + v8::ObjectTemplate::New(isolate); + obj_template->SetAccessCheckCallbacks(BlockEverythingNamed, + BlockEverythingIndexed); + LocalContext env; + env->Global()->Set(v8_str("prohibited"), obj_template->NewInstance()); + + { + v8::TryCatch try_catch; + CompileRun( + "function f() { return super.hasOwnProperty; };" + "var m = f.toMethod(prohibited);" + "m();"); + CHECK(try_catch.HasCaught()); + } + + { + v8::TryCatch try_catch; + CompileRun( + "function f() { super.hasOwnProperty = function () {}; };" + "var m = f.toMethod(prohibited);" + "m();"); + CHECK(try_catch.HasCaught()); + } + + { + v8::TryCatch try_catch; + CompileRun( + "Object.defineProperty(Object.prototype, 'x', { set : function(){}});" + "function f() { " + " 'use strict';" + " super.x = function () {}; " + "};" + "var m = f.toMethod(prohibited);" + "m();"); + CHECK(try_catch.HasCaught()); + } +} + + static void IndexedPropertyEnumerator( const v8::PropertyCallbackInfo<v8::Array>& info) { v8::Handle<v8::Array> result = v8::Array::New(info.GetIsolate(), 2); @@ -14040,19 +14286,14 @@ void SetFunctionEntryHookTest::RunLoopInNewEnv(v8::Isolate* isolate) { void SetFunctionEntryHookTest::RunTest() { // Work in a new isolate throughout. - v8::Isolate* isolate = v8::Isolate::New(); - - // Test setting the entry hook on the new isolate. - CHECK(v8::V8::SetFunctionEntryHook(isolate, EntryHook)); - - // Replacing the hook, once set should fail. - CHECK_EQ(false, v8::V8::SetFunctionEntryHook(isolate, EntryHook)); + v8::Isolate::CreateParams create_params; + create_params.entry_hook = EntryHook; + create_params.code_event_handler = JitEvent; + v8::Isolate* isolate = v8::Isolate::New(create_params); { v8::Isolate::Scope scope(isolate); - v8::V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, JitEvent); - RunLoopInNewEnv(isolate); // Check the exepected invocation counts. @@ -14080,9 +14321,6 @@ void SetFunctionEntryHookTest::RunTest() { // We should record no invocations in this isolate. CHECK_EQ(0, static_cast<int>(invocations_.size())); } - // Since the isolate has been used, we shouldn't be able to set an entry - // hook anymore. - CHECK_EQ(false, v8::V8::SetFunctionEntryHook(isolate, EntryHook)); isolate->Dispose(); } @@ -14276,7 +14514,7 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) { saw_bar = 0; move_events = 0; - V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); + isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); // Generate new code objects sparsely distributed across several // different fragmented code-space pages. @@ -14300,7 +14538,7 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) { // Force code movement. heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); - V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); + isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); CHECK_LE(kIterations, saw_bar); CHECK_LT(0, move_events); @@ -14330,8 +14568,9 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) { i::HashMap lineinfo(MatchPointers); jitcode_line_info = &lineinfo; - V8::SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, event_handler); - V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); + isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting, + event_handler); + isolate->SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); jitcode_line_info = NULL; // We expect that we got some events. Note that if we could get code removal @@ -15003,11 +15242,11 @@ TEST(ObjectClone) { } -class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { +class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { public: - explicit AsciiVectorResource(i::Vector<const char> vector) + explicit OneByteVectorResource(i::Vector<const char> vector) : data_(vector) {} - virtual ~AsciiVectorResource() {} + virtual ~OneByteVectorResource() {} virtual size_t length() const { return data_.length(); } virtual const char* data() const { return data_.start(); } private: @@ -15028,12 +15267,12 @@ class UC16VectorResource : public v8::String::ExternalStringResource { static void MorphAString(i::String* string, - AsciiVectorResource* ascii_resource, + OneByteVectorResource* one_byte_resource, UC16VectorResource* uc16_resource) { CHECK(i::StringShape(string).IsExternal()); if (string->IsOneByteRepresentation()) { // Check old map is not internalized or long. - CHECK(string->map() == CcTest::heap()->external_ascii_string_map()); + CHECK(string->map() == CcTest::heap()->external_one_byte_string_map()); // Morph external string to be TwoByte string. string->set_map(CcTest::heap()->external_string_map()); i::ExternalTwoByteString* morphed = @@ -15042,11 +15281,10 @@ static void MorphAString(i::String* string, } else { // Check old map is not internalized or long. CHECK(string->map() == CcTest::heap()->external_string_map()); - // Morph external string to be ASCII string. - string->set_map(CcTest::heap()->external_ascii_string_map()); - i::ExternalAsciiString* morphed = - i::ExternalAsciiString::cast(string); - morphed->set_resource(ascii_resource); + // Morph external string to be one-byte string. + string->set_map(CcTest::heap()->external_one_byte_string_map()); + i::ExternalOneByteString* morphed = i::ExternalOneByteString::cast(string); + morphed->set_resource(one_byte_resource); } } @@ -15062,18 +15300,18 @@ THREADED_TEST(MorphCompositeStringTest) { LocalContext env; i::Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(env->GetIsolate()); - AsciiVectorResource ascii_resource( + OneByteVectorResource one_byte_resource( i::Vector<const char>(c_string, i::StrLength(c_string))); UC16VectorResource uc16_resource( i::Vector<const uint16_t>(two_byte_string, i::StrLength(c_string))); - Local<String> lhs(v8::Utils::ToLocal( - factory->NewExternalStringFromAscii(&ascii_resource) - .ToHandleChecked())); - Local<String> rhs(v8::Utils::ToLocal( - factory->NewExternalStringFromAscii(&ascii_resource) - .ToHandleChecked())); + Local<String> lhs( + v8::Utils::ToLocal(factory->NewExternalStringFromOneByte( + &one_byte_resource).ToHandleChecked())); + Local<String> rhs( + v8::Utils::ToLocal(factory->NewExternalStringFromOneByte( + &one_byte_resource).ToHandleChecked())); env->Global()->Set(v8_str("lhs"), lhs); env->Global()->Set(v8_str("rhs"), rhs); @@ -15086,8 +15324,10 @@ THREADED_TEST(MorphCompositeStringTest) { CHECK(lhs->IsOneByte()); CHECK(rhs->IsOneByte()); - MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource); - MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource); + MorphAString(*v8::Utils::OpenHandle(*lhs), &one_byte_resource, + &uc16_resource); + MorphAString(*v8::Utils::OpenHandle(*rhs), &one_byte_resource, + &uc16_resource); // This should UTF-8 without flattening, since everything is ASCII. Handle<String> cons = v8_compile("cons")->Run().As<String>(); @@ -15130,16 +15370,15 @@ TEST(CompileExternalTwoByteSource) { // This is a very short list of sources, which currently is to check for a // regression caused by r2703. - const char* ascii_sources[] = { - "0.5", - "-0.5", // This mainly testes PushBack in the Scanner. - "--0.5", // This mainly testes PushBack in the Scanner. - NULL - }; + const char* one_byte_sources[] = { + "0.5", + "-0.5", // This mainly testes PushBack in the Scanner. + "--0.5", // This mainly testes PushBack in the Scanner. + NULL}; // Compile the sources as external two byte strings. - for (int i = 0; ascii_sources[i] != NULL; i++) { - uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]); + for (int i = 0; one_byte_sources[i] != NULL; i++) { + uint16_t* two_byte_string = AsciiToTwoByteString(one_byte_sources[i]); TestResource* uc16_resource = new TestResource(two_byte_string); v8::Local<v8::String> source = v8::String::NewExternal(context->GetIsolate(), uc16_resource); @@ -15198,14 +15437,14 @@ TEST(RegExpInterruption) { RegExpInterruptionThread timeout_thread(CcTest::isolate()); v8::V8::AddGCPrologueCallback(RunBeforeGC); - static const char* ascii_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - i::uc16* uc16_content = AsciiToTwoByteString(ascii_content); - v8::Local<v8::String> string = v8_str(ascii_content); + static const char* one_byte_content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + i::uc16* uc16_content = AsciiToTwoByteString(one_byte_content); + v8::Local<v8::String> string = v8_str(one_byte_content); CcTest::global()->Set(v8_str("a"), string); regexp_interruption_data.string.Reset(CcTest::isolate(), string); regexp_interruption_data.string_resource = new UC16VectorResource( - i::Vector<const i::uc16>(uc16_content, i::StrLength(ascii_content))); + i::Vector<const i::uc16>(uc16_content, i::StrLength(one_byte_content))); v8::TryCatch try_catch; timeout_thread.Start(); @@ -17697,14 +17936,13 @@ TEST(IdleNotificationWithLargeHint) { TEST(Regress2107) { const intptr_t MB = 1024 * 1024; - const int kShortIdlePauseInMs = 100; - const int kLongIdlePauseInMs = 1000; + const int kIdlePauseInMs = 1000; LocalContext env; v8::Isolate* isolate = env->GetIsolate(); v8::HandleScope scope(env->GetIsolate()); intptr_t initial_size = CcTest::heap()->SizeOfObjects(); // Send idle notification to start a round of incremental GCs. - env->GetIsolate()->IdleNotification(kShortIdlePauseInMs); + env->GetIsolate()->IdleNotification(kIdlePauseInMs); // Emulate 7 page reloads. for (int i = 0; i < 7; i++) { { @@ -17715,7 +17953,7 @@ TEST(Regress2107) { ctx->Exit(); } env->GetIsolate()->ContextDisposedNotification(); - env->GetIsolate()->IdleNotification(kLongIdlePauseInMs); + env->GetIsolate()->IdleNotification(kIdlePauseInMs); } // Create garbage and check that idle notification still collects it. CreateGarbageInOldSpace(); @@ -17723,7 +17961,7 @@ TEST(Regress2107) { CHECK_GT(size_with_garbage, initial_size + MB); bool finished = false; for (int i = 0; i < 200 && !finished; i++) { - finished = env->GetIsolate()->IdleNotification(kShortIdlePauseInMs); + finished = env->GetIsolate()->IdleNotification(kIdlePauseInMs); } intptr_t final_size = CcTest::heap()->SizeOfObjects(); CHECK_LT(final_size, initial_size + 1); @@ -17764,13 +18002,11 @@ static uint32_t* ComputeStackLimit(uint32_t size) { static const int stack_breathing_room = 256 * i::KB; -TEST(SetResourceConstraints) { +TEST(SetStackLimit) { uint32_t* set_limit = ComputeStackLimit(stack_breathing_room); // Set stack limit. - v8::ResourceConstraints constraints; - constraints.set_stack_limit(set_limit); - CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints)); + CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit)); // Execute a script. LocalContext env; @@ -17785,16 +18021,14 @@ TEST(SetResourceConstraints) { } -TEST(SetResourceConstraintsInThread) { +TEST(SetStackLimitInThread) { uint32_t* set_limit; { v8::Locker locker(CcTest::isolate()); set_limit = ComputeStackLimit(stack_breathing_room); // Set stack limit. - v8::ResourceConstraints constraints; - constraints.set_stack_limit(set_limit); - CHECK(v8::SetResourceConstraints(CcTest::isolate(), &constraints)); + CcTest::isolate()->SetStackLimit(reinterpret_cast<uintptr_t>(set_limit)); // Execute a script. v8::HandleScope scope(CcTest::isolate()); @@ -17837,7 +18071,7 @@ class VisitorImpl : public v8::ExternalResourceVisitor { virtual ~VisitorImpl() {} virtual void VisitExternalString(v8::Handle<v8::String> string) { if (!string->IsExternal()) { - CHECK(string->IsExternalAscii()); + CHECK(string->IsExternalOneByte()); return; } v8::String::ExternalStringResource* resource = @@ -17894,12 +18128,12 @@ TEST(ExternalizeOldSpaceOneByteCons) { CHECK(CcTest::heap()->old_pointer_space()->Contains( *v8::Utils::OpenHandle(*cons))); - TestAsciiResource* resource = - new TestAsciiResource(i::StrDup("Romeo Montague Juliet Capulet")); + TestOneByteResource* resource = + new TestOneByteResource(i::StrDup("Romeo Montague Juliet Capulet")); cons->MakeExternal(resource); - CHECK(cons->IsExternalAscii()); - CHECK_EQ(resource, cons->GetExternalAsciiStringResource()); + CHECK(cons->IsExternalOneByte()); + CHECK_EQ(resource, cons->GetExternalOneByteStringResource()); String::Encoding encoding; CHECK_EQ(resource, cons->GetExternalStringResourceBase(&encoding)); CHECK_EQ(String::ONE_BYTE_ENCODING, encoding); @@ -17954,8 +18188,8 @@ TEST(ExternalStringCollectedAtTearDown) { { v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); const char* s = "One string to test them all, one string to find them."; - TestAsciiResource* inscription = - new TestAsciiResource(i::StrDup(s), &destroyed); + TestOneByteResource* inscription = + new TestOneByteResource(i::StrDup(s), &destroyed); v8::Local<v8::String> ring = v8::String::NewExternal(isolate, inscription); // Ring is still alive. Orcs are roaming freely across our lands. CHECK_EQ(0, destroyed); @@ -17976,8 +18210,8 @@ TEST(ExternalInternalizedStringCollectedAtTearDown) { v8::HandleScope handle_scope(isolate); CompileRun("var ring = 'One string to test them all';"); const char* s = "One string to test them all"; - TestAsciiResource* inscription = - new TestAsciiResource(i::StrDup(s), &destroyed); + TestOneByteResource* inscription = + new TestOneByteResource(i::StrDup(s), &destroyed); v8::Local<v8::String> ring = CompileRun("ring")->ToString(); CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString()); ring->MakeExternal(inscription); @@ -17998,8 +18232,8 @@ TEST(ExternalInternalizedStringCollectedAtGC) { v8::HandleScope handle_scope(env->GetIsolate()); CompileRun("var ring = 'One string to test them all';"); const char* s = "One string to test them all"; - TestAsciiResource* inscription = - new TestAsciiResource(i::StrDup(s), &destroyed); + TestOneByteResource* inscription = + new TestOneByteResource(i::StrDup(s), &destroyed); v8::Local<v8::String> ring = CompileRun("ring")->ToString(); CHECK(v8::Utils::OpenHandle(*ring)->IsInternalizedString()); ring->MakeExternal(inscription); @@ -18942,7 +19176,7 @@ THREADED_TEST(TestEviction) { } -THREADED_TEST(TwoByteStringInAsciiCons) { +THREADED_TEST(TwoByteStringInOneByteCons) { // See Chromium issue 47824. LocalContext context; v8::HandleScope scope(context->GetIsolate()); @@ -18980,10 +19214,10 @@ THREADED_TEST(TwoByteStringInAsciiCons) { // If the cons string has been short-circuited, skip the following checks. if (!string.is_identical_to(flat_string)) { - // At this point, we should have a Cons string which is flat and ASCII, + // At this point, we should have a Cons string which is flat and one-byte, // with a first half that is a two-byte string (although it only contains - // ASCII characters). This is a valid sequence of steps, and it can happen - // in real pages. + // one-byte characters). This is a valid sequence of steps, and it can + // happen in real pages. CHECK(string->IsOneByteRepresentation()); i::ConsString* cons = i::ConsString::cast(*string); CHECK_EQ(0, cons->second()->length()); @@ -19071,7 +19305,7 @@ TEST(ContainsOnlyOneByte) { String::NewExternal(isolate, new TestResource(string_contents, NULL, false)); USE(two_byte); USE(cons_strings); - for (size_t i = 0; i < ARRAY_SIZE(cons_strings); i++) { + for (size_t i = 0; i < arraysize(cons_strings); i++) { // Base assumptions. string = cons_strings[i]; CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); @@ -19367,31 +19601,26 @@ static int CalcFibonacci(v8::Isolate* isolate, int limit) { class IsolateThread : public v8::base::Thread { public: - IsolateThread(v8::Isolate* isolate, int fib_limit) - : Thread(Options("IsolateThread")), - isolate_(isolate), - fib_limit_(fib_limit), - result_(0) {} + explicit IsolateThread(int fib_limit) + : Thread(Options("IsolateThread")), fib_limit_(fib_limit), result_(0) {} void Run() { - result_ = CalcFibonacci(isolate_, fib_limit_); + v8::Isolate* isolate = v8::Isolate::New(); + result_ = CalcFibonacci(isolate, fib_limit_); + isolate->Dispose(); } 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); + IsolateThread thread1(21); + IsolateThread thread2(12); // Compute some fibonacci numbers on 3 threads in 3 isolates. thread1.Start(); @@ -19409,9 +19638,6 @@ TEST(MultipleIsolatesOnIndividualThreads) { CHECK_EQ(result2, 144); CHECK_EQ(result1, thread1.result()); CHECK_EQ(result2, thread2.result()); - - isolate1->Dispose(); - isolate2->Dispose(); } @@ -19455,16 +19681,22 @@ class InitDefaultIsolateThread : public v8::base::Thread { result_(false) {} void Run() { - v8::Isolate* isolate = v8::Isolate::New(); - isolate->Enter(); + v8::Isolate::CreateParams create_params; switch (testCase_) { case SetResourceConstraints: { - v8::ResourceConstraints constraints; - constraints.set_max_semi_space_size(1); - constraints.set_max_old_space_size(4); - v8::SetResourceConstraints(CcTest::isolate(), &constraints); + create_params.constraints.set_max_semi_space_size(1); + create_params.constraints.set_max_old_space_size(4); break; } + default: + break; + } + v8::Isolate* isolate = v8::Isolate::New(create_params); + isolate->Enter(); + switch (testCase_) { + case SetResourceConstraints: + // Already handled in pre-Isolate-creation block. + break; case SetFatalHandler: v8::V8::SetFatalErrorHandler(NULL); @@ -21490,7 +21722,7 @@ THREADED_TEST(JSONParseNumber) { } -#if V8_OS_POSIX +#if V8_OS_POSIX && !V8_OS_NACL class ThreadInterruptTest { public: ThreadInterruptTest() : sem_(0), sem_value_(0) { } @@ -21689,7 +21921,6 @@ TEST(AccessCheckThrows) { // Create a context and set an x property on it's global object. LocalContext context0(NULL, global_template); - context0->Global()->Set(v8_str("x"), v8_num(42)); v8::Handle<v8::Object> global0 = context0->Global(); // Create a context with a different security token so that the @@ -22287,12 +22518,12 @@ class ApiCallOptimizationChecker { void RunAll() { SignatureType signature_types[] = {kNoSignature, kSignatureOnReceiver, kSignatureOnPrototype}; - for (unsigned i = 0; i < ARRAY_SIZE(signature_types); i++) { + for (unsigned i = 0; i < arraysize(signature_types); i++) { SignatureType signature_type = signature_types[i]; for (int j = 0; j < 2; j++) { bool global = j == 0; int key = signature_type + - ARRAY_SIZE(signature_types) * (global ? 1 : 0); + arraysize(signature_types) * (global ? 1 : 0); Run(signature_type, global, key); } } @@ -22736,32 +22967,6 @@ TEST(ScriptNameAndLineNumber) { } -Local<v8::Context> call_eval_context; -Local<v8::Function> call_eval_bound_function; -static void CallEval(const v8::FunctionCallbackInfo<v8::Value>& args) { - v8::Context::Scope scope(call_eval_context); - args.GetReturnValue().Set( - call_eval_bound_function->Call(call_eval_context->Global(), 0, NULL)); -} - - -TEST(CrossActivationEval) { - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - { - call_eval_context = v8::Context::New(isolate); - v8::Context::Scope scope(call_eval_context); - call_eval_bound_function = - Local<Function>::Cast(CompileRun("eval.bind(this, '1')")); - } - env->Global()->Set(v8_str("CallEval"), - v8::FunctionTemplate::New(isolate, CallEval)->GetFunction()); - Local<Value> result = CompileRun("CallEval();"); - CHECK_EQ(result, v8::Integer::New(isolate, 1)); -} - - void SourceURLHelper(const char* source, const char* expected_source_url, const char* expected_source_mapping_url) { Local<Script> script = v8_compile(source); @@ -22870,3 +23075,381 @@ TEST(GetOwnPropertyDescriptor) { set->Call(x, 1, args); CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); } + + +TEST(Regress411877) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope handle_scope(isolate); + v8::Handle<v8::ObjectTemplate> object_template = + v8::ObjectTemplate::New(isolate); + object_template->SetAccessCheckCallbacks(NamedAccessCounter, + IndexedAccessCounter); + + v8::Handle<Context> context = Context::New(isolate); + v8::Context::Scope context_scope(context); + + context->Global()->Set(v8_str("o"), object_template->NewInstance()); + CompileRun("Object.getOwnPropertyNames(o)"); +} + + +TEST(GetHiddenPropertyTableAfterAccessCheck) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope handle_scope(isolate); + v8::Handle<v8::ObjectTemplate> object_template = + v8::ObjectTemplate::New(isolate); + object_template->SetAccessCheckCallbacks(NamedAccessCounter, + IndexedAccessCounter); + + v8::Handle<Context> context = Context::New(isolate); + v8::Context::Scope context_scope(context); + + v8::Handle<v8::Object> obj = object_template->NewInstance(); + obj->Set(v8_str("key"), v8_str("value")); + obj->Delete(v8_str("key")); + + obj->SetHiddenValue(v8_str("hidden key 2"), v8_str("hidden value 2")); +} + + +TEST(Regress411793) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope handle_scope(isolate); + v8::Handle<v8::ObjectTemplate> object_template = + v8::ObjectTemplate::New(isolate); + object_template->SetAccessCheckCallbacks(NamedAccessCounter, + IndexedAccessCounter); + + v8::Handle<Context> context = Context::New(isolate); + v8::Context::Scope context_scope(context); + + context->Global()->Set(v8_str("o"), object_template->NewInstance()); + CompileRun( + "Object.defineProperty(o, 'key', " + " { get: function() {}, set: function() {} });"); +} + +class TestSourceStream : public v8::ScriptCompiler::ExternalSourceStream { + public: + explicit TestSourceStream(const char** chunks) : chunks_(chunks), index_(0) {} + + virtual size_t GetMoreData(const uint8_t** src) { + // Unlike in real use cases, this function will never block. + if (chunks_[index_] == NULL) { + return 0; + } + // Copy the data, since the caller takes ownership of it. + size_t len = strlen(chunks_[index_]); + // We don't need to zero-terminate since we return the length. + uint8_t* copy = new uint8_t[len]; + memcpy(copy, chunks_[index_], len); + *src = copy; + ++index_; + return len; + } + + // Helper for constructing a string from chunks (the compilation needs it + // too). + static char* FullSourceString(const char** chunks) { + size_t total_len = 0; + for (size_t i = 0; chunks[i] != NULL; ++i) { + total_len += strlen(chunks[i]); + } + char* full_string = new char[total_len + 1]; + size_t offset = 0; + for (size_t i = 0; chunks[i] != NULL; ++i) { + size_t len = strlen(chunks[i]); + memcpy(full_string + offset, chunks[i], len); + offset += len; + } + full_string[total_len] = 0; + return full_string; + } + + private: + const char** chunks_; + unsigned index_; +}; + + +// Helper function for running streaming tests. +void RunStreamingTest(const char** chunks, + v8::ScriptCompiler::StreamedSource::Encoding encoding = + v8::ScriptCompiler::StreamedSource::ONE_BYTE, + bool expected_success = true) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + v8::TryCatch try_catch; + + v8::ScriptCompiler::StreamedSource source(new TestSourceStream(chunks), + encoding); + v8::ScriptCompiler::ScriptStreamingTask* task = + v8::ScriptCompiler::StartStreamingScript(isolate, &source); + + // TestSourceStream::GetMoreData won't block, so it's OK to just run the + // task here in the main thread. + task->Run(); + delete task; + + v8::ScriptOrigin origin(v8_str("http://foo.com")); + char* full_source = TestSourceStream::FullSourceString(chunks); + + // The possible errors are only produced while compiling. + CHECK_EQ(false, try_catch.HasCaught()); + + v8::Handle<Script> script = v8::ScriptCompiler::Compile( + isolate, &source, v8_str(full_source), origin); + if (expected_success) { + CHECK(!script.IsEmpty()); + v8::Handle<Value> result(script->Run()); + // All scripts are supposed to return the fixed value 13 when ran. + CHECK_EQ(13, result->Int32Value()); + } else { + CHECK(script.IsEmpty()); + CHECK(try_catch.HasCaught()); + } + delete[] full_source; +} + + +TEST(StreamingSimpleScript) { + // This script is unrealistically small, since no one chunk is enough to fill + // the backing buffer of Scanner, let alone overflow it. + const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ", + NULL}; + RunStreamingTest(chunks); +} + + +TEST(StreamingBiggerScript) { + const char* chunk1 = + "function foo() {\n" + " // Make this chunk sufficiently long so that it will overflow the\n" + " // backing buffer of the Scanner.\n" + " var i = 0;\n" + " var result = 0;\n" + " for (i = 0; i < 13; ++i) { result = result + 1; }\n" + " result = 0;\n" + " for (i = 0; i < 13; ++i) { result = result + 1; }\n" + " result = 0;\n" + " for (i = 0; i < 13; ++i) { result = result + 1; }\n" + " result = 0;\n" + " for (i = 0; i < 13; ++i) { result = result + 1; }\n" + " return result;\n" + "}\n"; + const char* chunks[] = {chunk1, "foo(); ", NULL}; + RunStreamingTest(chunks); +} + + +TEST(StreamingScriptWithParseError) { + // Test that parse errors from streamed scripts are propagated correctly. + { + char chunk1[] = + " // This will result in a parse error.\n" + " var if else then foo"; + char chunk2[] = " 13\n"; + const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; + + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::ONE_BYTE, + false); + } + // Test that the next script succeeds normally. + { + char chunk1[] = + " // This will be parsed successfully.\n" + " function foo() { return "; + char chunk2[] = " 13; }\n"; + const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; + + RunStreamingTest(chunks); + } +} + + +TEST(StreamingUtf8Script) { + // We'd want to write \uc481 instead of \xeb\x91\x80, but Windows compilers + // don't like it. + const char* chunk1 = + "function foo() {\n" + " // This function will contain an UTF-8 character which is not in\n" + " // ASCII.\n" + " var foob\xeb\x91\x80r = 13;\n" + " return foob\xeb\x91\x80r;\n" + "}\n"; + const char* chunks[] = {chunk1, "foo(); ", NULL}; + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); +} + + +TEST(StreamingUtf8ScriptWithSplitCharactersSanityCheck) { + // A sanity check to prove that the approach of splitting UTF-8 + // characters is correct. Here is an UTF-8 character which will take three + // bytes. + const char* reference = "\xeb\x91\x80"; + CHECK(3u == strlen(reference)); // NOLINT - no CHECK_EQ for unsigned. + + char chunk1[] = + "function foo() {\n" + " // This function will contain an UTF-8 character which is not in\n" + " // ASCII.\n" + " var foob"; + char chunk2[] = + "XXXr = 13;\n" + " return foob\xeb\x91\x80r;\n" + "}\n"; + for (int i = 0; i < 3; ++i) { + chunk2[i] = reference[i]; + } + const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); +} + + +TEST(StreamingUtf8ScriptWithSplitCharacters) { + // Stream data where a multi-byte UTF-8 character is split between two data + // chunks. + const char* reference = "\xeb\x91\x80"; + char chunk1[] = + "function foo() {\n" + " // This function will contain an UTF-8 character which is not in\n" + " // ASCII.\n" + " var foobX"; + char chunk2[] = + "XXr = 13;\n" + " return foob\xeb\x91\x80r;\n" + "}\n"; + chunk1[strlen(chunk1) - 1] = reference[0]; + chunk2[0] = reference[1]; + chunk2[1] = reference[2]; + const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); +} + + +TEST(StreamingUtf8ScriptWithSplitCharactersValidEdgeCases) { + // Tests edge cases which should still be decoded correctly. + + // Case 1: a chunk contains only bytes for a split character (and no other + // data). This kind of a chunk would be exceptionally small, but we should + // still decode it correctly. + const char* reference = "\xeb\x91\x80"; + // The small chunk is at the beginning of the split character + { + char chunk1[] = + "function foo() {\n" + " // This function will contain an UTF-8 character which is not in\n" + " // ASCII.\n" + " var foob"; + char chunk2[] = "XX"; + char chunk3[] = + "Xr = 13;\n" + " return foob\xeb\x91\x80r;\n" + "}\n"; + chunk2[0] = reference[0]; + chunk2[1] = reference[1]; + chunk3[0] = reference[2]; + const char* chunks[] = {chunk1, chunk2, chunk3, "foo();", NULL}; + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); + } + // The small chunk is at the end of a character + { + char chunk1[] = + "function foo() {\n" + " // This function will contain an UTF-8 character which is not in\n" + " // ASCII.\n" + " var foobX"; + char chunk2[] = "XX"; + char chunk3[] = + "r = 13;\n" + " return foob\xeb\x91\x80r;\n" + "}\n"; + chunk1[strlen(chunk1) - 1] = reference[0]; + chunk2[0] = reference[1]; + chunk2[1] = reference[2]; + const char* chunks[] = {chunk1, chunk2, chunk3, "foo();", NULL}; + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); + } + // Case 2: the script ends with a multi-byte character. Make sure that it's + // decoded correctly and not just ignored. + { + char chunk1[] = + "var foob\xeb\x91\x80 = 13;\n" + "foob\xeb\x91\x80"; + const char* chunks[] = {chunk1, NULL}; + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); + } +} + + +TEST(StreamingUtf8ScriptWithSplitCharactersInvalidEdgeCases) { + // Test cases where a UTF-8 character is split over several chunks. Those + // cases are not supported (the embedder should give the data in big enough + // chunks), but we shouldn't crash, just produce a parse error. + const char* reference = "\xeb\x91\x80"; + char chunk1[] = + "function foo() {\n" + " // This function will contain an UTF-8 character which is not in\n" + " // ASCII.\n" + " var foobX"; + char chunk2[] = "X"; + char chunk3[] = + "Xr = 13;\n" + " return foob\xeb\x91\x80r;\n" + "}\n"; + chunk1[strlen(chunk1) - 1] = reference[0]; + chunk2[0] = reference[1]; + chunk3[0] = reference[2]; + const char* chunks[] = {chunk1, chunk2, chunk3, "foo();", NULL}; + + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, false); +} + + +TEST(StreamingProducesParserCache) { + i::FLAG_min_preparse_length = 0; + const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ", + NULL}; + + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); + + v8::ScriptCompiler::StreamedSource source( + new TestSourceStream(chunks), + v8::ScriptCompiler::StreamedSource::ONE_BYTE); + v8::ScriptCompiler::ScriptStreamingTask* task = + v8::ScriptCompiler::StartStreamingScript( + isolate, &source, v8::ScriptCompiler::kProduceParserCache); + + // TestSourceStream::GetMoreData won't block, so it's OK to just run the + // task here in the main thread. + task->Run(); + delete task; + + const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); + CHECK(cached_data != NULL); + CHECK(cached_data->data != NULL); + CHECK_GT(cached_data->length, 0); +} + + +TEST(StreamingScriptWithInvalidUtf8) { + // Regression test for a crash: test that invalid UTF-8 bytes in the end of a + // chunk don't produce a crash. + const char* reference = "\xeb\x91\x80\x80\x80"; + char chunk1[] = + "function foo() {\n" + " // This function will contain an UTF-8 character which is not in\n" + " // ASCII.\n" + " var foobXXXXX"; // Too many bytes which look like incomplete chars! + char chunk2[] = + "r = 13;\n" + " return foob\xeb\x91\x80\x80\x80r;\n" + "}\n"; + for (int i = 0; i < 5; ++i) chunk1[strlen(chunk1) - 5 + i] = reference[i]; + + const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; + RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, false); +} diff --git a/deps/v8/test/cctest/test-assembler-arm.cc b/deps/v8/test/cctest/test-assembler-arm.cc index 4c339a32b4..ed9563d04b 100644 --- a/deps/v8/test/cctest/test-assembler-arm.cc +++ b/deps/v8/test/cctest/test-assembler-arm.cc @@ -1182,7 +1182,7 @@ TEST(14) { code->Print(os); #endif F3 f = FUNCTION_CAST<F3>(code->entry()); - t.left = BitCast<double>(kHoleNanInt64); + t.left = bit_cast<double>(kHoleNanInt64); t.right = 1; t.add_result = 0; t.sub_result = 0; @@ -1199,14 +1199,18 @@ TEST(14) { #endif // With VFP2 the sign of the canonicalized Nan is undefined. So // we remove the sign bit for the upper tests. - CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.add_result) >> 32) & 0x7fffffff); - CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.add_result) & 0xffffffffu); - CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.sub_result) >> 32) & 0x7fffffff); - CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.sub_result) & 0xffffffffu); - CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.mul_result) >> 32) & 0x7fffffff); - CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.mul_result) & 0xffffffffu); - CHECK_EQ(kArmNanUpper32, (BitCast<int64_t>(t.div_result) >> 32) & 0x7fffffff); - CHECK_EQ(kArmNanLower32, BitCast<int64_t>(t.div_result) & 0xffffffffu); + CHECK_EQ(kArmNanUpper32, + (bit_cast<int64_t>(t.add_result) >> 32) & 0x7fffffff); + CHECK_EQ(kArmNanLower32, bit_cast<int64_t>(t.add_result) & 0xffffffffu); + CHECK_EQ(kArmNanUpper32, + (bit_cast<int64_t>(t.sub_result) >> 32) & 0x7fffffff); + CHECK_EQ(kArmNanLower32, bit_cast<int64_t>(t.sub_result) & 0xffffffffu); + CHECK_EQ(kArmNanUpper32, + (bit_cast<int64_t>(t.mul_result) >> 32) & 0x7fffffff); + CHECK_EQ(kArmNanLower32, bit_cast<int64_t>(t.mul_result) & 0xffffffffu); + CHECK_EQ(kArmNanUpper32, + (bit_cast<int64_t>(t.div_result) >> 32) & 0x7fffffff); + CHECK_EQ(kArmNanLower32, bit_cast<int64_t>(t.div_result) & 0xffffffffu); } diff --git a/deps/v8/test/cctest/test-assembler-arm64.cc b/deps/v8/test/cctest/test-assembler-arm64.cc index 3d05487f39..587a4ce971 100644 --- a/deps/v8/test/cctest/test-assembler-arm64.cc +++ b/deps/v8/test/cctest/test-assembler-arm64.cc @@ -10270,58 +10270,6 @@ TEST(copyfields) { } -static void DoSmiAbsTest(int32_t value, bool must_fail = false) { - SETUP(); - - START(); - Label end, slow; - __ Mov(x2, 0xc001c0de); - __ Mov(x1, value); - __ SmiTag(x1); - __ SmiAbs(x1, &slow); - __ SmiUntag(x1); - __ B(&end); - - __ Bind(&slow); - __ Mov(x2, 0xbad); - - __ Bind(&end); - END(); - - RUN(); - - if (must_fail) { - // We tested an invalid conversion. The code must have jump on slow. - CHECK_EQUAL_64(0xbad, x2); - } else { - // The conversion is valid, check the result. - int32_t result = (value >= 0) ? value : -value; - CHECK_EQUAL_64(result, x1); - - // Check that we didn't jump on slow. - CHECK_EQUAL_64(0xc001c0de, x2); - } - - TEARDOWN(); -} - - -TEST(smi_abs) { - INIT_V8(); - // Simple and edge cases. - DoSmiAbsTest(0); - DoSmiAbsTest(0x12345); - DoSmiAbsTest(0x40000000); - DoSmiAbsTest(0x7fffffff); - DoSmiAbsTest(-1); - DoSmiAbsTest(-12345); - DoSmiAbsTest(0x80000001); - - // Check that the most negative SMI is detected. - DoSmiAbsTest(0x80000000, true); -} - - TEST(blr_lr) { // A simple test to check that the simulator correcty handle "blr lr". INIT_V8(); diff --git a/deps/v8/test/cctest/test-assembler-ia32.cc b/deps/v8/test/cctest/test-assembler-ia32.cc index e8c7f951fe..d943297393 100644 --- a/deps/v8/test/cctest/test-assembler-ia32.cc +++ b/deps/v8/test/cctest/test-assembler-ia32.cc @@ -170,11 +170,10 @@ TEST(AssemblerIa323) { assm.GetCode(&desc); Handle<Code> code = isolate->factory()->NewCode( desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - // don't print the code - our disassembler can't handle cvttss2si - // instead print bytes - Disassembler::Dump(stdout, - code->instruction_start(), - code->instruction_start() + code->instruction_size()); +#ifdef OBJECT_PRINT + OFStream os(stdout); + code->Print(os); +#endif F3 f = FUNCTION_CAST<F3>(code->entry()); int res = f(static_cast<float>(-3.1415)); ::printf("f() = %d\n", res); @@ -200,11 +199,10 @@ TEST(AssemblerIa324) { assm.GetCode(&desc); Handle<Code> code = isolate->factory()->NewCode( desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - // don't print the code - our disassembler can't handle cvttsd2si - // instead print bytes - Disassembler::Dump(stdout, - code->instruction_start(), - code->instruction_start() + code->instruction_size()); +#ifdef OBJECT_PRINT + OFStream os(stdout); + code->Print(os); +#endif F4 f = FUNCTION_CAST<F4>(code->entry()); int res = f(2.718281828); ::printf("f() = %d\n", res); @@ -261,13 +259,9 @@ TEST(AssemblerIa326) { assm.GetCode(&desc); Handle<Code> code = isolate->factory()->NewCode( desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); -#ifdef DEBUG - ::printf("\n---\n"); - // don't print the code - our disassembler can't handle SSE instructions - // instead print bytes - Disassembler::Dump(stdout, - code->instruction_start(), - code->instruction_start() + code->instruction_size()); +#ifdef OBJECT_PRINT + OFStream os(stdout); + code->Print(os); #endif F5 f = FUNCTION_CAST<F5>(code->entry()); double res = f(2.2, 1.1); diff --git a/deps/v8/test/cctest/test-assembler-mips.cc b/deps/v8/test/cctest/test-assembler-mips.cc index cd1d5d6cc7..74dcc3a0a2 100644 --- a/deps/v8/test/cctest/test-assembler-mips.cc +++ b/deps/v8/test/cctest/test-assembler-mips.cc @@ -170,7 +170,7 @@ TEST(MIPS2) { __ Branch(&error, ne, v0, Operand(0x1)); __ nop(); __ sltu(v0, t7, t3); - __ Branch(&error, ne, v0, Operand(0x0)); + __ Branch(&error, ne, v0, Operand(zero_reg)); __ nop(); // End of SPECIAL class. @@ -185,7 +185,7 @@ TEST(MIPS2) { __ slti(v0, t1, 0x00002000); // 0x1 __ slti(v0, v0, 0xffff8000); // 0x0 - __ Branch(&error, ne, v0, Operand(0x0)); + __ Branch(&error, ne, v0, Operand(zero_reg)); __ nop(); __ sltiu(v0, t1, 0x00002000); // 0x1 __ sltiu(v0, v0, 0x00008000); // 0x1 @@ -293,7 +293,7 @@ TEST(MIPS3) { __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, g)) ); // g = sqrt(f) = 10.97451593465515908537 - if (kArchVariant == kMips32r2) { + if (IsMipsArchVariant(kMips32r2)) { __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, h)) ); __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, i)) ); __ madd_d(f14, f6, f4, f6); @@ -325,7 +325,7 @@ TEST(MIPS3) { CHECK_EQ(1.8066e16, t.e); CHECK_EQ(120.44, t.f); CHECK_EQ(10.97451593465515908537, t.g); - if (kArchVariant == kMips32r2) { + if (IsMipsArchVariant(kMips32r2)) { CHECK_EQ(6.875, t.h); } } @@ -351,16 +351,28 @@ TEST(MIPS4) { __ 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); - + if (!IsFp64Mode()) { + __ mfc1(t0, f4); + __ mfc1(t1, f5); + __ mfc1(t2, f6); + __ mfc1(t3, f7); + + __ mtc1(t0, f6); + __ mtc1(t1, f7); + __ mtc1(t2, f4); + __ mtc1(t3, f5); + } else { + DCHECK(!IsMipsArchVariant(kMips32r1) && !IsMipsArchVariant(kLoongson)); + __ mfc1(t0, f4); + __ mfhc1(t1, f4); + __ mfc1(t2, f6); + __ mfhc1(t3, f6); + + __ mtc1(t0, f6); + __ mthc1(t1, f6); + __ mtc1(t2, f4); + __ mthc1(t3, f4); + } // 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)) ); @@ -554,21 +566,30 @@ TEST(MIPS7) { __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); + if (!IsMipsArchVariant(kMips32r6)) { __ c(UN, D, f4, f6); __ bc1f(&neither_is_nan); + } else { + __ cmp(UN, L, f2, f4, f6); + __ bc1eqz(&neither_is_nan, f2); + } __ nop(); __ sw(zero_reg, MemOperand(a0, OFFSET_OF(T, result)) ); __ Branch(&outa_here); __ bind(&neither_is_nan); - if (kArchVariant == kLoongson) { + if (IsMipsArchVariant(kLoongson)) { __ c(OLT, D, f6, f4); __ bc1t(&less_than); + } else if (IsMipsArchVariant(kMips32r6)) { + __ cmp(OLT, L, f2, f6, f4); + __ bc1nez(&less_than, f2); } else { __ c(OLT, D, f6, f4, 2); __ bc1t(&less_than, 2); } + __ nop(); __ sw(zero_reg, MemOperand(a0, OFFSET_OF(T, result)) ); __ Branch(&outa_here); @@ -716,7 +737,7 @@ TEST(MIPS9) { MacroAssembler assm(isolate, NULL, 0); Label exit, exit2, exit3; - __ Branch(&exit, ge, a0, Operand(0x00000000)); + __ Branch(&exit, ge, a0, Operand(zero_reg)); __ Branch(&exit2, ge, a0, Operand(0x00001FFF)); __ Branch(&exit3, ge, a0, Operand(0x0001FFFF)); @@ -753,50 +774,52 @@ TEST(MIPS10) { Assembler assm(isolate, NULL, 0); Label L, C; - if (kArchVariant == kMips32r2) { - // 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_w_d(f0, f0); - __ mfc1(t0, f0); // f0 has a 32-bits word. - __ sw(t0, MemOperand(a0, OFFSET_OF(T, word))); - - // Convert the b long integers to double b. - __ lw(t0, MemOperand(a0, OFFSET_OF(T, b_word))); - __ mtc1(t0, f8); // f8 has a 32-bits word. - __ cvt_d_w(f10, f8); - __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, b))); - - __ jr(ra); - __ nop(); - - CodeDesc desc; - assm.GetCode(&desc); - Handle<Code> code = isolate->factory()->NewCode( - desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); - F3 f = FUNCTION_CAST<F3>(code->entry()); - t.a = 2.147483646e+09; // 0x7FFFFFFE -> 0xFF80000041DFFFFF as double. - t.b_word = 0x0ff00ff0; // 0x0FF00FF0 -> 0x as double. - Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); - USE(dummy); - - CHECK_EQ(0x41DFFFFF, t.dbl_exp); - CHECK_EQ(0xFF800000, t.dbl_mant); - CHECK_EQ(0X7FFFFFFE, t.word); - // 0x0FF00FF0 -> 2.6739096+e08 - CHECK_EQ(2.6739096e08, t.b); - } + if (!IsMipsArchVariant(kMips32r2)) return; + + // 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_w_d(f0, f0); + __ mfc1(t0, f0); // f0 has a 32-bits word. + __ sw(t0, MemOperand(a0, OFFSET_OF(T, word))); + + // Convert the b long integers to double b. + __ lw(t0, MemOperand(a0, OFFSET_OF(T, b_word))); + __ mtc1(t0, f8); // f8 has a 32-bits word. + __ cvt_d_w(f10, f8); + __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, b))); + + __ jr(ra); + __ nop(); + + CodeDesc desc; + assm.GetCode(&desc); + Handle<Code> code = isolate->factory()->NewCode( + desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); + F3 f = FUNCTION_CAST<F3>(code->entry()); + t.a = 2.147483646e+09; // 0x7FFFFFFE -> 0xFF80000041DFFFFF as double. + t.b_word = 0x0ff00ff0; // 0x0FF00FF0 -> 0x as double. + Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); + USE(dummy); + + CHECK_EQ(0x41DFFFFF, t.dbl_exp); + CHECK_EQ(0xFF800000, t.dbl_mant); + CHECK_EQ(0X7FFFFFFE, t.word); + // 0x0FF00FF0 -> 2.6739096+e08 + CHECK_EQ(2.6739096e08, t.b); } TEST(MIPS11) { + // Do not run test on MIPS32r6, as these instructions are removed. + if (IsMipsArchVariant(kMips32r6)) return; // Test LWL, LWR, SWL and SWR instructions. CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); diff --git a/deps/v8/test/cctest/test-assembler-mips64.cc b/deps/v8/test/cctest/test-assembler-mips64.cc index 4e9238930a..1ec9a65c96 100644 --- a/deps/v8/test/cctest/test-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-assembler-mips64.cc @@ -353,14 +353,17 @@ TEST(MIPS4) { double a; double b; double c; + double d; + int64_t high; + int64_t low; } T; T t; Assembler assm(isolate, NULL, 0); Label L, C; - __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); - __ ldc1(f5, MemOperand(a0, OFFSET_OF(T, b)) ); + __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a))); + __ ldc1(f5, MemOperand(a0, OFFSET_OF(T, b))); // Swap f4 and f5, by using 3 integer registers, a4-a6, // both two 32-bit chunks, and one 64-bit chunk. @@ -375,8 +378,16 @@ TEST(MIPS4) { __ dmtc1(a6, f4); // Store the swapped f4 and f5 back to memory. - __ sdc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); - __ sdc1(f5, MemOperand(a0, OFFSET_OF(T, c)) ); + __ sdc1(f4, MemOperand(a0, OFFSET_OF(T, a))); + __ sdc1(f5, MemOperand(a0, OFFSET_OF(T, c))); + + // Test sign extension of move operations from coprocessor. + __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, d))); + __ mfhc1(a4, f4); + __ mfc1(a5, f4); + + __ sd(a4, MemOperand(a0, OFFSET_OF(T, high))); + __ sd(a5, MemOperand(a0, OFFSET_OF(T, low))); __ jr(ra); __ nop(); @@ -389,12 +400,15 @@ TEST(MIPS4) { t.a = 1.5e22; t.b = 2.75e11; t.c = 17.17; + t.d = -2.75e11; 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); + CHECK_EQ(0xffffffffc25001d1L, t.high); + CHECK_EQ(0xffffffffbf800000L, t.low); } @@ -870,80 +884,80 @@ TEST(MIPS11) { Assembler assm(isolate, NULL, 0); // Test all combinations of LWL and vAddr. - __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwl(a4, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a4, MemOperand(a0, OFFSET_OF(T, lwl_0)) ); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwl(a4, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a4, MemOperand(a0, OFFSET_OF(T, lwl_0))); - __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwl(a5, MemOperand(a0, OFFSET_OF(T, mem_init) + 1) ); - __ sw(a5, MemOperand(a0, OFFSET_OF(T, lwl_1)) ); + __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwl(a5, MemOperand(a0, OFFSET_OF(T, mem_init) + 1)); + __ sw(a5, MemOperand(a0, OFFSET_OF(T, lwl_1))); - __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwl(a6, MemOperand(a0, OFFSET_OF(T, mem_init) + 2) ); - __ sw(a6, MemOperand(a0, OFFSET_OF(T, lwl_2)) ); + __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwl(a6, MemOperand(a0, OFFSET_OF(T, mem_init) + 2)); + __ sw(a6, MemOperand(a0, OFFSET_OF(T, lwl_2))); - __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwl(a7, MemOperand(a0, OFFSET_OF(T, mem_init) + 3) ); - __ sw(a7, MemOperand(a0, OFFSET_OF(T, lwl_3)) ); + __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwl(a7, MemOperand(a0, OFFSET_OF(T, mem_init) + 3)); + __ sw(a7, MemOperand(a0, OFFSET_OF(T, lwl_3))); // Test all combinations of LWR and vAddr. - __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwr(a4, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a4, MemOperand(a0, OFFSET_OF(T, lwr_0)) ); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwr(a4, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a4, MemOperand(a0, OFFSET_OF(T, lwr_0))); - __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwr(a5, MemOperand(a0, OFFSET_OF(T, mem_init) + 1) ); - __ sw(a5, MemOperand(a0, OFFSET_OF(T, lwr_1)) ); + __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwr(a5, MemOperand(a0, OFFSET_OF(T, mem_init) + 1)); + __ sw(a5, MemOperand(a0, OFFSET_OF(T, lwr_1))); - __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwr(a6, MemOperand(a0, OFFSET_OF(T, mem_init) + 2) ); + __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwr(a6, MemOperand(a0, OFFSET_OF(T, mem_init) + 2)); __ sw(a6, MemOperand(a0, OFFSET_OF(T, lwr_2)) ); - __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ lwr(a7, MemOperand(a0, OFFSET_OF(T, mem_init) + 3) ); + __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ lwr(a7, MemOperand(a0, OFFSET_OF(T, mem_init) + 3)); __ sw(a7, MemOperand(a0, OFFSET_OF(T, lwr_3)) ); // Test all combinations of SWL and vAddr. - __ lw(a4, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a4, MemOperand(a0, OFFSET_OF(T, swl_0)) ); - __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swl(a4, MemOperand(a0, OFFSET_OF(T, swl_0)) ); - - __ lw(a5, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a5, MemOperand(a0, OFFSET_OF(T, swl_1)) ); - __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swl(a5, MemOperand(a0, OFFSET_OF(T, swl_1) + 1) ); - - __ lw(a6, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a6, MemOperand(a0, OFFSET_OF(T, swl_2)) ); - __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swl(a6, MemOperand(a0, OFFSET_OF(T, swl_2) + 2) ); - - __ lw(a7, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a7, MemOperand(a0, OFFSET_OF(T, swl_3)) ); - __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swl(a7, MemOperand(a0, OFFSET_OF(T, swl_3) + 3) ); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a4, MemOperand(a0, OFFSET_OF(T, swl_0))); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swl(a4, MemOperand(a0, OFFSET_OF(T, swl_0))); + + __ lw(a5, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a5, MemOperand(a0, OFFSET_OF(T, swl_1))); + __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swl(a5, MemOperand(a0, OFFSET_OF(T, swl_1) + 1)); + + __ lw(a6, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a6, MemOperand(a0, OFFSET_OF(T, swl_2))); + __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swl(a6, MemOperand(a0, OFFSET_OF(T, swl_2) + 2)); + + __ lw(a7, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a7, MemOperand(a0, OFFSET_OF(T, swl_3))); + __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swl(a7, MemOperand(a0, OFFSET_OF(T, swl_3) + 3)); // Test all combinations of SWR and vAddr. - __ lw(a4, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a4, MemOperand(a0, OFFSET_OF(T, swr_0)) ); - __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swr(a4, MemOperand(a0, OFFSET_OF(T, swr_0)) ); - - __ lw(a5, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a5, MemOperand(a0, OFFSET_OF(T, swr_1)) ); - __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swr(a5, MemOperand(a0, OFFSET_OF(T, swr_1) + 1) ); - - __ lw(a6, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a6, MemOperand(a0, OFFSET_OF(T, swr_2)) ); - __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swr(a6, MemOperand(a0, OFFSET_OF(T, swr_2) + 2) ); - - __ lw(a7, MemOperand(a0, OFFSET_OF(T, mem_init)) ); - __ sw(a7, MemOperand(a0, OFFSET_OF(T, swr_3)) ); - __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init)) ); - __ swr(a7, MemOperand(a0, OFFSET_OF(T, swr_3) + 3) ); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a4, MemOperand(a0, OFFSET_OF(T, swr_0))); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swr(a4, MemOperand(a0, OFFSET_OF(T, swr_0))); + + __ lw(a5, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a5, MemOperand(a0, OFFSET_OF(T, swr_1))); + __ lw(a5, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swr(a5, MemOperand(a0, OFFSET_OF(T, swr_1) + 1)); + + __ lw(a6, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a6, MemOperand(a0, OFFSET_OF(T, swr_2))); + __ lw(a6, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swr(a6, MemOperand(a0, OFFSET_OF(T, swr_2) + 2)); + + __ lw(a7, MemOperand(a0, OFFSET_OF(T, mem_init))); + __ sw(a7, MemOperand(a0, OFFSET_OF(T, swr_3))); + __ lw(a7, MemOperand(a0, OFFSET_OF(T, reg_init))); + __ swr(a7, MemOperand(a0, OFFSET_OF(T, swr_3) + 3)); __ jr(ra); __ nop(); @@ -1001,8 +1015,8 @@ TEST(MIPS12) { __ mov(t2, fp); // Save frame pointer. __ mov(fp, a0); // Access struct T by fp. - __ lw(a4, MemOperand(a0, OFFSET_OF(T, y)) ); - __ lw(a7, MemOperand(a0, OFFSET_OF(T, y4)) ); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, y))); + __ lw(a7, MemOperand(a0, OFFSET_OF(T, y4))); __ addu(a5, a4, a7); __ subu(t0, a4, a7); @@ -1020,30 +1034,30 @@ TEST(MIPS12) { __ push(a7); __ pop(t0); __ nop(); - __ sw(a4, MemOperand(fp, OFFSET_OF(T, y)) ); - __ lw(a4, MemOperand(fp, OFFSET_OF(T, y)) ); + __ sw(a4, MemOperand(fp, OFFSET_OF(T, y))); + __ lw(a4, MemOperand(fp, OFFSET_OF(T, y))); __ nop(); - __ sw(a4, MemOperand(fp, OFFSET_OF(T, y)) ); - __ lw(a5, MemOperand(fp, OFFSET_OF(T, y)) ); + __ sw(a4, MemOperand(fp, OFFSET_OF(T, y))); + __ lw(a5, MemOperand(fp, OFFSET_OF(T, y))); __ nop(); __ push(a5); - __ lw(a5, MemOperand(fp, OFFSET_OF(T, y)) ); + __ lw(a5, MemOperand(fp, OFFSET_OF(T, y))); __ pop(a5); __ nop(); __ push(a5); - __ lw(a6, MemOperand(fp, OFFSET_OF(T, y)) ); + __ lw(a6, MemOperand(fp, OFFSET_OF(T, y))); __ pop(a5); __ nop(); __ push(a5); - __ lw(a6, MemOperand(fp, OFFSET_OF(T, y)) ); + __ lw(a6, MemOperand(fp, OFFSET_OF(T, y))); __ pop(a6); __ nop(); __ push(a6); - __ lw(a6, MemOperand(fp, OFFSET_OF(T, y)) ); + __ lw(a6, MemOperand(fp, OFFSET_OF(T, y))); __ pop(a5); __ nop(); __ push(a5); - __ lw(a6, MemOperand(fp, OFFSET_OF(T, y)) ); + __ lw(a6, MemOperand(fp, OFFSET_OF(T, y))); __ pop(a7); __ nop(); @@ -1297,48 +1311,48 @@ TEST(MIPS16) { Label L, C; // Basic 32-bit word load/store, with un-signed data. - __ lw(a4, MemOperand(a0, OFFSET_OF(T, ui)) ); - __ sw(a4, MemOperand(a0, OFFSET_OF(T, r1)) ); + __ lw(a4, MemOperand(a0, OFFSET_OF(T, ui))); + __ sw(a4, MemOperand(a0, OFFSET_OF(T, r1))); // Check that the data got zero-extended into 64-bit a4. - __ sd(a4, MemOperand(a0, OFFSET_OF(T, r2)) ); + __ sd(a4, MemOperand(a0, OFFSET_OF(T, r2))); // Basic 32-bit word load/store, with SIGNED data. - __ lw(a5, MemOperand(a0, OFFSET_OF(T, si)) ); - __ sw(a5, MemOperand(a0, OFFSET_OF(T, r3)) ); + __ lw(a5, MemOperand(a0, OFFSET_OF(T, si))); + __ sw(a5, MemOperand(a0, OFFSET_OF(T, r3))); // Check that the data got sign-extended into 64-bit a4. - __ sd(a5, MemOperand(a0, OFFSET_OF(T, r4)) ); + __ sd(a5, MemOperand(a0, OFFSET_OF(T, r4))); // 32-bit UNSIGNED word load/store, with SIGNED data. - __ lwu(a6, MemOperand(a0, OFFSET_OF(T, si)) ); - __ sw(a6, MemOperand(a0, OFFSET_OF(T, r5)) ); + __ lwu(a6, MemOperand(a0, OFFSET_OF(T, si))); + __ sw(a6, MemOperand(a0, OFFSET_OF(T, r5))); // Check that the data got zero-extended into 64-bit a4. - __ sd(a6, MemOperand(a0, OFFSET_OF(T, r6)) ); + __ sd(a6, MemOperand(a0, OFFSET_OF(T, r6))); // lh with positive data. - __ lh(a5, MemOperand(a0, OFFSET_OF(T, ui)) ); - __ sw(a5, MemOperand(a0, OFFSET_OF(T, r2)) ); + __ lh(a5, MemOperand(a0, OFFSET_OF(T, ui))); + __ sw(a5, MemOperand(a0, OFFSET_OF(T, r2))); // lh with negative data. - __ lh(a6, MemOperand(a0, OFFSET_OF(T, si)) ); - __ sw(a6, MemOperand(a0, OFFSET_OF(T, r3)) ); + __ lh(a6, MemOperand(a0, OFFSET_OF(T, si))); + __ sw(a6, MemOperand(a0, OFFSET_OF(T, r3))); // lhu with negative data. - __ lhu(a7, MemOperand(a0, OFFSET_OF(T, si)) ); - __ sw(a7, MemOperand(a0, OFFSET_OF(T, r4)) ); + __ lhu(a7, MemOperand(a0, OFFSET_OF(T, si))); + __ sw(a7, MemOperand(a0, OFFSET_OF(T, r4))); // lb with negative data. - __ lb(t0, MemOperand(a0, OFFSET_OF(T, si)) ); - __ sw(t0, MemOperand(a0, OFFSET_OF(T, r5)) ); + __ lb(t0, MemOperand(a0, OFFSET_OF(T, si))); + __ sw(t0, MemOperand(a0, OFFSET_OF(T, r5))); // // sh writes only 1/2 of word. __ lui(t1, 0x3333); __ ori(t1, t1, 0x3333); - __ sw(t1, MemOperand(a0, OFFSET_OF(T, r6)) ); - __ lhu(t1, MemOperand(a0, OFFSET_OF(T, si)) ); - __ sh(t1, MemOperand(a0, OFFSET_OF(T, r6)) ); + __ sw(t1, MemOperand(a0, OFFSET_OF(T, r6))); + __ lhu(t1, MemOperand(a0, OFFSET_OF(T, si))); + __ sh(t1, MemOperand(a0, OFFSET_OF(T, r6))); __ jr(ra); __ nop(); diff --git a/deps/v8/test/cctest/test-ast.cc b/deps/v8/test/cctest/test-ast.cc index a25ae69b61..24819dfcd4 100644 --- a/deps/v8/test/cctest/test-ast.cc +++ b/deps/v8/test/cctest/test-ast.cc @@ -35,13 +35,13 @@ using namespace v8::internal; TEST(List) { - v8::internal::V8::Initialize(NULL); List<AstNode*>* list = new List<AstNode*>(0); CHECK_EQ(0, list->length()); Isolate* isolate = CcTest::i_isolate(); Zone zone(isolate); - AstNodeFactory<AstNullVisitor> factory(&zone, NULL); + AstNode::IdGen id_gen; + AstNodeFactory<AstNullVisitor> factory(&zone, NULL, &id_gen); AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition); list->Add(node); CHECK_EQ(1, list->length()); diff --git a/deps/v8/test/cctest/test-checks.cc b/deps/v8/test/cctest/test-checks.cc index a49a7dbe2a..79e87ddd0c 100644 --- a/deps/v8/test/cctest/test-checks.cc +++ b/deps/v8/test/cctest/test-checks.cc @@ -20,7 +20,7 @@ TEST(CheckEqualsReflexivity) { double nan = v8::base::OS::nan_value(); double constants[] = {-nan, -inf, -3.1415, -1.0, -0.1, -0.0, 0.0, 0.1, 1.0, 3.1415, inf, nan}; - for (size_t i = 0; i < ARRAY_SIZE(constants); ++i) { + for (size_t i = 0; i < arraysize(constants); ++i) { CHECK_EQ(constants[i], constants[i]); } } diff --git a/deps/v8/test/cctest/test-code-stubs.cc b/deps/v8/test/cctest/test-code-stubs.cc index 0784aac78e..95035aab0b 100644 --- a/deps/v8/test/cctest/test-code-stubs.cc +++ b/deps/v8/test/cctest/test-code-stubs.cc @@ -62,7 +62,7 @@ int STDCALL ConvertDToICVersion(double d) { } } else { uint64_t big_result = - (BitCast<uint64_t>(d) & Double::kSignificandMask) | Double::kHiddenBit; + (bit_cast<uint64_t>(d) & Double::kSignificandMask) | Double::kHiddenBit; big_result = big_result >> (Double::kPhysicalSignificandSize - exponent); result = static_cast<uint32_t>(big_result); } @@ -172,3 +172,19 @@ void RunAllTruncationTests(ConvertDToICallWrapper callWrapper, #undef NaN #undef Infinity #undef RunOneTruncationTest + + +TEST(CodeStubMajorKeys) { + CcTest::InitializeVM(); + LocalContext context; + Isolate* isolate = CcTest::i_isolate(); + +#define CHECK_STUB(NAME) \ + { \ + HandleScope scope(isolate); \ + NAME##Stub stub_impl(0xabcd, isolate); \ + CodeStub* stub = &stub_impl; \ + CHECK_EQ(stub->MajorKey(), CodeStub::NAME); \ + } + CODE_STUB_LIST(CHECK_STUB); +} diff --git a/deps/v8/test/cctest/test-compiler.cc b/deps/v8/test/cctest/test-compiler.cc index 2d913715e1..4d6e005a8b 100644 --- a/deps/v8/test/cctest/test-compiler.cc +++ b/deps/v8/test/cctest/test-compiler.cc @@ -227,18 +227,18 @@ TEST(C2JSFrames) { Handle<JSObject> global(isolate->context()->global_object()); Execution::Call(isolate, fun0, global, 0, NULL).Check(); - Handle<String> foo_string = isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("foo")); + Handle<String> foo_string = + isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("foo")); Handle<Object> fun1 = Object::GetProperty( isolate->global_object(), foo_string).ToHandleChecked(); CHECK(fun1->IsJSFunction()); - Handle<Object> argv[] = { isolate->factory()->InternalizeOneByteString( - STATIC_ASCII_VECTOR("hello")) }; + Handle<Object> argv[] = {isolate->factory()->InternalizeOneByteString( + STATIC_CHAR_VECTOR("hello"))}; Execution::Call(isolate, Handle<JSFunction>::cast(fun1), global, - ARRAY_SIZE(argv), + arraysize(argv), argv).Check(); } diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index 6051c3fd7f..8d429d2e21 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -469,7 +469,7 @@ static const v8::CpuProfileNode* GetChild(v8::Isolate* isolate, const v8::CpuProfileNode* result = FindChild(isolate, node, name); if (!result) { char buffer[100]; - i::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)), + i::SNPrintF(Vector<char>(buffer, arraysize(buffer)), "Failed to GetChild: %s", name); FATAL(buffer); } @@ -552,8 +552,8 @@ TEST(CollectCpuProfile) { v8::Integer::New(env->GetIsolate(), profiling_interval_ms) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); - function->Call(env->Global(), ARRAY_SIZE(args), args); + RunProfiler(env.local(), function, args, arraysize(args), 200); + function->Call(env->Global(), arraysize(args), args); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); @@ -575,13 +575,13 @@ TEST(CollectCpuProfile) { const char* barBranch[] = { "bar", "delay", "loop" }; CheckSimpleBranch(env->GetIsolate(), fooNode, barBranch, - ARRAY_SIZE(barBranch)); + arraysize(barBranch)); const char* bazBranch[] = { "baz", "delay", "loop" }; CheckSimpleBranch(env->GetIsolate(), fooNode, bazBranch, - ARRAY_SIZE(bazBranch)); + arraysize(bazBranch)); const char* delayBranch[] = { "delay", "loop" }; CheckSimpleBranch(env->GetIsolate(), fooNode, delayBranch, - ARRAY_SIZE(delayBranch)); + arraysize(delayBranch)); profile->Delete(); } @@ -630,8 +630,8 @@ TEST(HotDeoptNoFrameEntry) { v8::Integer::New(env->GetIsolate(), profiling_interval_ms) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); - function->Call(env->Global(), ARRAY_SIZE(args), args); + RunProfiler(env.local(), function, args, arraysize(args), 200); + function->Call(env->Global(), arraysize(args), args); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); @@ -667,7 +667,7 @@ TEST(CollectCpuProfileSamples) { v8::Integer::New(env->GetIsolate(), profiling_interval_ms) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200, true); + RunProfiler(env.local(), function, args, arraysize(args), 200, true); CHECK_LE(200, profile->GetSamplesCount()); uint64_t end_time = profile->GetEndTime(); @@ -723,7 +723,7 @@ TEST(SampleWhenFrameIsNotSetup) { v8::Integer::New(env->GetIsolate(), repeat_count) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); + RunProfiler(env.local(), function, args, arraysize(args), 100); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); @@ -843,7 +843,7 @@ TEST(NativeAccessorUninitializedIC) { int32_t repeat_count = 1; v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 180); + RunProfiler(env.local(), function, args, arraysize(args), 180); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); const v8::CpuProfileNode* startNode = @@ -893,14 +893,14 @@ TEST(NativeAccessorMonomorphicIC) { v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, warm_up_iterations) }; - function->Call(env->Global(), ARRAY_SIZE(args), args); + function->Call(env->Global(), arraysize(args), args); accessors.set_warming_up(false); } int32_t repeat_count = 100; v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 200); + RunProfiler(env.local(), function, args, arraysize(args), 200); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); const v8::CpuProfileNode* startNode = @@ -954,7 +954,7 @@ TEST(NativeMethodUninitializedIC) { int32_t repeat_count = 1; v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); + RunProfiler(env.local(), function, args, arraysize(args), 100); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); const v8::CpuProfileNode* startNode = @@ -1004,14 +1004,14 @@ TEST(NativeMethodMonomorphicIC) { v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, warm_up_iterations) }; - function->Call(env->Global(), ARRAY_SIZE(args), args); + function->Call(env->Global(), arraysize(args), args); callbacks.set_warming_up(false); } int32_t repeat_count = 100; v8::Handle<v8::Value> args[] = { v8::Integer::New(isolate, repeat_count) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); + RunProfiler(env.local(), function, args, arraysize(args), 100); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); GetChild(isolate, root, "start"); @@ -1105,7 +1105,7 @@ TEST(FunctionCallSample) { v8::Integer::New(env->GetIsolate(), duration_ms) }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); + RunProfiler(env.local(), function, args, arraysize(args), 100); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); { @@ -1188,7 +1188,7 @@ TEST(FunctionApplySample) { }; v8::CpuProfile* profile = - RunProfiler(env.local(), function, args, ARRAY_SIZE(args), 100); + RunProfiler(env.local(), function, args, arraysize(args), 100); const v8::CpuProfileNode* root = profile->GetTopDownRoot(); { @@ -1321,7 +1321,7 @@ static const char* js_native_js_test_source = static void CallJsFunction(const v8::FunctionCallbackInfo<v8::Value>& info) { v8::Handle<v8::Function> function = info[0].As<v8::Function>(); v8::Handle<v8::Value> argv[] = { info[1] }; - function->Call(info.This(), ARRAY_SIZE(argv), argv); + function->Call(info.This(), arraysize(argv), argv); } diff --git a/deps/v8/test/cctest/test-dataflow.cc b/deps/v8/test/cctest/test-dataflow.cc index fc1a7fa13f..43d950d860 100644 --- a/deps/v8/test/cctest/test-dataflow.cc +++ b/deps/v8/test/cctest/test-dataflow.cc @@ -35,7 +35,6 @@ using namespace v8::internal; TEST(BitVector) { - v8::internal::V8::Initialize(NULL); Zone zone(CcTest::i_isolate()); { BitVector v(15, &zone); diff --git a/deps/v8/test/cctest/test-date.cc b/deps/v8/test/cctest/test-date.cc index f2187955ad..2f722c2baf 100644 --- a/deps/v8/test/cctest/test-date.cc +++ b/deps/v8/test/cctest/test-date.cc @@ -132,7 +132,7 @@ TEST(DaylightSavingsTime) { int local_offset_ms = -36000000; // -10 hours. DateCacheMock* date_cache = - new DateCacheMock(local_offset_ms, rules, ARRAY_SIZE(rules)); + new DateCacheMock(local_offset_ms, rules, arraysize(rules)); reinterpret_cast<Isolate*>(isolate)->set_date_cache(date_cache); diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index 5c0b0f392d..2f0674a34d 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -36,7 +36,6 @@ #include "src/debug.h" #include "src/deoptimizer.h" #include "src/frames.h" -#include "src/stub-cache.h" #include "src/utils.h" #include "test/cctest/cctest.h" @@ -74,16 +73,23 @@ using ::v8::internal::StrLength; class DebugLocalContext { public: inline DebugLocalContext( + v8::Isolate* isolate, v8::ExtensionConfiguration* extensions = 0, + v8::Handle<v8::ObjectTemplate> global_template = + v8::Handle<v8::ObjectTemplate>(), + v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) + : scope_(isolate), + context_(v8::Context::New(isolate, extensions, global_template, + global_object)) { + context_->Enter(); + } + inline DebugLocalContext( v8::ExtensionConfiguration* extensions = 0, v8::Handle<v8::ObjectTemplate> global_template = v8::Handle<v8::ObjectTemplate>(), v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) : scope_(CcTest::isolate()), - context_( - v8::Context::New(CcTest::isolate(), - extensions, - global_template, - global_object)) { + context_(v8::Context::New(CcTest::isolate(), extensions, + global_template, global_object)) { context_->Enter(); } inline ~DebugLocalContext() { @@ -108,7 +114,7 @@ class DebugLocalContext { Handle<JSGlobalProxy> global(Handle<JSGlobalProxy>::cast( v8::Utils::OpenHandle(*context_->Global()))); Handle<v8::internal::String> debug_string = - factory->InternalizeOneByteString(STATIC_ASCII_VECTOR("debug")); + factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("debug")); v8::internal::Runtime::DefineObjectProperty(global, debug_string, handle(debug_context->global_proxy(), isolate), DONT_ENUM).Check(); } @@ -138,8 +144,7 @@ static v8::Local<v8::Function> CompileFunction(v8::Isolate* isolate, const char* source, const char* function_name) { v8::Script::Compile(v8::String::NewFromUtf8(isolate, source))->Run(); - v8::Local<v8::Object> global = - CcTest::isolate()->GetCurrentContext()->Global(); + v8::Local<v8::Object> global = isolate->GetCurrentContext()->Global(); return v8::Local<v8::Function>::Cast( global->Get(v8::String::NewFromUtf8(isolate, function_name))); } @@ -670,6 +675,8 @@ static void DebugEventBreakPointHitCount( int exception_hit_count = 0; int uncaught_exception_hit_count = 0; int last_js_stack_height = -1; +v8::Handle<v8::Function> debug_event_listener_callback; +int debug_event_listener_callback_result; static void DebugEventCounterClear() { break_point_hit_count = 0; @@ -710,9 +717,17 @@ static void DebugEventCounter( static const int kArgc = 1; v8::Handle<v8::Value> argv[kArgc] = { exec_state }; // Using exec_state as receiver is just to have a receiver. - v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv); + v8::Handle<v8::Value> result = frame_count->Call(exec_state, kArgc, argv); last_js_stack_height = result->Int32Value(); } + + // Run callback from DebugEventListener and check the result. + if (!debug_event_listener_callback.IsEmpty()) { + v8::Handle<v8::Value> result = + debug_event_listener_callback->Call(event_data, 0, NULL); + CHECK(!result.IsEmpty()); + CHECK_EQ(debug_event_listener_callback_result, result->Int32Value()); + } } @@ -750,6 +765,7 @@ static void DebugEventEvaluate( CHECK_NE(debug->break_id(), 0); if (event == v8::Break) { + break_point_hit_count++; for (int i = 0; checks[i].expr != NULL; i++) { const int argc = 3; v8::Handle<v8::Value> argv[argc] = { @@ -2391,7 +2407,7 @@ TEST(DebugEvaluate) { }; // Simple test function. The "y=0" is in the function foo to provide a break - // location. For "y=0" the "y" is at position 15 in the barbar function + // location. For "y=0" the "y" is at position 15 in the foo function // therefore setting breakpoint at position 15 will break at "y=0" and // setting it higher will break after. v8::Local<v8::Function> foo = CompileFunction(&env, @@ -2424,6 +2440,34 @@ TEST(DebugEvaluate) { checks = checks_hh; foo->Call(env->Global(), 1, argv_foo); + // Test that overriding Object.prototype will not interfere into evaluation + // on call frame. + v8::Local<v8::Function> zoo = + CompileFunction(&env, + "x = undefined;" + "function zoo(t) {" + " var a=x;" + " Object.prototype.x = 42;" + " x=t;" + " y=0;" // To ensure break location. + " delete Object.prototype.x;" + " x=a;" + "}", + "zoo"); + const int zoo_break_position = 50; + + // Arguments with one parameter "Hello, world!" + v8::Handle<v8::Value> argv_zoo[1] = { + v8::String::NewFromUtf8(env->GetIsolate(), "Hello, world!")}; + + // Call zoo with breakpoint set at y=0. + DebugEventCounterClear(); + bp = SetBreakPoint(zoo, zoo_break_position); + checks = checks_hu; + zoo->Call(env->Global(), 1, argv_zoo); + CHECK_EQ(1, break_point_hit_count); + ClearBreakPoint(bp); + // Test function with an inner function. The "y=0" is in function barbar // to provide a break location. For "y=0" the "y" is at position 8 in the // barbar function therefore setting breakpoint at position 8 will break at @@ -3968,6 +4012,43 @@ TEST(BreakOnException) { } +TEST(EvalJSInDebugEventListenerOnNativeReThrownException) { + DebugLocalContext env; + v8::HandleScope scope(env->GetIsolate()); + env.ExposeDebug(); + + // Create functions for testing break on exception. + v8::Local<v8::Function> noThrowJS = CompileFunction( + &env, "function noThrowJS(){var a=[1]; a.push(2); return a.length;}", + "noThrowJS"); + + debug_event_listener_callback = noThrowJS; + debug_event_listener_callback_result = 2; + + v8::V8::AddMessageListener(MessageCallbackCount); + v8::Debug::SetDebugEventListener(DebugEventCounter); + // Break on uncaught exception + ChangeBreakOnException(false, true); + DebugEventCounterClear(); + MessageCallbackCountClear(); + + // ReThrow native error + { + v8::TryCatch tryCatch; + env->GetIsolate()->ThrowException(v8::Exception::TypeError( + v8::String::NewFromUtf8(env->GetIsolate(), "Type error"))); + CHECK(tryCatch.HasCaught()); + tryCatch.ReThrow(); + } + CHECK_EQ(1, exception_hit_count); + CHECK_EQ(1, uncaught_exception_hit_count); + CHECK_EQ(0, message_callback_count); // FIXME: Should it be 1 ? + CHECK(!debug_event_listener_callback.IsEmpty()); + + debug_event_listener_callback.Clear(); +} + + // Test break on exception from compiler errors. When compiling using // v8::Script::Compile there is no JavaScript stack whereas when compiling using // eval there are JavaScript frames. @@ -4151,10 +4232,11 @@ TEST(DebugBreak) { // Set the debug break flag. v8::Debug::DebugBreak(env->GetIsolate()); + CHECK(v8::Debug::CheckDebugBreak(env->GetIsolate())); // Call all functions with different argument count. break_point_hit_count = 0; - for (unsigned int i = 0; i < ARRAY_SIZE(argv); i++) { + for (unsigned int i = 0; i < arraysize(argv); i++) { f0->Call(env->Global(), i, argv); f1->Call(env->Global(), i, argv); f2->Call(env->Global(), i, argv); @@ -4162,7 +4244,7 @@ TEST(DebugBreak) { } // One break for each function called. - CHECK_EQ(4 * ARRAY_SIZE(argv), break_point_hit_count); + CHECK_EQ(4 * arraysize(argv), break_point_hit_count); // Get rid of the debug event listener. v8::Debug::SetDebugEventListener(NULL); @@ -4183,6 +4265,12 @@ TEST(DisableBreak) { const char* src = "function f() {g()};function g(){i=0; while(i<10){i++}}"; v8::Local<v8::Function> f = CompileFunction(&env, src, "f"); + // Set, test and cancel debug break. + v8::Debug::DebugBreak(env->GetIsolate()); + CHECK(v8::Debug::CheckDebugBreak(env->GetIsolate())); + v8::Debug::CancelDebugBreak(env->GetIsolate()); + CHECK(!v8::Debug::CheckDebugBreak(env->GetIsolate())); + // Set the debug break flag. v8::Debug::DebugBreak(env->GetIsolate()); @@ -4377,10 +4465,6 @@ TEST(InterceptorPropertyMirror) { "named_values[%d] instanceof debug.PropertyMirror", i); CHECK(CompileRun(buffer.start())->BooleanValue()); - SNPrintF(buffer, "named_values[%d].propertyType()", i); - CHECK_EQ(v8::internal::INTERCEPTOR, - CompileRun(buffer.start())->Int32Value()); - SNPrintF(buffer, "named_values[%d].isNative()", i); CHECK(CompileRun(buffer.start())->BooleanValue()); } @@ -4696,7 +4780,7 @@ TEST(NoHiddenProperties) { // The Wait() call blocks a thread until it is called for the Nth time, then all // calls return. Each ThreadBarrier object can only be used once. template <int N> -class ThreadBarrier V8_FINAL { +class ThreadBarrier FINAL { public: ThreadBarrier() : num_blocked_(0) {} @@ -5106,12 +5190,20 @@ class V8Thread : public v8::base::Thread { public: V8Thread() : Thread(Options("V8Thread")) {} void Run(); + v8::Isolate* isolate() { return isolate_; } + + private: + v8::Isolate* isolate_; }; class DebuggerThread : public v8::base::Thread { public: - DebuggerThread() : Thread(Options("DebuggerThread")) {} + explicit DebuggerThread(v8::Isolate* isolate) + : Thread(Options("DebuggerThread")), isolate_(isolate) {} void Run(); + + private: + v8::Isolate* isolate_; }; @@ -5154,22 +5246,25 @@ void V8Thread::Run() { "\n" "foo();\n"; - v8::Isolate* isolate = CcTest::isolate(); - v8::Isolate::Scope isolate_scope(isolate); - DebugLocalContext env; - v8::HandleScope scope(env->GetIsolate()); - v8::Debug::SetMessageHandler(&ThreadedMessageHandler); - v8::Handle<v8::ObjectTemplate> global_template = - v8::ObjectTemplate::New(env->GetIsolate()); - global_template->Set( - v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), - v8::FunctionTemplate::New(isolate, ThreadedAtBarrier1)); - v8::Handle<v8::Context> context = v8::Context::New(isolate, - NULL, - global_template); - v8::Context::Scope context_scope(context); - - CompileRun(source); + isolate_ = v8::Isolate::New(); + threaded_debugging_barriers.barrier_3.Wait(); + { + v8::Isolate::Scope isolate_scope(isolate_); + DebugLocalContext env(isolate_); + v8::HandleScope scope(isolate_); + v8::Debug::SetMessageHandler(&ThreadedMessageHandler); + v8::Handle<v8::ObjectTemplate> global_template = + v8::ObjectTemplate::New(env->GetIsolate()); + global_template->Set( + v8::String::NewFromUtf8(env->GetIsolate(), "ThreadedAtBarrier1"), + v8::FunctionTemplate::New(isolate_, ThreadedAtBarrier1)); + v8::Handle<v8::Context> context = + v8::Context::New(isolate_, NULL, global_template); + v8::Context::Scope context_scope(context); + + CompileRun(source); + } + isolate_->Dispose(); } @@ -5185,21 +5280,21 @@ void DebuggerThread::Run() { "\"type\":\"request\"," "\"command\":\"continue\"}"; - v8::Isolate* isolate = CcTest::isolate(); threaded_debugging_barriers.barrier_1.Wait(); - v8::Debug::DebugBreak(isolate); + v8::Debug::DebugBreak(isolate_); threaded_debugging_barriers.barrier_2.Wait(); - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer)); - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer)); } TEST(ThreadedDebugging) { - DebuggerThread debugger_thread; V8Thread v8_thread; // Create a V8 environment v8_thread.Start(); + threaded_debugging_barriers.barrier_3.Wait(); + DebuggerThread debugger_thread(v8_thread.isolate()); debugger_thread.Start(); v8_thread.Join(); @@ -5218,17 +5313,24 @@ class BreakpointsV8Thread : public v8::base::Thread { public: BreakpointsV8Thread() : Thread(Options("BreakpointsV8Thread")) {} void Run(); + + v8::Isolate* isolate() { return isolate_; } + + private: + v8::Isolate* isolate_; }; class BreakpointsDebuggerThread : public v8::base::Thread { public: - explicit BreakpointsDebuggerThread(bool global_evaluate) + BreakpointsDebuggerThread(bool global_evaluate, v8::Isolate* isolate) : Thread(Options("BreakpointsDebuggerThread")), - global_evaluate_(global_evaluate) {} + global_evaluate_(global_evaluate), + isolate_(isolate) {} void Run(); private: bool global_evaluate_; + v8::Isolate* isolate_; }; @@ -5273,16 +5375,20 @@ void BreakpointsV8Thread::Run() { const char* source_2 = "cat(17);\n" "cat(19);\n"; - v8::Isolate* isolate = CcTest::isolate(); - v8::Isolate::Scope isolate_scope(isolate); - DebugLocalContext env; - v8::HandleScope scope(isolate); - v8::Debug::SetMessageHandler(&BreakpointsMessageHandler); - - CompileRun(source_1); - breakpoints_barriers->barrier_1.Wait(); - breakpoints_barriers->barrier_2.Wait(); - CompileRun(source_2); + isolate_ = v8::Isolate::New(); + breakpoints_barriers->barrier_3.Wait(); + { + v8::Isolate::Scope isolate_scope(isolate_); + DebugLocalContext env(isolate_); + v8::HandleScope scope(isolate_); + v8::Debug::SetMessageHandler(&BreakpointsMessageHandler); + + CompileRun(source_1); + breakpoints_barriers->barrier_1.Wait(); + breakpoints_barriers->barrier_2.Wait(); + CompileRun(source_2); + } + isolate_->Dispose(); } @@ -5348,14 +5454,12 @@ void BreakpointsDebuggerThread::Run() { "\"command\":\"continue\"}"; - v8::Isolate* isolate = CcTest::isolate(); - v8::Isolate::Scope isolate_scope(isolate); // v8 thread initializes, runs source_1 breakpoints_barriers->barrier_1.Wait(); // 1:Set breakpoint in cat() (will get id 1). - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_1, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_1, buffer)); // 2:Set breakpoint in dog() (will get id 2). - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_2, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_2, buffer)); breakpoints_barriers->barrier_2.Wait(); // V8 thread starts compiling source_2. // Automatic break happens, to run queued commands @@ -5367,43 +5471,42 @@ void BreakpointsDebuggerThread::Run() { // Must have hit breakpoint #1. CHECK_EQ(1, break_event_breakpoint_id); // 4:Evaluate dog() (which has a breakpoint). - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_3, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_3, buffer)); // V8 thread hits breakpoint in dog(). breakpoints_barriers->semaphore_1.Wait(); // wait for break event // Must have hit breakpoint #2. CHECK_EQ(2, break_event_breakpoint_id); // 5:Evaluate (x + 1). - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_4, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_4, buffer)); // Evaluate (x + 1) finishes. breakpoints_barriers->semaphore_1.Wait(); // Must have result 108. CHECK_EQ(108, evaluate_int_result); // 6:Continue evaluation of dog(). - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_5, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_5, buffer)); // Evaluate dog() finishes. breakpoints_barriers->semaphore_1.Wait(); // Must have result 107. CHECK_EQ(107, evaluate_int_result); // 7:Continue evaluation of source_2, finish cat(17), hit breakpoint // in cat(19). - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_6, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_6, buffer)); // Message callback gets break event. breakpoints_barriers->semaphore_1.Wait(); // wait for break event // Must have hit breakpoint #1. CHECK_EQ(1, break_event_breakpoint_id); // 8: Evaluate dog() with breaks disabled. - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_7, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_7, buffer)); // Evaluate dog() finishes. breakpoints_barriers->semaphore_1.Wait(); // Must have result 116. CHECK_EQ(116, evaluate_int_result); // 9: Continue evaluation of source2, reach end. - v8::Debug::SendCommand(isolate, buffer, AsciiToUtf16(command_8, buffer)); + v8::Debug::SendCommand(isolate_, buffer, AsciiToUtf16(command_8, buffer)); } void TestRecursiveBreakpointsGeneric(bool global_evaluate) { - BreakpointsDebuggerThread breakpoints_debugger_thread(global_evaluate); BreakpointsV8Thread breakpoints_v8_thread; // Create a V8 environment @@ -5411,6 +5514,9 @@ void TestRecursiveBreakpointsGeneric(bool global_evaluate) { breakpoints_barriers = &stack_allocated_breakpoints_barriers; breakpoints_v8_thread.Start(); + breakpoints_barriers->barrier_3.Wait(); + BreakpointsDebuggerThread breakpoints_debugger_thread( + global_evaluate, breakpoints_v8_thread.isolate()); breakpoints_debugger_thread.Start(); breakpoints_v8_thread.Join(); @@ -6522,6 +6628,10 @@ TEST(ProcessDebugMessages) { } +class SendCommandThread; +static SendCommandThread* send_command_thread_ = NULL; + + class SendCommandThread : public v8::base::Thread { public: explicit SendCommandThread(v8::Isolate* isolate) @@ -6529,9 +6639,12 @@ class SendCommandThread : public v8::base::Thread { semaphore_(0), isolate_(isolate) {} - static void ProcessDebugMessages(v8::Isolate* isolate, void* data) { - v8::Debug::ProcessDebugMessages(); - reinterpret_cast<v8::base::Semaphore*>(data)->Signal(); + static void CountingAndSignallingMessageHandler( + const v8::Debug::Message& message) { + if (message.IsResponse()) { + counting_message_handler_counter++; + send_command_thread_->semaphore_.Signal(); + } } virtual void Run() { @@ -6545,21 +6658,22 @@ class SendCommandThread : public v8::base::Thread { int length = AsciiToUtf16(scripts_command, buffer); // Send scripts command. - for (int i = 0; i < 100; i++) { + for (int i = 0; i < 20; i++) { + v8::base::ElapsedTimer timer; + timer.Start(); CHECK_EQ(i, counting_message_handler_counter); // Queue debug message. v8::Debug::SendCommand(isolate_, buffer, length); - // Synchronize with the main thread to force message processing. - isolate_->RequestInterrupt(ProcessDebugMessages, &semaphore_); + // Wait for the message handler to pick up the response. semaphore_.Wait(); + i::PrintF("iteration %d took %f ms\n", i, + timer.Elapsed().InMillisecondsF()); } v8::V8::TerminateExecution(isolate_); } - void StartSending() { - semaphore_.Signal(); - } + void StartSending() { semaphore_.Signal(); } private: v8::base::Semaphore semaphore_; @@ -6567,8 +6681,6 @@ class SendCommandThread : public v8::base::Thread { }; -static SendCommandThread* send_command_thread_ = NULL; - static void StartSendingCommands( const v8::FunctionCallbackInfo<v8::Value>& info) { send_command_thread_->StartSending(); @@ -6582,7 +6694,8 @@ TEST(ProcessDebugMessagesThreaded) { counting_message_handler_counter = 0; - v8::Debug::SetMessageHandler(CountingMessageHandler); + v8::Debug::SetMessageHandler( + SendCommandThread::CountingAndSignallingMessageHandler); send_command_thread_ = new SendCommandThread(isolate); send_command_thread_->Start(); @@ -6592,7 +6705,7 @@ TEST(ProcessDebugMessagesThreaded) { CompileRun("start(); while (true) { }"); - CHECK_EQ(100, counting_message_handler_counter); + CHECK_EQ(20, counting_message_handler_counter); v8::Debug::SetMessageHandler(NULL); CheckDebuggerUnloaded(); diff --git a/deps/v8/test/cctest/test-deoptimization.cc b/deps/v8/test/cctest/test-deoptimization.cc index 3127acc6a6..a201ccd7e4 100644 --- a/deps/v8/test/cctest/test-deoptimization.cc +++ b/deps/v8/test/cctest/test-deoptimization.cc @@ -35,7 +35,6 @@ #include "src/debug.h" #include "src/deoptimizer.h" #include "src/isolate.h" -#include "src/stub-cache.h" #include "test/cctest/cctest.h" using ::v8::base::OS; @@ -99,8 +98,8 @@ class AllowNativesSyntaxNoInlining { // Abort any ongoing incremental marking to make sure that all weak global // handle callbacks are processed. -static void NonIncrementalGC() { - CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); +static void NonIncrementalGC(i::Isolate* isolate) { + isolate->heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); } @@ -128,7 +127,7 @@ TEST(DeoptimizeSimple) { "function f() { g(); };" "f();"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -144,7 +143,7 @@ TEST(DeoptimizeSimple) { "function f(x) { if (x) { g(); } else { return } };" "f(true);"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -168,7 +167,7 @@ TEST(DeoptimizeSimpleWithArguments) { "function f(x, y, z) { g(1,x); y+z; };" "f(1, \"2\", false);"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -185,7 +184,7 @@ TEST(DeoptimizeSimpleWithArguments) { "function f(x, y, z) { if (x) { g(x, y); } else { return y + z; } };" "f(true, 1, \"2\");"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); @@ -210,7 +209,7 @@ TEST(DeoptimizeSimpleNested) { "function g(z) { count++; %DeoptimizeFunction(f); return z;}" "function f(x,y,z) { return h(x, y, g(z)); };" "result = f(1, 2, 3);"); - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -236,7 +235,7 @@ TEST(DeoptimizeRecursive) { "function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" "f(10);"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); @@ -269,7 +268,7 @@ TEST(DeoptimizeMultiple) { "function f1(x) { return f2(x + 1, x + 1) + x; };" "result = f1(1);"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -291,7 +290,7 @@ TEST(DeoptimizeConstructor) { "function f() { g(); };" "result = new f() instanceof f;"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK(env->Global()->Get(v8_str("result"))->IsTrue()); @@ -308,7 +307,7 @@ TEST(DeoptimizeConstructor) { "result = new f(1, 2);" "result = result.x + result.y;"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -338,7 +337,7 @@ TEST(DeoptimizeConstructorMultiple) { "function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" "result = new f1(1).result;"); } - NonIncrementalGC(); + NonIncrementalGC(CcTest::i_isolate()); CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); @@ -346,51 +345,61 @@ TEST(DeoptimizeConstructorMultiple) { } -TEST(DeoptimizeBinaryOperationADDString) { +UNINITIALIZED_TEST(DeoptimizeBinaryOperationADDString) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; AllowNativesSyntaxNoInlining options; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - - const char* f_source = "function f(x, y) { return x + y; };"; - + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); { - // Compile function f and collect to type feedback to insert binary op stub - // call in the optimized code. - i::FLAG_prepare_always_opt = true; - CompileRun("var count = 0;" - "var result = 0;" - "var deopt = false;" - "function X() { };" - "X.prototype.toString = function () {" - " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" - "};"); - CompileRun(f_source); - CompileRun("for (var i = 0; i < 5; i++) {" - " f('a+', new X());" - "};"); - - // Compile an optimized version of f. - i::FLAG_always_opt = true; - CompileRun(f_source); - CompileRun("f('a+', new X());"); - CHECK(!CcTest::i_isolate()->use_crankshaft() || - GetJSFunction(env->Global(), "f")->IsOptimized()); - - // Call f and force deoptimization while processing the binary operation. - CompileRun("deopt = true;" - "var result = f('a+', new X());"); - } - NonIncrementalGC(); + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); + + const char* f_source = "function f(x, y) { return x + y; };"; + + { + // Compile function f and collect to type feedback to insert binary op + // stub call in the optimized code. + i::FLAG_prepare_always_opt = true; + CompileRun( + "var count = 0;" + "var result = 0;" + "var deopt = false;" + "function X() { };" + "X.prototype.toString = function () {" + " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" + "};"); + CompileRun(f_source); + CompileRun( + "for (var i = 0; i < 5; i++) {" + " f('a+', new X());" + "};"); + + // Compile an optimized version of f. + i::FLAG_always_opt = true; + CompileRun(f_source); + CompileRun("f('a+', new X());"); + CHECK(!i_isolate->use_crankshaft() || + GetJSFunction(env->Global(), "f")->IsOptimized()); + + // Call f and force deoptimization while processing the binary operation. + CompileRun( + "deopt = true;" + "var result = f('a+', new X());"); + } + NonIncrementalGC(i_isolate); - CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); - CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); - v8::Handle<v8::Value> result = env->Global()->Get(v8_str("result")); - CHECK(result->IsString()); - v8::String::Utf8Value utf8(result); - CHECK_EQ("a+an X", *utf8); - CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); + CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); + CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); + v8::Handle<v8::Value> result = env->Global()->Get(v8_str("result")); + CHECK(result->IsString()); + v8::String::Utf8Value utf8(result); + CHECK_EQ("a+an X", *utf8); + CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); + } + isolate->Exit(); + isolate->Dispose(); } @@ -407,6 +416,7 @@ static void CompileConstructorWithDeoptimizingValueOf() { static void TestDeoptimizeBinaryOpHelper(LocalContext* env, const char* binary_op) { + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>((*env)->GetIsolate()); EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer; SNPrintF(f_source_buffer, "function f(x, y) { return x %s y; };", @@ -427,290 +437,355 @@ static void TestDeoptimizeBinaryOpHelper(LocalContext* env, i::FLAG_always_opt = true; CompileRun(f_source); CompileRun("f(7, new X());"); - CHECK(!CcTest::i_isolate()->use_crankshaft() || + CHECK(!i_isolate->use_crankshaft() || GetJSFunction((*env)->Global(), "f")->IsOptimized()); // Call f and force deoptimization while processing the binary operation. CompileRun("deopt = true;" "var result = f(7, new X());"); - NonIncrementalGC(); + NonIncrementalGC(i_isolate); CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); } -TEST(DeoptimizeBinaryOperationADD) { +UNINITIALIZED_TEST(DeoptimizeBinaryOperationADD) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); + { + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); - TestDeoptimizeBinaryOpHelper(&env, "+"); + TestDeoptimizeBinaryOpHelper(&env, "+"); - 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(CcTest::i_isolate())); + 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(i_isolate)); + } + isolate->Exit(); + isolate->Dispose(); } -TEST(DeoptimizeBinaryOperationSUB) { +UNINITIALIZED_TEST(DeoptimizeBinaryOperationSUB) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); + { + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); - TestDeoptimizeBinaryOpHelper(&env, "-"); + TestDeoptimizeBinaryOpHelper(&env, "-"); - 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(CcTest::i_isolate())); + 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(i_isolate)); + } + isolate->Exit(); + isolate->Dispose(); } -TEST(DeoptimizeBinaryOperationMUL) { +UNINITIALIZED_TEST(DeoptimizeBinaryOperationMUL) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); + { + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); - TestDeoptimizeBinaryOpHelper(&env, "*"); + TestDeoptimizeBinaryOpHelper(&env, "*"); - 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(CcTest::i_isolate())); + 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(i_isolate)); + } + isolate->Exit(); + isolate->Dispose(); } -TEST(DeoptimizeBinaryOperationDIV) { +UNINITIALIZED_TEST(DeoptimizeBinaryOperationDIV) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); + { + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); - TestDeoptimizeBinaryOpHelper(&env, "/"); + TestDeoptimizeBinaryOpHelper(&env, "/"); - 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(CcTest::i_isolate())); + 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(i_isolate)); + } + isolate->Exit(); + isolate->Dispose(); } -TEST(DeoptimizeBinaryOperationMOD) { +UNINITIALIZED_TEST(DeoptimizeBinaryOperationMOD) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); + { + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); - TestDeoptimizeBinaryOpHelper(&env, "%"); + TestDeoptimizeBinaryOpHelper(&env, "%"); - 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(CcTest::i_isolate())); + 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(i_isolate)); + } + isolate->Exit(); + isolate->Dispose(); } -TEST(DeoptimizeCompare) { +UNINITIALIZED_TEST(DeoptimizeCompare) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - - const char* f_source = "function f(x, y) { return x < y; };"; - + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); { - AllowNativesSyntaxNoInlining options; - // Compile function f and collect to type feedback to insert compare ic - // call in the optimized code. - i::FLAG_prepare_always_opt = true; - CompileRun("var count = 0;" - "var result = 0;" - "var deopt = false;" - "function X() { };" - "X.prototype.toString = function () {" - " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" - "};"); - CompileRun(f_source); - CompileRun("for (var i = 0; i < 5; i++) {" - " f('a', new X());" - "};"); - - // Compile an optimized version of f. - i::FLAG_always_opt = true; - CompileRun(f_source); - CompileRun("f('a', new X());"); - CHECK(!CcTest::i_isolate()->use_crankshaft() || - GetJSFunction(env->Global(), "f")->IsOptimized()); - - // Call f and force deoptimization while processing the comparison. - CompileRun("deopt = true;" - "var result = f('a', new X());"); - } - NonIncrementalGC(); + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); + + const char* f_source = "function f(x, y) { return x < y; };"; + + { + AllowNativesSyntaxNoInlining options; + // Compile function f and collect to type feedback to insert compare ic + // call in the optimized code. + i::FLAG_prepare_always_opt = true; + CompileRun( + "var count = 0;" + "var result = 0;" + "var deopt = false;" + "function X() { };" + "X.prototype.toString = function () {" + " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" + "};"); + CompileRun(f_source); + CompileRun( + "for (var i = 0; i < 5; i++) {" + " f('a', new X());" + "};"); + + // Compile an optimized version of f. + i::FLAG_always_opt = true; + CompileRun(f_source); + CompileRun("f('a', new X());"); + CHECK(!i_isolate->use_crankshaft() || + GetJSFunction(env->Global(), "f")->IsOptimized()); + + // Call f and force deoptimization while processing the comparison. + CompileRun( + "deopt = true;" + "var result = f('a', new X());"); + } + NonIncrementalGC(i_isolate); - 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(CcTest::i_isolate())); + 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(i_isolate)); + } + isolate->Exit(); + isolate->Dispose(); } -TEST(DeoptimizeLoadICStoreIC) { +UNINITIALIZED_TEST(DeoptimizeLoadICStoreIC) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - - // Functions to generate load/store/keyed load/keyed store IC calls. - const char* f1_source = "function f1(x) { return x.y; };"; - const char* g1_source = "function g1(x) { x.y = 1; };"; - const char* f2_source = "function f2(x, y) { return x[y]; };"; - const char* g2_source = "function g2(x, y) { x[y] = 1; };"; - + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); { - AllowNativesSyntaxNoInlining options; - // Compile functions and collect to type feedback to insert ic - // calls in the optimized code. - i::FLAG_prepare_always_opt = true; - CompileRun("var count = 0;" - "var result = 0;" - "var deopt = false;" - "function X() { };" - "X.prototype.__defineGetter__('y', function () {" - " if (deopt) { count++; %DeoptimizeFunction(f1); };" - " return 13;" - "});" - "X.prototype.__defineSetter__('y', function () {" - " if (deopt) { count++; %DeoptimizeFunction(g1); };" - "});" - "X.prototype.__defineGetter__('z', function () {" - " if (deopt) { count++; %DeoptimizeFunction(f2); };" - " return 13;" - "});" - "X.prototype.__defineSetter__('z', function () {" - " if (deopt) { count++; %DeoptimizeFunction(g2); };" - "});"); - CompileRun(f1_source); - CompileRun(g1_source); - CompileRun(f2_source); - CompileRun(g2_source); - CompileRun("for (var i = 0; i < 5; i++) {" - " f1(new X());" - " g1(new X());" - " f2(new X(), 'z');" - " g2(new X(), 'z');" - "};"); - - // Compile an optimized version of the functions. - i::FLAG_always_opt = true; - CompileRun(f1_source); - CompileRun(g1_source); - CompileRun(f2_source); - CompileRun(g2_source); - CompileRun("f1(new X());"); - CompileRun("g1(new X());"); - CompileRun("f2(new X(), 'z');"); - CompileRun("g2(new X(), 'z');"); - if (CcTest::i_isolate()->use_crankshaft()) { - CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); - CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); - CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); - CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); + + // Functions to generate load/store/keyed load/keyed store IC calls. + const char* f1_source = "function f1(x) { return x.y; };"; + const char* g1_source = "function g1(x) { x.y = 1; };"; + const char* f2_source = "function f2(x, y) { return x[y]; };"; + const char* g2_source = "function g2(x, y) { x[y] = 1; };"; + + { + AllowNativesSyntaxNoInlining options; + // Compile functions and collect to type feedback to insert ic + // calls in the optimized code. + i::FLAG_prepare_always_opt = true; + CompileRun( + "var count = 0;" + "var result = 0;" + "var deopt = false;" + "function X() { };" + "X.prototype.__defineGetter__('y', function () {" + " if (deopt) { count++; %DeoptimizeFunction(f1); };" + " return 13;" + "});" + "X.prototype.__defineSetter__('y', function () {" + " if (deopt) { count++; %DeoptimizeFunction(g1); };" + "});" + "X.prototype.__defineGetter__('z', function () {" + " if (deopt) { count++; %DeoptimizeFunction(f2); };" + " return 13;" + "});" + "X.prototype.__defineSetter__('z', function () {" + " if (deopt) { count++; %DeoptimizeFunction(g2); };" + "});"); + CompileRun(f1_source); + CompileRun(g1_source); + CompileRun(f2_source); + CompileRun(g2_source); + CompileRun( + "for (var i = 0; i < 5; i++) {" + " f1(new X());" + " g1(new X());" + " f2(new X(), 'z');" + " g2(new X(), 'z');" + "};"); + + // Compile an optimized version of the functions. + i::FLAG_always_opt = true; + CompileRun(f1_source); + CompileRun(g1_source); + CompileRun(f2_source); + CompileRun(g2_source); + CompileRun("f1(new X());"); + CompileRun("g1(new X());"); + CompileRun("f2(new X(), 'z');"); + CompileRun("g2(new X(), 'z');"); + if (i_isolate->use_crankshaft()) { + CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); + CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); + CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); + CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); + } + + // Call functions and force deoptimization while processing the ics. + CompileRun( + "deopt = true;" + "var result = f1(new X());" + "g1(new X());" + "f2(new X(), 'z');" + "g2(new X(), 'z');"); } - - // Call functions and force deoptimization while processing the ics. - CompileRun("deopt = true;" - "var result = f1(new X());" - "g1(new X());" - "f2(new X(), 'z');" - "g2(new X(), 'z');"); + NonIncrementalGC(i_isolate); + + CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); + CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); + CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); + 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()); } - NonIncrementalGC(); - - CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); - CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); - CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); - 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()); + isolate->Exit(); + isolate->Dispose(); } -TEST(DeoptimizeLoadICStoreICNested) { +UNINITIALIZED_TEST(DeoptimizeLoadICStoreICNested) { i::FLAG_turbo_deoptimization = true; i::FLAG_concurrent_recompilation = false; - LocalContext env; - v8::HandleScope scope(env->GetIsolate()); - - // Functions to generate load/store/keyed load/keyed store IC calls. - const char* f1_source = "function f1(x) { return x.y; };"; - const char* g1_source = "function g1(x) { x.y = 1; };"; - const char* f2_source = "function f2(x, y) { return x[y]; };"; - const char* g2_source = "function g2(x, y) { x[y] = 1; };"; - + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); { - AllowNativesSyntaxNoInlining options; - // Compile functions and collect to type feedback to insert ic - // calls in the optimized code. - i::FLAG_prepare_always_opt = true; - CompileRun("var count = 0;" - "var result = 0;" - "var deopt = false;" - "function X() { };" - "X.prototype.__defineGetter__('y', function () {" - " g1(this);" - " return 13;" - "});" - "X.prototype.__defineSetter__('y', function () {" - " f2(this, 'z');" - "});" - "X.prototype.__defineGetter__('z', function () {" - " g2(this, 'z');" - "});" - "X.prototype.__defineSetter__('z', function () {" - " if (deopt) {" - " count++;" - " %DeoptimizeFunction(f1);" - " %DeoptimizeFunction(g1);" - " %DeoptimizeFunction(f2);" - " %DeoptimizeFunction(g2); };" - "});"); - CompileRun(f1_source); - CompileRun(g1_source); - CompileRun(f2_source); - CompileRun(g2_source); - CompileRun("for (var i = 0; i < 5; i++) {" - " f1(new X());" - " g1(new X());" - " f2(new X(), 'z');" - " g2(new X(), 'z');" - "};"); - - // Compile an optimized version of the functions. - i::FLAG_always_opt = true; - CompileRun(f1_source); - CompileRun(g1_source); - CompileRun(f2_source); - CompileRun(g2_source); - CompileRun("f1(new X());"); - CompileRun("g1(new X());"); - CompileRun("f2(new X(), 'z');"); - CompileRun("g2(new X(), 'z');"); - if (CcTest::i_isolate()->use_crankshaft()) { - CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); - CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); - CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); - CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); + LocalContext env(isolate); + v8::HandleScope scope(env->GetIsolate()); + + // Functions to generate load/store/keyed load/keyed store IC calls. + const char* f1_source = "function f1(x) { return x.y; };"; + const char* g1_source = "function g1(x) { x.y = 1; };"; + const char* f2_source = "function f2(x, y) { return x[y]; };"; + const char* g2_source = "function g2(x, y) { x[y] = 1; };"; + + { + AllowNativesSyntaxNoInlining options; + // Compile functions and collect to type feedback to insert ic + // calls in the optimized code. + i::FLAG_prepare_always_opt = true; + CompileRun( + "var count = 0;" + "var result = 0;" + "var deopt = false;" + "function X() { };" + "X.prototype.__defineGetter__('y', function () {" + " g1(this);" + " return 13;" + "});" + "X.prototype.__defineSetter__('y', function () {" + " f2(this, 'z');" + "});" + "X.prototype.__defineGetter__('z', function () {" + " g2(this, 'z');" + "});" + "X.prototype.__defineSetter__('z', function () {" + " if (deopt) {" + " count++;" + " %DeoptimizeFunction(f1);" + " %DeoptimizeFunction(g1);" + " %DeoptimizeFunction(f2);" + " %DeoptimizeFunction(g2); };" + "});"); + CompileRun(f1_source); + CompileRun(g1_source); + CompileRun(f2_source); + CompileRun(g2_source); + CompileRun( + "for (var i = 0; i < 5; i++) {" + " f1(new X());" + " g1(new X());" + " f2(new X(), 'z');" + " g2(new X(), 'z');" + "};"); + + // Compile an optimized version of the functions. + i::FLAG_always_opt = true; + CompileRun(f1_source); + CompileRun(g1_source); + CompileRun(f2_source); + CompileRun(g2_source); + CompileRun("f1(new X());"); + CompileRun("g1(new X());"); + CompileRun("f2(new X(), 'z');"); + CompileRun("g2(new X(), 'z');"); + if (i_isolate->use_crankshaft()) { + CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); + CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); + CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); + CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); + } + + // Call functions and force deoptimization while processing the ics. + CompileRun( + "deopt = true;" + "var result = f1(new X());"); } + NonIncrementalGC(i_isolate); - // Call functions and force deoptimization while processing the ics. - CompileRun("deopt = true;" - "var result = f1(new X());"); + CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); + CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); + CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); + 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()); } - NonIncrementalGC(); - - CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); - CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); - CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); - 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()); + isolate->Exit(); + isolate->Dispose(); } diff --git a/deps/v8/test/cctest/test-dictionary.cc b/deps/v8/test/cctest/test-dictionary.cc index 9a1914237f..14e5d69d43 100644 --- a/deps/v8/test/cctest/test-dictionary.cc +++ b/deps/v8/test/cctest/test-dictionary.cc @@ -99,8 +99,8 @@ static void TestHashMap(Handle<HashMap> table) { for (int i = 0; i < 100; i++) { Handle<JSReceiver> key = factory->NewJSArray(7); CHECK_EQ(table->Lookup(key), CcTest::heap()->the_hole_value()); - CHECK_EQ(key->GetIdentityHash(), - CcTest::heap()->undefined_value()); + Object* identity_hash = key->GetIdentityHash(); + CHECK_EQ(identity_hash, CcTest::heap()->undefined_value()); } } diff --git a/deps/v8/test/cctest/test-disasm-ia32.cc b/deps/v8/test/cctest/test-disasm-ia32.cc index 8436df7c5a..49088f6e94 100644 --- a/deps/v8/test/cctest/test-disasm-ia32.cc +++ b/deps/v8/test/cctest/test-disasm-ia32.cc @@ -32,9 +32,9 @@ #include "src/debug.h" #include "src/disasm.h" #include "src/disassembler.h" +#include "src/ic/ic.h" #include "src/macro-assembler.h" #include "src/serialize.h" -#include "src/stub-cache.h" #include "test/cctest/cctest.h" using namespace v8::internal; @@ -416,6 +416,7 @@ TEST(DisasmIa320) { __ addsd(xmm1, xmm0); __ mulsd(xmm1, xmm0); __ subsd(xmm1, xmm0); + __ subsd(xmm1, Operand(ebx, ecx, times_4, 10000)); __ divsd(xmm1, xmm0); __ ucomisd(xmm0, xmm1); __ cmpltsd(xmm0, xmm1); diff --git a/deps/v8/test/cctest/test-disasm-mips.cc b/deps/v8/test/cctest/test-disasm-mips.cc index cfd861e241..131f41384c 100644 --- a/deps/v8/test/cctest/test-disasm-mips.cc +++ b/deps/v8/test/cctest/test-disasm-mips.cc @@ -110,41 +110,127 @@ TEST(Type0) { COMPARE(subu(v0, v1, s0), "00701023 subu v0, v1, s0"); - COMPARE(mult(a0, a1), - "00850018 mult a0, a1"); - COMPARE(mult(t2, t3), - "014b0018 mult t2, t3"); - COMPARE(mult(v0, v1), - "00430018 mult v0, v1"); - - COMPARE(multu(a0, a1), - "00850019 multu a0, a1"); - COMPARE(multu(t2, t3), - "014b0019 multu t2, t3"); - COMPARE(multu(v0, v1), - "00430019 multu v0, v1"); - - COMPARE(div(a0, a1), - "0085001a div a0, a1"); - COMPARE(div(t2, t3), - "014b001a div t2, t3"); - COMPARE(div(v0, v1), - "0043001a div v0, v1"); - - COMPARE(divu(a0, a1), - "0085001b divu a0, a1"); - COMPARE(divu(t2, t3), - "014b001b divu t2, t3"); - COMPARE(divu(v0, v1), - "0043001b divu v0, v1"); - - if (kArchVariant != kLoongson) { + if (!IsMipsArchVariant(kMips32r6)) { + COMPARE(mult(a0, a1), + "00850018 mult a0, a1"); + COMPARE(mult(t2, t3), + "014b0018 mult t2, t3"); + COMPARE(mult(v0, v1), + "00430018 mult v0, v1"); + + COMPARE(multu(a0, a1), + "00850019 multu a0, a1"); + COMPARE(multu(t2, t3), + "014b0019 multu t2, t3"); + COMPARE(multu(v0, v1), + "00430019 multu v0, v1"); + + COMPARE(div(a0, a1), + "0085001a div a0, a1"); + COMPARE(div(t2, t3), + "014b001a div t2, t3"); + COMPARE(div(v0, v1), + "0043001a div v0, v1"); + + COMPARE(divu(a0, a1), + "0085001b divu a0, a1"); + COMPARE(divu(t2, t3), + "014b001b divu t2, t3"); + COMPARE(divu(v0, v1), + "0043001b divu v0, v1"); + + if (!IsMipsArchVariant(kLoongson)) { + COMPARE(mul(a0, a1, a2), + "70a62002 mul a0, a1, a2"); + COMPARE(mul(t2, t3, t4), + "716c5002 mul t2, t3, t4"); + COMPARE(mul(v0, v1, s0), + "70701002 mul v0, v1, s0"); + } + } else { // MIPS32r6. COMPARE(mul(a0, a1, a2), - "70a62002 mul a0, a1, a2"); - COMPARE(mul(t2, t3, t4), - "716c5002 mul t2, t3, t4"); - COMPARE(mul(v0, v1, s0), - "70701002 mul v0, v1, s0"); + "00a62098 mul a0, a1, a2"); + COMPARE(muh(a0, a1, a2), + "00a620d8 muh a0, a1, a2"); + COMPARE(mul(t1, t2, t3), + "014b4898 mul t1, t2, t3"); + COMPARE(muh(t1, t2, t3), + "014b48d8 muh t1, t2, t3"); + COMPARE(mul(v0, v1, a0), + "00641098 mul v0, v1, a0"); + COMPARE(muh(v0, v1, a0), + "006410d8 muh v0, v1, a0"); + + COMPARE(mulu(a0, a1, a2), + "00a62099 mulu a0, a1, a2"); + COMPARE(muhu(a0, a1, a2), + "00a620d9 muhu a0, a1, a2"); + COMPARE(mulu(t1, t2, t3), + "014b4899 mulu t1, t2, t3"); + COMPARE(muhu(t1, t2, t3), + "014b48d9 muhu t1, t2, t3"); + COMPARE(mulu(v0, v1, a0), + "00641099 mulu v0, v1, a0"); + COMPARE(muhu(v0, v1, a0), + "006410d9 muhu v0, v1, a0"); + + COMPARE(div(a0, a1, a2), + "00a6209a div a0, a1, a2"); + COMPARE(mod(a0, a1, a2), + "00a620da mod a0, a1, a2"); + COMPARE(div(t1, t2, t3), + "014b489a div t1, t2, t3"); + COMPARE(mod(t1, t2, t3), + "014b48da mod t1, t2, t3"); + COMPARE(div(v0, v1, a0), + "0064109a div v0, v1, a0"); + COMPARE(mod(v0, v1, a0), + "006410da mod v0, v1, a0"); + + COMPARE(divu(a0, a1, a2), + "00a6209b divu a0, a1, a2"); + COMPARE(modu(a0, a1, a2), + "00a620db modu a0, a1, a2"); + COMPARE(divu(t1, t2, t3), + "014b489b divu t1, t2, t3"); + COMPARE(modu(t1, t2, t3), + "014b48db modu t1, t2, t3"); + COMPARE(divu(v0, v1, a0), + "0064109b divu v0, v1, a0"); + COMPARE(modu(v0, v1, a0), + "006410db modu v0, v1, a0"); + + COMPARE(bovc(a0, a0, static_cast<int16_t>(0)), + "20840000 bovc a0, a0, 0"); + COMPARE(bovc(a1, a0, static_cast<int16_t>(0)), + "20a40000 bovc a1, a0, 0"); + COMPARE(bovc(a1, a0, 32767), + "20a47fff bovc a1, a0, 32767"); + COMPARE(bovc(a1, a0, -32768), + "20a48000 bovc a1, a0, -32768"); + + COMPARE(bnvc(a0, a0, static_cast<int16_t>(0)), + "60840000 bnvc a0, a0, 0"); + COMPARE(bnvc(a1, a0, static_cast<int16_t>(0)), + "60a40000 bnvc a1, a0, 0"); + COMPARE(bnvc(a1, a0, 32767), + "60a47fff bnvc a1, a0, 32767"); + COMPARE(bnvc(a1, a0, -32768), + "60a48000 bnvc a1, a0, -32768"); + + COMPARE(beqzc(a0, 0), + "d8800000 beqzc a0, 0x0"); + COMPARE(beqzc(a0, 0xfffff), // 0x0fffff == 1048575. + "d88fffff beqzc a0, 0xfffff"); + COMPARE(beqzc(a0, 0x100000), // 0x100000 == -1048576. + "d8900000 beqzc a0, 0x100000"); + + COMPARE(bnezc(a0, 0), + "f8800000 bnezc a0, 0x0"); + COMPARE(bnezc(a0, 0xfffff), // 0x0fffff == 1048575. + "f88fffff bnezc a0, 0xfffff"); + COMPARE(bnezc(a0, 0x100000), // 0x100000 == -1048576. + "f8900000 bnezc a0, 0x100000"); } COMPARE(addiu(a0, a1, 0x0), @@ -266,7 +352,7 @@ TEST(Type0) { COMPARE(srav(v0, v1, fp), "03c31007 srav v0, v1, fp"); - if (kArchVariant == kMips32r2) { + if (IsMipsArchVariant(kMips32r2)) { COMPARE(rotr(a0, a1, 0), "00252002 rotr a0, a1, 0"); COMPARE(rotr(s0, s1, 8), @@ -369,7 +455,7 @@ TEST(Type0) { COMPARE(sltiu(v0, v1, -1), "2c62ffff sltiu v0, v1, -1"); - if (kArchVariant != kLoongson) { + if (!IsMipsArchVariant(kLoongson)) { COMPARE(movz(a0, a1, a2), "00a6200a movz a0, a1, a2"); COMPARE(movz(s0, s1, s2), @@ -404,15 +490,24 @@ TEST(Type0) { COMPARE(movf(v0, v1, 6), "00781001 movf v0, v1, 6"); - COMPARE(clz(a0, a1), - "70a42020 clz a0, a1"); - COMPARE(clz(s6, s7), - "72f6b020 clz s6, s7"); - COMPARE(clz(v0, v1), - "70621020 clz v0, v1"); + if (IsMipsArchVariant(kMips32r6)) { + COMPARE(clz(a0, a1), + "00a02050 clz a0, a1"); + COMPARE(clz(s6, s7), + "02e0b050 clz s6, s7"); + COMPARE(clz(v0, v1), + "00601050 clz v0, v1"); + } else { + COMPARE(clz(a0, a1), + "70a42020 clz a0, a1"); + COMPARE(clz(s6, s7), + "72f6b020 clz s6, s7"); + COMPARE(clz(v0, v1), + "70621020 clz v0, v1"); + } } - if (kArchVariant == kMips32r2) { + if (IsMipsArchVariant(kMips32r2)) { COMPARE(ins_(a0, a1, 31, 1), "7ca4ffc4 ins a0, a1, 31, 1"); COMPARE(ins_(s6, s7, 30, 2), diff --git a/deps/v8/test/cctest/test-disasm-x64.cc b/deps/v8/test/cctest/test-disasm-x64.cc index 4778b04bb7..d238410fa4 100644 --- a/deps/v8/test/cctest/test-disasm-x64.cc +++ b/deps/v8/test/cctest/test-disasm-x64.cc @@ -32,9 +32,9 @@ #include "src/debug.h" #include "src/disasm.h" #include "src/disassembler.h" +#include "src/ic/ic.h" #include "src/macro-assembler.h" #include "src/serialize.h" -#include "src/stub-cache.h" #include "test/cctest/cctest.h" using namespace v8::internal; @@ -167,6 +167,7 @@ TEST(DisasmX64) { __ imulq(rdx, Operand(rbx, rcx, times_4, 10000)); __ imulq(rdx, rcx, Immediate(12)); __ imulq(rdx, rcx, Immediate(1000)); + __ imulq(rdx, Operand(rbx, rcx, times_4, 10000), Immediate(1000)); __ incq(rdx); __ incq(Operand(rbx, rcx, times_4, 10000)); @@ -378,6 +379,7 @@ TEST(DisasmX64) { __ cvttsd2si(rdx, Operand(rbx, rcx, times_4, 10000)); __ cvttsd2si(rdx, xmm1); __ cvttsd2siq(rdx, xmm1); + __ cvttsd2siq(rdx, Operand(rbx, rcx, times_4, 10000)); __ movsd(xmm1, Operand(rbx, rcx, times_4, 10000)); __ movsd(Operand(rbx, rcx, times_4, 10000), xmm1); // 128 bit move instructions. diff --git a/deps/v8/test/cctest/test-disasm-x87.cc b/deps/v8/test/cctest/test-disasm-x87.cc index 1515cc793b..6cd33e5574 100644 --- a/deps/v8/test/cctest/test-disasm-x87.cc +++ b/deps/v8/test/cctest/test-disasm-x87.cc @@ -32,9 +32,9 @@ #include "src/debug.h" #include "src/disasm.h" #include "src/disassembler.h" +#include "src/ic/ic.h" #include "src/macro-assembler.h" #include "src/serialize.h" -#include "src/stub-cache.h" #include "test/cctest/cctest.h" using namespace v8::internal; @@ -349,6 +349,7 @@ TEST(DisasmIa320) { __ fprem1(); __ fincstp(); __ ftst(); + __ fxam(); __ fxch(3); __ fld_s(Operand(ebx, ecx, times_4, 10000)); __ fstp_s(Operand(ebx, ecx, times_4, 10000)); @@ -378,6 +379,12 @@ TEST(DisasmIa320) { __ fninit(); __ nop(); + __ fldcw(Operand(ebx, ecx, times_4, 10000)); + __ fnstcw(Operand(ebx, ecx, times_4, 10000)); + __ fadd_d(Operand(ebx, ecx, times_4, 10000)); + __ fnsave(Operand(ebx, ecx, times_4, 10000)); + __ frstor(Operand(ebx, ecx, times_4, 10000)); + // xchg. { __ xchg(eax, eax); diff --git a/deps/v8/test/cctest/test-func-name-inference.cc b/deps/v8/test/cctest/test-func-name-inference.cc index bc503b58c6..ceceff63a0 100644 --- a/deps/v8/test/cctest/test-func-name-inference.cc +++ b/deps/v8/test/cctest/test-func-name-inference.cc @@ -30,7 +30,7 @@ #include "src/api.h" #include "src/debug.h" -#include "src/runtime.h" +#include "src/runtime/runtime.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/test-hashing.cc b/deps/v8/test/cctest/test-hashing.cc index 9857f9d88a..692861cfe4 100644 --- a/deps/v8/test/cctest/test-hashing.cc +++ b/deps/v8/test/cctest/test-hashing.cc @@ -47,94 +47,6 @@ typedef uint32_t (*HASH_FUNCTION)(); #define __ masm-> -void generate(MacroAssembler* masm, i::Vector<const uint8_t> string) { - // GenerateHashInit takes the first character as an argument so it can't - // handle the zero length string. - DCHECK(string.length() > 0); -#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 - __ push(ebx); - __ push(ecx); - __ mov(eax, Immediate(0)); - __ mov(ebx, Immediate(string.at(0))); - StringHelper::GenerateHashInit(masm, eax, ebx, ecx); - for (int i = 1; i < string.length(); i++) { - __ mov(ebx, Immediate(string.at(i))); - StringHelper::GenerateHashAddCharacter(masm, eax, ebx, ecx); - } - StringHelper::GenerateHashGetHash(masm, eax, ecx); - __ pop(ecx); - __ pop(ebx); - __ Ret(); -#elif V8_TARGET_ARCH_X64 - __ pushq(kRootRegister); - __ InitializeRootRegister(); - __ pushq(rbx); - __ pushq(rcx); - __ movp(rax, Immediate(0)); - __ movp(rbx, Immediate(string.at(0))); - StringHelper::GenerateHashInit(masm, rax, rbx, rcx); - for (int i = 1; i < string.length(); i++) { - __ movp(rbx, Immediate(string.at(i))); - StringHelper::GenerateHashAddCharacter(masm, rax, rbx, rcx); - } - StringHelper::GenerateHashGetHash(masm, rax, rcx); - __ popq(rcx); - __ popq(rbx); - __ popq(kRootRegister); - __ Ret(); -#elif V8_TARGET_ARCH_ARM - __ push(kRootRegister); - __ InitializeRootRegister(); - - __ mov(r0, Operand(0)); - __ mov(ip, Operand(string.at(0))); - StringHelper::GenerateHashInit(masm, r0, ip); - for (int i = 1; i < string.length(); i++) { - __ mov(ip, Operand(string.at(i))); - StringHelper::GenerateHashAddCharacter(masm, r0, ip); - } - StringHelper::GenerateHashGetHash(masm, r0); - __ pop(kRootRegister); - __ mov(pc, Operand(lr)); -#elif V8_TARGET_ARCH_ARM64 - // The ARM64 assembler usually uses jssp (x28) as a stack pointer, but only - // csp is initialized by the calling (C++) code. - Register old_stack_pointer = __ StackPointer(); - __ SetStackPointer(csp); - __ Push(root, xzr); - __ InitializeRootRegister(); - __ Mov(x0, 0); - __ Mov(x10, Operand(string.at(0))); - StringHelper::GenerateHashInit(masm, x0, x10); - for (int i = 1; i < string.length(); i++) { - __ Mov(x10, Operand(string.at(i))); - StringHelper::GenerateHashAddCharacter(masm, x0, x10); - } - StringHelper::GenerateHashGetHash(masm, x0, x10); - __ Pop(xzr, root); - __ Ret(); - __ SetStackPointer(old_stack_pointer); -#elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 - __ push(kRootRegister); - __ InitializeRootRegister(); - - __ mov(v0, zero_reg); - __ li(t1, Operand(string.at(0))); - StringHelper::GenerateHashInit(masm, v0, t1); - for (int i = 1; i < string.length(); i++) { - __ li(t1, Operand(string.at(i))); - StringHelper::GenerateHashAddCharacter(masm, v0, t1); - } - StringHelper::GenerateHashGetHash(masm, v0); - __ pop(kRootRegister); - __ jr(ra); - __ nop(); -#else -#error Unsupported architecture. -#endif -} - - void generate(MacroAssembler* masm, uint32_t key) { #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X87 __ push(ebx); @@ -184,44 +96,6 @@ void generate(MacroAssembler* masm, uint32_t key) { } -void check(i::Vector<const uint8_t> string) { - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - HandleScope scope(isolate); - - v8::internal::byte buffer[2048]; - MacroAssembler masm(isolate, buffer, sizeof buffer); - - generate(&masm, string); - - CodeDesc desc; - masm.GetCode(&desc); - Handle<Object> undefined(isolate->heap()->undefined_value(), isolate); - Handle<Code> code = factory->NewCode(desc, - Code::ComputeFlags(Code::STUB), - undefined); - CHECK(code->IsCode()); - - HASH_FUNCTION hash = FUNCTION_CAST<HASH_FUNCTION>(code->entry()); - Handle<String> v8_string = - factory->NewStringFromOneByte(string).ToHandleChecked(); - v8_string->set_hash_field(String::kEmptyHashField); -#ifdef USE_SIMULATOR - uint32_t codegen_hash = static_cast<uint32_t>( - reinterpret_cast<uintptr_t>(CALL_GENERATED_CODE(hash, 0, 0, 0, 0, 0))); -#else - uint32_t codegen_hash = hash(); -#endif - uint32_t runtime_hash = v8_string->Hash(); - CHECK(runtime_hash == codegen_hash); -} - - -void check(i::Vector<const char> s) { - check(i::Vector<const uint8_t>::cast(s)); -} - - void check(uint32_t key) { Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); @@ -253,38 +127,11 @@ void check(uint32_t key) { } -void check_twochars(uint8_t a, uint8_t b) { - uint8_t ab[2] = {a, b}; - check(i::Vector<const uint8_t>(ab, 2)); -} - - static uint32_t PseudoRandom(uint32_t i, uint32_t j) { return ~(~((i * 781) ^ (j * 329))); } -TEST(StringHash) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope handle_scope(isolate); - v8::Context::Scope context_scope(v8::Context::New(isolate)); - - for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) { - // Numbers are hashed differently. - if (a >= '0' && a <= '9') continue; - for (uint8_t b = 0; b < String::kMaxOneByteCharCode; b++) { - if (b >= '0' && b <= '9') continue; - check_twochars(a, b); - } - } - check(i::Vector<const char>("*", 1)); - check(i::Vector<const char>(".zZ", 3)); - check(i::Vector<const char>("muc", 3)); - check(i::Vector<const char>("(>'_')>", 7)); - check(i::Vector<const char>("-=[ vee eight ftw ]=-", 21)); -} - - TEST(NumberHash) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope handle_scope(isolate); diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index e456323bae..8f9b484391 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -441,8 +441,8 @@ TEST(HeapSnapshotConsString) { CHECK_EQ(1, global->InternalFieldCount()); i::Factory* factory = CcTest::i_isolate()->factory(); - i::Handle<i::String> first = factory->NewStringFromStaticAscii("0123456789"); - i::Handle<i::String> second = factory->NewStringFromStaticAscii("0123456789"); + i::Handle<i::String> first = factory->NewStringFromStaticChars("0123456789"); + i::Handle<i::String> second = factory->NewStringFromStaticChars("0123456789"); i::Handle<i::String> cons_string = factory->NewConsString(first, second).ToHandleChecked(); @@ -875,9 +875,9 @@ class TestJSONStream : public v8::OutputStream { int abort_countdown_; }; -class AsciiResource: public v8::String::ExternalAsciiStringResource { +class OneByteResource : public v8::String::ExternalOneByteStringResource { public: - explicit AsciiResource(i::Vector<char> string): data_(string.start()) { + explicit OneByteResource(i::Vector<char> string) : data_(string.start()) { length_ = string.length(); } virtual const char* data() const { return data_; } @@ -913,7 +913,7 @@ TEST(HeapSnapshotJSONSerialization) { stream.WriteTo(json); // Verify that snapshot string is valid JSON. - AsciiResource* json_res = new AsciiResource(json); + OneByteResource* json_res = new OneByteResource(json); v8::Local<v8::String> json_string = v8::String::NewExternal(env->GetIsolate(), json_res); env->Global()->Set(v8_str("json_snapshot"), json_string); @@ -1863,12 +1863,16 @@ TEST(GetConstructorName) { "Constructor2", i::V8HeapExplorer::GetConstructorName(*js_obj2))); v8::Local<v8::Object> obj3 = js_global->Get(v8_str("obj3")).As<v8::Object>(); i::Handle<i::JSObject> js_obj3 = v8::Utils::OpenHandle(*obj3); - CHECK_EQ(0, StringCmp( - "Constructor3", i::V8HeapExplorer::GetConstructorName(*js_obj3))); + // TODO(verwaest): Restore to Constructor3 once supported by the + // heap-snapshot-generator. + CHECK_EQ( + 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj3))); v8::Local<v8::Object> obj4 = js_global->Get(v8_str("obj4")).As<v8::Object>(); i::Handle<i::JSObject> js_obj4 = v8::Utils::OpenHandle(*obj4); - CHECK_EQ(0, StringCmp( - "Constructor4", i::V8HeapExplorer::GetConstructorName(*js_obj4))); + // TODO(verwaest): Restore to Constructor4 once supported by the + // heap-snapshot-generator. + CHECK_EQ( + 0, StringCmp("Object", i::V8HeapExplorer::GetConstructorName(*js_obj4))); v8::Local<v8::Object> obj5 = js_global->Get(v8_str("obj5")).As<v8::Object>(); i::Handle<i::JSObject> js_obj5 = v8::Utils::OpenHandle(*obj5); CHECK_EQ(0, StringCmp( @@ -1983,6 +1987,46 @@ TEST(HiddenPropertiesFastCase) { } +TEST(AccessorInfo) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); + + CompileRun("function foo(x) { }\n"); + const v8::HeapSnapshot* snapshot = + heap_profiler->TakeHeapSnapshot(v8_str("AccessorInfoTest")); + CHECK(ValidateSnapshot(snapshot)); + const v8::HeapGraphNode* global = GetGlobalObject(snapshot); + const v8::HeapGraphNode* foo = + GetProperty(global, v8::HeapGraphEdge::kProperty, "foo"); + CHECK_NE(NULL, foo); + const v8::HeapGraphNode* map = + GetProperty(foo, v8::HeapGraphEdge::kInternal, "map"); + CHECK_NE(NULL, map); + const v8::HeapGraphNode* descriptors = + GetProperty(map, v8::HeapGraphEdge::kInternal, "descriptors"); + CHECK_NE(NULL, descriptors); + const v8::HeapGraphNode* length_name = + GetProperty(descriptors, v8::HeapGraphEdge::kInternal, "2"); + CHECK_NE(NULL, length_name); + CHECK_EQ("length", *v8::String::Utf8Value(length_name->GetName())); + const v8::HeapGraphNode* length_accessor = + GetProperty(descriptors, v8::HeapGraphEdge::kInternal, "4"); + CHECK_NE(NULL, length_accessor); + CHECK_EQ("system / ExecutableAccessorInfo", + *v8::String::Utf8Value(length_accessor->GetName())); + const v8::HeapGraphNode* name = + GetProperty(length_accessor, v8::HeapGraphEdge::kInternal, "name"); + CHECK_NE(NULL, name); + const v8::HeapGraphNode* getter = + GetProperty(length_accessor, v8::HeapGraphEdge::kInternal, "getter"); + CHECK_NE(NULL, getter); + const v8::HeapGraphNode* setter = + GetProperty(length_accessor, v8::HeapGraphEdge::kInternal, "setter"); + CHECK_NE(NULL, setter); +} + + bool HasWeakEdge(const v8::HeapGraphNode* node) { for (int i = 0; i < node->GetChildrenCount(); ++i) { const v8::HeapGraphEdge* handle_edge = node->GetChild(i); @@ -2307,7 +2351,7 @@ TEST(CheckCodeNames) { "::(ArraySingleArgumentConstructorStub code)" }; const v8::HeapGraphNode* node = GetNodeByPath(snapshot, - stub_path, ARRAY_SIZE(stub_path)); + stub_path, arraysize(stub_path)); CHECK_NE(NULL, node); const char* builtin_path1[] = { @@ -2315,18 +2359,15 @@ TEST(CheckCodeNames) { "::(Builtins)", "::(KeyedLoadIC_Generic builtin)" }; - node = GetNodeByPath(snapshot, builtin_path1, ARRAY_SIZE(builtin_path1)); + node = GetNodeByPath(snapshot, builtin_path1, arraysize(builtin_path1)); CHECK_NE(NULL, node); - const char* builtin_path2[] = { - "::(GC roots)", - "::(Builtins)", - "::(CompileUnoptimized builtin)" - }; - node = GetNodeByPath(snapshot, builtin_path2, ARRAY_SIZE(builtin_path2)); + const char* builtin_path2[] = {"::(GC roots)", "::(Builtins)", + "::(CompileLazy builtin)"}; + node = GetNodeByPath(snapshot, builtin_path2, arraysize(builtin_path2)); CHECK_NE(NULL, node); v8::String::Utf8Value node_name(node->GetName()); - CHECK_EQ("(CompileUnoptimized builtin)", *node_name); + CHECK_EQ("(CompileLazy builtin)", *node_name); } @@ -2416,7 +2457,7 @@ TEST(ArrayGrowLeftTrim) { tracker->trace_tree()->Print(tracker); AllocationTraceNode* node = - FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); + FindNode(tracker, Vector<const char*>(names, arraysize(names))); CHECK_NE(NULL, node); CHECK_GE(node->allocation_count(), 2); CHECK_GE(node->allocation_size(), 4 * 5); @@ -2443,7 +2484,7 @@ TEST(TrackHeapAllocations) { const char* names[] = {"", "start", "f_0_0", "f_0_1", "f_0_2"}; AllocationTraceNode* node = - FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); + FindNode(tracker, Vector<const char*>(names, arraysize(names))); CHECK_NE(NULL, node); CHECK_GE(node->allocation_count(), 100); CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); @@ -2492,7 +2533,7 @@ TEST(TrackBumpPointerAllocations) { tracker->trace_tree()->Print(tracker); AllocationTraceNode* node = - FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); + FindNode(tracker, Vector<const char*>(names, arraysize(names))); CHECK_NE(NULL, node); CHECK_GE(node->allocation_count(), 100); CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); @@ -2518,7 +2559,7 @@ TEST(TrackBumpPointerAllocations) { tracker->trace_tree()->Print(tracker); AllocationTraceNode* node = - FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); + FindNode(tracker, Vector<const char*>(names, arraysize(names))); CHECK_NE(NULL, node); CHECK_LT(node->allocation_count(), 100); @@ -2548,7 +2589,7 @@ TEST(TrackV8ApiAllocation) { tracker->trace_tree()->Print(tracker); AllocationTraceNode* node = - FindNode(tracker, Vector<const char*>(names, ARRAY_SIZE(names))); + FindNode(tracker, Vector<const char*>(names, arraysize(names))); CHECK_NE(NULL, node); CHECK_GE(node->allocation_count(), 2); CHECK_GE(node->allocation_size(), 4 * node->allocation_count()); @@ -2650,7 +2691,7 @@ TEST(BoxObject) { v8::Handle<v8::Object> global = global_proxy->GetPrototype().As<v8::Object>(); i::Factory* factory = CcTest::i_isolate()->factory(); - i::Handle<i::String> string = factory->NewStringFromStaticAscii("string"); + i::Handle<i::String> string = factory->NewStringFromStaticChars("string"); i::Handle<i::Object> box = factory->NewBox(string); global->Set(0, v8::ToApiHandle<v8::Object>(box)); diff --git a/deps/v8/test/cctest/test-heap.cc b/deps/v8/test/cctest/test-heap.cc index ab000dc6a6..e526761b9c 100644 --- a/deps/v8/test/cctest/test-heap.cc +++ b/deps/v8/test/cctest/test-heap.cc @@ -34,8 +34,8 @@ #include "src/execution.h" #include "src/factory.h" #include "src/global-handles.h" +#include "src/ic/ic.h" #include "src/macro-assembler.h" -#include "src/stub-cache.h" #include "test/cctest/cctest.h" using namespace v8::internal; @@ -185,7 +185,7 @@ TEST(HeapObjects) { CHECK(factory->nan_value()->IsNumber()); CHECK(std::isnan(factory->nan_value()->Number())); - Handle<String> s = factory->NewStringFromStaticAscii("fisk hest "); + Handle<String> s = factory->NewStringFromStaticChars("fisk hest "); CHECK(s->IsString()); CHECK_EQ(10, s->length()); @@ -341,7 +341,7 @@ TEST(GlobalHandles) { { HandleScope scope(isolate); - Handle<Object> i = factory->NewStringFromStaticAscii("fisk"); + Handle<Object> i = factory->NewStringFromStaticChars("fisk"); Handle<Object> u = factory->NewNumber(1.12344); h1 = global_handles->Create(*i); @@ -396,7 +396,7 @@ TEST(WeakGlobalHandlesScavenge) { { HandleScope scope(isolate); - Handle<Object> i = factory->NewStringFromStaticAscii("fisk"); + Handle<Object> i = factory->NewStringFromStaticChars("fisk"); Handle<Object> u = factory->NewNumber(1.12344); h1 = global_handles->Create(*i); @@ -438,7 +438,7 @@ TEST(WeakGlobalHandlesMark) { { HandleScope scope(isolate); - Handle<Object> i = factory->NewStringFromStaticAscii("fisk"); + Handle<Object> i = factory->NewStringFromStaticChars("fisk"); Handle<Object> u = factory->NewNumber(1.12344); h1 = global_handles->Create(*i); @@ -484,7 +484,7 @@ TEST(DeleteWeakGlobalHandle) { { HandleScope scope(isolate); - Handle<Object> i = factory->NewStringFromStaticAscii("fisk"); + Handle<Object> i = factory->NewStringFromStaticChars("fisk"); h = global_handles->Create(*i); } @@ -870,33 +870,34 @@ TEST(StringAllocation) { const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 }; for (int length = 0; length < 100; length++) { v8::HandleScope scope(CcTest::isolate()); - char* non_ascii = NewArray<char>(3 * length + 1); - char* ascii = NewArray<char>(length + 1); - non_ascii[3 * length] = 0; - ascii[length] = 0; + char* non_one_byte = NewArray<char>(3 * length + 1); + char* one_byte = NewArray<char>(length + 1); + non_one_byte[3 * length] = 0; + one_byte[length] = 0; for (int i = 0; i < length; i++) { - ascii[i] = 'a'; - non_ascii[3 * i] = chars[0]; - non_ascii[3 * i + 1] = chars[1]; - non_ascii[3 * i + 2] = chars[2]; + one_byte[i] = 'a'; + non_one_byte[3 * i] = chars[0]; + non_one_byte[3 * i + 1] = chars[1]; + non_one_byte[3 * i + 2] = chars[2]; } - Handle<String> non_ascii_sym = - factory->InternalizeUtf8String( - Vector<const char>(non_ascii, 3 * length)); - CHECK_EQ(length, non_ascii_sym->length()); - Handle<String> ascii_sym = - factory->InternalizeOneByteString(OneByteVector(ascii, length)); - CHECK_EQ(length, ascii_sym->length()); - Handle<String> non_ascii_str = factory->NewStringFromUtf8( - Vector<const char>(non_ascii, 3 * length)).ToHandleChecked(); - non_ascii_str->Hash(); - CHECK_EQ(length, non_ascii_str->length()); - Handle<String> ascii_str = factory->NewStringFromUtf8( - Vector<const char>(ascii, length)).ToHandleChecked(); - ascii_str->Hash(); - CHECK_EQ(length, ascii_str->length()); - DeleteArray(non_ascii); - DeleteArray(ascii); + Handle<String> non_one_byte_sym = factory->InternalizeUtf8String( + Vector<const char>(non_one_byte, 3 * length)); + CHECK_EQ(length, non_one_byte_sym->length()); + Handle<String> one_byte_sym = + factory->InternalizeOneByteString(OneByteVector(one_byte, length)); + CHECK_EQ(length, one_byte_sym->length()); + Handle<String> non_one_byte_str = + factory->NewStringFromUtf8(Vector<const char>(non_one_byte, 3 * length)) + .ToHandleChecked(); + non_one_byte_str->Hash(); + CHECK_EQ(length, non_one_byte_str->length()); + Handle<String> one_byte_str = + factory->NewStringFromUtf8(Vector<const char>(one_byte, length)) + .ToHandleChecked(); + one_byte_str->Hash(); + CHECK_EQ(length, one_byte_str->length()); + DeleteArray(non_one_byte); + DeleteArray(one_byte); } } @@ -934,10 +935,9 @@ TEST(Iteration) { TENURED); // Allocate a small string to OLD_DATA_SPACE and NEW_SPACE + objs[next_objs_index++] = factory->NewStringFromStaticChars("abcdefghij"); objs[next_objs_index++] = - factory->NewStringFromStaticAscii("abcdefghij"); - objs[next_objs_index++] = - factory->NewStringFromStaticAscii("abcdefghij", TENURED); + factory->NewStringFromStaticChars("abcdefghij", TENURED); // Allocate a large string (for large object space). int large_size = Page::kMaxRegularHeapObjectSize + 1; @@ -992,11 +992,8 @@ 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( - CcTest::i_isolate()->native_context()->object_function()); - CHECK(object_ctor->has_initial_map()); // Create a map with single inobject property. - Handle<Map> my_map = Map::Create(object_ctor, 1); + Handle<Map> my_map = Map::Create(CcTest::i_isolate(), 1); int n_properties = my_map->inobject_properties(); CHECK_GT(n_properties, 0); @@ -1052,53 +1049,61 @@ TEST(Regression39128) { } -TEST(TestCodeFlushing) { +UNINITIALIZED_TEST(TestCodeFlushing) { // If we do not flush code this test is invalid. if (!FLAG_flush_code) return; i::FLAG_allow_natives_syntax = true; i::FLAG_optimize_for_size = false; - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - Factory* factory = isolate->factory(); - v8::HandleScope scope(CcTest::isolate()); - const char* source = "function foo() {" - " var x = 42;" - " var y = 42;" - " var z = x + y;" - "};" - "foo()"; - Handle<String> foo_name = factory->InternalizeUtf8String("foo"); + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + isolate->Enter(); + Factory* factory = i_isolate->factory(); + { + v8::HandleScope scope(isolate); + v8::Context::New(isolate)->Enter(); + const char* source = + "function foo() {" + " var x = 42;" + " var y = 42;" + " var z = x + y;" + "};" + "foo()"; + Handle<String> foo_name = factory->InternalizeUtf8String("foo"); + + // This compile will add the code to the compilation cache. + { + v8::HandleScope scope(isolate); + CompileRun(source); + } - // This compile will add the code to the compilation cache. - { v8::HandleScope scope(CcTest::isolate()); - CompileRun(source); - } + // Check function is compiled. + Handle<Object> func_value = Object::GetProperty(i_isolate->global_object(), + foo_name).ToHandleChecked(); + CHECK(func_value->IsJSFunction()); + Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); + CHECK(function->shared()->is_compiled()); - // Check function is compiled. - Handle<Object> func_value = Object::GetProperty( - CcTest::i_isolate()->global_object(), foo_name).ToHandleChecked(); - CHECK(func_value->IsJSFunction()); - Handle<JSFunction> function = Handle<JSFunction>::cast(func_value); - CHECK(function->shared()->is_compiled()); + // The code will survive at least two GCs. + i_isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + i_isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CHECK(function->shared()->is_compiled()); - // The code will survive at least two GCs. - CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); - CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); - CHECK(function->shared()->is_compiled()); + // Simulate several GCs that use full marking. + const int kAgingThreshold = 6; + for (int i = 0; i < kAgingThreshold; i++) { + i_isolate->heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + } - // Simulate several GCs that use full marking. - const int kAgingThreshold = 6; - for (int i = 0; i < kAgingThreshold; i++) { - CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + // foo should no longer be in the compilation cache + CHECK(!function->shared()->is_compiled() || function->IsOptimized()); + CHECK(!function->is_compiled() || function->IsOptimized()); + // Call foo to get it recompiled. + CompileRun("foo()"); + CHECK(function->shared()->is_compiled()); + CHECK(function->is_compiled()); } - - // foo should no longer be in the compilation cache - CHECK(!function->shared()->is_compiled() || function->IsOptimized()); - CHECK(!function->is_compiled() || function->IsOptimized()); - // Call foo to get it recompiled. - CompileRun("foo()"); - CHECK(function->shared()->is_compiled()); - CHECK(function->is_compiled()); + isolate->Exit(); + isolate->Dispose(); } @@ -1684,7 +1689,7 @@ static void FillUpNewSpace(NewSpace* new_space) { Factory* factory = isolate->factory(); HandleScope scope(isolate); AlwaysAllocateScope always_allocate(isolate); - intptr_t available = new_space->EffectiveCapacity() - new_space->Size(); + intptr_t available = new_space->Capacity() - new_space->Size(); intptr_t number_of_fillers = (available / FixedArray::SizeFor(32)) - 1; for (intptr_t i = 0; i < number_of_fillers; i++) { CHECK(heap->InNewSpace(*factory->NewFixedArray(32, NOT_TENURED))); @@ -1707,20 +1712,20 @@ TEST(GrowAndShrinkNewSpace) { // Explicitly growing should double the space capacity. intptr_t old_capacity, new_capacity; - old_capacity = new_space->Capacity(); + old_capacity = new_space->TotalCapacity(); new_space->Grow(); - new_capacity = new_space->Capacity(); + new_capacity = new_space->TotalCapacity(); CHECK(2 * old_capacity == new_capacity); - old_capacity = new_space->Capacity(); + old_capacity = new_space->TotalCapacity(); FillUpNewSpace(new_space); - new_capacity = new_space->Capacity(); + new_capacity = new_space->TotalCapacity(); CHECK(old_capacity == new_capacity); // Explicitly shrinking should not affect space capacity. - old_capacity = new_space->Capacity(); + old_capacity = new_space->TotalCapacity(); new_space->Shrink(); - new_capacity = new_space->Capacity(); + new_capacity = new_space->TotalCapacity(); CHECK(old_capacity == new_capacity); // Let the scavenger empty the new space. @@ -1728,17 +1733,17 @@ TEST(GrowAndShrinkNewSpace) { CHECK_LE(new_space->Size(), old_capacity); // Explicitly shrinking should halve the space capacity. - old_capacity = new_space->Capacity(); + old_capacity = new_space->TotalCapacity(); new_space->Shrink(); - new_capacity = new_space->Capacity(); + new_capacity = new_space->TotalCapacity(); CHECK(old_capacity == 2 * new_capacity); // Consecutive shrinking should not affect space capacity. - old_capacity = new_space->Capacity(); + old_capacity = new_space->TotalCapacity(); new_space->Shrink(); new_space->Shrink(); new_space->Shrink(); - new_capacity = new_space->Capacity(); + new_capacity = new_space->TotalCapacity(); CHECK(old_capacity == new_capacity); } @@ -1757,13 +1762,13 @@ TEST(CollectingAllAvailableGarbageShrinksNewSpace) { v8::HandleScope scope(CcTest::isolate()); NewSpace* new_space = heap->new_space(); intptr_t old_capacity, new_capacity; - old_capacity = new_space->Capacity(); + old_capacity = new_space->TotalCapacity(); new_space->Grow(); - new_capacity = new_space->Capacity(); + new_capacity = new_space->TotalCapacity(); CHECK(2 * old_capacity == new_capacity); FillUpNewSpace(new_space); heap->CollectAllAvailableGarbage(); - new_capacity = new_space->Capacity(); + new_capacity = new_space->TotalCapacity(); CHECK(old_capacity == new_capacity); } @@ -2853,6 +2858,7 @@ TEST(TransitionArrayShrinksDuringAllocToOnePropertyFound) { root = GetByName("root"); AddPropertyTo(0, root, "prop9"); + CcTest::i_isolate()->heap()->CollectGarbage(OLD_POINTER_SPACE); // Count number of live transitions after marking. Note that one transition // is left, because 'o' still holds an instance of one transition target. @@ -3139,7 +3145,7 @@ TEST(IncrementalMarkingClearsTypeFeedbackInfo) { *v8::Handle<v8::Function>::Cast( CcTest::global()->Get(v8_str("f")))); - Handle<FixedArray> feedback_vector(f->shared()->feedback_vector()); + Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); int expected_length = FLAG_vector_ics ? 4 : 2; CHECK_EQ(expected_length, feedback_vector->length()); @@ -3155,7 +3161,7 @@ TEST(IncrementalMarkingClearsTypeFeedbackInfo) { CHECK_EQ(expected_length, feedback_vector->length()); for (int i = 0; i < expected_length; i++) { CHECK_EQ(feedback_vector->get(i), - *TypeFeedbackInfo::UninitializedSentinel(CcTest::i_isolate())); + *TypeFeedbackVector::UninitializedSentinel(CcTest::i_isolate())); } } @@ -3275,7 +3281,7 @@ TEST(IncrementalMarkingClearsPolymorphicIC) { } -class SourceResource: public v8::String::ExternalAsciiStringResource { +class SourceResource : public v8::String::ExternalOneByteStringResource { public: explicit SourceResource(const char* data) : data_(data), length_(strlen(data)) { } @@ -3297,26 +3303,28 @@ class SourceResource: public v8::String::ExternalAsciiStringResource { }; -void ReleaseStackTraceDataTest(const char* source, const char* accessor) { +void ReleaseStackTraceDataTest(v8::Isolate* isolate, const char* source, + const char* accessor) { // Test that the data retained by the Error.stack accessor is released // after the first time the accessor is fired. We use external string // to check whether the data is being released since the external string // resource's callback is fired when the external string is GC'ed. - v8::HandleScope scope(CcTest::isolate()); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + v8::HandleScope scope(isolate); SourceResource* resource = new SourceResource(i::StrDup(source)); { - v8::HandleScope scope(CcTest::isolate()); + v8::HandleScope scope(isolate); v8::Handle<v8::String> source_string = - v8::String::NewExternal(CcTest::isolate(), resource); - CcTest::heap()->CollectAllAvailableGarbage(); + v8::String::NewExternal(isolate, resource); + i_isolate->heap()->CollectAllAvailableGarbage(); v8::Script::Compile(source_string)->Run(); CHECK(!resource->IsDisposed()); } - // CcTest::heap()->CollectAllAvailableGarbage(); + // i_isolate->heap()->CollectAllAvailableGarbage(); CHECK(!resource->IsDisposed()); CompileRun(accessor); - CcTest::heap()->CollectAllAvailableGarbage(); + i_isolate->heap()->CollectAllAvailableGarbage(); // External source has been released. CHECK(resource->IsDisposed()); @@ -3324,7 +3332,7 @@ void ReleaseStackTraceDataTest(const char* source, const char* accessor) { } -TEST(ReleaseStackTraceData) { +UNINITIALIZED_TEST(ReleaseStackTraceData) { if (i::FLAG_always_opt) { // TODO(ulan): Remove this once the memory leak via code_next_link is fixed. // See: https://codereview.chromium.org/181833004/ @@ -3332,46 +3340,52 @@ TEST(ReleaseStackTraceData) { } FLAG_use_ic = false; // ICs retain objects. FLAG_concurrent_recompilation = false; - CcTest::InitializeVM(); - static const char* source1 = "var error = null; " - /* Normal Error */ "try { " - " throw new Error(); " - "} catch (e) { " - " error = e; " - "} "; - static const char* source2 = "var error = null; " - /* Stack overflow */ "try { " - " (function f() { f(); })(); " - "} catch (e) { " - " error = e; " - "} "; - static const char* source3 = "var error = null; " - /* Normal Error */ "try { " - /* as prototype */ " throw new Error(); " - "} catch (e) { " - " error = {}; " - " error.__proto__ = e; " - "} "; - static const char* source4 = "var error = null; " - /* Stack overflow */ "try { " - /* as prototype */ " (function f() { f(); })(); " - "} catch (e) { " - " error = {}; " - " error.__proto__ = e; " - "} "; - static const char* getter = "error.stack"; - static const char* setter = "error.stack = 0"; - - ReleaseStackTraceDataTest(source1, setter); - ReleaseStackTraceDataTest(source2, setter); - // We do not test source3 and source4 with setter, since the setter is - // supposed to (untypically) write to the receiver, not the holder. This is - // to emulate the behavior of a data property. - - ReleaseStackTraceDataTest(source1, getter); - ReleaseStackTraceDataTest(source2, getter); - ReleaseStackTraceDataTest(source3, getter); - ReleaseStackTraceDataTest(source4, getter); + v8::Isolate* isolate = v8::Isolate::New(); + { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + v8::Context::New(isolate)->Enter(); + static const char* source1 = "var error = null; " + /* Normal Error */ "try { " + " throw new Error(); " + "} catch (e) { " + " error = e; " + "} "; + static const char* source2 = "var error = null; " + /* Stack overflow */ "try { " + " (function f() { f(); })(); " + "} catch (e) { " + " error = e; " + "} "; + static const char* source3 = "var error = null; " + /* Normal Error */ "try { " + /* as prototype */ " throw new Error(); " + "} catch (e) { " + " error = {}; " + " error.__proto__ = e; " + "} "; + static const char* source4 = "var error = null; " + /* Stack overflow */ "try { " + /* as prototype */ " (function f() { f(); })(); " + "} catch (e) { " + " error = {}; " + " error.__proto__ = e; " + "} "; + static const char* getter = "error.stack"; + static const char* setter = "error.stack = 0"; + + ReleaseStackTraceDataTest(isolate, source1, setter); + ReleaseStackTraceDataTest(isolate, source2, setter); + // We do not test source3 and source4 with setter, since the setter is + // supposed to (untypically) write to the receiver, not the holder. This is + // to emulate the behavior of a data property. + + ReleaseStackTraceDataTest(isolate, source1, getter); + ReleaseStackTraceDataTest(isolate, source2, getter); + ReleaseStackTraceDataTest(isolate, source3, getter); + ReleaseStackTraceDataTest(isolate, source4, getter); + } + isolate->Dispose(); } @@ -4050,6 +4064,7 @@ static int GetCodeChainLength(Code* code) { TEST(NextCodeLinkIsWeak) { i::FLAG_allow_natives_syntax = true; + i::FLAG_turbo_deoptimization = true; CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); v8::internal::Heap* heap = CcTest::heap(); @@ -4348,78 +4363,90 @@ TEST(ArrayShiftSweeping) { } -TEST(PromotionQueue) { +UNINITIALIZED_TEST(PromotionQueue) { i::FLAG_expose_gc = true; i::FLAG_max_semi_space_size = 2; - CcTest::InitializeVM(); - v8::HandleScope scope(CcTest::isolate()); - Isolate* isolate = CcTest::i_isolate(); - Heap* heap = isolate->heap(); - NewSpace* new_space = heap->new_space(); - - // In this test we will try to overwrite the promotion queue which is at the - // end of to-space. To actually make that possible, we need at least two - // semi-space pages and take advantage of fragementation. - // (1) Grow semi-space to two pages. - // (2) Create a few small long living objects and call the scavenger to - // move them to the other semi-space. - // (3) Create a huge object, i.e., remainder of first semi-space page and - // create another huge object which should be of maximum allocatable memory - // size of the second semi-space page. - // (4) Call the scavenger again. - // What will happen is: the scavenger will promote the objects created in (2) - // and will create promotion queue entries at the end of the second - // semi-space page during the next scavenge when it promotes the objects to - // the old generation. The first allocation of (3) will fill up the first - // semi-space page. The second allocation in (3) will not fit into the first - // semi-space page, but it will overwrite the promotion queue which are in - // the second semi-space page. If the right guards are in place, the promotion - // queue will be evacuated in that case. - - // Grow the semi-space to two pages to make semi-space copy overwrite the - // promotion queue, which will be at the end of the second page. - intptr_t old_capacity = new_space->Capacity(); - new_space->Grow(); - CHECK(new_space->IsAtMaximumCapacity()); - CHECK(2 * old_capacity == new_space->Capacity()); - - // Call the scavenger two times to get an empty new space - heap->CollectGarbage(NEW_SPACE); - heap->CollectGarbage(NEW_SPACE); - - // First create a few objects which will survive a scavenge, and will get - // promoted to the old generation later on. These objects will create - // promotion queue entries at the end of the second semi-space page. - const int number_handles = 12; - Handle<FixedArray> handles[number_handles]; - for (int i = 0; i < number_handles; i++) { - handles[i] = isolate->factory()->NewFixedArray(1, NOT_TENURED); + v8::Isolate* isolate = v8::Isolate::New(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + v8::Context::New(isolate)->Enter(); + Heap* heap = i_isolate->heap(); + NewSpace* new_space = heap->new_space(); + + // In this test we will try to overwrite the promotion queue which is at the + // end of to-space. To actually make that possible, we need at least two + // semi-space pages and take advantage of fragmentation. + // (1) Grow semi-space to two pages. + // (2) Create a few small long living objects and call the scavenger to + // move them to the other semi-space. + // (3) Create a huge object, i.e., remainder of first semi-space page and + // create another huge object which should be of maximum allocatable memory + // size of the second semi-space page. + // (4) Call the scavenger again. + // What will happen is: the scavenger will promote the objects created in + // (2) and will create promotion queue entries at the end of the second + // semi-space page during the next scavenge when it promotes the objects to + // the old generation. The first allocation of (3) will fill up the first + // semi-space page. The second allocation in (3) will not fit into the + // first semi-space page, but it will overwrite the promotion queue which + // are in the second semi-space page. If the right guards are in place, the + // promotion queue will be evacuated in that case. + + // Grow the semi-space to two pages to make semi-space copy overwrite the + // promotion queue, which will be at the end of the second page. + intptr_t old_capacity = new_space->TotalCapacity(); + + // If we are in a low memory config, we can't grow to two pages and we can't + // run this test. This also means the issue we are testing cannot arise, as + // there is no fragmentation. + if (new_space->IsAtMaximumCapacity()) return; + + new_space->Grow(); + CHECK(new_space->IsAtMaximumCapacity()); + CHECK(2 * old_capacity == new_space->TotalCapacity()); + + // Call the scavenger two times to get an empty new space + heap->CollectGarbage(NEW_SPACE); + heap->CollectGarbage(NEW_SPACE); + + // First create a few objects which will survive a scavenge, and will get + // promoted to the old generation later on. These objects will create + // promotion queue entries at the end of the second semi-space page. + const int number_handles = 12; + Handle<FixedArray> handles[number_handles]; + for (int i = 0; i < number_handles; i++) { + handles[i] = i_isolate->factory()->NewFixedArray(1, NOT_TENURED); + } + heap->CollectGarbage(NEW_SPACE); + + // Create the first huge object which will exactly fit the first semi-space + // page. + int new_linear_size = + static_cast<int>(*heap->new_space()->allocation_limit_address() - + *heap->new_space()->allocation_top_address()); + int length = new_linear_size / kPointerSize - FixedArray::kHeaderSize; + Handle<FixedArray> first = + i_isolate->factory()->NewFixedArray(length, NOT_TENURED); + CHECK(heap->InNewSpace(*first)); + + // Create the second huge object of maximum allocatable second semi-space + // page size. + new_linear_size = + static_cast<int>(*heap->new_space()->allocation_limit_address() - + *heap->new_space()->allocation_top_address()); + length = Page::kMaxRegularHeapObjectSize / kPointerSize - + FixedArray::kHeaderSize; + Handle<FixedArray> second = + i_isolate->factory()->NewFixedArray(length, NOT_TENURED); + CHECK(heap->InNewSpace(*second)); + + // This scavenge will corrupt memory if the promotion queue is not + // evacuated. + heap->CollectGarbage(NEW_SPACE); } - heap->CollectGarbage(NEW_SPACE); - - // Create the first huge object which will exactly fit the first semi-space - // page. - int new_linear_size = static_cast<int>( - *heap->new_space()->allocation_limit_address() - - *heap->new_space()->allocation_top_address()); - int length = new_linear_size / kPointerSize - FixedArray::kHeaderSize; - Handle<FixedArray> first = - isolate->factory()->NewFixedArray(length, NOT_TENURED); - CHECK(heap->InNewSpace(*first)); - - // Create the second huge object of maximum allocatable second semi-space - // page size. - new_linear_size = static_cast<int>( - *heap->new_space()->allocation_limit_address() - - *heap->new_space()->allocation_top_address()); - length = Page::kMaxRegularHeapObjectSize / kPointerSize - - FixedArray::kHeaderSize; - Handle<FixedArray> second = - isolate->factory()->NewFixedArray(length, NOT_TENURED); - CHECK(heap->InNewSpace(*second)); - - // This scavenge will corrupt memory if the promotion queue is not evacuated. - heap->CollectGarbage(NEW_SPACE); + isolate->Dispose(); } @@ -4431,9 +4458,9 @@ TEST(Regress388880) { Factory* factory = isolate->factory(); Heap* heap = isolate->heap(); - Handle<Map> map1 = Map::Create(isolate->object_function(), 1); + Handle<Map> map1 = Map::Create(isolate, 1); Handle<Map> map2 = - Map::CopyWithField(map1, factory->NewStringFromStaticAscii("foo"), + Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"), HeapType::Any(isolate), NONE, Representation::Tagged(), OMIT_TRANSITION).ToHandleChecked(); diff --git a/deps/v8/test/cctest/test-libplatform-default-platform.cc b/deps/v8/test/cctest/test-libplatform-default-platform.cc deleted file mode 100644 index dac6db2a00..0000000000 --- a/deps/v8/test/cctest/test-libplatform-default-platform.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/v8.h" - -#include "src/libplatform/default-platform.h" -#include "test/cctest/cctest.h" -#include "test/cctest/test-libplatform.h" - -using namespace v8::internal; -using namespace v8::platform; - - -TEST(DefaultPlatformMessagePump) { - TaskCounter task_counter; - - DefaultPlatform platform; - - TestTask* task = new TestTask(&task_counter, true); - - CHECK(!platform.PumpMessageLoop(CcTest::isolate())); - - platform.CallOnForegroundThread(CcTest::isolate(), task); - - CHECK_EQ(1, task_counter.GetCount()); - CHECK(platform.PumpMessageLoop(CcTest::isolate())); - CHECK_EQ(0, task_counter.GetCount()); - CHECK(!platform.PumpMessageLoop(CcTest::isolate())); -} diff --git a/deps/v8/test/cctest/test-libplatform.h b/deps/v8/test/cctest/test-libplatform.h deleted file mode 100644 index 67147f33e6..0000000000 --- a/deps/v8/test/cctest/test-libplatform.h +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2013 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. - -#ifndef TEST_LIBPLATFORM_H_ -#define TEST_LIBPLATFORM_H_ - -#include "src/v8.h" - -#include "test/cctest/cctest.h" - -using namespace v8::internal; -using namespace v8::platform; - -class TaskCounter { - public: - TaskCounter() : counter_(0) {} - ~TaskCounter() { CHECK_EQ(0, counter_); } - - int GetCount() const { - v8::base::LockGuard<v8::base::Mutex> guard(&lock_); - return counter_; - } - - void Inc() { - v8::base::LockGuard<v8::base::Mutex> guard(&lock_); - ++counter_; - } - - void Dec() { - v8::base::LockGuard<v8::base::Mutex> guard(&lock_); - --counter_; - } - - private: - mutable v8::base::Mutex lock_; - int counter_; - - DISALLOW_COPY_AND_ASSIGN(TaskCounter); -}; - - -class TestTask : public v8::Task { - public: - TestTask(TaskCounter* task_counter, bool expected_to_run) - : task_counter_(task_counter), - expected_to_run_(expected_to_run), - executed_(false) { - task_counter_->Inc(); - } - - explicit TestTask(TaskCounter* task_counter) - : task_counter_(task_counter), expected_to_run_(false), executed_(false) { - task_counter_->Inc(); - } - - virtual ~TestTask() { - CHECK_EQ(expected_to_run_, executed_); - task_counter_->Dec(); - } - - // v8::Task implementation. - virtual void Run() V8_OVERRIDE { executed_ = true; } - - private: - TaskCounter* task_counter_; - bool expected_to_run_; - bool executed_; - - DISALLOW_COPY_AND_ASSIGN(TestTask); -}; - - -class TestWorkerThread : public v8::base::Thread { - public: - explicit TestWorkerThread(v8::Task* task) - : Thread(Options("libplatform TestWorkerThread")), - semaphore_(0), - task_(task) {} - virtual ~TestWorkerThread() {} - - void Signal() { semaphore_.Signal(); } - - // Thread implementation. - virtual void Run() V8_OVERRIDE { - semaphore_.Wait(); - if (task_) { - task_->Run(); - delete task_; - } - } - - private: - v8::base::Semaphore semaphore_; - v8::Task* task_; - - DISALLOW_COPY_AND_ASSIGN(TestWorkerThread); -}; - -#endif // TEST_LIBPLATFORM_H_ diff --git a/deps/v8/test/cctest/test-liveedit.cc b/deps/v8/test/cctest/test-liveedit.cc index f5c22743bd..6a5f0b2997 100644 --- a/deps/v8/test/cctest/test-liveedit.cc +++ b/deps/v8/test/cctest/test-liveedit.cc @@ -158,7 +158,6 @@ 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/deps/v8/test/cctest/test-log.cc b/deps/v8/test/cctest/test-log.cc index d72e6f0e1e..482f89f9c4 100644 --- a/deps/v8/test/cctest/test-log.cc +++ b/deps/v8/test/cctest/test-log.cc @@ -61,9 +61,11 @@ class ScopedLoggerInitializer { temp_file_(NULL), // Need to run this prior to creating the scope. trick_to_run_init_flags_(init_flags_()), - scope_(CcTest::isolate()), - env_(v8::Context::New(CcTest::isolate())), - logger_(CcTest::i_isolate()->logger()) { + isolate_(v8::Isolate::New()), + isolate_scope_(isolate_), + scope_(isolate_), + env_(v8::Context::New(isolate_)), + logger_(reinterpret_cast<i::Isolate*>(isolate_)->logger()) { env_->Enter(); } @@ -77,6 +79,8 @@ class ScopedLoggerInitializer { v8::Handle<v8::Context>& env() { return env_; } + v8::Isolate* isolate() { return isolate_; } + Logger* logger() { return logger_; } FILE* StopLoggingGetTempFile() { @@ -100,6 +104,8 @@ class ScopedLoggerInitializer { const bool saved_prof_; FILE* temp_file_; const bool trick_to_run_init_flags_; + v8::Isolate* isolate_; + v8::Isolate::Scope isolate_scope_; v8::HandleScope scope_; v8::Handle<v8::Context> env_; Logger* logger_; @@ -330,41 +336,41 @@ static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) { TEST(LogCallbacks) { - v8::Isolate* isolate = CcTest::isolate(); - ScopedLoggerInitializer initialize_logger; - Logger* logger = initialize_logger.logger(); - - v8::Local<v8::FunctionTemplate> obj = - v8::Local<v8::FunctionTemplate>::New(isolate, - v8::FunctionTemplate::New(isolate)); - obj->SetClassName(v8_str("Obj")); - v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate(); - v8::Local<v8::Signature> signature = - v8::Signature::New(isolate, obj); - proto->Set(v8_str("method1"), - v8::FunctionTemplate::New(isolate, - ObjMethod1, - v8::Handle<v8::Value>(), - signature), - static_cast<v8::PropertyAttribute>(v8::DontDelete)); - - initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction()); - CompileRun("Obj.prototype.method1.toString();"); - - logger->LogCompiledFunctions(); - - bool exists = false; - i::Vector<const char> log( - i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); - CHECK(exists); - - i::EmbeddedVector<char, 100> ref_data; - i::SNPrintF(ref_data, - "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"", - reinterpret_cast<intptr_t>(ObjMethod1)); - - CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); - log.Dispose(); + v8::Isolate* isolate; + { + ScopedLoggerInitializer initialize_logger; + isolate = initialize_logger.isolate(); + Logger* logger = initialize_logger.logger(); + + v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New( + isolate, v8::FunctionTemplate::New(isolate)); + obj->SetClassName(v8_str("Obj")); + v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate(); + v8::Local<v8::Signature> signature = v8::Signature::New(isolate, obj); + proto->Set(v8_str("method1"), + v8::FunctionTemplate::New(isolate, ObjMethod1, + v8::Handle<v8::Value>(), signature), + static_cast<v8::PropertyAttribute>(v8::DontDelete)); + + initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction()); + CompileRun("Obj.prototype.method1.toString();"); + + logger->LogCompiledFunctions(); + + bool exists = false; + i::Vector<const char> log( + i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); + CHECK(exists); + + i::EmbeddedVector<char, 100> ref_data; + i::SNPrintF(ref_data, + "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"", + reinterpret_cast<intptr_t>(ObjMethod1)); + + CHECK_NE(NULL, StrNStr(log.start(), ref_data.start(), log.length())); + log.Dispose(); + } + isolate->Dispose(); } @@ -383,46 +389,49 @@ static void Prop2Getter(v8::Local<v8::String> property, TEST(LogAccessorCallbacks) { - v8::Isolate* isolate = CcTest::isolate(); - ScopedLoggerInitializer initialize_logger; - Logger* logger = initialize_logger.logger(); - - v8::Local<v8::FunctionTemplate> obj = - v8::Local<v8::FunctionTemplate>::New(isolate, - v8::FunctionTemplate::New(isolate)); - obj->SetClassName(v8_str("Obj")); - v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate(); - inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter); - inst->SetAccessor(v8_str("prop2"), Prop2Getter); - - logger->LogAccessorCallbacks(); - - bool exists = false; - i::Vector<const char> log( - i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); - CHECK(exists); - - EmbeddedVector<char, 100> prop1_getter_record; - i::SNPrintF(prop1_getter_record, - "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"", - reinterpret_cast<intptr_t>(Prop1Getter)); - CHECK_NE(NULL, - StrNStr(log.start(), prop1_getter_record.start(), log.length())); - - EmbeddedVector<char, 100> prop1_setter_record; - i::SNPrintF(prop1_setter_record, - "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"", - reinterpret_cast<intptr_t>(Prop1Setter)); - CHECK_NE(NULL, - StrNStr(log.start(), prop1_setter_record.start(), log.length())); - - EmbeddedVector<char, 100> prop2_getter_record; - i::SNPrintF(prop2_getter_record, - "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"", - reinterpret_cast<intptr_t>(Prop2Getter)); - CHECK_NE(NULL, - StrNStr(log.start(), prop2_getter_record.start(), log.length())); - log.Dispose(); + v8::Isolate* isolate; + { + ScopedLoggerInitializer initialize_logger; + isolate = initialize_logger.isolate(); + Logger* logger = initialize_logger.logger(); + + v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New( + isolate, v8::FunctionTemplate::New(isolate)); + obj->SetClassName(v8_str("Obj")); + v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate(); + inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter); + inst->SetAccessor(v8_str("prop2"), Prop2Getter); + + logger->LogAccessorCallbacks(); + + bool exists = false; + i::Vector<const char> log( + i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); + CHECK(exists); + + EmbeddedVector<char, 100> prop1_getter_record; + i::SNPrintF(prop1_getter_record, + "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"", + reinterpret_cast<intptr_t>(Prop1Getter)); + CHECK_NE(NULL, + StrNStr(log.start(), prop1_getter_record.start(), log.length())); + + EmbeddedVector<char, 100> prop1_setter_record; + i::SNPrintF(prop1_setter_record, + "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"", + reinterpret_cast<intptr_t>(Prop1Setter)); + CHECK_NE(NULL, + StrNStr(log.start(), prop1_setter_record.start(), log.length())); + + EmbeddedVector<char, 100> prop2_getter_record; + i::SNPrintF(prop2_getter_record, + "code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"", + reinterpret_cast<intptr_t>(Prop2Getter)); + CHECK_NE(NULL, + StrNStr(log.start(), prop2_getter_record.start(), log.length())); + log.Dispose(); + } + isolate->Dispose(); } @@ -439,57 +448,63 @@ TEST(EquivalenceOfLoggingAndTraversal) { // are using V8. // Start with profiling to capture all code events from the beginning. - ScopedLoggerInitializer initialize_logger; - Logger* logger = initialize_logger.logger(); - - // Compile and run a function that creates other functions. - CompileRun( - "(function f(obj) {\n" - " obj.test =\n" - " (function a(j) { return function b() { return j; } })(100);\n" - "})(this);"); - logger->StopProfiler(); - CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); - logger->StringEvent("test-logging-done", ""); - - // Iterate heap to find compiled functions, will write to log. - logger->LogCompiledFunctions(); - logger->StringEvent("test-traversal-done", ""); - - bool exists = false; - i::Vector<const char> log( - i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); - CHECK(exists); - v8::Handle<v8::String> log_str = v8::String::NewFromUtf8( - CcTest::isolate(), log.start(), v8::String::kNormalString, log.length()); - initialize_logger.env()->Global()->Set(v8_str("_log"), log_str); - - i::Vector<const unsigned char> source = TestSources::GetScriptsSource(); - v8::Handle<v8::String> source_str = v8::String::NewFromUtf8( - CcTest::isolate(), reinterpret_cast<const char*>(source.start()), - v8::String::kNormalString, source.length()); - v8::TryCatch try_catch; - v8::Handle<v8::Script> script = CompileWithOrigin(source_str, ""); - if (script.IsEmpty()) { - v8::String::Utf8Value exception(try_catch.Exception()); - printf("compile: %s\n", *exception); - CHECK(false); - } - v8::Handle<v8::Value> result = script->Run(); - if (result.IsEmpty()) { - v8::String::Utf8Value exception(try_catch.Exception()); - printf("run: %s\n", *exception); - CHECK(false); - } - // The result either be a "true" literal or problem description. - if (!result->IsTrue()) { - v8::Local<v8::String> s = result->ToString(); - i::ScopedVector<char> data(s->Utf8Length() + 1); - CHECK_NE(NULL, data.start()); - s->WriteUtf8(data.start()); - printf("%s\n", data.start()); - // Make sure that our output is written prior crash due to CHECK failure. - fflush(stdout); - CHECK(false); + v8::Isolate* isolate; + { + ScopedLoggerInitializer initialize_logger; + isolate = initialize_logger.isolate(); + Logger* logger = initialize_logger.logger(); + + // Compile and run a function that creates other functions. + CompileRun( + "(function f(obj) {\n" + " obj.test =\n" + " (function a(j) { return function b() { return j; } })(100);\n" + "})(this);"); + logger->StopProfiler(); + reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage( + i::Heap::kMakeHeapIterableMask); + logger->StringEvent("test-logging-done", ""); + + // Iterate heap to find compiled functions, will write to log. + logger->LogCompiledFunctions(); + logger->StringEvent("test-traversal-done", ""); + + bool exists = false; + i::Vector<const char> log( + i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true)); + CHECK(exists); + v8::Handle<v8::String> log_str = v8::String::NewFromUtf8( + isolate, log.start(), v8::String::kNormalString, log.length()); + initialize_logger.env()->Global()->Set(v8_str("_log"), log_str); + + i::Vector<const unsigned char> source = TestSources::GetScriptsSource(); + v8::Handle<v8::String> source_str = v8::String::NewFromUtf8( + isolate, reinterpret_cast<const char*>(source.start()), + v8::String::kNormalString, source.length()); + v8::TryCatch try_catch; + v8::Handle<v8::Script> script = CompileWithOrigin(source_str, ""); + if (script.IsEmpty()) { + v8::String::Utf8Value exception(try_catch.Exception()); + printf("compile: %s\n", *exception); + CHECK(false); + } + v8::Handle<v8::Value> result = script->Run(); + if (result.IsEmpty()) { + v8::String::Utf8Value exception(try_catch.Exception()); + printf("run: %s\n", *exception); + CHECK(false); + } + // The result either be a "true" literal or problem description. + if (!result->IsTrue()) { + v8::Local<v8::String> s = result->ToString(); + i::ScopedVector<char> data(s->Utf8Length() + 1); + CHECK_NE(NULL, data.start()); + s->WriteUtf8(data.start()); + printf("%s\n", data.start()); + // Make sure that our output is written prior crash due to CHECK failure. + fflush(stdout); + CHECK(false); + } } + isolate->Dispose(); } diff --git a/deps/v8/test/cctest/test-macro-assembler-arm.cc b/deps/v8/test/cctest/test-macro-assembler-arm.cc index 2cfad0df83..3ca02662fa 100644 --- a/deps/v8/test/cctest/test-macro-assembler-arm.cc +++ b/deps/v8/test/cctest/test-macro-assembler-arm.cc @@ -137,8 +137,6 @@ typedef int (*F5)(void*, void*, void*, void*, void*); TEST(LoadAndStoreWithRepresentation) { - v8::internal::V8::Initialize(NULL); - // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( diff --git a/deps/v8/test/cctest/test-macro-assembler-ia32.cc b/deps/v8/test/cctest/test-macro-assembler-ia32.cc index 4d37579918..b2b8c946c3 100644 --- a/deps/v8/test/cctest/test-macro-assembler-ia32.cc +++ b/deps/v8/test/cctest/test-macro-assembler-ia32.cc @@ -50,8 +50,6 @@ typedef F0Type* F0; TEST(LoadAndStoreWithRepresentation) { - v8::internal::V8::Initialize(NULL); - // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( diff --git a/deps/v8/test/cctest/test-macro-assembler-mips.cc b/deps/v8/test/cctest/test-macro-assembler-mips.cc index 33a4611540..6cb00e4456 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips.cc @@ -149,9 +149,9 @@ static void TestNaN(const char *code) { i::FixedDoubleArray* a = i::FixedDoubleArray::cast(array1->elements()); double value = a->get_scalar(0); CHECK(std::isnan(value) && - i::BitCast<uint64_t>(value) == - i::BitCast<uint64_t>( - i::FixedDoubleArray::canonical_not_the_hole_nan_as_double())); + bit_cast<uint64_t>(value) == + bit_cast<uint64_t>( + i::FixedDoubleArray::canonical_not_the_hole_nan_as_double())); } diff --git a/deps/v8/test/cctest/test-macro-assembler-x64.cc b/deps/v8/test/cctest/test-macro-assembler-x64.cc index 2c0e918057..7f20a8dd4b 100644 --- a/deps/v8/test/cctest/test-macro-assembler-x64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-x64.cc @@ -153,7 +153,6 @@ 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) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -239,7 +238,6 @@ void TestSmiCompare(MacroAssembler* masm, Label* exit, int id, int x, int y) { // Test that we can compare smis for equality (and more). TEST(SmiCompare) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -288,7 +286,6 @@ TEST(SmiCompare) { TEST(Integer32ToSmi) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -415,7 +412,6 @@ void TestI64PlusConstantToSmi(MacroAssembler* masm, TEST(Integer64PlusConstantToSmi) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -458,7 +454,6 @@ TEST(Integer64PlusConstantToSmi) { TEST(SmiCheck) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -704,7 +699,6 @@ void TestSmiNeg(MacroAssembler* masm, Label* exit, int id, int x) { TEST(SmiNeg) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -918,7 +912,6 @@ static void SmiAddOverflowTest(MacroAssembler* masm, TEST(SmiAdd) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1137,7 +1130,6 @@ static void SmiSubOverflowTest(MacroAssembler* masm, TEST(SmiSub) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1226,7 +1218,6 @@ void TestSmiMul(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiMul) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1330,7 +1321,6 @@ void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiDiv) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1438,7 +1428,6 @@ void TestSmiMod(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiMod) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1533,7 +1522,6 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { TEST(SmiIndex) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1600,7 +1588,6 @@ void TestSelectNonSmi(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiSelectNonSmi) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1677,7 +1664,6 @@ void TestSmiAnd(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiAnd) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1756,7 +1742,6 @@ void TestSmiOr(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiOr) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1837,7 +1822,6 @@ void TestSmiXor(MacroAssembler* masm, Label* exit, int id, int x, int y) { TEST(SmiXor) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1902,7 +1886,6 @@ void TestSmiNot(MacroAssembler* masm, Label* exit, int id, int x) { TEST(SmiNot) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -1996,7 +1979,6 @@ void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { TEST(SmiShiftLeft) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -2100,7 +2082,6 @@ void TestSmiShiftLogicalRight(MacroAssembler* masm, TEST(SmiShiftLogicalRight) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -2167,7 +2148,6 @@ void TestSmiShiftArithmeticRight(MacroAssembler* masm, TEST(SmiShiftArithmeticRight) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -2229,7 +2209,6 @@ void TestPositiveSmiPowerUp(MacroAssembler* masm, Label* exit, int id, int x) { TEST(PositiveSmiTimesPowerOfTwoToInteger64) { - i::V8::Initialize(NULL); // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( @@ -2267,7 +2246,6 @@ TEST(PositiveSmiTimesPowerOfTwoToInteger64) { TEST(OperandOffset) { - i::V8::Initialize(NULL); uint32_t data[256]; for (uint32_t i = 0; i < 256; i++) { data[i] = i * 0x01010101; } @@ -2621,8 +2599,6 @@ TEST(OperandOffset) { TEST(LoadAndStoreWithRepresentation) { - v8::internal::V8::Initialize(NULL); - // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( diff --git a/deps/v8/test/cctest/test-macro-assembler-x87.cc b/deps/v8/test/cctest/test-macro-assembler-x87.cc index 9aa40c0b10..0b057d818f 100644 --- a/deps/v8/test/cctest/test-macro-assembler-x87.cc +++ b/deps/v8/test/cctest/test-macro-assembler-x87.cc @@ -50,8 +50,6 @@ typedef F0Type* F0; TEST(LoadAndStoreWithRepresentation) { - v8::internal::V8::Initialize(NULL); - // Allocate an executable page of memory. size_t actual_size; byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( diff --git a/deps/v8/test/cctest/test-mark-compact.cc b/deps/v8/test/cctest/test-mark-compact.cc index 1d4b0d8e7d..c7d65310a4 100644 --- a/deps/v8/test/cctest/test-mark-compact.cc +++ b/deps/v8/test/cctest/test-mark-compact.cc @@ -139,13 +139,13 @@ TEST(MarkCompactCollector) { heap->CollectGarbage(OLD_POINTER_SPACE, "trigger 1"); // keep allocating garbage in new space until it fails - const int ARRAY_SIZE = 100; + const int arraysize = 100; AllocationResult allocation; do { - allocation = heap->AllocateFixedArray(ARRAY_SIZE); + allocation = heap->AllocateFixedArray(arraysize); } while (!allocation.IsRetry()); heap->CollectGarbage(NEW_SPACE, "trigger 2"); - heap->AllocateFixedArray(ARRAY_SIZE).ToObjectChecked(); + heap->AllocateFixedArray(arraysize).ToObjectChecked(); // keep allocating maps until it fails do { @@ -301,15 +301,13 @@ TEST(ObjectGroups) { { Object** g1_objects[] = { g1s1.location(), g1s2.location() }; - Object** g1_children[] = { g1c1.location() }; Object** g2_objects[] = { g2s1.location(), g2s2.location() }; - Object** g2_children[] = { g2c1.location() }; global_handles->AddObjectGroup(g1_objects, 2, NULL); - global_handles->AddImplicitReferences( - Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); + global_handles->SetReference(Handle<HeapObject>::cast(g1s1).location(), + g1c1.location()); global_handles->AddObjectGroup(g2_objects, 2, NULL); - global_handles->AddImplicitReferences( - Handle<HeapObject>::cast(g2s1).location(), g2_children, 1); + global_handles->SetReference(Handle<HeapObject>::cast(g2s1).location(), + g2c1.location()); } // Do a full GC heap->CollectGarbage(OLD_POINTER_SPACE); @@ -330,15 +328,13 @@ TEST(ObjectGroups) { // Groups are deleted, rebuild groups. { Object** g1_objects[] = { g1s1.location(), g1s2.location() }; - Object** g1_children[] = { g1c1.location() }; Object** g2_objects[] = { g2s1.location(), g2s2.location() }; - Object** g2_children[] = { g2c1.location() }; global_handles->AddObjectGroup(g1_objects, 2, NULL); - global_handles->AddImplicitReferences( - Handle<HeapObject>::cast(g1s1).location(), g1_children, 1); + global_handles->SetReference(Handle<HeapObject>::cast(g1s1).location(), + g1c1.location()); global_handles->AddObjectGroup(g2_objects, 2, NULL); - global_handles->AddImplicitReferences( - Handle<HeapObject>::cast(g2s1).location(), g2_children, 1); + global_handles->SetReference(Handle<HeapObject>::cast(g2s1).location(), + g2c1.location()); } heap->CollectGarbage(OLD_POINTER_SPACE); @@ -389,15 +385,9 @@ TEST(EmptyObjectGroups) { v8::HandleScope handle_scope(CcTest::isolate()); - Handle<Object> object = global_handles->Create( - CcTest::test_heap()->AllocateFixedArray(1).ToObjectChecked()); - TestRetainedObjectInfo info; global_handles->AddObjectGroup(NULL, 0, &info); DCHECK(info.has_been_disposed()); - - global_handles->AddImplicitReferences( - Handle<HeapObject>::cast(object).location(), NULL, 0); } diff --git a/deps/v8/test/cctest/test-object-observe.cc b/deps/v8/test/cctest/test-object-observe.cc index 679569e27c..d208a26922 100644 --- a/deps/v8/test/cctest/test-object-observe.cc +++ b/deps/v8/test/cctest/test-object-observe.cc @@ -253,7 +253,7 @@ static void ExpectRecords(v8::Isolate* isolate, #define EXPECT_RECORDS(records, expectations) \ ExpectRecords(CcTest::isolate(), records, expectations, \ - ARRAY_SIZE(expectations)) + arraysize(expectations)) TEST(APITestBasicMutation) { v8::Isolate* v8_isolate = CcTest::isolate(); diff --git a/deps/v8/test/cctest/test-ordered-hash-table.cc b/deps/v8/test/cctest/test-ordered-hash-table.cc index bb1e0145b5..9578936317 100644 --- a/deps/v8/test/cctest/test-ordered-hash-table.cc +++ b/deps/v8/test/cctest/test-ordered-hash-table.cc @@ -118,7 +118,8 @@ TEST(Map) { CHECK(ordered_map->Lookup(obj)->IsTheHole()); ordered_map = OrderedHashMap::Put(ordered_map, obj, val); CHECK_EQ(1, ordered_map->NumberOfElements()); - CHECK(ordered_map->Lookup(obj)->SameValue(*val)); + Object* lookup = ordered_map->Lookup(obj); + CHECK(lookup->SameValue(*val)); bool was_present = false; ordered_map = OrderedHashMap::Remove(ordered_map, obj, &was_present); CHECK(was_present); @@ -136,20 +137,28 @@ TEST(Map) { ordered_map = OrderedHashMap::Put(ordered_map, obj2, val2); ordered_map = OrderedHashMap::Put(ordered_map, obj3, val3); CHECK_EQ(3, ordered_map->NumberOfElements()); - CHECK(ordered_map->Lookup(obj1)->SameValue(*val1)); - CHECK(ordered_map->Lookup(obj2)->SameValue(*val2)); - CHECK(ordered_map->Lookup(obj3)->SameValue(*val3)); + lookup = ordered_map->Lookup(obj1); + CHECK(lookup->SameValue(*val1)); + lookup = ordered_map->Lookup(obj2); + CHECK(lookup->SameValue(*val2)); + lookup = ordered_map->Lookup(obj3); + CHECK(lookup->SameValue(*val3)); // Test growth ordered_map = OrderedHashMap::Put(ordered_map, obj, val); Handle<JSObject> obj4 = factory->NewJSObjectFromMap(map); Handle<JSObject> val4 = factory->NewJSObjectFromMap(map); ordered_map = OrderedHashMap::Put(ordered_map, obj4, val4); - CHECK(ordered_map->Lookup(obj)->SameValue(*val)); - CHECK(ordered_map->Lookup(obj1)->SameValue(*val1)); - CHECK(ordered_map->Lookup(obj2)->SameValue(*val2)); - CHECK(ordered_map->Lookup(obj3)->SameValue(*val3)); - CHECK(ordered_map->Lookup(obj4)->SameValue(*val4)); + lookup = ordered_map->Lookup(obj); + CHECK(lookup->SameValue(*val)); + lookup = ordered_map->Lookup(obj1); + CHECK(lookup->SameValue(*val1)); + lookup = ordered_map->Lookup(obj2); + CHECK(lookup->SameValue(*val2)); + lookup = ordered_map->Lookup(obj3); + CHECK(lookup->SameValue(*val3)); + lookup = ordered_map->Lookup(obj4); + CHECK(lookup->SameValue(*val4)); CHECK_EQ(5, ordered_map->NumberOfElements()); CHECK_EQ(4, ordered_map->NumberOfBuckets()); diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index 9cb5d69e6c..72f2298042 100644 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -72,6 +72,7 @@ TEST(ScanKeywords) { // The scanner should parse Harmony keywords for this test. scanner.SetHarmonyScoping(true); scanner.SetHarmonyModules(true); + scanner.SetHarmonyClasses(true); scanner.Initialize(&stream); CHECK_EQ(key_token.token, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); @@ -86,7 +87,7 @@ TEST(ScanKeywords) { } // Adding characters will make keyword matching fail. static const char chars_to_append[] = { 'z', '0', '_' }; - for (int j = 0; j < static_cast<int>(ARRAY_SIZE(chars_to_append)); ++j) { + for (int j = 0; j < static_cast<int>(arraysize(chars_to_append)); ++j) { i::MemMove(buffer, keyword, length); buffer[length] = chars_to_append[j]; i::Utf8ToUtf16CharacterStream stream(buffer, length + 1); @@ -144,8 +145,8 @@ TEST(ScanHTMLEndComments) { }; // Parser/Scanner needs a stack limit. - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); for (int i = 0; tests[i]; i++) { const i::byte* source = @@ -178,7 +179,7 @@ TEST(ScanHTMLEndComments) { } -class ScriptResource : public v8::String::ExternalAsciiStringResource { +class ScriptResource : public v8::String::ExternalOneByteStringResource { public: ScriptResource(const char* data, size_t length) : data_(data), length_(length) { } @@ -197,8 +198,8 @@ TEST(UsingCachedData) { v8::HandleScope handles(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Context::Scope context_scope(context); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); // Source containing functions that might be lazily compiled and all types // of symbols (string, propertyName, regexp). @@ -250,8 +251,8 @@ TEST(PreparseFunctionDataIsUsed) { v8::HandleScope handles(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Context::Scope context_scope(context); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); const char* good_code[] = { "function this_is_lazy() { var a; } function foo() { return 25; } foo();", @@ -264,7 +265,7 @@ TEST(PreparseFunctionDataIsUsed) { "var this_is_lazy = () => { if ( }; var foo = () => 25; foo();", }; - for (unsigned i = 0; i < ARRAY_SIZE(good_code); i++) { + for (unsigned i = 0; i < arraysize(good_code); i++) { v8::ScriptCompiler::Source good_source(v8_str(good_code[i])); v8::ScriptCompiler::Compile(isolate, &good_source, v8::ScriptCompiler::kProduceDataToCache); @@ -291,8 +292,8 @@ TEST(PreparseFunctionDataIsUsed) { TEST(StandAlonePreParser) { v8::V8::Initialize(); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); const char* programs[] = { "{label: 42}", @@ -328,8 +329,8 @@ TEST(StandAlonePreParser) { TEST(StandAlonePreParserNoNatives) { v8::V8::Initialize(); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); const char* programs[] = { "%ArgleBargle(glop);", @@ -364,8 +365,8 @@ TEST(PreparsingObjectLiterals) { v8::HandleScope handles(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate); v8::Context::Scope context_scope(context); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); { const char* source = "var myo = {if: \"foo\"}; myo.if;"; @@ -397,7 +398,8 @@ TEST(RegressChromium62639) { v8::V8::Initialize(); i::Isolate* isolate = CcTest::i_isolate(); - isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024); + isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - + 128 * 1024); const char* program = "var x = 'something';\n" "escape: function() {}"; @@ -431,7 +433,8 @@ TEST(Regress928) { // as with-content, which made it assume that a function inside // the block could be lazily compiled, and an extra, unexpected, // entry was added to the data. - isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024); + isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - + 128 * 1024); const char* program = "try { } catch (e) { var foo = function () { /* first */ } }" @@ -474,8 +477,8 @@ TEST(Regress928) { TEST(PreParseOverflow) { v8::V8::Initialize(); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); size_t kProgramSize = 1024 * 1024; i::SmartArrayPointer<char> program(i::NewArray<char>(kProgramSize + 1)); @@ -521,10 +524,8 @@ class TestExternalResource: public v8::String::ExternalStringResource { #define CHECK_EQU(v1, v2) CHECK_EQ(static_cast<int>(v1), static_cast<int>(v2)) -void TestCharacterStream(const char* ascii_source, - unsigned length, - unsigned start = 0, - unsigned end = 0) { +void TestCharacterStream(const char* one_byte_source, unsigned length, + unsigned start = 0, unsigned end = 0) { if (end == 0) end = length; unsigned sub_length = end - start; i::Isolate* isolate = CcTest::i_isolate(); @@ -532,20 +533,22 @@ void TestCharacterStream(const char* ascii_source, i::HandleScope test_scope(isolate); i::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]); for (unsigned i = 0; i < length; i++) { - uc16_buffer[i] = static_cast<i::uc16>(ascii_source[i]); + uc16_buffer[i] = static_cast<i::uc16>(one_byte_source[i]); } - i::Vector<const char> ascii_vector(ascii_source, static_cast<int>(length)); - i::Handle<i::String> ascii_string = - factory->NewStringFromAscii(ascii_vector).ToHandleChecked(); + i::Vector<const char> one_byte_vector(one_byte_source, + static_cast<int>(length)); + i::Handle<i::String> one_byte_string = + factory->NewStringFromAscii(one_byte_vector).ToHandleChecked(); TestExternalResource resource(uc16_buffer.get(), length); i::Handle<i::String> uc16_string( factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked()); i::ExternalTwoByteStringUtf16CharacterStream uc16_stream( i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end); - i::GenericStringUtf16CharacterStream string_stream(ascii_string, start, end); + i::GenericStringUtf16CharacterStream string_stream(one_byte_string, start, + end); i::Utf8ToUtf16CharacterStream utf8_stream( - reinterpret_cast<const i::byte*>(ascii_source), end); + reinterpret_cast<const i::byte*>(one_byte_source), end); utf8_stream.SeekForward(start); unsigned i = start; @@ -554,7 +557,7 @@ void TestCharacterStream(const char* ascii_source, CHECK_EQU(i, uc16_stream.pos()); CHECK_EQU(i, string_stream.pos()); CHECK_EQU(i, utf8_stream.pos()); - int32_t c0 = ascii_source[i]; + int32_t c0 = one_byte_source[i]; int32_t c1 = uc16_stream.Advance(); int32_t c2 = string_stream.Advance(); int32_t c3 = utf8_stream.Advance(); @@ -568,7 +571,7 @@ void TestCharacterStream(const char* ascii_source, } while (i > start + sub_length / 4) { // Pushback, re-read, pushback again. - int32_t c0 = ascii_source[i - 1]; + int32_t c0 = one_byte_source[i - 1]; CHECK_EQU(i, uc16_stream.pos()); CHECK_EQU(i, string_stream.pos()); CHECK_EQU(i, utf8_stream.pos()); @@ -611,7 +614,7 @@ void TestCharacterStream(const char* ascii_source, CHECK_EQU(i, uc16_stream.pos()); CHECK_EQU(i, string_stream.pos()); CHECK_EQU(i, utf8_stream.pos()); - int32_t c0 = ascii_source[i]; + int32_t c0 = one_byte_source[i]; int32_t c1 = uc16_stream.Advance(); int32_t c2 = string_stream.Advance(); int32_t c3 = utf8_stream.Advance(); @@ -807,7 +810,7 @@ void TestScanRegExp(const char* re_source, const char* expected) { scanner.CurrentSymbol(&ast_value_factory)->string(); i::DisallowHeapAllocation no_alloc; i::String::FlatContent content = val->GetFlatContent(); - CHECK(content.IsAscii()); + CHECK(content.IsOneByte()); i::Vector<const uint8_t> actual = content.ToOneByteVector(); for (int i = 0; i < actual.length(); i++) { CHECK_NE('\0', expected[i]); @@ -1104,7 +1107,8 @@ TEST(ScopePositions) { v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); v8::Context::Scope context_scope(context); - isolate->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 128 * 1024); + isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - + 128 * 1024); for (int i = 0; source_data[i].outer_prefix; i++) { int kPrefixLen = Utf8LengthHelper(source_data[i].outer_prefix); @@ -1127,7 +1131,10 @@ TEST(ScopePositions) { CHECK_EQ(source->length(), kProgramSize); i::Handle<i::Script> script = factory->NewScript(source); i::CompilationInfoWithZone info(script); - i::Parser parser(&info); + i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(), + isolate->heap()->HashSeed(), + isolate->unicode_cache()}; + i::Parser parser(&info, &parse_info); parser.set_allow_lazy(true); parser.set_allow_harmony_scoping(true); parser.set_allow_arrow_functions(true); @@ -1207,9 +1214,10 @@ enum ParserFlag { kAllowNativesSyntax, kAllowHarmonyScoping, kAllowModules, - kAllowGenerators, kAllowHarmonyNumericLiterals, - kAllowArrowFunctions + kAllowArrowFunctions, + kAllowClasses, + kAllowHarmonyObjectLiterals }; @@ -1226,10 +1234,12 @@ void SetParserFlags(i::ParserBase<Traits>* parser, parser->set_allow_natives_syntax(flags.Contains(kAllowNativesSyntax)); parser->set_allow_harmony_scoping(flags.Contains(kAllowHarmonyScoping)); parser->set_allow_modules(flags.Contains(kAllowModules)); - parser->set_allow_generators(flags.Contains(kAllowGenerators)); parser->set_allow_harmony_numeric_literals( flags.Contains(kAllowHarmonyNumericLiterals)); + parser->set_allow_harmony_object_literals( + flags.Contains(kAllowHarmonyObjectLiterals)); parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions)); + parser->set_allow_classes(flags.Contains(kAllowClasses)); } @@ -1260,7 +1270,10 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, { i::Handle<i::Script> script = factory->NewScript(source); i::CompilationInfoWithZone info(script); - i::Parser parser(&info); + i::Parser::ParseInfo parse_info = {isolate->stack_guard()->real_climit(), + isolate->heap()->HashSeed(), + isolate->unicode_cache()}; + i::Parser parser(&info, &parse_info); SetParserFlags(&parser, flags); info.MarkAsGlobal(); parser.Parse(); @@ -1431,12 +1444,19 @@ TEST(ParserSync) { v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); v8::Context::Scope context_scope(context); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); + + static const ParserFlag flags1[] = { + kAllowArrowFunctions, + kAllowClasses, + kAllowHarmonyNumericLiterals, + kAllowHarmonyObjectLiterals, + kAllowHarmonyScoping, + kAllowLazy, + kAllowModules, + }; - static const ParserFlag flags1[] = {kAllowLazy, kAllowHarmonyScoping, - kAllowModules, kAllowGenerators, - kAllowArrowFunctions}; for (int i = 0; context_data[i][0] != NULL; ++i) { for (int j = 0; statement_data[j] != NULL; ++j) { for (int k = 0; termination_data[k] != NULL; ++k) { @@ -1456,7 +1476,7 @@ TEST(ParserSync) { termination_data[k], context_data[i][1]); CHECK(length == kProgramSize); - TestParserSync(program.start(), flags1, ARRAY_SIZE(flags1)); + TestParserSync(program.start(), flags1, arraysize(flags1)); } } } @@ -1465,11 +1485,11 @@ TEST(ParserSync) { // interaction with the flags above, so test these separately to reduce // the combinatorial explosion. static const ParserFlag flags2[] = { kAllowHarmonyNumericLiterals }; - TestParserSync("0o1234", flags2, ARRAY_SIZE(flags2)); - TestParserSync("0b1011", flags2, ARRAY_SIZE(flags2)); + TestParserSync("0o1234", flags2, arraysize(flags2)); + TestParserSync("0b1011", flags2, arraysize(flags2)); static const ParserFlag flags3[] = { kAllowNativesSyntax }; - TestParserSync("%DebugPrint(123)", flags3, ARRAY_SIZE(flags3)); + TestParserSync("%DebugPrint(123)", flags3, arraysize(flags3)); } @@ -1507,16 +1527,23 @@ void RunParserSyncTest(const char* context_data[][2], v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); v8::Context::Scope context_scope(context); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); static const ParserFlag default_flags[] = { - kAllowLazy, kAllowHarmonyScoping, kAllowModules, - kAllowGenerators, kAllowNativesSyntax, kAllowArrowFunctions}; + kAllowArrowFunctions, + kAllowClasses, + kAllowHarmonyNumericLiterals, + kAllowHarmonyObjectLiterals, + kAllowHarmonyScoping, + kAllowLazy, + kAllowModules, + kAllowNativesSyntax, + }; ParserFlag* generated_flags = NULL; if (flags == NULL) { flags = default_flags; - flags_len = ARRAY_SIZE(default_flags); + flags_len = arraysize(default_flags); if (always_true_flags != NULL) { // Remove always_true_flags from default_flags. CHECK(always_true_flags_len < flags_len); @@ -1666,7 +1693,7 @@ TEST(NoErrorsEvalAndArgumentsStrict) { static const ParserFlag always_flags[] = {kAllowArrowFunctions}; RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, - always_flags, ARRAY_SIZE(always_flags)); + always_flags, arraysize(always_flags)); } @@ -1699,7 +1726,7 @@ TEST(ErrorsFutureStrictReservedWords) { static const ParserFlag always_flags[] = {kAllowArrowFunctions}; RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags, - ARRAY_SIZE(always_flags)); + arraysize(always_flags)); } @@ -1728,7 +1755,7 @@ TEST(NoErrorsFutureStrictReservedWords) { static const ParserFlag always_flags[] = {kAllowArrowFunctions}; RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, - always_flags, ARRAY_SIZE(always_flags)); + always_flags, arraysize(always_flags)); } @@ -1873,10 +1900,7 @@ TEST(NoErrorsYieldSloppyGeneratorsEnabled) { NULL }; - // This test requires kAllowGenerators to succeed. - static const ParserFlag always_true_flags[] = { kAllowGenerators }; - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, - always_true_flags, 1); + RunParserSyncTest(context_data, statement_data, kSuccess); } @@ -1969,12 +1993,7 @@ TEST(NoErrorsGenerator) { NULL }; - // This test requires kAllowGenerators to succeed. - static const ParserFlag always_true_flags[] = { - kAllowGenerators - }; - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, - always_true_flags, 1); + RunParserSyncTest(context_data, statement_data, kSuccess); } @@ -2085,12 +2104,7 @@ TEST(NoErrorsNameOfStrictGenerator) { NULL }; - // This test requires kAllowGenerators to succeed. - static const ParserFlag always_true_flags[] = { - kAllowGenerators - }; - RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, - always_true_flags, 1); + RunParserSyncTest(context_data, statement_data, kSuccess); } @@ -2153,7 +2167,7 @@ TEST(NoErrorsIllegalWordsAsLabels) { static const ParserFlag always_flags[] = {kAllowArrowFunctions}; RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, - always_flags, ARRAY_SIZE(always_flags)); + always_flags, arraysize(always_flags)); } @@ -2241,8 +2255,8 @@ TEST(DontRegressPreParserDataSizes) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope handles(isolate); - CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - - 128 * 1024); + CcTest::i_isolate()->stack_guard()->SetStackLimit( + i::GetCurrentStackPosition() - 128 * 1024); struct TestCase { const char* program; @@ -2507,34 +2521,36 @@ TEST(ErrorsObjectLiteralChecking) { }; const char* statement_data[] = { - ",", - "foo: 1, get foo() {}", - "foo: 1, set foo(v) {}", - "\"foo\": 1, get \"foo\"() {}", - "\"foo\": 1, set \"foo\"(v) {}", - "1: 1, get 1() {}", - "1: 1, set 1() {}", - // It's counter-intuitive, but these collide too (even in classic - // mode). Note that we can have "foo" and foo as properties in classic mode, - // but we cannot have "foo" and get foo, or foo and get "foo". - "foo: 1, get \"foo\"() {}", - "foo: 1, set \"foo\"(v) {}", - "\"foo\": 1, get foo() {}", - "\"foo\": 1, set foo(v) {}", - "1: 1, get \"1\"() {}", - "1: 1, set \"1\"() {}", - "\"1\": 1, get 1() {}" - "\"1\": 1, set 1(v) {}" - // Wrong number of parameters - "get bar(x) {}", - "get bar(x, y) {}", - "set bar() {}", - "set bar(x, y) {}", - // Parsing FunctionLiteral for getter or setter fails - "get foo( +", - "get foo() \"error\"", - NULL - }; + ",", + "foo: 1, get foo() {}", + "foo: 1, set foo(v) {}", + "\"foo\": 1, get \"foo\"() {}", + "\"foo\": 1, set \"foo\"(v) {}", + "1: 1, get 1() {}", + "1: 1, set 1() {}", + "get foo() {}, get foo() {}", + "set foo(_) {}, set foo(_) {}", + // It's counter-intuitive, but these collide too (even in classic + // mode). Note that we can have "foo" and foo as properties in classic + // mode, + // but we cannot have "foo" and get foo, or foo and get "foo". + "foo: 1, get \"foo\"() {}", + "foo: 1, set \"foo\"(v) {}", + "\"foo\": 1, get foo() {}", + "\"foo\": 1, set foo(v) {}", + "1: 1, get \"1\"() {}", + "1: 1, set \"1\"() {}", + "\"1\": 1, get 1() {}" + "\"1\": 1, set 1(v) {}" + // Wrong number of parameters + "get bar(x) {}", + "get bar(x, y) {}", + "set bar() {}", + "set bar(x, y) {}", + // Parsing FunctionLiteral for getter or setter fails + "get foo( +", + "get foo() \"error\"", + NULL}; RunParserSyncTest(context_data, statement_data, kError); } @@ -2571,6 +2587,8 @@ TEST(NoErrorsObjectLiteralChecking) { "\"foo\": 1, set \"bar\"(v) {}", "1: 1, get 2() {}", "1: 1, set 2(v) {}", + "get: 1, get foo() {}", + "set: 1, set foo(_) {}", // Keywords, future reserved and strict future reserved are also allowed as // property names. "if: 4", @@ -2793,7 +2811,7 @@ TEST(FuncNameInferrerTwoByte) { "var obj1 = { oXj2 : { foo1: function() {} } }; " "%FunctionGetInferredName(obj1.oXj2.foo1)"); uint16_t* two_byte_name = AsciiToTwoByteString("obj1.oXj2.foo1"); - // Make it really non-ASCII (replace the Xs with a non-ASCII character). + // Make it really non-Latin1 (replace the Xs with a non-Latin1 character). two_byte_source[14] = two_byte_source[78] = two_byte_name[6] = 0x010d; v8::Local<v8::String> source = v8::String::NewFromTwoByte(isolate, two_byte_source); @@ -3105,10 +3123,10 @@ TEST(InnerAssignment) { int prefix_len = Utf8LengthHelper(prefix); int midfix_len = Utf8LengthHelper(midfix); int suffix_len = Utf8LengthHelper(suffix); - for (unsigned i = 0; i < ARRAY_SIZE(outers); ++i) { + for (unsigned i = 0; i < arraysize(outers); ++i) { const char* outer = outers[i].source; int outer_len = Utf8LengthHelper(outer); - for (unsigned j = 0; j < ARRAY_SIZE(inners); ++j) { + for (unsigned j = 0; j < arraysize(inners); ++j) { for (unsigned outer_lazy = 0; outer_lazy < 2; ++outer_lazy) { for (unsigned inner_lazy = 0; inner_lazy < 2; ++inner_lazy) { if (outers[i].strict && inners[j].with) continue; @@ -3132,7 +3150,10 @@ TEST(InnerAssignment) { i::Handle<i::Script> script = factory->NewScript(source); i::CompilationInfoWithZone info(script); - i::Parser parser(&info); + i::Parser::ParseInfo parse_info = { + isolate->stack_guard()->real_climit(), + isolate->heap()->HashSeed(), isolate->unicode_cache()}; + i::Parser parser(&info, &parse_info); parser.set_allow_harmony_scoping(true); CHECK(parser.Parse()); CHECK(i::Rewriter::Rewrite(&info)); @@ -3282,12 +3303,10 @@ TEST(ErrorsArrowFunctions) { }; // The test is quite slow, so run it with a reduced set of flags. - static const ParserFlag flags[] = { - kAllowLazy, kAllowHarmonyScoping, kAllowGenerators - }; + static const ParserFlag flags[] = {kAllowLazy, kAllowHarmonyScoping}; static const ParserFlag always_flags[] = { kAllowArrowFunctions }; RunParserSyncTest(context_data, statement_data, kError, flags, - ARRAY_SIZE(flags), always_flags, ARRAY_SIZE(always_flags)); + arraysize(flags), always_flags, arraysize(always_flags)); } @@ -3341,5 +3360,612 @@ TEST(NoErrorsArrowFunctions) { static const ParserFlag always_flags[] = {kAllowArrowFunctions}; RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, - always_flags, ARRAY_SIZE(always_flags)); + always_flags, arraysize(always_flags)); +} + + +TEST(NoErrorsSuper) { + // Tests that parser and preparser accept 'super' keyword in right places. + const char* context_data[][2] = {{"", ";"}, + {"k = ", ";"}, + {"foo(", ");"}, + {NULL, NULL}}; + + const char* statement_data[] = { + "super.x", + "super[27]", + "new super", + "new super()", + "new super(12, 45)", + "new new super", + "new new super()", + "new new super()()", + "z.super", // Ok, property lookup. + NULL}; + + static const ParserFlag always_flags[] = {kAllowClasses}; + RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ErrorsSuper) { + // Tests that parser and preparser generate same errors for 'super'. + const char* context_data[][2] = {{"", ";"}, + {"k = ", ";"}, + {"foo(", ");"}, + {NULL, NULL}}; + + const char* statement_data[] = { + "super = x", + "y = super", + "f(super)", + NULL}; + + static const ParserFlag always_flags[] = {kAllowClasses}; + RunParserSyncTest(context_data, statement_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(NoErrorsMethodDefinition) { + const char* context_data[][2] = {{"({", "});"}, + {"'use strict'; ({", "});"}, + {"({*", "});"}, + {"'use strict'; ({*", "});"}, + {NULL, NULL}}; + + const char* object_literal_body_data[] = { + "m() {}", + "m(x) { return x; }", + "m(x, y) {}, n() {}", + "set(x, y) {}", + "get(x, y) {}", + NULL + }; + + static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; + RunParserSyncTest(context_data, object_literal_body_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(MethodDefinitionNames) { + const char* context_data[][2] = {{"({", "(x, y) {}});"}, + {"'use strict'; ({", "(x, y) {}});"}, + {"({*", "(x, y) {}});"}, + {"'use strict'; ({*", "(x, y) {}});"}, + {NULL, NULL}}; + + const char* name_data[] = { + "m", + "'m'", + "\"m\"", + "\"m n\"", + "true", + "false", + "null", + "0", + "1.2", + "1e1", + "1E1", + "1e+1", + "1e-1", + + // Keywords + "async", + "await", + "break", + "case", + "catch", + "class", + "const", + "continue", + "debugger", + "default", + "delete", + "do", + "else", + "enum", + "export", + "extends", + "finally", + "for", + "function", + "if", + "implements", + "import", + "in", + "instanceof", + "interface", + "let", + "new", + "package", + "private", + "protected", + "public", + "return", + "static", + "super", + "switch", + "this", + "throw", + "try", + "typeof", + "var", + "void", + "while", + "with", + "yield", + NULL + }; + + static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; + RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(MethodDefinitionStrictFormalParamereters) { + const char* context_data[][2] = {{"({method(", "){}});"}, + {"'use strict'; ({method(", "){}});"}, + {"({*method(", "){}});"}, + {"'use strict'; ({*method(", "){}});"}, + {NULL, NULL}}; + + const char* params_data[] = { + "x, x", + "x, y, x", + "eval", + "arguments", + "var", + "const", + NULL + }; + + static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; + RunParserSyncTest(context_data, params_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(MethodDefinitionDuplicateProperty) { + // Duplicate properties are allowed in ES6 but we haven't removed that check + // yet. + const char* context_data[][2] = {{"'use strict'; ({", "});"}, + {NULL, NULL}}; + + const char* params_data[] = { + "x: 1, x() {}", + "x() {}, x: 1", + "x() {}, get x() {}", + "x() {}, set x(_) {}", + "x() {}, x() {}", + "x() {}, y() {}, x() {}", + "x() {}, \"x\"() {}", + "x() {}, 'x'() {}", + "0() {}, '0'() {}", + "1.0() {}, 1: 1", + + "x: 1, *x() {}", + "*x() {}, x: 1", + "*x() {}, get x() {}", + "*x() {}, set x(_) {}", + "*x() {}, *x() {}", + "*x() {}, y() {}, *x() {}", + "*x() {}, *\"x\"() {}", + "*x() {}, *'x'() {}", + "*0() {}, *'0'() {}", + "*1.0() {}, 1: 1", + + NULL + }; + + static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; + RunParserSyncTest(context_data, params_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassExpressionNoErrors) { + const char* context_data[][2] = {{"(", ");"}, + {"var C = ", ";"}, + {"bar, ", ";"}, + {NULL, NULL}}; + const char* class_data[] = { + "class {}", + "class name {}", + "class extends F {}", + "class name extends F {}", + "class extends (F, G) {}", + "class name extends (F, G) {}", + "class extends class {} {}", + "class name extends class {} {}", + "class extends class base {} {}", + "class name extends class base {} {}", + NULL}; + + static const ParserFlag always_flags[] = {kAllowClasses}; + RunParserSyncTest(context_data, class_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassDeclarationNoErrors) { + const char* context_data[][2] = {{"", ""}, + {"{", "}"}, + {"if (true) {", "}"}, + {NULL, NULL}}; + const char* statement_data[] = { + "class name {}", + "class name extends F {}", + "class name extends (F, G) {}", + "class name extends class {} {}", + "class name extends class base {} {}", + NULL}; + + static const ParserFlag always_flags[] = {kAllowClasses}; + RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassBodyNoErrors) { + // Tests that parser and preparser accept valid class syntax. + const char* context_data[][2] = {{"(class {", "});"}, + {"(class extends Base {", "});"}, + {"class C {", "}"}, + {"class C extends Base {", "}"}, + {NULL, NULL}}; + const char* class_body_data[] = { + ";", + ";;", + "m() {}", + "m() {};", + "; m() {}", + "m() {}; n(x) {}", + "get x() {}", + "set x(v) {}", + "get() {}", + "set() {}", + "*g() {}", + "*g() {};", + "; *g() {}", + "*g() {}; *h(x) {}", + "static() {}", + "static m() {}", + "static get x() {}", + "static set x(v) {}", + "static get() {}", + "static set() {}", + "static static() {}", + "static get static() {}", + "static set static(v) {}", + "*static() {}", + "*get() {}", + "*set() {}", + "static *g() {}", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassPropertyNameNoErrors) { + const char* context_data[][2] = {{"(class {", "() {}});"}, + {"(class { get ", "() {}});"}, + {"(class { set ", "(v) {}});"}, + {"(class { static ", "() {}});"}, + {"(class { static get ", "() {}});"}, + {"(class { static set ", "(v) {}});"}, + {"(class { *", "() {}});"}, + {"(class { static *", "() {}});"}, + {"class C {", "() {}}"}, + {"class C { get ", "() {}}"}, + {"class C { set ", "(v) {}}"}, + {"class C { static ", "() {}}"}, + {"class C { static get ", "() {}}"}, + {"class C { static set ", "(v) {}}"}, + {"class C { *", "() {}}"}, + {"class C { static *", "() {}}"}, + {NULL, NULL}}; + const char* name_data[] = { + "42", + "42.5", + "42e2", + "42e+2", + "42e-2", + "null", + "false", + "true", + "'str'", + "\"str\"", + "static", + "get", + "set", + "var", + "const", + "let", + "this", + "class", + "function", + "yield", + "if", + "else", + "for", + "while", + "do", + "try", + "catch", + "finally", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassExpressionErrors) { + const char* context_data[][2] = {{"(", ");"}, + {"var C = ", ";"}, + {"bar, ", ";"}, + {NULL, NULL}}; + const char* class_data[] = { + "class", + "class name", + "class name extends", + "class extends", + "class {", + "class { m }", + "class { m; n }", + "class { m: 1 }", + "class { m(); n() }", + "class { get m }", + "class { get m() }", + "class { get m() { }", + "class { set m() {} }", // Missing required parameter. + "class { m() {}, n() {} }", // No commas allowed. + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassDeclarationErrors) { + const char* context_data[][2] = {{"", ""}, + {"{", "}"}, + {"if (true) {", "}"}, + {NULL, NULL}}; + const char* class_data[] = { + "class", + "class name", + "class name extends", + "class extends", + "class name {", + "class name { m }", + "class name { m; n }", + "class name { m: 1 }", + "class name { m(); n() }", + "class name { get x }", + "class name { get x() }", + "class name { set x() {) }", // missing required param + "class {}", // Name is required for declaration + "class extends base {}", + "class name { *", + "class name { * }", + "class name { *; }", + "class name { *get x() {} }", + "class name { *set x(_) {} }", + "class name { *static m() {} }", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyNumericLiterals + }; + RunParserSyncTest(context_data, class_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassNameErrors) { + const char* context_data[][2] = {{"class ", "{}"}, + {"(class ", "{});"}, + {"'use strict'; class ", "{}"}, + {"'use strict'; (class ", "{});"}, + {NULL, NULL}}; + const char* class_name[] = { + "arguments", + "eval", + "implements", + "interface", + "let", + "package", + "private", + "protected", + "public", + "static", + "var", + "yield", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_name, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassGetterParamNameErrors) { + const char* context_data[][2] = { + {"class C { get name(", ") {} }"}, + {"(class { get name(", ") {} });"}, + {"'use strict'; class C { get name(", ") {} }"}, + {"'use strict'; (class { get name(", ") {} })"}, + {NULL, NULL} + }; + + const char* class_name[] = { + "arguments", + "eval", + "implements", + "interface", + "let", + "package", + "private", + "protected", + "public", + "static", + "var", + "yield", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_name, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassStaticPrototypeErrors) { + const char* context_data[][2] = {{"class C {", "}"}, + {"(class {", "});"}, + {NULL, NULL}}; + + const char* class_body_data[] = { + "static prototype() {}", + "static get prototype() {}", + "static set prototype(_) {}", + "static *prototype() {}", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassSpecialConstructorErrors) { + const char* context_data[][2] = {{"class C {", "}"}, + {"(class {", "});"}, + {NULL, NULL}}; + + const char* class_body_data[] = { + "get constructor() {}", + "get constructor(_) {}", + "*constructor() {}", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassConstructorNoErrors) { + const char* context_data[][2] = {{"class C {", "}"}, + {"(class {", "});"}, + {NULL, NULL}}; + + const char* class_body_data[] = { + "constructor() {}", + "static constructor() {}", + "static get constructor() {}", + "static set constructor(_) {}", + "static *constructor() {}", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassMultipleConstructorErrors) { + // We currently do not allow any duplicate properties in class bodies. This + // test ensures that when we change that we still throw on duplicate + // constructors. + const char* context_data[][2] = {{"class C {", "}"}, + {"(class {", "});"}, + {NULL, NULL}}; + + const char* class_body_data[] = { + "constructor() {}; constructor() {}", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +// TODO(arv): We should allow duplicate property names. +// https://code.google.com/p/v8/issues/detail?id=3570 +DISABLED_TEST(ClassMultiplePropertyNamesNoErrors) { + const char* context_data[][2] = {{"class C {", "}"}, + {"(class {", "});"}, + {NULL, NULL}}; + + const char* class_body_data[] = { + "constructor() {}; static constructor() {}", + "m() {}; static m() {}", + "m() {}; m() {}", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, + always_flags, arraysize(always_flags)); +} + + +TEST(ClassesAreStrictErrors) { + const char* context_data[][2] = {{"", ""}, + {"(", ");"}, + {NULL, NULL}}; + + const char* class_body_data[] = { + "class C { method() { with ({}) {} } }", + "class C extends function() { with ({}) {} } {}", + "class C { *method() { with ({}) {} } }", + NULL}; + + static const ParserFlag always_flags[] = { + kAllowClasses, + kAllowHarmonyObjectLiterals + }; + RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, + always_flags, arraysize(always_flags)); } diff --git a/deps/v8/test/cctest/test-platform.cc b/deps/v8/test/cctest/test-platform.cc index 3beaccea8e..100a5a78cf 100644 --- a/deps/v8/test/cctest/test-platform.cc +++ b/deps/v8/test/cctest/test-platform.cc @@ -1,77 +1,35 @@ // Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include <stdlib.h> +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "include/v8stdint.h" +#include "src/base/build_config.h" #include "src/base/platform/platform.h" #include "test/cctest/cctest.h" -using namespace ::v8::internal; +#ifdef V8_CC_GNU -#ifdef __GNUC__ -#define ASM __asm__ __volatile__ +static uintptr_t sp_addr = 0; -#if defined(_M_X64) || defined(__x86_64__) -#define GET_STACK_POINTER() \ - static int sp_addr = 0; \ - do { \ - ASM("mov %%rsp, %0" : "=g" (sp_addr)); \ - } while (0) -#elif defined(_M_IX86) || defined(__i386__) -#define GET_STACK_POINTER() \ - static int sp_addr = 0; \ - do { \ - ASM("mov %%esp, %0" : "=g" (sp_addr)); \ - } while (0) -#elif defined(__ARMEL__) -#define GET_STACK_POINTER() \ - static int sp_addr = 0; \ - do { \ - ASM("str %%sp, %0" : "=g" (sp_addr)); \ - } while (0) -#elif defined(__AARCH64EL__) -#define GET_STACK_POINTER() \ - static int sp_addr = 0; \ - do { \ - ASM("mov x16, sp; str x16, %0" : "=g" (sp_addr)); \ - } while (0) -#elif defined(__MIPSEB__) || defined(__MIPSEL__) -#define GET_STACK_POINTER() \ - static int sp_addr = 0; \ - do { \ - ASM("sw $sp, %0" : "=g" (sp_addr)); \ - } while (0) +void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { +#if V8_HOST_ARCH_X64 + __asm__ __volatile__("mov %%rsp, %0" : "=g"(sp_addr)); +#elif V8_HOST_ARCH_IA32 + __asm__ __volatile__("mov %%esp, %0" : "=g"(sp_addr)); +#elif V8_HOST_ARCH_ARM + __asm__ __volatile__("str %%sp, %0" : "=g"(sp_addr)); +#elif V8_HOST_ARCH_ARM64 + __asm__ __volatile__("mov x16, sp; str x16, %0" : "=g"(sp_addr)); +#elif V8_HOST_ARCH_MIPS + __asm__ __volatile__("sw $sp, %0" : "=g"(sp_addr)); +#elif V8_HOST_ARCH_MIPS64 + __asm__ __volatile__("sd $sp, %0" : "=g"(sp_addr)); #else #error Host architecture was not detected as supported by v8 #endif -void GetStackPointer(const v8::FunctionCallbackInfo<v8::Value>& args) { - GET_STACK_POINTER(); - args.GetReturnValue().Set(v8_num(sp_addr)); + args.GetReturnValue().Set(v8::Integer::NewFromUnsigned( + args.GetIsolate(), static_cast<uint32_t>(sp_addr))); } @@ -94,9 +52,7 @@ TEST(StackAlignment) { v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); v8::Local<v8::Value> result = foo->Call(global_object, 0, NULL); - CHECK_EQ(0, result->Int32Value() % v8::base::OS::ActivationFrameAlignment()); + CHECK_EQ(0, result->Uint32Value() % v8::base::OS::ActivationFrameAlignment()); } -#undef GET_STACK_POINTERS -#undef ASM -#endif // __GNUC__ +#endif // V8_CC_GNU diff --git a/deps/v8/test/cctest/test-random-number-generator.cc b/deps/v8/test/cctest/test-random-number-generator.cc index a53205c9c8..04b58820a2 100644 --- a/deps/v8/test/cctest/test-random-number-generator.cc +++ b/deps/v8/test/cctest/test-random-number-generator.cc @@ -34,28 +34,16 @@ using namespace v8::internal; -static const int kMaxRuns = 12345; -static const int kRandomSeeds[] = { - -1, 1, 42, 100, 1234567890, 987654321 -}; +static const int64_t kRandomSeeds[] = {-1, 1, 42, 100, 1234567890, 987654321}; TEST(RandomSeedFlagIsUsed) { - for (unsigned n = 0; n < ARRAY_SIZE(kRandomSeeds); ++n) { - FLAG_random_seed = kRandomSeeds[n]; + for (unsigned n = 0; n < arraysize(kRandomSeeds); ++n) { + FLAG_random_seed = static_cast<int>(kRandomSeeds[n]); v8::Isolate* i = v8::Isolate::New(); - v8::base::RandomNumberGenerator& rng1 = + v8::base::RandomNumberGenerator& rng = *reinterpret_cast<Isolate*>(i)->random_number_generator(); - v8::base::RandomNumberGenerator rng2(kRandomSeeds[n]); - for (int k = 1; k <= kMaxRuns; ++k) { - int64_t i1, i2; - rng1.NextBytes(&i1, sizeof(i1)); - rng2.NextBytes(&i2, sizeof(i2)); - CHECK_EQ(i2, i1); - CHECK_EQ(rng2.NextInt(), rng1.NextInt()); - CHECK_EQ(rng2.NextInt(k), rng1.NextInt(k)); - CHECK_EQ(rng2.NextDouble(), rng1.NextDouble()); - } + CHECK_EQ(kRandomSeeds[n], rng.initial_seed()); i->Dispose(); } } diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index 5c1764eacf..9d1d52e675 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -85,7 +85,6 @@ using namespace v8::internal; static bool CheckParse(const char* input) { - V8::Initialize(NULL); v8::HandleScope scope(CcTest::isolate()); Zone zone(CcTest::i_isolate()); FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); @@ -96,7 +95,6 @@ static bool CheckParse(const char* input) { static void CheckParseEq(const char* input, const char* expected) { - V8::Initialize(NULL); v8::HandleScope scope(CcTest::isolate()); Zone zone(CcTest::i_isolate()); FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); @@ -112,7 +110,6 @@ static void CheckParseEq(const char* input, const char* expected) { static bool CheckSimple(const char* input) { - V8::Initialize(NULL); v8::HandleScope scope(CcTest::isolate()); Zone zone(CcTest::i_isolate()); FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); @@ -131,7 +128,6 @@ struct MinMaxPair { static MinMaxPair CheckMinMaxMatch(const char* input) { - V8::Initialize(NULL); v8::HandleScope scope(CcTest::isolate()); Zone zone(CcTest::i_isolate()); FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); @@ -156,8 +152,6 @@ static MinMaxPair CheckMinMaxMatch(const char* input) { } TEST(Parser) { - V8::Initialize(NULL); - CHECK_PARSE_ERROR("?"); CheckParseEq("abc", "'abc'"); @@ -407,7 +401,6 @@ TEST(ParserRegression) { static void ExpectError(const char* input, const char* expected) { - V8::Initialize(NULL); v8::HandleScope scope(CcTest::isolate()); Zone zone(CcTest::i_isolate()); FlatStringReader reader(CcTest::i_isolate(), CStrVector(input)); @@ -494,7 +487,6 @@ static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { TEST(CharacterClassEscapes) { - v8::internal::V8::Initialize(NULL); TestCharacterClassEscapes('.', IsRegExpNewline); TestCharacterClassEscapes('d', IsDigit); TestCharacterClassEscapes('D', NotDigit); @@ -505,11 +497,8 @@ TEST(CharacterClassEscapes) { } -static RegExpNode* Compile(const char* input, - bool multiline, - bool is_ascii, +static RegExpNode* Compile(const char* input, bool multiline, bool is_one_byte, Zone* zone) { - V8::Initialize(NULL); Isolate* isolate = CcTest::i_isolate(); FlatStringReader reader(isolate, CStrVector(input)); RegExpCompileData compile_data; @@ -520,25 +509,17 @@ static RegExpNode* Compile(const char* input, NewStringFromUtf8(CStrVector(input)).ToHandleChecked(); Handle<String> sample_subject = isolate->factory()->NewStringFromUtf8(CStrVector("")).ToHandleChecked(); - RegExpEngine::Compile(&compile_data, - false, - false, - multiline, - pattern, - sample_subject, - is_ascii, - zone); + RegExpEngine::Compile(&compile_data, false, false, multiline, false, pattern, + sample_subject, is_one_byte, zone); return compile_data.node; } -static void Execute(const char* input, - bool multiline, - bool is_ascii, +static void Execute(const char* input, bool multiline, bool is_one_byte, bool dot_output = false) { v8::HandleScope scope(CcTest::isolate()); Zone zone(CcTest::i_isolate()); - RegExpNode* node = Compile(input, multiline, is_ascii, &zone); + RegExpNode* node = Compile(input, multiline, is_one_byte, &zone); USE(node); #ifdef DEBUG if (dot_output) { @@ -574,7 +555,6 @@ static unsigned PseudoRandom(int i, int j) { TEST(SplayTreeSimple) { - v8::internal::V8::Initialize(NULL); static const unsigned kLimit = 1000; Zone zone(CcTest::i_isolate()); ZoneSplayTree<TestConfig> tree(&zone); @@ -627,7 +607,6 @@ TEST(SplayTreeSimple) { TEST(DispatchTableConstruction) { - v8::internal::V8::Initialize(NULL); // Initialize test data. static const int kLimit = 1000; static const int kRangeCount = 8; @@ -756,16 +735,16 @@ TEST(MacroAssemblerNativeSuccess) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); m.Succeed(); - Handle<String> source = factory->NewStringFromStaticAscii(""); + Handle<String> source = factory->NewStringFromStaticChars(""); 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->NewStringFromStaticAscii("foofoo"); + Handle<String> input = factory->NewStringFromStaticChars("foofoo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); const byte* start_adr = reinterpret_cast<const byte*>(seq_input->GetCharsAddress()); @@ -793,7 +772,7 @@ TEST(MacroAssemblerNativeSimple) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); Label fail, backtrack; m.PushBacktrack(&fail); @@ -814,12 +793,12 @@ TEST(MacroAssemblerNativeSimple) { m.Bind(&fail); m.Fail(); - Handle<String> source = factory->NewStringFromStaticAscii("^foo"); + Handle<String> source = factory->NewStringFromStaticChars("^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->NewStringFromStaticAscii("foofoo"); + Handle<String> input = factory->NewStringFromStaticChars("foofoo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -837,7 +816,7 @@ TEST(MacroAssemblerNativeSimple) { CHECK_EQ(-1, captures[2]); CHECK_EQ(-1, captures[3]); - input = factory->NewStringFromStaticAscii("barbarbar"); + input = factory->NewStringFromStaticChars("barbarbar"); seq_input = Handle<SeqOneByteString>::cast(input); start_adr = seq_input->GetCharsAddress(); @@ -880,7 +859,7 @@ TEST(MacroAssemblerNativeSimpleUC16) { m.Bind(&fail); m.Fail(); - Handle<String> source = factory->NewStringFromStaticAscii("^foo"); + Handle<String> source = factory->NewStringFromStaticChars("^foo"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); @@ -931,7 +910,7 @@ TEST(MacroAssemblerNativeBacktrack) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone); Label fail; Label backtrack; @@ -944,11 +923,11 @@ TEST(MacroAssemblerNativeBacktrack) { m.Bind(&backtrack); m.Fail(); - Handle<String> source = factory->NewStringFromStaticAscii(".........."); + Handle<String> source = factory->NewStringFromStaticChars(".........."); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); - Handle<String> input = factory->NewStringFromStaticAscii("foofoo"); + Handle<String> input = factory->NewStringFromStaticChars("foofoo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -964,14 +943,14 @@ TEST(MacroAssemblerNativeBacktrack) { } -TEST(MacroAssemblerNativeBackReferenceASCII) { +TEST(MacroAssemblerNativeBackReferenceLATIN1) { v8::V8::Initialize(); ContextInitializer initializer; Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); m.WriteCurrentPositionToRegister(0, 0); m.AdvanceCurrentPosition(2); @@ -988,11 +967,11 @@ TEST(MacroAssemblerNativeBackReferenceASCII) { m.Bind(&missing_match); m.Fail(); - Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1"); + Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); - Handle<String> input = factory->NewStringFromStaticAscii("fooofo"); + Handle<String> input = factory->NewStringFromStaticChars("fooofo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1037,7 +1016,7 @@ TEST(MacroAssemblerNativeBackReferenceUC16) { m.Bind(&missing_match); m.Fail(); - Handle<String> source = factory->NewStringFromStaticAscii("^(..)..\1"); + Handle<String> source = factory->NewStringFromStaticChars("^(..)..\1"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); @@ -1072,7 +1051,7 @@ TEST(MacroAssemblernativeAtStart) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone); Label not_at_start, newline, fail; m.CheckNotAtStart(¬_at_start); @@ -1095,11 +1074,11 @@ TEST(MacroAssemblernativeAtStart) { m.CheckNotCharacter('b', &fail); m.Succeed(); - Handle<String> source = factory->NewStringFromStaticAscii("(^f|ob)"); + Handle<String> source = factory->NewStringFromStaticChars("(^f|ob)"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); - Handle<String> input = factory->NewStringFromStaticAscii("foobar"); + Handle<String> input = factory->NewStringFromStaticChars("foobar"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1131,7 +1110,7 @@ TEST(MacroAssemblerNativeBackRefNoCase) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 4, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 4, &zone); Label fail, succ; @@ -1156,12 +1135,11 @@ TEST(MacroAssemblerNativeBackRefNoCase) { m.Succeed(); Handle<String> source = - factory->NewStringFromStaticAscii("^(abc)\1\1(?!\1)...(?!\1)"); + factory->NewStringFromStaticChars("^(abc)\1\1(?!\1)...(?!\1)"); Handle<Object> code_object = m.GetCode(source); Handle<Code> code = Handle<Code>::cast(code_object); - Handle<String> input = - factory->NewStringFromStaticAscii("aBcAbCABCxYzab"); + Handle<String> input = factory->NewStringFromStaticChars("aBcAbCABCxYzab"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1190,7 +1168,7 @@ TEST(MacroAssemblerNativeRegisters) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 6, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 6, &zone); uc16 foo_chars[3] = {'f', 'o', 'o'}; Vector<const uc16> foo(foo_chars, 3); @@ -1256,14 +1234,12 @@ TEST(MacroAssemblerNativeRegisters) { m.Bind(&fail); m.Fail(); - Handle<String> source = - factory->NewStringFromStaticAscii("<loop test>"); + Handle<String> source = factory->NewStringFromStaticChars("<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->NewStringFromStaticAscii("foofoofoofoofoo"); + Handle<String> input = factory->NewStringFromStaticChars("foofoofoofoofoo"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1293,7 +1269,7 @@ TEST(MacroAssemblerStackOverflow) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 0, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 0, &zone); Label loop; m.Bind(&loop); @@ -1301,13 +1277,12 @@ TEST(MacroAssemblerStackOverflow) { m.GoTo(&loop); Handle<String> source = - factory->NewStringFromStaticAscii("<stack overflow test>"); + factory->NewStringFromStaticChars("<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->NewStringFromStaticAscii("dummy"); + Handle<String> input = factory->NewStringFromStaticChars("dummy"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1332,7 +1307,7 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { Factory* factory = isolate->factory(); Zone zone(isolate); - ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::ASCII, 2, &zone); + ArchRegExpMacroAssembler m(NativeRegExpMacroAssembler::LATIN1, 2, &zone); // At least 2048, to ensure the allocated space for registers // span one full page. @@ -1348,13 +1323,12 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { m.Succeed(); Handle<String> source = - factory->NewStringFromStaticAscii("<huge register space test>"); + factory->NewStringFromStaticChars("<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->NewStringFromStaticAscii("sample text"); + Handle<String> input = factory->NewStringFromStaticChars("sample text"); Handle<SeqOneByteString> seq_input = Handle<SeqOneByteString>::cast(input); Address start_adr = seq_input->GetCharsAddress(); @@ -1377,7 +1351,6 @@ TEST(MacroAssemblerNativeLotsOfRegisters) { #else // V8_INTERPRETED_REGEXP TEST(MacroAssembler) { - V8::Initialize(NULL); byte codes[1024]; Zone zone(CcTest::i_isolate()); RegExpMacroAssemblerIrregexp m(Vector<byte>(codes, 1024), &zone); @@ -1416,7 +1389,7 @@ TEST(MacroAssembler) { Factory* factory = isolate->factory(); HandleScope scope(isolate); - Handle<String> source = factory->NewStringFromStaticAscii("^f(o)o"); + Handle<String> source = factory->NewStringFromStaticChars("^f(o)o"); Handle<ByteArray> array = Handle<ByteArray>::cast(m.GetCode(source)); int captures[5]; @@ -1443,7 +1416,6 @@ 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++) { @@ -1603,7 +1575,6 @@ static void TestSimpleRangeCaseIndependence(CharacterRange input, TEST(CharacterRangeCaseIndependence) { - v8::internal::V8::Initialize(NULL); TestSimpleRangeCaseIndependence(CharacterRange::Singleton('a'), CharacterRange::Singleton('A')); TestSimpleRangeCaseIndependence(CharacterRange::Singleton('z'), @@ -1645,7 +1616,6 @@ static bool InClass(uc16 c, ZoneList<CharacterRange>* ranges) { TEST(CharClassDifference) { - v8::internal::V8::Initialize(NULL); Zone zone(CcTest::i_isolate()); ZoneList<CharacterRange>* base = new(&zone) ZoneList<CharacterRange>(1, &zone); @@ -1673,7 +1643,6 @@ TEST(CharClassDifference) { TEST(CanonicalizeCharacterSets) { - v8::internal::V8::Initialize(NULL); Zone zone(CcTest::i_isolate()); ZoneList<CharacterRange>* list = new(&zone) ZoneList<CharacterRange>(4, &zone); @@ -1735,7 +1704,6 @@ TEST(CanonicalizeCharacterSets) { TEST(CharacterRangeMerge) { - v8::internal::V8::Initialize(NULL); Zone zone(CcTest::i_isolate()); ZoneList<CharacterRange> l1(4, &zone); ZoneList<CharacterRange> l2(4, &zone); @@ -1823,6 +1791,5 @@ TEST(CharacterRangeMerge) { TEST(Graph) { - V8::Initialize(NULL); Execute("\\b\\w+\\b", false, true, true); } diff --git a/deps/v8/test/cctest/test-semaphore.cc b/deps/v8/test/cctest/test-semaphore.cc deleted file mode 100644 index c7fca519dc..0000000000 --- a/deps/v8/test/cctest/test-semaphore.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include <stdlib.h> - -#include "src/v8.h" - -#include "src/base/platform/platform.h" -#include "test/cctest/cctest.h" - - -using namespace ::v8::internal; - - -class WaitAndSignalThread V8_FINAL : public v8::base::Thread { - public: - explicit WaitAndSignalThread(v8::base::Semaphore* semaphore) - : Thread(Options("WaitAndSignalThread")), semaphore_(semaphore) {} - virtual ~WaitAndSignalThread() {} - - virtual void Run() V8_OVERRIDE { - for (int n = 0; n < 1000; ++n) { - semaphore_->Wait(); - bool result = - semaphore_->WaitFor(v8::base::TimeDelta::FromMicroseconds(1)); - DCHECK(!result); - USE(result); - semaphore_->Signal(); - } - } - - private: - v8::base::Semaphore* semaphore_; -}; - - -TEST(WaitAndSignal) { - v8::base::Semaphore semaphore(0); - WaitAndSignalThread t1(&semaphore); - WaitAndSignalThread t2(&semaphore); - - t1.Start(); - t2.Start(); - - // Make something available. - semaphore.Signal(); - - t1.Join(); - t2.Join(); - - semaphore.Wait(); - - bool result = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(1)); - DCHECK(!result); - USE(result); -} - - -TEST(WaitFor) { - bool ok; - v8::base::Semaphore semaphore(0); - - // Semaphore not signalled - timeout. - ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(0)); - CHECK(!ok); - ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(100)); - CHECK(!ok); - ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(1000)); - CHECK(!ok); - - // Semaphore signalled - no timeout. - semaphore.Signal(); - ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(0)); - CHECK(ok); - semaphore.Signal(); - ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(100)); - CHECK(ok); - semaphore.Signal(); - ok = semaphore.WaitFor(v8::base::TimeDelta::FromMicroseconds(1000)); - CHECK(ok); -} - - -static const char alphabet[] = "XKOAD"; -static const int kAlphabetSize = sizeof(alphabet) - 1; -static const int kBufferSize = 4096; // GCD(buffer size, alphabet size) = 1 -static char buffer[kBufferSize]; -static const int kDataSize = kBufferSize * kAlphabetSize * 10; - -static v8::base::Semaphore free_space(kBufferSize); -static v8::base::Semaphore used_space(0); - - -class ProducerThread V8_FINAL : public v8::base::Thread { - public: - ProducerThread() : Thread(Options("ProducerThread")) {} - virtual ~ProducerThread() {} - - virtual void Run() V8_OVERRIDE { - for (int n = 0; n < kDataSize; ++n) { - free_space.Wait(); - buffer[n % kBufferSize] = alphabet[n % kAlphabetSize]; - used_space.Signal(); - } - } -}; - - -class ConsumerThread V8_FINAL : public v8::base::Thread { - public: - ConsumerThread() : Thread(Options("ConsumerThread")) {} - virtual ~ConsumerThread() {} - - virtual void Run() V8_OVERRIDE { - for (int n = 0; n < kDataSize; ++n) { - used_space.Wait(); - DCHECK_EQ(static_cast<int>(alphabet[n % kAlphabetSize]), - static_cast<int>(buffer[n % kBufferSize])); - free_space.Signal(); - } - } -}; - - -TEST(ProducerConsumer) { - ProducerThread producer_thread; - ConsumerThread consumer_thread; - producer_thread.Start(); - consumer_thread.Start(); - producer_thread.Join(); - consumer_thread.Join(); -} diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index 9ae90c4776..ed9419dfe0 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -35,10 +35,9 @@ #include "src/compilation-cache.h" #include "src/debug.h" #include "src/heap/spaces.h" -#include "src/ic-inl.h" #include "src/natives.h" #include "src/objects.h" -#include "src/runtime.h" +#include "src/runtime/runtime.h" #include "src/scopeinfo.h" #include "src/serialize.h" #include "src/snapshot.h" @@ -46,42 +45,6 @@ using namespace v8::internal; -static const unsigned kCounters = 256; -static int local_counters[kCounters]; -static const char* local_counter_names[kCounters]; - - -static unsigned CounterHash(const char* s) { - unsigned hash = 0; - while (*++s) { - hash |= hash << 5; - hash += *s; - } - return hash; -} - - -// Callback receiver to track counters in test. -static int* counter_function(const char* name) { - unsigned hash = CounterHash(name) % kCounters; - unsigned original_hash = hash; - USE(original_hash); - while (true) { - if (local_counter_names[hash] == name) { - return &local_counters[hash]; - } - if (local_counter_names[hash] == 0) { - local_counter_names[hash] = name; - return &local_counters[hash]; - } - if (strcmp(local_counter_names[hash], name) == 0) { - return &local_counters[hash]; - } - hash = (hash + 1) % kCounters; - DCHECK(hash != original_hash); // Hash table has been filled up. - } -} - template <class T> static Address AddressOf(T id) { @@ -102,7 +65,6 @@ static int make_code(TypeCode type, int id) { TEST(ExternalReferenceEncoder) { Isolate* isolate = CcTest::i_isolate(); - isolate->stats_table()->SetCounterFunction(counter_function); v8::V8::Initialize(); ExternalReferenceEncoder encoder(isolate); @@ -110,10 +72,6 @@ TEST(ExternalReferenceEncoder) { Encode(encoder, Builtins::kArrayCode)); CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), Encode(encoder, Runtime::kAbort)); - ExternalReference total_compile_size = - ExternalReference(isolate->counters()->total_compile_size()); - CHECK_EQ(make_code(STATS_COUNTER, Counters::k_total_compile_size), - encoder.Encode(total_compile_size.address())); ExternalReference stack_limit_address = ExternalReference::address_of_stack_limit(isolate); CHECK_EQ(make_code(UNCLASSIFIED, 2), @@ -137,7 +95,6 @@ TEST(ExternalReferenceEncoder) { TEST(ExternalReferenceDecoder) { Isolate* isolate = CcTest::i_isolate(); - isolate->stats_table()->SetCounterFunction(counter_function); v8::V8::Initialize(); ExternalReferenceDecoder decoder(isolate); @@ -146,12 +103,6 @@ TEST(ExternalReferenceDecoder) { CHECK_EQ(AddressOf(Runtime::kAbort), decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort))); - ExternalReference total_compile_size = - ExternalReference(isolate->counters()->total_compile_size()); - CHECK_EQ(total_compile_size.address(), - decoder.Decode( - make_code(STATS_COUNTER, - Counters::k_total_compile_size))); CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(), decoder.Decode(make_code(UNCLASSIFIED, 2))); CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(), @@ -186,14 +137,10 @@ class FileByteSink : public SnapshotByteSink { virtual int Position() { return ftell(fp_); } - void WriteSpaceUsed( - int new_space_used, - int pointer_space_used, - int data_space_used, - int code_space_used, - int map_space_used, - int cell_space_used, - int property_cell_space_used); + void WriteSpaceUsed(int new_space_used, int pointer_space_used, + int data_space_used, int code_space_used, + int map_space_used, int cell_space_used, + int property_cell_space_used, int lo_space_used); private: FILE* fp_; @@ -201,14 +148,11 @@ class FileByteSink : public SnapshotByteSink { }; -void FileByteSink::WriteSpaceUsed( - int new_space_used, - int pointer_space_used, - int data_space_used, - int code_space_used, - int map_space_used, - int cell_space_used, - int property_cell_space_used) { +void FileByteSink::WriteSpaceUsed(int new_space_used, int pointer_space_used, + int data_space_used, int code_space_used, + int map_space_used, int cell_space_used, + int property_cell_space_used, + int lo_space_used) { int file_name_length = StrLength(file_name_) + 10; Vector<char> name = Vector<char>::New(file_name_length + 1); SNPrintF(name, "%s.size", file_name_); @@ -221,6 +165,7 @@ void FileByteSink::WriteSpaceUsed( fprintf(fp, "map %d\n", map_space_used); fprintf(fp, "cell %d\n", cell_space_used); fprintf(fp, "property cell %d\n", property_cell_space_used); + fprintf(fp, "lo %d\n", lo_space_used); fclose(fp); } @@ -230,53 +175,55 @@ static bool WriteToFile(Isolate* isolate, const char* snapshot_file) { StartupSerializer ser(isolate, &file); ser.Serialize(); - file.WriteSpaceUsed( - ser.CurrentAllocationAddress(NEW_SPACE), - ser.CurrentAllocationAddress(OLD_POINTER_SPACE), - ser.CurrentAllocationAddress(OLD_DATA_SPACE), - ser.CurrentAllocationAddress(CODE_SPACE), - ser.CurrentAllocationAddress(MAP_SPACE), - ser.CurrentAllocationAddress(CELL_SPACE), - ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); + file.WriteSpaceUsed(ser.CurrentAllocationAddress(NEW_SPACE), + ser.CurrentAllocationAddress(OLD_POINTER_SPACE), + ser.CurrentAllocationAddress(OLD_DATA_SPACE), + ser.CurrentAllocationAddress(CODE_SPACE), + ser.CurrentAllocationAddress(MAP_SPACE), + ser.CurrentAllocationAddress(CELL_SPACE), + ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE), + ser.CurrentAllocationAddress(LO_SPACE)); return true; } -static void Serialize() { +static void Serialize(v8::Isolate* isolate) { // We have to create one context. One reason for this is so that the builtins // can be loaded from v8natives.js and their addresses can be processed. This // will clear the pending fixups array, which would otherwise contain GC roots // that would confuse the serialization/deserialization process. - v8::Isolate* isolate = CcTest::isolate(); + v8::Isolate::Scope isolate_scope(isolate); { v8::HandleScope scope(isolate); v8::Context::New(isolate); } - Isolate* internal_isolate = CcTest::i_isolate(); + Isolate* internal_isolate = reinterpret_cast<Isolate*>(isolate); internal_isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "serialize"); WriteToFile(internal_isolate, FLAG_testing_serialization_file); } // Test that the whole heap can be serialized. -TEST(Serialize) { +UNINITIALIZED_TEST(Serialize) { if (!Snapshot::HaveASnapshotToStartFrom()) { - CcTest::i_isolate()->enable_serializer(); - v8::V8::Initialize(); - Serialize(); + v8::Isolate::CreateParams params; + params.enable_serializer = true; + v8::Isolate* isolate = v8::Isolate::New(params); + Serialize(isolate); } } // Test that heap serialization is non-destructive. -TEST(SerializeTwice) { +UNINITIALIZED_TEST(SerializeTwice) { if (!Snapshot::HaveASnapshotToStartFrom()) { - CcTest::i_isolate()->enable_serializer(); - v8::V8::Initialize(); - Serialize(); - Serialize(); + v8::Isolate::CreateParams params; + params.enable_serializer = true; + v8::Isolate* isolate = v8::Isolate::New(params); + Serialize(isolate); + Serialize(isolate); } } @@ -293,7 +240,7 @@ static void ReserveSpaceForSnapshot(Deserializer* deserializer, FILE* fp = v8::base::OS::FOpen(name.start(), "r"); name.Dispose(); int new_size, pointer_size, data_size, code_size, map_size, cell_size, - property_cell_size; + property_cell_size, lo_size; #ifdef _MSC_VER // Avoid warning about unsafe fscanf from MSVC. // Please note that this is only fine if %c and %s are not being used. @@ -306,6 +253,7 @@ static void ReserveSpaceForSnapshot(Deserializer* deserializer, CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size)); CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size)); CHECK_EQ(1, fscanf(fp, "property cell %d\n", &property_cell_size)); + CHECK_EQ(1, fscanf(fp, "lo %d\n", &lo_size)); #ifdef _MSC_VER #undef fscanf #endif @@ -317,333 +265,378 @@ static void ReserveSpaceForSnapshot(Deserializer* deserializer, deserializer->set_reservation(MAP_SPACE, map_size); deserializer->set_reservation(CELL_SPACE, cell_size); deserializer->set_reservation(PROPERTY_CELL_SPACE, property_cell_size); + deserializer->set_reservation(LO_SPACE, lo_size); } -bool InitializeFromFile(const char* snapshot_file) { +v8::Isolate* InitializeFromFile(const char* snapshot_file) { int len; byte* str = ReadBytes(snapshot_file, &len); - if (!str) return false; - bool success; + if (!str) return NULL; + v8::Isolate* v8_isolate = NULL; { SnapshotByteSource source(str, len); Deserializer deserializer(&source); ReserveSpaceForSnapshot(&deserializer, snapshot_file); - success = V8::Initialize(&deserializer); + Isolate* isolate = Isolate::NewForTesting(); + v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); + v8::Isolate::Scope isolate_scope(v8_isolate); + isolate->Init(&deserializer); } DeleteArray(str); - return success; + return v8_isolate; } -static void Deserialize() { - CHECK(InitializeFromFile(FLAG_testing_serialization_file)); +static v8::Isolate* Deserialize() { + v8::Isolate* isolate = InitializeFromFile(FLAG_testing_serialization_file); + CHECK(isolate); + return isolate; } -static void SanityCheck() { - Isolate* isolate = CcTest::i_isolate(); - v8::HandleScope scope(CcTest::isolate()); +static void SanityCheck(v8::Isolate* v8_isolate) { + Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); + v8::HandleScope scope(v8_isolate); #ifdef VERIFY_HEAP - CcTest::heap()->Verify(); + isolate->heap()->Verify(); #endif CHECK(isolate->global_object()->IsJSObject()); CHECK(isolate->native_context()->IsContext()); - CHECK(CcTest::heap()->string_table()->IsStringTable()); - isolate->factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR("Empty")); + CHECK(isolate->heap()->string_table()->IsStringTable()); + isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); } -DEPENDENT_TEST(Deserialize, Serialize) { +UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) { // The serialize-deserialize tests only work if the VM is built without // serialization. That doesn't matter. We don't need to be able to // serialize a snapshot in a VM that is booted from a snapshot. if (!Snapshot::HaveASnapshotToStartFrom()) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - Deserialize(); + v8::Isolate* isolate = Deserialize(); + { + v8::HandleScope handle_scope(isolate); + v8::Isolate::Scope isolate_scope(isolate); - v8::Local<v8::Context> env = v8::Context::New(isolate); - env->Enter(); + v8::Local<v8::Context> env = v8::Context::New(isolate); + env->Enter(); - SanityCheck(); + SanityCheck(isolate); + } + isolate->Dispose(); } } -DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { +UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization, + SerializeTwice) { if (!Snapshot::HaveASnapshotToStartFrom()) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - Deserialize(); + v8::Isolate* isolate = Deserialize(); + { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); - v8::Local<v8::Context> env = v8::Context::New(isolate); - env->Enter(); + v8::Local<v8::Context> env = v8::Context::New(isolate); + env->Enter(); - SanityCheck(); + SanityCheck(isolate); + } + isolate->Dispose(); } } -DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { +UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { if (!Snapshot::HaveASnapshotToStartFrom()) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - Deserialize(); + v8::Isolate* isolate = Deserialize(); + { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + - v8::Local<v8::Context> env = v8::Context::New(isolate); - env->Enter(); + v8::Local<v8::Context> env = v8::Context::New(isolate); + env->Enter(); - const char* c_source = "\"1234\".length"; - v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); - v8::Local<v8::Script> script = v8::Script::Compile(source); - CHECK_EQ(4, script->Run()->Int32Value()); + const char* c_source = "\"1234\".length"; + v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); + v8::Local<v8::Script> script = v8::Script::Compile(source); + CHECK_EQ(4, script->Run()->Int32Value()); + } + isolate->Dispose(); } } -DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, - SerializeTwice) { +UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, + SerializeTwice) { if (!Snapshot::HaveASnapshotToStartFrom()) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - Deserialize(); + v8::Isolate* isolate = Deserialize(); + { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); - v8::Local<v8::Context> env = v8::Context::New(isolate); - env->Enter(); + v8::Local<v8::Context> env = v8::Context::New(isolate); + env->Enter(); - const char* c_source = "\"1234\".length"; - v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); - v8::Local<v8::Script> script = v8::Script::Compile(source); - CHECK_EQ(4, script->Run()->Int32Value()); + const char* c_source = "\"1234\".length"; + v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, c_source); + v8::Local<v8::Script> script = v8::Script::Compile(source); + CHECK_EQ(4, script->Run()->Int32Value()); + } + isolate->Dispose(); } } -TEST(PartialSerialization) { +UNINITIALIZED_TEST(PartialSerialization) { if (!Snapshot::HaveASnapshotToStartFrom()) { - Isolate* isolate = CcTest::i_isolate(); - CcTest::i_isolate()->enable_serializer(); - v8::V8::Initialize(); - v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); - Heap* heap = isolate->heap(); - - v8::Persistent<v8::Context> env; - { - HandleScope scope(isolate); - env.Reset(v8_isolate, v8::Context::New(v8_isolate)); - } - DCHECK(!env.IsEmpty()); + v8::Isolate::CreateParams params; + params.enable_serializer = true; + v8::Isolate* v8_isolate = v8::Isolate::New(params); + Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); + v8_isolate->Enter(); { - v8::HandleScope handle_scope(v8_isolate); - v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); - } - // Make sure all builtin scripts are cached. - { HandleScope scope(isolate); - for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { - isolate->bootstrapper()->NativesSourceLookup(i); + Heap* heap = isolate->heap(); + + v8::Persistent<v8::Context> env; + { + HandleScope scope(isolate); + env.Reset(v8_isolate, v8::Context::New(v8_isolate)); + } + DCHECK(!env.IsEmpty()); + { + v8::HandleScope handle_scope(v8_isolate); + v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); + } + // Make sure all builtin scripts are cached. + { + HandleScope scope(isolate); + for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { + isolate->bootstrapper()->NativesSourceLookup(i); + } + } + heap->CollectAllGarbage(Heap::kNoGCFlags); + heap->CollectAllGarbage(Heap::kNoGCFlags); + + Object* raw_foo; + { + v8::HandleScope handle_scope(v8_isolate); + v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); + DCHECK(!foo.IsEmpty()); + raw_foo = *(v8::Utils::OpenHandle(*foo)); } - } - heap->CollectAllGarbage(Heap::kNoGCFlags); - heap->CollectAllGarbage(Heap::kNoGCFlags); - Object* raw_foo; - { - v8::HandleScope handle_scope(v8_isolate); - v8::Local<v8::String> foo = v8::String::NewFromUtf8(v8_isolate, "foo"); - DCHECK(!foo.IsEmpty()); - raw_foo = *(v8::Utils::OpenHandle(*foo)); - } + int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; + Vector<char> startup_name = Vector<char>::New(file_name_length + 1); + SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); - int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; - Vector<char> startup_name = Vector<char>::New(file_name_length + 1); - SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); - - { - v8::HandleScope handle_scope(v8_isolate); - v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); + { + v8::HandleScope handle_scope(v8_isolate); + v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); + } + env.Reset(); + + FileByteSink startup_sink(startup_name.start()); + StartupSerializer startup_serializer(isolate, &startup_sink); + startup_serializer.SerializeStrongReferences(); + + FileByteSink partial_sink(FLAG_testing_serialization_file); + PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); + p_ser.Serialize(&raw_foo); + startup_serializer.SerializeWeakReferences(); + + partial_sink.WriteSpaceUsed( + p_ser.CurrentAllocationAddress(NEW_SPACE), + p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), + p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), + p_ser.CurrentAllocationAddress(CODE_SPACE), + p_ser.CurrentAllocationAddress(MAP_SPACE), + p_ser.CurrentAllocationAddress(CELL_SPACE), + p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE), + p_ser.CurrentAllocationAddress(LO_SPACE)); + + startup_sink.WriteSpaceUsed( + startup_serializer.CurrentAllocationAddress(NEW_SPACE), + startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), + startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), + startup_serializer.CurrentAllocationAddress(CODE_SPACE), + startup_serializer.CurrentAllocationAddress(MAP_SPACE), + startup_serializer.CurrentAllocationAddress(CELL_SPACE), + startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE), + startup_serializer.CurrentAllocationAddress(LO_SPACE)); + startup_name.Dispose(); } - env.Reset(); - - FileByteSink startup_sink(startup_name.start()); - StartupSerializer startup_serializer(isolate, &startup_sink); - startup_serializer.SerializeStrongReferences(); - - FileByteSink partial_sink(FLAG_testing_serialization_file); - PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); - p_ser.Serialize(&raw_foo); - startup_serializer.SerializeWeakReferences(); - - partial_sink.WriteSpaceUsed( - p_ser.CurrentAllocationAddress(NEW_SPACE), - p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), - p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), - p_ser.CurrentAllocationAddress(CODE_SPACE), - p_ser.CurrentAllocationAddress(MAP_SPACE), - p_ser.CurrentAllocationAddress(CELL_SPACE), - p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); - - startup_sink.WriteSpaceUsed( - startup_serializer.CurrentAllocationAddress(NEW_SPACE), - startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), - startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), - startup_serializer.CurrentAllocationAddress(CODE_SPACE), - startup_serializer.CurrentAllocationAddress(MAP_SPACE), - startup_serializer.CurrentAllocationAddress(CELL_SPACE), - startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); - startup_name.Dispose(); + v8_isolate->Exit(); + v8_isolate->Dispose(); } } -DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { +UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { if (!Snapshot::HaveASnapshotToStartFrom()) { int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; Vector<char> startup_name = Vector<char>::New(file_name_length + 1); SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); - CHECK(InitializeFromFile(startup_name.start())); + v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); + CHECK(v8_isolate); startup_name.Dispose(); - - const char* file_name = FLAG_testing_serialization_file; - - int snapshot_size = 0; - byte* snapshot = ReadBytes(file_name, &snapshot_size); - - Isolate* isolate = CcTest::i_isolate(); - Object* root; { - SnapshotByteSource source(snapshot, snapshot_size); - Deserializer deserializer(&source); - ReserveSpaceForSnapshot(&deserializer, file_name); - deserializer.DeserializePartial(isolate, &root); - CHECK(root->IsString()); - } - HandleScope handle_scope(isolate); - Handle<Object> root_handle(root, isolate); + v8::Isolate::Scope isolate_scope(v8_isolate); + const char* file_name = FLAG_testing_serialization_file; - Object* root2; - { - SnapshotByteSource source(snapshot, snapshot_size); - Deserializer deserializer(&source); - ReserveSpaceForSnapshot(&deserializer, file_name); - deserializer.DeserializePartial(isolate, &root2); - CHECK(root2->IsString()); - CHECK(*root_handle == root2); + int snapshot_size = 0; + byte* snapshot = ReadBytes(file_name, &snapshot_size); + + Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); + Object* root; + { + SnapshotByteSource source(snapshot, snapshot_size); + Deserializer deserializer(&source); + ReserveSpaceForSnapshot(&deserializer, file_name); + deserializer.DeserializePartial(isolate, &root); + CHECK(root->IsString()); + } + HandleScope handle_scope(isolate); + Handle<Object> root_handle(root, isolate); + + + Object* root2; + { + SnapshotByteSource source(snapshot, snapshot_size); + Deserializer deserializer(&source); + ReserveSpaceForSnapshot(&deserializer, file_name); + deserializer.DeserializePartial(isolate, &root2); + CHECK(root2->IsString()); + CHECK(*root_handle == root2); + } } + v8_isolate->Dispose(); } } -TEST(ContextSerialization) { +UNINITIALIZED_TEST(ContextSerialization) { if (!Snapshot::HaveASnapshotToStartFrom()) { - Isolate* isolate = CcTest::i_isolate(); - CcTest::i_isolate()->enable_serializer(); - v8::V8::Initialize(); - v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); + v8::Isolate::CreateParams params; + params.enable_serializer = true; + v8::Isolate* v8_isolate = v8::Isolate::New(params); + Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); Heap* heap = isolate->heap(); - - v8::Persistent<v8::Context> env; { - HandleScope scope(isolate); - env.Reset(v8_isolate, v8::Context::New(v8_isolate)); - } - DCHECK(!env.IsEmpty()); - { - v8::HandleScope handle_scope(v8_isolate); - v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); - } - // Make sure all builtin scripts are cached. - { HandleScope scope(isolate); - for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { - isolate->bootstrapper()->NativesSourceLookup(i); + v8::Isolate::Scope isolate_scope(v8_isolate); + + v8::Persistent<v8::Context> env; + { + HandleScope scope(isolate); + env.Reset(v8_isolate, v8::Context::New(v8_isolate)); } - } - // If we don't do this then we end up with a stray root pointing at the - // context even after we have disposed of env. - heap->CollectAllGarbage(Heap::kNoGCFlags); + DCHECK(!env.IsEmpty()); + { + v8::HandleScope handle_scope(v8_isolate); + v8::Local<v8::Context>::New(v8_isolate, env)->Enter(); + } + // Make sure all builtin scripts are cached. + { + HandleScope scope(isolate); + for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { + isolate->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(Heap::kNoGCFlags); - int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; - Vector<char> startup_name = Vector<char>::New(file_name_length + 1); - SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); + int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; + Vector<char> startup_name = Vector<char>::New(file_name_length + 1); + SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); - { - v8::HandleScope handle_scope(v8_isolate); - v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); - } + { + v8::HandleScope handle_scope(v8_isolate); + v8::Local<v8::Context>::New(v8_isolate, env)->Exit(); + } - i::Object* raw_context = *v8::Utils::OpenPersistent(env); - - env.Reset(); - - FileByteSink startup_sink(startup_name.start()); - StartupSerializer startup_serializer(isolate, &startup_sink); - startup_serializer.SerializeStrongReferences(); - - FileByteSink partial_sink(FLAG_testing_serialization_file); - PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); - p_ser.Serialize(&raw_context); - startup_serializer.SerializeWeakReferences(); - - partial_sink.WriteSpaceUsed( - p_ser.CurrentAllocationAddress(NEW_SPACE), - p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), - p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), - p_ser.CurrentAllocationAddress(CODE_SPACE), - p_ser.CurrentAllocationAddress(MAP_SPACE), - p_ser.CurrentAllocationAddress(CELL_SPACE), - p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); - - startup_sink.WriteSpaceUsed( - startup_serializer.CurrentAllocationAddress(NEW_SPACE), - startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), - startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), - startup_serializer.CurrentAllocationAddress(CODE_SPACE), - startup_serializer.CurrentAllocationAddress(MAP_SPACE), - startup_serializer.CurrentAllocationAddress(CELL_SPACE), - startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE)); - startup_name.Dispose(); + i::Object* raw_context = *v8::Utils::OpenPersistent(env); + + env.Reset(); + + FileByteSink startup_sink(startup_name.start()); + StartupSerializer startup_serializer(isolate, &startup_sink); + startup_serializer.SerializeStrongReferences(); + + FileByteSink partial_sink(FLAG_testing_serialization_file); + PartialSerializer p_ser(isolate, &startup_serializer, &partial_sink); + p_ser.Serialize(&raw_context); + startup_serializer.SerializeWeakReferences(); + + partial_sink.WriteSpaceUsed( + p_ser.CurrentAllocationAddress(NEW_SPACE), + p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), + p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), + p_ser.CurrentAllocationAddress(CODE_SPACE), + p_ser.CurrentAllocationAddress(MAP_SPACE), + p_ser.CurrentAllocationAddress(CELL_SPACE), + p_ser.CurrentAllocationAddress(PROPERTY_CELL_SPACE), + p_ser.CurrentAllocationAddress(LO_SPACE)); + + startup_sink.WriteSpaceUsed( + startup_serializer.CurrentAllocationAddress(NEW_SPACE), + startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), + startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), + startup_serializer.CurrentAllocationAddress(CODE_SPACE), + startup_serializer.CurrentAllocationAddress(MAP_SPACE), + startup_serializer.CurrentAllocationAddress(CELL_SPACE), + startup_serializer.CurrentAllocationAddress(PROPERTY_CELL_SPACE), + startup_serializer.CurrentAllocationAddress(LO_SPACE)); + startup_name.Dispose(); + } + v8_isolate->Dispose(); } } -DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { +UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { if (!Snapshot::HaveASnapshotToStartFrom()) { int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; Vector<char> startup_name = Vector<char>::New(file_name_length + 1); SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); - CHECK(InitializeFromFile(startup_name.start())); + v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); + CHECK(v8_isolate); startup_name.Dispose(); - - const char* file_name = FLAG_testing_serialization_file; - - int snapshot_size = 0; - byte* snapshot = ReadBytes(file_name, &snapshot_size); - - Isolate* isolate = CcTest::i_isolate(); - Object* root; { - SnapshotByteSource source(snapshot, snapshot_size); - Deserializer deserializer(&source); - ReserveSpaceForSnapshot(&deserializer, file_name); - deserializer.DeserializePartial(isolate, &root); - CHECK(root->IsContext()); - } - HandleScope handle_scope(isolate); - Handle<Object> root_handle(root, isolate); + v8::Isolate::Scope isolate_scope(v8_isolate); + const char* file_name = FLAG_testing_serialization_file; - Object* root2; - { - SnapshotByteSource source(snapshot, snapshot_size); - Deserializer deserializer(&source); - ReserveSpaceForSnapshot(&deserializer, file_name); - deserializer.DeserializePartial(isolate, &root2); - CHECK(root2->IsContext()); - CHECK(*root_handle != root2); + int snapshot_size = 0; + byte* snapshot = ReadBytes(file_name, &snapshot_size); + + Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); + Object* root; + { + SnapshotByteSource source(snapshot, snapshot_size); + Deserializer deserializer(&source); + ReserveSpaceForSnapshot(&deserializer, file_name); + deserializer.DeserializePartial(isolate, &root); + CHECK(root->IsContext()); + } + HandleScope handle_scope(isolate); + Handle<Object> root_handle(root, isolate); + + + Object* root2; + { + SnapshotByteSource source(snapshot, snapshot_size); + Deserializer deserializer(&source); + ReserveSpaceForSnapshot(&deserializer, file_name); + deserializer.DeserializePartial(isolate, &root2); + CHECK(root2->IsContext()); + CHECK(*root_handle != root2); + } } + v8_isolate->Dispose(); } } @@ -793,6 +786,121 @@ TEST(SerializeToplevelInternalizedString) { } +Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head, + Vector<const uint8_t> body, + Vector<const uint8_t> tail, int repeats) { + int source_length = head.length() + body.length() * repeats + tail.length(); + uint8_t* source = NewArray<uint8_t>(static_cast<size_t>(source_length)); + CopyChars(source, head.start(), head.length()); + for (int i = 0; i < repeats; i++) { + CopyChars(source + head.length() + i * body.length(), body.start(), + body.length()); + } + CopyChars(source + head.length() + repeats * body.length(), tail.start(), + tail.length()); + return Vector<const uint8_t>(const_cast<const uint8_t*>(source), + source_length); +} + + +TEST(SerializeToplevelLargeCodeObject) { + FLAG_serialize_toplevel = true; + LocalContext context; + Isolate* isolate = CcTest::i_isolate(); + isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. + + v8::HandleScope scope(CcTest::isolate()); + + Vector<const uint8_t> source = + ConstructSource(STATIC_CHAR_VECTOR("var j=1; try { if (j) throw 1;"), + STATIC_CHAR_VECTOR("for(var i=0;i<1;i++)j++;"), + STATIC_CHAR_VECTOR("} catch (e) { j=7; } j"), 10000); + Handle<String> source_str = + isolate->factory()->NewStringFromOneByte(source).ToHandleChecked(); + + Handle<JSObject> global(isolate->context()->global_object()); + ScriptData* cache = NULL; + + Handle<SharedFunctionInfo> orig = Compiler::CompileScript( + source_str, Handle<String>(), 0, 0, false, + Handle<Context>(isolate->native_context()), NULL, &cache, + v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); + + CHECK(isolate->heap()->InSpace(orig->code(), LO_SPACE)); + + Handle<SharedFunctionInfo> copy; + { + DisallowCompilation no_compile_expected(isolate); + copy = Compiler::CompileScript( + source_str, Handle<String>(), 0, 0, false, + Handle<Context>(isolate->native_context()), NULL, &cache, + v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); + } + CHECK_NE(*orig, *copy); + + Handle<JSFunction> copy_fun = + isolate->factory()->NewFunctionFromSharedFunctionInfo( + copy, isolate->native_context()); + + Handle<Object> copy_result = + Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); + + int result_int; + CHECK(copy_result->ToInt32(&result_int)); + CHECK_EQ(7, result_int); + + delete cache; + source.Dispose(); +} + + +TEST(SerializeToplevelLargeString) { + FLAG_serialize_toplevel = true; + LocalContext context; + Isolate* isolate = CcTest::i_isolate(); + isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. + + v8::HandleScope scope(CcTest::isolate()); + + Vector<const uint8_t> source = ConstructSource( + STATIC_CHAR_VECTOR("var s = \""), STATIC_CHAR_VECTOR("abcdef"), + STATIC_CHAR_VECTOR("\"; s"), 1000000); + Handle<String> source_str = + isolate->factory()->NewStringFromOneByte(source).ToHandleChecked(); + + Handle<JSObject> global(isolate->context()->global_object()); + ScriptData* cache = NULL; + + Handle<SharedFunctionInfo> orig = Compiler::CompileScript( + source_str, Handle<String>(), 0, 0, false, + Handle<Context>(isolate->native_context()), NULL, &cache, + v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); + + Handle<SharedFunctionInfo> copy; + { + DisallowCompilation no_compile_expected(isolate); + copy = Compiler::CompileScript( + source_str, Handle<String>(), 0, 0, false, + Handle<Context>(isolate->native_context()), NULL, &cache, + v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); + } + CHECK_NE(*orig, *copy); + + Handle<JSFunction> copy_fun = + isolate->factory()->NewFunctionFromSharedFunctionInfo( + copy, isolate->native_context()); + + Handle<Object> copy_result = + Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); + + CHECK_EQ(6 * 1000000, Handle<String>::cast(copy_result)->length()); + CHECK(isolate->heap()->InSpace(HeapObject::cast(*copy_result), LO_SPACE)); + + delete cache; + source.Dispose(); +} + + TEST(SerializeToplevelIsolates) { FLAG_serialize_toplevel = true; @@ -800,7 +908,6 @@ TEST(SerializeToplevelIsolates) { v8::ScriptCompiler::CachedData* cache; v8::Isolate* isolate1 = v8::Isolate::New(); - v8::Isolate* isolate2 = v8::Isolate::New(); { v8::Isolate::Scope iscope(isolate1); v8::HandleScope scope(isolate1); @@ -824,6 +931,7 @@ TEST(SerializeToplevelIsolates) { } isolate1->Dispose(); + v8::Isolate* isolate2 = v8::Isolate::New(); { v8::Isolate::Scope iscope(isolate2); v8::HandleScope scope(isolate2); diff --git a/deps/v8/test/cctest/test-spaces.cc b/deps/v8/test/cctest/test-spaces.cc index 0062094400..d09c128d17 100644 --- a/deps/v8/test/cctest/test-spaces.cc +++ b/deps/v8/test/cctest/test-spaces.cc @@ -203,6 +203,33 @@ static void VerifyMemoryChunk(Isolate* isolate, } +TEST(Regress3540) { + Isolate* isolate = CcTest::i_isolate(); + Heap* heap = isolate->heap(); + MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); + CHECK( + memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); + TestMemoryAllocatorScope test_allocator_scope(isolate, memory_allocator); + CodeRange* code_range = new CodeRange(isolate); + const size_t code_range_size = 4 * MB; + if (!code_range->SetUp(code_range_size)) return; + Address address; + size_t size; + address = code_range->AllocateRawMemory(code_range_size - MB, + code_range_size - MB, &size); + CHECK(address != NULL); + Address null_address; + size_t null_size; + null_address = code_range->AllocateRawMemory( + code_range_size - MB, code_range_size - MB, &null_size); + CHECK(null_address == NULL); + code_range->FreeRawMemory(address, size); + delete code_range; + memory_allocator->TearDown(); + delete memory_allocator; +} + + static unsigned int Pseudorandom() { static uint32_t lo = 2345; lo = 18273 * (lo & 0xFFFFF) + (lo >> 16); @@ -212,9 +239,7 @@ static unsigned int Pseudorandom() { TEST(MemoryChunk) { Isolate* isolate = CcTest::i_isolate(); - isolate->InitializeLoggingAndCounters(); Heap* heap = isolate->heap(); - CHECK(heap->ConfigureHeapDefault()); size_t reserve_area_size = 1 * MB; size_t initial_commit_area_size, second_commit_area_size; @@ -268,9 +293,7 @@ TEST(MemoryChunk) { TEST(MemoryAllocator) { Isolate* isolate = CcTest::i_isolate(); - isolate->InitializeLoggingAndCounters(); Heap* heap = isolate->heap(); - CHECK(isolate->heap()->ConfigureHeapDefault()); MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); CHECK(memory_allocator->SetUp(heap->MaxReserved(), @@ -317,9 +340,7 @@ TEST(MemoryAllocator) { TEST(NewSpace) { Isolate* isolate = CcTest::i_isolate(); - isolate->InitializeLoggingAndCounters(); Heap* heap = isolate->heap(); - CHECK(heap->ConfigureHeapDefault()); MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); @@ -345,9 +366,7 @@ TEST(NewSpace) { TEST(OldSpace) { Isolate* isolate = CcTest::i_isolate(); - isolate->InitializeLoggingAndCounters(); Heap* heap = isolate->heap(); - CHECK(heap->ConfigureHeapDefault()); MemoryAllocator* memory_allocator = new MemoryAllocator(isolate); CHECK(memory_allocator->SetUp(heap->MaxReserved(), heap->MaxExecutableSize())); diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index b55780182b..ef13c4dadf 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -112,11 +112,11 @@ class Resource: public v8::String::ExternalStringResource { }; -class AsciiResource: public v8::String::ExternalAsciiStringResource { +class OneByteResource : public v8::String::ExternalOneByteStringResource { public: - AsciiResource(const char* data, size_t length) + OneByteResource(const char* data, size_t length) : data_(data), length_(length) {} - ~AsciiResource() { i::DeleteArray(data_); } + ~OneByteResource() { i::DeleteArray(data_); } virtual const char* data() const { return data_; } virtual size_t length() const { return length_; } @@ -202,7 +202,7 @@ static void InitializeBuildingBlocks(Handle<String>* building_blocks, for (int j = 0; j < len; j++) { buf[j] = rng->next(0x80); } - AsciiResource* resource = new AsciiResource(buf, len); + OneByteResource* resource = new OneByteResource(buf, len); building_blocks[i] = v8::Utils::OpenHandle( *v8::String::NewExternal(CcTest::isolate(), resource)); @@ -454,7 +454,7 @@ static Handle<String> ConstructLeft( ConsStringGenerationData* data, int depth) { Factory* factory = CcTest::i_isolate()->factory(); - Handle<String> answer = factory->NewStringFromStaticAscii(""); + Handle<String> answer = factory->NewStringFromStaticChars(""); data->stats_.leaves_++; for (int i = 0; i < depth; i++) { Handle<String> block = data->block(i); @@ -473,7 +473,7 @@ static Handle<String> ConstructRight( ConsStringGenerationData* data, int depth) { Factory* factory = CcTest::i_isolate()->factory(); - Handle<String> answer = factory->NewStringFromStaticAscii(""); + Handle<String> answer = factory->NewStringFromStaticChars(""); data->stats_.leaves_++; for (int i = depth - 1; i >= 0; i--) { Handle<String> block = data->block(i); @@ -848,23 +848,23 @@ TEST(StringCharacterStreamRandom) { } -static const int DEEP_ASCII_DEPTH = 100000; +static const int kDeepOneByteDepth = 100000; -TEST(DeepAscii) { - printf("TestDeepAscii\n"); +TEST(DeepOneByte) { CcTest::InitializeVM(); Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(CcTest::isolate()); - char* foo = NewArray<char>(DEEP_ASCII_DEPTH); - for (int i = 0; i < DEEP_ASCII_DEPTH; i++) { + char* foo = NewArray<char>(kDeepOneByteDepth); + for (int i = 0; i < kDeepOneByteDepth; i++) { foo[i] = "foo "[i % 4]; } - Handle<String> string = factory->NewStringFromOneByte( - OneByteVector(foo, DEEP_ASCII_DEPTH)).ToHandleChecked(); - Handle<String> foo_string = factory->NewStringFromStaticAscii("foo"); - for (int i = 0; i < DEEP_ASCII_DEPTH; i += 10) { + Handle<String> string = + factory->NewStringFromOneByte(OneByteVector(foo, kDeepOneByteDepth)) + .ToHandleChecked(); + Handle<String> foo_string = factory->NewStringFromStaticChars("foo"); + for (int i = 0; i < kDeepOneByteDepth; i += 10) { string = factory->NewConsString(string, foo_string).ToHandleChecked(); } Handle<String> flat_string = @@ -872,7 +872,7 @@ TEST(DeepAscii) { String::Flatten(flat_string); for (int i = 0; i < 500; i++) { - TraverseFirst(flat_string, string, DEEP_ASCII_DEPTH); + TraverseFirst(flat_string, string, kDeepOneByteDepth); } DeleteArray<char>(foo); } @@ -882,13 +882,13 @@ TEST(Utf8Conversion) { // Smoke test for converting strings to utf-8. CcTest::InitializeVM(); v8::HandleScope handle_scope(CcTest::isolate()); - // A simple ascii string - const char* ascii_string = "abcdef12345"; - int len = v8::String::NewFromUtf8(CcTest::isolate(), ascii_string, + // A simple one-byte string + const char* one_byte_string = "abcdef12345"; + int len = v8::String::NewFromUtf8(CcTest::isolate(), one_byte_string, v8::String::kNormalString, - StrLength(ascii_string))->Utf8Length(); - CHECK_EQ(StrLength(ascii_string), len); - // A mixed ascii and non-ascii string + StrLength(one_byte_string))->Utf8Length(); + CHECK_EQ(StrLength(one_byte_string), len); + // A mixed one-byte and two-byte string // U+02E4 -> CB A4 // U+0064 -> 64 // U+12E4 -> E1 8B A4 @@ -934,79 +934,89 @@ TEST(ExternalShortStringAdd) { CHECK_GT(kMaxLength, i::ConsString::kMinLength); // Allocate two JavaScript arrays for holding short strings. - v8::Handle<v8::Array> ascii_external_strings = + v8::Handle<v8::Array> one_byte_external_strings = v8::Array::New(CcTest::isolate(), kMaxLength + 1); - v8::Handle<v8::Array> non_ascii_external_strings = + v8::Handle<v8::Array> non_one_byte_external_strings = v8::Array::New(CcTest::isolate(), kMaxLength + 1); - // Generate short ascii and non-ascii external strings. + // Generate short one-byte and two-byte external strings. for (int i = 0; i <= kMaxLength; i++) { - char* ascii = NewArray<char>(i + 1); + char* one_byte = NewArray<char>(i + 1); for (int j = 0; j < i; j++) { - ascii[j] = 'a'; + one_byte[j] = 'a'; } // Terminating '\0' is left out on purpose. It is not required for external // string data. - AsciiResource* ascii_resource = new AsciiResource(ascii, i); - v8::Local<v8::String> ascii_external_string = - v8::String::NewExternal(CcTest::isolate(), ascii_resource); + OneByteResource* one_byte_resource = new OneByteResource(one_byte, i); + v8::Local<v8::String> one_byte_external_string = + v8::String::NewExternal(CcTest::isolate(), one_byte_resource); - ascii_external_strings->Set(v8::Integer::New(CcTest::isolate(), i), - ascii_external_string); - uc16* non_ascii = NewArray<uc16>(i + 1); + one_byte_external_strings->Set(v8::Integer::New(CcTest::isolate(), i), + one_byte_external_string); + uc16* non_one_byte = NewArray<uc16>(i + 1); for (int j = 0; j < i; j++) { - non_ascii[j] = 0x1234; + non_one_byte[j] = 0x1234; } // Terminating '\0' is left out on purpose. It is not required for external // string data. - Resource* resource = new Resource(non_ascii, i); - v8::Local<v8::String> non_ascii_external_string = - v8::String::NewExternal(CcTest::isolate(), resource); - non_ascii_external_strings->Set(v8::Integer::New(CcTest::isolate(), i), - non_ascii_external_string); + Resource* resource = new Resource(non_one_byte, i); + v8::Local<v8::String> non_one_byte_external_string = + v8::String::NewExternal(CcTest::isolate(), resource); + non_one_byte_external_strings->Set(v8::Integer::New(CcTest::isolate(), i), + non_one_byte_external_string); } // Add the arrays with the short external strings in the global object. v8::Handle<v8::Object> global = context->Global(); - global->Set(v8_str("external_ascii"), ascii_external_strings); - global->Set(v8_str("external_non_ascii"), non_ascii_external_strings); + global->Set(v8_str("external_one_byte"), one_byte_external_strings); + global->Set(v8_str("external_non_one_byte"), non_one_byte_external_strings); global->Set(v8_str("max_length"), v8::Integer::New(CcTest::isolate(), kMaxLength)); - // Add short external ascii and non-ascii strings checking the result. + // Add short external one-byte and two-byte strings checking the result. static const char* source = - "function test() {" - " var ascii_chars = 'aaaaaaaaaaaaaaaaaaaa';" - " var non_ascii_chars = '\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234';" //NOLINT - " if (ascii_chars.length != max_length) return 1;" - " if (non_ascii_chars.length != max_length) return 2;" - " var ascii = Array(max_length + 1);" - " var non_ascii = Array(max_length + 1);" - " for (var i = 0; i <= max_length; i++) {" - " ascii[i] = ascii_chars.substring(0, i);" - " non_ascii[i] = non_ascii_chars.substring(0, i);" - " };" - " for (var i = 0; i <= max_length; i++) {" - " if (ascii[i] != external_ascii[i]) return 3;" - " if (non_ascii[i] != external_non_ascii[i]) return 4;" - " for (var j = 0; j < i; j++) {" - " if (external_ascii[i] !=" - " (external_ascii[j] + external_ascii[i - j])) return 5;" - " if (external_non_ascii[i] !=" - " (external_non_ascii[j] + external_non_ascii[i - j])) return 6;" - " if (non_ascii[i] != (non_ascii[j] + non_ascii[i - j])) return 7;" - " if (ascii[i] != (ascii[j] + ascii[i - j])) return 8;" - " if (ascii[i] != (external_ascii[j] + ascii[i - j])) return 9;" - " if (ascii[i] != (ascii[j] + external_ascii[i - j])) return 10;" - " if (non_ascii[i] !=" - " (external_non_ascii[j] + non_ascii[i - j])) return 11;" - " if (non_ascii[i] !=" - " (non_ascii[j] + external_non_ascii[i - j])) return 12;" - " }" - " }" - " return 0;" - "};" - "test()"; + "function test() {" + " var one_byte_chars = 'aaaaaaaaaaaaaaaaaaaa';" + " var non_one_byte_chars = " + "'\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1" + "234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\u1234\\" + "u1234';" // NOLINT + " if (one_byte_chars.length != max_length) return 1;" + " if (non_one_byte_chars.length != max_length) return 2;" + " var one_byte = Array(max_length + 1);" + " var non_one_byte = Array(max_length + 1);" + " for (var i = 0; i <= max_length; i++) {" + " one_byte[i] = one_byte_chars.substring(0, i);" + " non_one_byte[i] = non_one_byte_chars.substring(0, i);" + " };" + " for (var i = 0; i <= max_length; i++) {" + " if (one_byte[i] != external_one_byte[i]) return 3;" + " if (non_one_byte[i] != external_non_one_byte[i]) return 4;" + " for (var j = 0; j < i; j++) {" + " if (external_one_byte[i] !=" + " (external_one_byte[j] + external_one_byte[i - j])) return " + "5;" + " if (external_non_one_byte[i] !=" + " (external_non_one_byte[j] + external_non_one_byte[i - " + "j])) return 6;" + " if (non_one_byte[i] != (non_one_byte[j] + non_one_byte[i - " + "j])) return 7;" + " if (one_byte[i] != (one_byte[j] + one_byte[i - j])) return 8;" + " if (one_byte[i] != (external_one_byte[j] + one_byte[i - j])) " + "return 9;" + " if (one_byte[i] != (one_byte[j] + external_one_byte[i - j])) " + "return 10;" + " if (non_one_byte[i] !=" + " (external_non_one_byte[j] + non_one_byte[i - j])) return " + "11;" + " if (non_one_byte[i] !=" + " (non_one_byte[j] + external_non_one_byte[i - j])) return " + "12;" + " }" + " }" + " return 0;" + "};" + "test()"; CHECK_EQ(0, CompileRun(source)->Int32Value()); } @@ -1091,7 +1101,7 @@ TEST(SliceFromCons) { Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(CcTest::isolate()); Handle<String> string = - factory->NewStringFromStaticAscii("parentparentparent"); + factory->NewStringFromStaticChars("parentparentparent"); Handle<String> parent = factory->NewConsString(string, string).ToHandleChecked(); CHECK(parent->IsConsString()); @@ -1109,11 +1119,11 @@ TEST(SliceFromCons) { } -class AsciiVectorResource : public v8::String::ExternalAsciiStringResource { +class OneByteVectorResource : public v8::String::ExternalOneByteStringResource { public: - explicit AsciiVectorResource(i::Vector<const char> vector) + explicit OneByteVectorResource(i::Vector<const char> vector) : data_(vector) {} - virtual ~AsciiVectorResource() {} + virtual ~OneByteVectorResource() {} virtual size_t length() const { return data_.length(); } virtual const char* data() const { return data_.start(); } private: @@ -1126,10 +1136,10 @@ TEST(SliceFromExternal) { CcTest::InitializeVM(); Factory* factory = CcTest::i_isolate()->factory(); v8::HandleScope scope(CcTest::isolate()); - AsciiVectorResource resource( + OneByteVectorResource resource( i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26)); Handle<String> string = - factory->NewExternalStringFromAscii(&resource).ToHandleChecked(); + factory->NewExternalStringFromOneByte(&resource).ToHandleChecked(); CHECK(string->IsExternalString()); Handle<String> slice = factory->NewSubString(string, 1, 25); CHECK(slice->IsSlicedString()); @@ -1199,28 +1209,34 @@ TEST(SliceFromSlice) { } -TEST(AsciiArrayJoin) { +UNINITIALIZED_TEST(OneByteArrayJoin) { + v8::Isolate::CreateParams create_params; // Set heap limits. - v8::ResourceConstraints constraints; - constraints.set_max_semi_space_size(1); - constraints.set_max_old_space_size(4); - v8::SetResourceConstraints(CcTest::isolate(), &constraints); - - // String s is made of 2^17 = 131072 'c' characters and a is an array - // starting with 'bad', followed by 2^14 times the string s. That means the - // total length of the concatenated strings is 2^31 + 3. So on 32bit systems - // summing the lengths of the strings (as Smis) overflows and wraps. - LocalContext context; - v8::HandleScope scope(CcTest::isolate()); - v8::TryCatch try_catch; - CHECK(CompileRun( - "var two_14 = Math.pow(2, 14);" - "var two_17 = Math.pow(2, 17);" - "var s = Array(two_17 + 1).join('c');" - "var a = ['bad'];" - "for (var i = 1; i <= two_14; i++) a.push(s);" - "a.join("");").IsEmpty()); - CHECK(try_catch.HasCaught()); + create_params.constraints.set_max_semi_space_size(1); + create_params.constraints.set_max_old_space_size(4); + v8::Isolate* isolate = v8::Isolate::New(create_params); + isolate->Enter(); + + { + // String s is made of 2^17 = 131072 'c' characters and a is an array + // starting with 'bad', followed by 2^14 times the string s. That means the + // total length of the concatenated strings is 2^31 + 3. So on 32bit systems + // summing the lengths of the strings (as Smis) overflows and wraps. + LocalContext context(isolate); + v8::HandleScope scope(isolate); + v8::TryCatch try_catch; + CHECK(CompileRun( + "var two_14 = Math.pow(2, 14);" + "var two_17 = Math.pow(2, 17);" + "var s = Array(two_17 + 1).join('c');" + "var a = ['bad'];" + "for (var i = 1; i <= two_14; i++) a.push(s);" + "a.join(" + ");").IsEmpty()); + CHECK(try_catch.HasCaught()); + } + isolate->Exit(); + isolate->Dispose(); } @@ -1281,14 +1297,14 @@ TEST(StringReplaceAtomTwoByteResult) { v8::HandleScope scope(CcTest::isolate()); LocalContext context; v8::Local<v8::Value> result = CompileRun( - "var subject = 'ascii~only~string~'; " + "var subject = 'one_byte~only~string~'; " "var replace = '\x80'; " "subject.replace(/~/g, replace); "); CHECK(result->IsString()); Handle<String> string = v8::Utils::OpenHandle(v8::String::Cast(*result)); CHECK(string->IsSeqTwoByteString()); - v8::Local<v8::String> expected = v8_str("ascii\x80only\x80string\x80"); + v8::Local<v8::String> expected = v8_str("one_byte\x80only\x80string\x80"); CHECK(expected->Equals(result)); } @@ -1375,7 +1391,7 @@ TEST(InvalidExternalString) { Isolate* isolate = CcTest::i_isolate(); { HandleScope scope(isolate); DummyOneByteResource r; - CHECK(isolate->factory()->NewExternalStringFromAscii(&r).is_null()); + CHECK(isolate->factory()->NewExternalStringFromOneByte(&r).is_null()); CHECK(isolate->has_pending_exception()); isolate->clear_pending_exception(); } diff --git a/deps/v8/test/cctest/test-thread-termination.cc b/deps/v8/test/cctest/test-thread-termination.cc index a5ed7ab9bf..21d3b95f10 100644 --- a/deps/v8/test/cctest/test-thread-termination.cc +++ b/deps/v8/test/cctest/test-thread-termination.cc @@ -459,3 +459,15 @@ TEST(PostponeTerminateException) { CHECK(try_catch.HasTerminated()); CHECK_EQ(2, callback_counter); } + + +TEST(ErrorObjectAfterTermination) { + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); + v8::Context::Scope context_scope(context); + v8::V8::TerminateExecution(isolate); + v8::Local<v8::Value> error = v8::Exception::Error(v8_str("error")); + // TODO(yangguo): crbug/403509. Check for empty handle instead. + CHECK(error->IsUndefined()); +} diff --git a/deps/v8/test/cctest/test-types.cc b/deps/v8/test/cctest/test-types.cc index 8c5e41ca10..e9122b1c65 100644 --- a/deps/v8/test/cctest/test-types.cc +++ b/deps/v8/test/cctest/test-types.cc @@ -11,21 +11,37 @@ using namespace v8::internal; + // Testing auxiliaries (breaking the Type abstraction). + + +static bool IsInteger(double x) { + return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. +} + + +static bool IsInteger(i::Object* x) { + return x->IsNumber() && IsInteger(x->Number()); +} + + +typedef uint32_t bitset; + + struct ZoneRep { typedef void* Struct; static bool IsStruct(Type* t, int tag) { return !IsBitset(t) && reinterpret_cast<intptr_t>(AsStruct(t)[0]) == tag; } - static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; } + static bool IsBitset(Type* t) { return reinterpret_cast<uintptr_t>(t) & 1; } static bool IsUnion(Type* t) { return IsStruct(t, 6); } static Struct* AsStruct(Type* t) { return reinterpret_cast<Struct*>(t); } - static int AsBitset(Type* t) { - return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1); + static bitset AsBitset(Type* t) { + return static_cast<bitset>(reinterpret_cast<uintptr_t>(t) ^ 1u); } static Struct* AsUnion(Type* t) { return AsStruct(t); @@ -40,7 +56,7 @@ struct ZoneRep { using Type::BitsetType::New; using Type::BitsetType::Glb; using Type::BitsetType::Lub; - using Type::BitsetType::InherentLub; + using Type::BitsetType::IsInhabited; }; }; @@ -55,7 +71,9 @@ struct HeapRep { static bool IsUnion(Handle<HeapType> t) { return IsStruct(t, 6); } static Struct* AsStruct(Handle<HeapType> t) { return FixedArray::cast(*t); } - static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); } + static bitset AsBitset(Handle<HeapType> t) { + return static_cast<bitset>(reinterpret_cast<uintptr_t>(*t)); + } static Struct* AsUnion(Handle<HeapType> t) { return AsStruct(t); } static int Length(Struct* structured) { return structured->length() - 1; } @@ -65,10 +83,9 @@ struct HeapRep { using HeapType::BitsetType::New; using HeapType::BitsetType::Glb; using HeapType::BitsetType::Lub; - using HeapType::BitsetType::InherentLub; - static int Glb(Handle<HeapType> type) { return Glb(*type); } - static int Lub(Handle<HeapType> type) { return Lub(*type); } - static int InherentLub(Handle<HeapType> type) { return InherentLub(*type); } + using HeapType::BitsetType::IsInhabited; + static bitset Glb(Handle<HeapType> type) { return Glb(*type); } + static bitset Lub(Handle<HeapType> type) { return Lub(*type); } }; }; @@ -81,14 +98,19 @@ class Types { #define DECLARE_TYPE(name, value) \ name = Type::name(region); \ types.push_back(name); - BITSET_TYPE_LIST(DECLARE_TYPE) + PROPER_BITSET_TYPE_LIST(DECLARE_TYPE) #undef DECLARE_TYPE - object_map = isolate->factory()->NewMap(JS_OBJECT_TYPE, 3 * kPointerSize); - array_map = isolate->factory()->NewMap(JS_ARRAY_TYPE, 4 * kPointerSize); + object_map = isolate->factory()->NewMap( + JS_OBJECT_TYPE, JSObject::kHeaderSize); + array_map = isolate->factory()->NewMap( + JS_ARRAY_TYPE, JSArray::kSize); + number_map = isolate->factory()->NewMap( + HEAP_NUMBER_TYPE, HeapNumber::kSize); uninitialized_map = isolate->factory()->uninitialized_map(); ObjectClass = Type::Class(object_map, region); ArrayClass = Type::Class(array_map, region); + NumberClass = Type::Class(number_map, region); UninitializedClass = Type::Class(uninitialized_map, region); maps.push_back(object_map); @@ -121,13 +143,15 @@ class Types { types.push_back(Type::Constant(*it, region)); } - doubles.push_back(-0.0); - doubles.push_back(+0.0); - doubles.push_back(-std::numeric_limits<double>::infinity()); - doubles.push_back(+std::numeric_limits<double>::infinity()); + integers.push_back(isolate->factory()->NewNumber(-V8_INFINITY)); + integers.push_back(isolate->factory()->NewNumber(+V8_INFINITY)); + integers.push_back(isolate->factory()->NewNumber(-rng_->NextInt(10))); + integers.push_back(isolate->factory()->NewNumber(+rng_->NextInt(10))); for (int i = 0; i < 10; ++i) { - doubles.push_back(rng_->NextInt()); - doubles.push_back(rng_->NextDouble() * rng_->NextInt()); + double x = rng_->NextInt(); + integers.push_back(isolate->factory()->NewNumber(x)); + x *= rng_->NextInt(); + if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x)); } NumberArray = Type::Array(Number, region); @@ -146,6 +170,7 @@ class Types { Handle<i::Map> object_map; Handle<i::Map> array_map; + Handle<i::Map> number_map; Handle<i::Map> uninitialized_map; Handle<i::Smi> smi; @@ -161,6 +186,7 @@ class Types { TypeHandle ObjectClass; TypeHandle ArrayClass; + TypeHandle NumberClass; TypeHandle UninitializedClass; TypeHandle SmiConstant; @@ -182,27 +208,11 @@ class Types { typedef std::vector<TypeHandle> TypeVector; typedef std::vector<Handle<i::Map> > MapVector; typedef std::vector<Handle<i::Object> > ValueVector; - typedef std::vector<double> DoubleVector; TypeVector types; MapVector maps; ValueVector values; - DoubleVector doubles; // Some floating-point values, excluding NaN. - - // Range type helper functions, partially copied from types.cc. - // Note: dle(dmin(x,y), dmax(x,y)) holds iff neither x nor y is NaN. - bool dle(double x, double y) { - return x <= y && (x != 0 || IsMinusZero(x) || !IsMinusZero(y)); - } - bool deq(double x, double y) { - return dle(x, y) && dle(y, x); - } - double dmin(double x, double y) { - return dle(x, y) ? x : y; - } - double dmax(double x, double y) { - return dle(x, y) ? y : x; - } + ValueVector integers; // "Integer" values used for range limits. TypeHandle Of(Handle<i::Object> value) { return Type::Of(value, region_); @@ -212,16 +222,20 @@ class Types { return Type::NowOf(value, region_); } + TypeHandle Class(Handle<i::Map> map) { + return Type::Class(map, region_); + } + TypeHandle Constant(Handle<i::Object> value) { return Type::Constant(value, region_); } - TypeHandle Range(double min, double max) { + TypeHandle Range(Handle<i::Object> min, Handle<i::Object> max) { return Type::Range(min, max, region_); } - TypeHandle Class(Handle<i::Map> map) { - return Type::Class(map, region_); + TypeHandle Context(TypeHandle outer) { + return Type::Context(outer, region_); } TypeHandle Array1(TypeHandle element) { @@ -258,20 +272,31 @@ class Types { return types[rng_->NextInt(static_cast<int>(types.size()))]; } - TypeHandle Fuzz(int depth = 5) { + TypeHandle Fuzz(int depth = 4) { switch (rng_->NextInt(depth == 0 ? 3 : 20)) { case 0: { // bitset - int n = 0 #define COUNT_BITSET_TYPES(type, value) + 1 - BITSET_TYPE_LIST(COUNT_BITSET_TYPES) + int n = 0 PROPER_BITSET_TYPE_LIST(COUNT_BITSET_TYPES); #undef COUNT_BITSET_TYPES - ; - int i = rng_->NextInt(n); - #define PICK_BITSET_TYPE(type, value) \ - if (i-- == 0) return Type::type(region_); - BITSET_TYPE_LIST(PICK_BITSET_TYPE) - #undef PICK_BITSET_TYPE - UNREACHABLE(); + // Pick a bunch of named bitsets and return their intersection. + TypeHandle result = Type::Any(region_); + for (int i = 0, m = 1 + rng_->NextInt(3); i < m; ++i) { + int j = rng_->NextInt(n); + #define PICK_BITSET_TYPE(type, value) \ + if (j-- == 0) { \ + TypeHandle tmp = Type::Intersect( \ + result, Type::type(region_), region_); \ + if (tmp->Is(Type::None()) && i != 0) { \ + break; \ + } { \ + result = tmp; \ + continue; \ + } \ + } + PROPER_BITSET_TYPE_LIST(PICK_BITSET_TYPE) + #undef PICK_BITSET_TYPE + } + return result; } case 1: { // class int i = rng_->NextInt(static_cast<int>(maps.size())); @@ -281,18 +306,26 @@ class Types { int i = rng_->NextInt(static_cast<int>(values.size())); return Type::Constant(values[i], region_); } - case 3: { // context + case 3: { // range + int i = rng_->NextInt(static_cast<int>(integers.size())); + int j = rng_->NextInt(static_cast<int>(integers.size())); + i::Handle<i::Object> min = integers[i]; + i::Handle<i::Object> max = integers[j]; + if (min->Number() > max->Number()) std::swap(min, max); + return Type::Range(min, max, region_); + } + case 4: { // context int depth = rng_->NextInt(3); TypeHandle type = Type::Internal(region_); for (int i = 0; i < depth; ++i) type = Type::Context(type, region_); return type; } - case 4: { // array + case 5: { // array TypeHandle element = Fuzz(depth / 2); return Type::Array(element, region_); } - case 5: - case 6: { // function + case 6: + case 7: { // function TypeHandle result = Fuzz(depth / 2); TypeHandle receiver = Fuzz(depth / 2); int arity = rng_->NextInt(3); @@ -330,7 +363,6 @@ struct Tests : Rep { typedef typename TypesInstance::TypeVector::iterator TypeIterator; typedef typename TypesInstance::MapVector::iterator MapIterator; typedef typename TypesInstance::ValueVector::iterator ValueIterator; - typedef typename TypesInstance::DoubleVector::iterator DoubleIterator; Isolate* isolate; HandleScope scope; @@ -347,14 +379,15 @@ struct Tests : Rep { bool Equal(TypeHandle type1, TypeHandle type2) { return type1->Equals(type2) && - Rep::IsBitset(type1) == Rep::IsBitset(type2) && - Rep::IsUnion(type1) == Rep::IsUnion(type2) && + this->IsBitset(type1) == this->IsBitset(type2) && + this->IsUnion(type1) == this->IsUnion(type2) && type1->NumClasses() == type2->NumClasses() && type1->NumConstants() == type2->NumConstants() && - (!Rep::IsBitset(type1) || - Rep::AsBitset(type1) == Rep::AsBitset(type2)) && - (!Rep::IsUnion(type1) || - Rep::Length(Rep::AsUnion(type1)) == Rep::Length(Rep::AsUnion(type2))); + (!this->IsBitset(type1) || + this->AsBitset(type1) == this->AsBitset(type2)) && + (!this->IsUnion(type1) || + this->Length(this->AsUnion(type1)) == + this->Length(this->AsUnion(type2))); } void CheckEqual(TypeHandle type1, TypeHandle type2) { @@ -364,36 +397,37 @@ struct Tests : Rep { void CheckSub(TypeHandle type1, TypeHandle type2) { CHECK(type1->Is(type2)); CHECK(!type2->Is(type1)); - if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { - CHECK_NE(Rep::AsBitset(type1), Rep::AsBitset(type2)); + if (this->IsBitset(type1) && this->IsBitset(type2)) { + CHECK(this->AsBitset(type1) != this->AsBitset(type2)); } } void CheckUnordered(TypeHandle type1, TypeHandle type2) { CHECK(!type1->Is(type2)); CHECK(!type2->Is(type1)); - if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { - CHECK_NE(Rep::AsBitset(type1), Rep::AsBitset(type2)); + if (this->IsBitset(type1) && this->IsBitset(type2)) { + CHECK(this->AsBitset(type1) != this->AsBitset(type2)); } } - void CheckOverlap(TypeHandle type1, TypeHandle type2, TypeHandle mask) { + void CheckOverlap(TypeHandle type1, TypeHandle type2) { CHECK(type1->Maybe(type2)); CHECK(type2->Maybe(type1)); - if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { - CHECK_NE(0, - Rep::AsBitset(type1) & Rep::AsBitset(type2) & Rep::AsBitset(mask)); - } } - void CheckDisjoint(TypeHandle type1, TypeHandle type2, TypeHandle mask) { + void CheckDisjoint(TypeHandle type1, TypeHandle type2) { CHECK(!type1->Is(type2)); CHECK(!type2->Is(type1)); CHECK(!type1->Maybe(type2)); CHECK(!type2->Maybe(type1)); - if (Rep::IsBitset(type1) && Rep::IsBitset(type2)) { - CHECK_EQ(0, - Rep::AsBitset(type1) & Rep::AsBitset(type2) & Rep::AsBitset(mask)); + } + + void IsSomeType() { + for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { + TypeHandle t = *it; + CHECK(1 == + this->IsBitset(t) + t->IsClass() + t->IsConstant() + t->IsRange() + + this->IsUnion(t) + t->IsArray() + t->IsFunction() + t->IsContext()); } } @@ -402,8 +436,8 @@ struct Tests : Rep { CHECK(this->IsBitset(T.None)); CHECK(this->IsBitset(T.Any)); - CHECK_EQ(0, this->AsBitset(T.None)); - CHECK_EQ(-1, this->AsBitset(T.Any)); + CHECK(bitset(0) == this->AsBitset(T.None)); + CHECK(bitset(0xfffffffeu) == this->AsBitset(T.Any)); // Union(T1, T2) is bitset for bitsets T1,T2 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { @@ -445,22 +479,23 @@ struct Tests : Rep { TypeHandle type2 = *it2; TypeHandle union12 = T.Union(type1, type2); if (this->IsBitset(type1) && this->IsBitset(type2)) { - CHECK_EQ( - this->AsBitset(type1) | this->AsBitset(type2), + CHECK( + (this->AsBitset(type1) | this->AsBitset(type2)) == this->AsBitset(union12)); } } } - // Intersect(T1, T2) is bitwise conjunction for bitsets T1,T2 + // Intersect(T1, T2) is bitwise conjunction for bitsets T1,T2 (modulo None) for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { TypeHandle type1 = *it1; TypeHandle type2 = *it2; TypeHandle intersect12 = T.Intersect(type1, type2); if (this->IsBitset(type1) && this->IsBitset(type2)) { - CHECK_EQ( - this->AsBitset(type1) & this->AsBitset(type2), + bitset bits = this->AsBitset(type1) & this->AsBitset(type2); + CHECK( + (Rep::BitsetType::IsInhabited(bits) ? bits : 0) == this->AsBitset(intersect12)); } } @@ -562,50 +597,78 @@ struct Tests : Rep { void Range() { // Constructor - for (DoubleIterator i = T.doubles.begin(); i != T.doubles.end(); ++i) { - for (DoubleIterator j = T.doubles.begin(); j != T.doubles.end(); ++j) { - double min = T.dmin(*i, *j); - double max = T.dmax(*i, *j); + for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) { + for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) { + i::Handle<i::Object> min = *i; + i::Handle<i::Object> max = *j; + if (min->Number() > max->Number()) std::swap(min, max); TypeHandle type = T.Range(min, max); CHECK(type->IsRange()); } } // Range attributes - for (DoubleIterator i = T.doubles.begin(); i != T.doubles.end(); ++i) { - for (DoubleIterator j = T.doubles.begin(); j != T.doubles.end(); ++j) { - double min = T.dmin(*i, *j); - double max = T.dmax(*i, *j); - printf("RangeType: min, max = %f, %f\n", min, max); + for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) { + for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) { + i::Handle<i::Object> min = *i; + i::Handle<i::Object> max = *j; + if (min->Number() > max->Number()) std::swap(min, max); TypeHandle type = T.Range(min, max); - printf("RangeType: Min, Max = %f, %f\n", - type->AsRange()->Min(), type->AsRange()->Max()); - CHECK(min == type->AsRange()->Min()); - CHECK(max == type->AsRange()->Max()); - } - } - -// TODO(neis): enable once subtyping is updated. -// // Functionality & Injectivity: Range(min1, max1) = Range(min2, max2) <=> -// // min1 = min2 /\ max1 = max2 -// for (DoubleIterator i1 = T.doubles.begin(); i1 != T.doubles.end(); ++i1) { -// for (DoubleIterator j1 = T.doubles.begin(); j1 != T.doubles.end(); ++j1) { -// for (DoubleIterator i2 = T.doubles.begin(); -// i2 != T.doubles.end(); ++i2) { -// for (DoubleIterator j2 = T.doubles.begin(); -// j2 != T.doubles.end(); ++j2) { -// double min1 = T.dmin(*i1, *j1); -// double max1 = T.dmax(*i1, *j1); -// double min2 = T.dmin(*i2, *j2); -// double max2 = T.dmax(*i2, *j2); -// TypeHandle type1 = T.Range(min1, max1); -// TypeHandle type2 = T.Range(min2, max2); -// CHECK(Equal(type1, type2) == -// (T.deq(min1, min2) && T.deq(max1, max2))); -// } -// } -// } -// } + CHECK(*min == *type->AsRange()->Min()); + CHECK(*max == *type->AsRange()->Max()); + } + } + + // Functionality & Injectivity: + // Range(min1, max1) = Range(min2, max2) <=> min1 = min2 /\ max1 = max2 + for (ValueIterator i1 = T.integers.begin(); + i1 != T.integers.end(); ++i1) { + for (ValueIterator j1 = i1; + j1 != T.integers.end(); ++j1) { + for (ValueIterator i2 = T.integers.begin(); + i2 != T.integers.end(); ++i2) { + for (ValueIterator j2 = i2; + j2 != T.integers.end(); ++j2) { + i::Handle<i::Object> min1 = *i1; + i::Handle<i::Object> max1 = *j1; + i::Handle<i::Object> min2 = *i2; + i::Handle<i::Object> max2 = *j2; + if (min1->Number() > max1->Number()) std::swap(min1, max1); + if (min2->Number() > max2->Number()) std::swap(min2, max2); + TypeHandle type1 = T.Range(min1, max1); + TypeHandle type2 = T.Range(min2, max2); + CHECK(Equal(type1, type2) == (*min1 == *min2 && *max1 == *max2)); + } + } + } + } + } + + void Context() { + // Constructor + for (int i = 0; i < 20; ++i) { + TypeHandle type = T.Random(); + TypeHandle context = T.Context(type); + CHECK(context->Iscontext()); + } + + // Attributes + for (int i = 0; i < 20; ++i) { + TypeHandle type = T.Random(); + TypeHandle context = T.Context(type); + CheckEqual(type, context->AsContext()->Outer()); + } + + // Functionality & Injectivity: Context(T1) = Context(T2) iff T1 = T2 + for (int i = 0; i < 20; ++i) { + for (int j = 0; j < 20; ++j) { + TypeHandle type1 = T.Random(); + TypeHandle type2 = T.Random(); + TypeHandle context1 = T.Context(type1); + TypeHandle context2 = T.Context(type2); + CHECK(Equal(context1, context2) == Equal(type1, type2)); + } + } } void Array() { @@ -713,15 +776,26 @@ struct Tests : Rep { CHECK(const_type->Is(of_type)); } - // Constant(V)->Is(T) iff Of(V)->Is(T) or T->Maybe(Constant(V)) + // If Of(V)->Is(T), then Constant(V)->Is(T) for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { Handle<i::Object> value = *vt; TypeHandle type = *it; TypeHandle const_type = T.Constant(value); TypeHandle of_type = T.Of(value); - CHECK(const_type->Is(type) == - (of_type->Is(type) || type->Maybe(const_type))); + CHECK(!of_type->Is(type) || const_type->Is(type)); + } + } + + // If Constant(V)->Is(T), then Of(V)->Is(T) or T->Maybe(Constant(V)) + for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { + for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { + Handle<i::Object> value = *vt; + TypeHandle type = *it; + TypeHandle const_type = T.Constant(value); + TypeHandle of_type = T.Of(value); + CHECK(!const_type->Is(type) || + of_type->Is(type) || type->Maybe(const_type)); } } } @@ -743,19 +817,32 @@ struct Tests : Rep { CHECK(nowof_type->Is(of_type)); } - // Constant(V)->NowIs(T) iff NowOf(V)->NowIs(T) or T->Maybe(Constant(V)) + // If NowOf(V)->NowIs(T), then Constant(V)->NowIs(T) for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { Handle<i::Object> value = *vt; TypeHandle type = *it; TypeHandle const_type = T.Constant(value); TypeHandle nowof_type = T.NowOf(value); - CHECK(const_type->NowIs(type) == - (nowof_type->NowIs(type) || type->Maybe(const_type))); + CHECK(!nowof_type->NowIs(type) || const_type->NowIs(type)); } } - // Constant(V)->Is(T) implies NowOf(V)->Is(T) or T->Maybe(Constant(V)) + // If Constant(V)->NowIs(T), + // then NowOf(V)->NowIs(T) or T->Maybe(Constant(V)) + for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { + for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { + Handle<i::Object> value = *vt; + TypeHandle type = *it; + TypeHandle const_type = T.Constant(value); + TypeHandle nowof_type = T.NowOf(value); + CHECK(!const_type->NowIs(type) || + nowof_type->NowIs(type) || type->Maybe(const_type)); + } + } + + // If Constant(V)->Is(T), + // then NowOf(V)->Is(T) or T->Maybe(Constant(V)) for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { Handle<i::Object> value = *vt; @@ -763,23 +850,63 @@ struct Tests : Rep { TypeHandle const_type = T.Constant(value); TypeHandle nowof_type = T.NowOf(value); CHECK(!const_type->Is(type) || - (nowof_type->Is(type) || type->Maybe(const_type))); + nowof_type->Is(type) || type->Maybe(const_type)); } } } - void Bounds() { - // Ordering: (T->BitsetGlb())->Is(T->BitsetLub()) + void MinMax() { + // If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b). + // TODO(neis): Need to ignore representation for this to be true. + /* for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { TypeHandle type = *it; - TypeHandle glb = - Rep::BitsetType::New(Rep::BitsetType::Glb(type), T.region()); - TypeHandle lub = - Rep::BitsetType::New(Rep::BitsetType::Lub(type), T.region()); - CHECK(glb->Is(lub)); + if (this->IsBitset(type) && type->Is(T.Number) && + !type->Is(T.None) && !type->Is(T.NaN)) { + TypeHandle range = T.Range( + isolate->factory()->NewNumber(type->Min()), + isolate->factory()->NewNumber(type->Max())); + CHECK(range->Is(type)); + } + } + */ + + // If b is regular numeric bitset, then b->Min() and b->Max() are integers. + for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { + TypeHandle type = *it; + if (this->IsBitset(type) && type->Is(T.Number) && + !type->Is(T.None) && !type->Is(T.NaN)) { + CHECK(IsInteger(type->Min()) && IsInteger(type->Max())); + } } - // Lower bound: (T->BitsetGlb())->Is(T) + // If b1 and b2 are regular numeric bitsets with b1->Is(b2), then + // b1->Min() >= b2->Min() and b1->Max() <= b2->Max(). + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle type1 = *it1; + TypeHandle type2 = *it2; + if (this->IsBitset(type1) && type1->Is(type2) && type2->Is(T.Number) && + !type1->Is(T.NaN) && !type2->Is(T.NaN)) { + CHECK(type1->Min() >= type2->Min()); + CHECK(type1->Max() <= type2->Max()); + } + } + } + + // Lub(Range(x,y))->Min() <= x and y <= Lub(Range(x,y))->Max() + for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { + TypeHandle type = *it; + if (type->IsRange()) { + TypeHandle lub = Rep::BitsetType::New( + Rep::BitsetType::Lub(type), T.region()); + CHECK(lub->Min() <= type->Min() && type->Max() <= lub->Max()); + } + } + } + + void BitsetGlb() { + // Lower: (T->BitsetGlb())->Is(T) for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { TypeHandle type = *it; TypeHandle glb = @@ -787,7 +914,33 @@ struct Tests : Rep { CHECK(glb->Is(type)); } - // Upper bound: T->Is(T->BitsetLub()) + // Greatest: If T1->IsBitset() and T1->Is(T2), then T1->Is(T2->BitsetGlb()) + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle type1 = *it1; + TypeHandle type2 = *it2; + TypeHandle glb2 = + Rep::BitsetType::New(Rep::BitsetType::Glb(type2), T.region()); + CHECK(!this->IsBitset(type1) || !type1->Is(type2) || type1->Is(glb2)); + } + } + + // Monotonicity: T1->Is(T2) implies (T1->BitsetGlb())->Is(T2->BitsetGlb()) + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle type1 = *it1; + TypeHandle type2 = *it2; + TypeHandle glb1 = + Rep::BitsetType::New(Rep::BitsetType::Glb(type1), T.region()); + TypeHandle glb2 = + Rep::BitsetType::New(Rep::BitsetType::Glb(type2), T.region()); + CHECK(!type1->Is(type2) || glb1->Is(glb2)); + } + } + } + + void BitsetLub() { + // Upper: T->Is(T->BitsetLub()) for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { TypeHandle type = *it; TypeHandle lub = @@ -795,18 +948,32 @@ struct Tests : Rep { CHECK(type->Is(lub)); } - // Inherent bound: (T->BitsetLub())->Is(T->InherentBitsetLub()) - for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { - TypeHandle type = *it; - TypeHandle lub = - Rep::BitsetType::New(Rep::BitsetType::Lub(type), T.region()); - TypeHandle inherent = - Rep::BitsetType::New(Rep::BitsetType::InherentLub(type), T.region()); - CHECK(lub->Is(inherent)); + // Least: If T2->IsBitset() and T1->Is(T2), then (T1->BitsetLub())->Is(T2) + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle type1 = *it1; + TypeHandle type2 = *it2; + TypeHandle lub1 = + Rep::BitsetType::New(Rep::BitsetType::Lub(type1), T.region()); + CHECK(!this->IsBitset(type2) || !type1->Is(type2) || lub1->Is(type2)); + } + } + + // Monotonicity: T1->Is(T2) implies (T1->BitsetLub())->Is(T2->BitsetLub()) + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle type1 = *it1; + TypeHandle type2 = *it2; + TypeHandle lub1 = + Rep::BitsetType::New(Rep::BitsetType::Lub(type1), T.region()); + TypeHandle lub2 = + Rep::BitsetType::New(Rep::BitsetType::Lub(type2), T.region()); + CHECK(!type1->Is(type2) || lub1->Is(lub2)); + } } } - void Is() { + void Is1() { // Least Element (Bottom): None->Is(T) for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { TypeHandle type = *it; @@ -858,17 +1025,26 @@ struct Tests : Rep { } } - // Constant(V1)->Is(Constant(V2)) iff V1 = V2 - for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { - for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { - Handle<i::Object> value1 = *vt1; - Handle<i::Object> value2 = *vt2; - TypeHandle const_type1 = T.Constant(value1); - TypeHandle const_type2 = T.Constant(value2); - CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); + // (In-)Compatibilities. + for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { + for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { + TypeHandle type1 = *i; + TypeHandle type2 = *j; + CHECK(!type1->Is(type2) || this->IsBitset(type2) || + this->IsUnion(type2) || this->IsUnion(type1) || + (type1->IsClass() && type2->IsClass()) || + (type1->IsConstant() && type2->IsConstant()) || + (type1->IsConstant() && type2->IsRange()) || + (type1->IsRange() && type2->IsRange()) || + (type1->IsContext() && type2->IsContext()) || + (type1->IsArray() && type2->IsArray()) || + (type1->IsFunction() && type2->IsFunction()) || + type1->Equals(T.None)); } } + } + void Is2() { // Class(M1)->Is(Class(M2)) iff M1 = M2 for (MapIterator mt1 = T.maps.begin(); mt1 != T.maps.end(); ++mt1) { for (MapIterator mt2 = T.maps.begin(); mt2 != T.maps.end(); ++mt2) { @@ -880,29 +1056,117 @@ struct Tests : Rep { } } - // Constant(V)->Is(Class(M)) never - for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { - for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { - Handle<i::Map> map = *mt; - Handle<i::Object> value = *vt; - TypeHandle constant_type = T.Constant(value); - TypeHandle class_type = T.Class(map); - CHECK(!constant_type->Is(class_type)); + // Range(X1, Y1)->Is(Range(X2, Y2)) iff X1 >= X2 /\ Y1 <= Y2 + for (ValueIterator i1 = T.integers.begin(); + i1 != T.integers.end(); ++i1) { + for (ValueIterator j1 = i1; + j1 != T.integers.end(); ++j1) { + for (ValueIterator i2 = T.integers.begin(); + i2 != T.integers.end(); ++i2) { + for (ValueIterator j2 = i2; + j2 != T.integers.end(); ++j2) { + i::Handle<i::Object> min1 = *i1; + i::Handle<i::Object> max1 = *j1; + i::Handle<i::Object> min2 = *i2; + i::Handle<i::Object> max2 = *j2; + if (min1->Number() > max1->Number()) std::swap(min1, max1); + if (min2->Number() > max2->Number()) std::swap(min2, max2); + TypeHandle type1 = T.Range(min1, max1); + TypeHandle type2 = T.Range(min2, max2); + CHECK(type1->Is(type2) == + (min1->Number() >= min2->Number() && + max1->Number() <= max2->Number())); + } + } } } - // Class(M)->Is(Constant(V)) never - for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { - for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { - Handle<i::Map> map = *mt; - Handle<i::Object> value = *vt; - TypeHandle constant_type = T.Constant(value); - TypeHandle class_type = T.Class(map); - CHECK(!class_type->Is(constant_type)); + // Constant(V1)->Is(Constant(V2)) iff V1 = V2 + for (ValueIterator vt1 = T.values.begin(); vt1 != T.values.end(); ++vt1) { + for (ValueIterator vt2 = T.values.begin(); vt2 != T.values.end(); ++vt2) { + Handle<i::Object> value1 = *vt1; + Handle<i::Object> value2 = *vt2; + TypeHandle const_type1 = T.Constant(value1); + TypeHandle const_type2 = T.Constant(value2); + CHECK(const_type1->Is(const_type2) == (*value1 == *value2)); } } - // Basic types + // Context(T1)->Is(Context(T2)) iff T1 = T2 + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle outer1 = *it1; + TypeHandle outer2 = *it2; + TypeHandle type1 = T.Context(outer1); + TypeHandle type2 = T.Context(outer2); + CHECK(type1->Is(type2) == outer1->Equals(outer2)); + } + } + + // Array(T1)->Is(Array(T2)) iff T1 = T2 + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle element1 = *it1; + TypeHandle element2 = *it2; + TypeHandle type1 = T.Array1(element1); + TypeHandle type2 = T.Array1(element2); + CHECK(type1->Is(type2) == element1->Equals(element2)); + } + } + + // Function0(S1, T1)->Is(Function0(S2, T2)) iff S1 = S2 and T1 = T2 + for (TypeIterator i = T.types.begin(); i != T.types.end(); ++i) { + for (TypeIterator j = T.types.begin(); j != T.types.end(); ++j) { + TypeHandle result1 = *i; + TypeHandle receiver1 = *j; + TypeHandle type1 = T.Function0(result1, receiver1); + TypeHandle result2 = T.Random(); + TypeHandle receiver2 = T.Random(); + TypeHandle type2 = T.Function0(result2, receiver2); + CHECK(type1->Is(type2) == + (result1->Equals(result2) && receiver1->Equals(receiver2))); + } + } + + + // Range-specific subtyping + + // If IsInteger(v) then Constant(v)->Is(Range(v, v)). + for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { + TypeHandle type = *it; + if (type->IsConstant() && IsInteger(*type->AsConstant()->Value())) { + CHECK(type->Is( + T.Range(type->AsConstant()->Value(), type->AsConstant()->Value()))); + } + } + + // If Constant(x)->Is(Range(min,max)) then IsInteger(v) and min <= x <= max. + for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { + for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { + TypeHandle type1 = *it1; + TypeHandle type2 = *it2; + if (type1->IsConstant() && type2->IsRange() && type1->Is(type2)) { + double x = type1->AsConstant()->Value()->Number(); + double min = type2->AsRange()->Min()->Number(); + double max = type2->AsRange()->Max()->Number(); + CHECK(IsInteger(x) && min <= x && x <= max); + } + } + } + + // Lub(Range(x,y))->Is(T.Union(T.Integral32, T.OtherNumber)) + for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { + TypeHandle type = *it; + if (type->IsRange()) { + TypeHandle lub = Rep::BitsetType::New( + Rep::BitsetType::Lub(type), T.region()); + CHECK(lub->Is(T.Union(T.Integral32, T.OtherNumber))); + } + } + + + // Subtyping between concrete basic types + CheckUnordered(T.Boolean, T.Null); CheckUnordered(T.Undefined, T.Null); CheckUnordered(T.Boolean, T.Undefined); @@ -931,7 +1195,9 @@ struct Tests : Rep { CheckUnordered(T.Object, T.Proxy); CheckUnordered(T.Array, T.Function); - // Structural types + + // Subtyping between concrete structural types + CheckSub(T.ObjectClass, T.Object); CheckSub(T.ArrayClass, T.Object); CheckSub(T.ArrayClass, T.Array); @@ -1089,16 +1355,6 @@ struct Tests : Rep { CHECK(type->Contains(value) == const_type->Is(type)); } } - - // Of(V)->Is(T) implies T->Contains(V) - for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { - for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { - TypeHandle type = *it; - Handle<i::Object> value = *vt; - TypeHandle of_type = T.Of(value); - CHECK(!of_type->Is(type) || type->Contains(value)); - } - } } void NowContains() { @@ -1130,16 +1386,6 @@ struct Tests : Rep { CHECK(!nowof_type->NowIs(type) || type->NowContains(value)); } } - - // NowOf(V)->NowIs(T) implies T->NowContains(V) - for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { - for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { - TypeHandle type = *it; - Handle<i::Object> value = *vt; - TypeHandle nowof_type = T.Of(value); - CHECK(!nowof_type->NowIs(type) || type->NowContains(value)); - } - } } void Maybe() { @@ -1223,6 +1469,8 @@ struct Tests : Rep { } // Constant(V)->Maybe(Class(M)) never + // This does NOT hold! + /* for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { Handle<i::Map> map = *mt; @@ -1232,8 +1480,11 @@ struct Tests : Rep { CHECK(!const_type->Maybe(class_type)); } } + */ // Class(M)->Maybe(Constant(V)) never + // This does NOT hold! + /* for (MapIterator mt = T.maps.begin(); mt != T.maps.end(); ++mt) { for (ValueIterator vt = T.values.begin(); vt != T.values.end(); ++vt) { Handle<i::Map> map = *mt; @@ -1243,67 +1494,62 @@ struct Tests : Rep { CHECK(!class_type->Maybe(const_type)); } } + */ // Basic types - CheckDisjoint(T.Boolean, T.Null, T.Semantic); - CheckDisjoint(T.Undefined, T.Null, T.Semantic); - CheckDisjoint(T.Boolean, T.Undefined, T.Semantic); - - CheckOverlap(T.SignedSmall, T.Number, T.Semantic); - CheckOverlap(T.NaN, T.Number, T.Semantic); - CheckDisjoint(T.Signed32, T.NaN, T.Semantic); - - CheckOverlap(T.UniqueName, T.Name, T.Semantic); - CheckOverlap(T.String, T.Name, T.Semantic); - CheckOverlap(T.InternalizedString, T.String, T.Semantic); - CheckOverlap(T.InternalizedString, T.UniqueName, T.Semantic); - CheckOverlap(T.InternalizedString, T.Name, T.Semantic); - CheckOverlap(T.Symbol, T.UniqueName, T.Semantic); - CheckOverlap(T.Symbol, T.Name, T.Semantic); - CheckOverlap(T.String, T.UniqueName, T.Semantic); - CheckDisjoint(T.String, T.Symbol, T.Semantic); - CheckDisjoint(T.InternalizedString, T.Symbol, T.Semantic); - - CheckOverlap(T.Object, T.Receiver, T.Semantic); - CheckOverlap(T.Array, T.Object, T.Semantic); - CheckOverlap(T.Function, T.Object, T.Semantic); - CheckOverlap(T.Proxy, T.Receiver, T.Semantic); - CheckDisjoint(T.Object, T.Proxy, T.Semantic); - CheckDisjoint(T.Array, T.Function, T.Semantic); + CheckDisjoint(T.Boolean, T.Null); + CheckDisjoint(T.Undefined, T.Null); + CheckDisjoint(T.Boolean, T.Undefined); + CheckOverlap(T.SignedSmall, T.Number); + CheckOverlap(T.NaN, T.Number); + CheckDisjoint(T.Signed32, T.NaN); + CheckOverlap(T.UniqueName, T.Name); + CheckOverlap(T.String, T.Name); + CheckOverlap(T.InternalizedString, T.String); + CheckOverlap(T.InternalizedString, T.UniqueName); + CheckOverlap(T.InternalizedString, T.Name); + CheckOverlap(T.Symbol, T.UniqueName); + CheckOverlap(T.Symbol, T.Name); + CheckOverlap(T.String, T.UniqueName); + CheckDisjoint(T.String, T.Symbol); + CheckDisjoint(T.InternalizedString, T.Symbol); + CheckOverlap(T.Object, T.Receiver); + CheckOverlap(T.Array, T.Object); + CheckOverlap(T.Function, T.Object); + CheckOverlap(T.Proxy, T.Receiver); + CheckDisjoint(T.Object, T.Proxy); + CheckDisjoint(T.Array, T.Function); // Structural types - CheckOverlap(T.ObjectClass, T.Object, T.Semantic); - CheckOverlap(T.ArrayClass, T.Object, T.Semantic); - CheckOverlap(T.ObjectClass, T.ObjectClass, T.Semantic); - CheckOverlap(T.ArrayClass, T.ArrayClass, T.Semantic); - CheckDisjoint(T.ObjectClass, T.ArrayClass, T.Semantic); - - CheckOverlap(T.SmiConstant, T.SignedSmall, T.Semantic); - CheckOverlap(T.SmiConstant, T.Signed32, T.Semantic); - CheckOverlap(T.SmiConstant, T.Number, T.Semantic); - CheckOverlap(T.ObjectConstant1, T.Object, T.Semantic); - CheckOverlap(T.ObjectConstant2, T.Object, T.Semantic); - CheckOverlap(T.ArrayConstant, T.Object, T.Semantic); - CheckOverlap(T.ArrayConstant, T.Array, T.Semantic); - CheckOverlap(T.ObjectConstant1, T.ObjectConstant1, T.Semantic); - CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2, T.Semantic); - CheckDisjoint(T.ObjectConstant1, T.ArrayConstant, T.Semantic); - - CheckDisjoint(T.ObjectConstant1, T.ObjectClass, T.Semantic); - CheckDisjoint(T.ObjectConstant2, T.ObjectClass, T.Semantic); - CheckDisjoint(T.ObjectConstant1, T.ArrayClass, T.Semantic); - CheckDisjoint(T.ObjectConstant2, T.ArrayClass, T.Semantic); - CheckDisjoint(T.ArrayConstant, T.ObjectClass, T.Semantic); - - CheckOverlap(T.NumberArray, T.Array, T.Semantic); - CheckDisjoint(T.NumberArray, T.AnyArray, T.Semantic); - CheckDisjoint(T.NumberArray, T.StringArray, T.Semantic); - - CheckOverlap(T.MethodFunction, T.Function, T.Semantic); - CheckDisjoint(T.SignedFunction1, T.NumberFunction1, T.Semantic); - CheckDisjoint(T.SignedFunction1, T.NumberFunction2, T.Semantic); - CheckDisjoint(T.NumberFunction1, T.NumberFunction2, T.Semantic); - CheckDisjoint(T.SignedFunction1, T.MethodFunction, T.Semantic); + CheckOverlap(T.ObjectClass, T.Object); + CheckOverlap(T.ArrayClass, T.Object); + CheckOverlap(T.ObjectClass, T.ObjectClass); + CheckOverlap(T.ArrayClass, T.ArrayClass); + CheckDisjoint(T.ObjectClass, T.ArrayClass); + CheckOverlap(T.SmiConstant, T.SignedSmall); + CheckOverlap(T.SmiConstant, T.Signed32); + CheckOverlap(T.SmiConstant, T.Number); + CheckOverlap(T.ObjectConstant1, T.Object); + CheckOverlap(T.ObjectConstant2, T.Object); + CheckOverlap(T.ArrayConstant, T.Object); + CheckOverlap(T.ArrayConstant, T.Array); + CheckOverlap(T.ObjectConstant1, T.ObjectConstant1); + CheckDisjoint(T.ObjectConstant1, T.ObjectConstant2); + CheckDisjoint(T.ObjectConstant1, T.ArrayConstant); + CheckDisjoint(T.ObjectConstant1, T.ArrayClass); + CheckDisjoint(T.ObjectConstant2, T.ArrayClass); + CheckDisjoint(T.ArrayConstant, T.ObjectClass); + CheckOverlap(T.NumberArray, T.Array); + CheckDisjoint(T.NumberArray, T.AnyArray); + CheckDisjoint(T.NumberArray, T.StringArray); + CheckOverlap(T.MethodFunction, T.Function); + CheckDisjoint(T.SignedFunction1, T.NumberFunction1); + CheckDisjoint(T.SignedFunction1, T.NumberFunction2); + CheckDisjoint(T.NumberFunction1, T.NumberFunction2); + CheckDisjoint(T.SignedFunction1, T.MethodFunction); + CheckOverlap(T.ObjectConstant1, T.ObjectClass); // !!! + CheckOverlap(T.ObjectConstant2, T.ObjectClass); // !!! + CheckOverlap(T.NumberClass, T.Intersect(T.Number, T.Untagged)); // !!! } void Union1() { @@ -1340,6 +1586,10 @@ struct Tests : Rep { } // Associativity: Union(T1, Union(T2, T3)) = Union(Union(T1, T2), T3) + // This does NOT hold! For example: + // (Unsigned32 \/ Range(0,5)) \/ Range(-5,0) = Unsigned32 \/ Range(-5,0) + // Unsigned32 \/ (Range(0,5) \/ Range(-5,0)) = Unsigned32 \/ Range(-5,5) + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1354,6 +1604,7 @@ struct Tests : Rep { } } } + */ // Meet: T1->Is(Union(T1, T2)) and T2->Is(Union(T1, T2)) for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { @@ -1375,10 +1626,12 @@ struct Tests : Rep { if (type1->Is(type2)) CheckEqual(union12, type2); } } - } - void Union2() { // Monotonicity: T1->Is(T2) implies Union(T1, T3)->Is(Union(T2, T3)) + // This does NOT hold. For example: + // Range(-5,-1) <= Signed32 + // Range(-5,-1) \/ Range(1,5) = Range(-5,5) </= Signed32 \/ Range(1,5) + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1391,8 +1644,16 @@ struct Tests : Rep { } } } + */ + } + void Union2() { // Monotonicity: T1->Is(T3) and T2->Is(T3) implies Union(T1, T2)->Is(T3) + // This does NOT hold. For example: + // Range(-2^33, -2^33) <= OtherNumber + // Range(2^33, 2^33) <= OtherNumber + // Range(-2^33, 2^33) </= OtherNumber + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1404,11 +1665,14 @@ struct Tests : Rep { } } } + */ + } + void Union3() { // Monotonicity: T1->Is(T2) or T1->Is(T3) implies T1->Is(Union(T2, T3)) for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { - for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { + for (TypeIterator it3 = it2; it3 != T.types.end(); ++it3) { TypeHandle type1 = *it1; TypeHandle type2 = *it2; TypeHandle type3 = *it3; @@ -1417,12 +1681,14 @@ struct Tests : Rep { } } } + } + void Union4() { // Class-class CheckSub(T.Union(T.ObjectClass, T.ArrayClass), T.Object); CheckUnordered(T.Union(T.ObjectClass, T.ArrayClass), T.Array); - CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array, T.Semantic); - CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number, T.Semantic); + CheckOverlap(T.Union(T.ObjectClass, T.ArrayClass), T.Array); + CheckDisjoint(T.Union(T.ObjectClass, T.ArrayClass), T.Number); // Constant-constant CheckSub(T.Union(T.ObjectConstant1, T.ObjectConstant2), T.Object); @@ -1430,11 +1696,11 @@ struct Tests : Rep { CheckUnordered( T.Union(T.ObjectConstant1, T.ObjectConstant2), T.ObjectClass); CheckOverlap( - T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array, T.Semantic); - CheckDisjoint( - T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number, T.Semantic); + T.Union(T.ObjectConstant1, T.ArrayConstant), T.Array); CheckDisjoint( - T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass, T.Semantic); + T.Union(T.ObjectConstant1, T.ArrayConstant), T.Number); + CheckOverlap( + T.Union(T.ObjectConstant1, T.ArrayConstant), T.ObjectClass); // !!! // Bitset-array CHECK(this->IsBitset(T.Union(T.AnyArray, T.Array))); @@ -1442,8 +1708,8 @@ struct Tests : Rep { CheckEqual(T.Union(T.AnyArray, T.Array), T.Array); CheckUnordered(T.Union(T.AnyArray, T.String), T.Array); - CheckOverlap(T.Union(T.NumberArray, T.String), T.Object, T.Semantic); - CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number, T.Semantic); + CheckOverlap(T.Union(T.NumberArray, T.String), T.Object); + CheckDisjoint(T.Union(T.NumberArray, T.String), T.Number); // Bitset-function CHECK(this->IsBitset(T.Union(T.MethodFunction, T.Function))); @@ -1451,24 +1717,24 @@ struct Tests : Rep { CheckEqual(T.Union(T.MethodFunction, T.Function), T.Function); CheckUnordered(T.Union(T.NumberFunction1, T.String), T.Function); - CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object, T.Semantic); - CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number, T.Semantic); + CheckOverlap(T.Union(T.NumberFunction2, T.String), T.Object); + CheckDisjoint(T.Union(T.NumberFunction1, T.String), T.Number); // Bitset-class CheckSub( T.Union(T.ObjectClass, T.SignedSmall), T.Union(T.Object, T.Number)); CheckSub(T.Union(T.ObjectClass, T.Array), T.Object); CheckUnordered(T.Union(T.ObjectClass, T.String), T.Array); - CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object, T.Semantic); - CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number, T.Semantic); + CheckOverlap(T.Union(T.ObjectClass, T.String), T.Object); + CheckDisjoint(T.Union(T.ObjectClass, T.String), T.Number); // Bitset-constant CheckSub( T.Union(T.ObjectConstant1, T.Signed32), T.Union(T.Object, T.Number)); CheckSub(T.Union(T.ObjectConstant1, T.Array), T.Object); CheckUnordered(T.Union(T.ObjectConstant1, T.String), T.Array); - CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object, T.Semantic); - CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number, T.Semantic); + CheckOverlap(T.Union(T.ObjectConstant1, T.String), T.Object); + CheckDisjoint(T.Union(T.ObjectConstant1, T.String), T.Number); // Class-constant CheckSub(T.Union(T.ObjectConstant1, T.ArrayClass), T.Object); @@ -1477,10 +1743,9 @@ struct Tests : Rep { T.Union(T.ObjectConstant1, T.ArrayClass), T.Union(T.Array, T.Object)); CheckUnordered(T.Union(T.ObjectConstant1, T.ArrayClass), T.ArrayConstant); CheckDisjoint( - T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2, - T.Semantic); - CheckDisjoint( - T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass, T.Semantic); + T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectConstant2); + CheckOverlap( + T.Union(T.ObjectConstant1, T.ArrayClass), T.ObjectClass); // !!! // Bitset-union CheckSub( @@ -1534,7 +1799,7 @@ struct Tests : Rep { T.Union(T.Number, T.Array)); } - void Intersect1() { + void Intersect() { // Identity: Intersect(T, Any) = T for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { TypeHandle type = *it; @@ -1569,6 +1834,12 @@ struct Tests : Rep { // Associativity: // Intersect(T1, Intersect(T2, T3)) = Intersect(Intersect(T1, T2), T3) + // This does NOT hold. For example: + // (Class(..stringy1..) /\ Class(..stringy2..)) /\ Constant(..string..) = + // None + // Class(..stringy1..) /\ (Class(..stringy2..) /\ Constant(..string..)) = + // Constant(..string..) + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1583,8 +1854,15 @@ struct Tests : Rep { } } } + */ // Join: Intersect(T1, T2)->Is(T1) and Intersect(T1, T2)->Is(T2) + // This does NOT hold. For example: + // Class(..stringy..) /\ Constant(..string..) = Constant(..string..) + // Currently, not even the disjunction holds: + // Class(Internal/TaggedPtr) /\ (Any/Untagged \/ Context(..)) = + // Class(Internal/TaggedPtr) \/ Context(..) + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { TypeHandle type1 = *it1; @@ -1594,6 +1872,7 @@ struct Tests : Rep { CHECK(intersect12->Is(type2)); } } + */ // Lower Boundedness: T1->Is(T2) implies Intersect(T1, T2) = T1 for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { @@ -1604,10 +1883,13 @@ struct Tests : Rep { if (type1->Is(type2)) CheckEqual(intersect12, type1); } } - } - void Intersect2() { // Monotonicity: T1->Is(T2) implies Intersect(T1, T3)->Is(Intersect(T2, T3)) + // This does NOT hold. For example: + // Class(OtherObject/TaggedPtr) <= Any/TaggedPtr + // Class(OtherObject/TaggedPtr) /\ Any/UntaggedInt1 = Class(..) + // Any/TaggedPtr /\ Any/UntaggedInt1 = None + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1620,8 +1902,14 @@ struct Tests : Rep { } } } + */ // Monotonicity: T1->Is(T3) or T2->Is(T3) implies Intersect(T1, T2)->Is(T3) + // This does NOT hold. For example: + // Class(..stringy..) <= Class(..stringy..) + // Class(..stringy..) /\ Constant(..string..) = Constant(..string..) + // Constant(..string..) </= Class(..stringy..) + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1634,6 +1922,7 @@ struct Tests : Rep { } } } + */ // Monotonicity: T1->Is(T2) and T1->Is(T3) implies T1->Is(Intersect(T2, T3)) for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { @@ -1651,16 +1940,16 @@ struct Tests : Rep { // Bitset-class CheckEqual(T.Intersect(T.ObjectClass, T.Object), T.ObjectClass); - CheckSub(T.Intersect(T.ObjectClass, T.Array), T.Representation); - CheckSub(T.Intersect(T.ObjectClass, T.Number), T.Representation); + CheckEqual(T.Intersect(T.ObjectClass, T.Array), T.None); + CheckEqual(T.Intersect(T.ObjectClass, T.Number), T.None); // Bitset-array CheckEqual(T.Intersect(T.NumberArray, T.Object), T.NumberArray); - CheckSub(T.Intersect(T.AnyArray, T.Function), T.Representation); + CheckEqual(T.Intersect(T.AnyArray, T.Function), T.None); // Bitset-function CheckEqual(T.Intersect(T.MethodFunction, T.Object), T.MethodFunction); - CheckSub(T.Intersect(T.NumberFunction1, T.Array), T.Representation); + CheckEqual(T.Intersect(T.NumberFunction1, T.Array), T.None); // Bitset-union CheckEqual( @@ -1671,7 +1960,7 @@ struct Tests : Rep { ->IsInhabited()); // Class-constant - CHECK(!T.Intersect(T.ObjectConstant1, T.ObjectClass)->IsInhabited()); + CHECK(T.Intersect(T.ObjectConstant1, T.ObjectClass)->IsInhabited()); // !!! CHECK(!T.Intersect(T.ArrayClass, T.ObjectConstant2)->IsInhabited()); // Array-union @@ -1704,8 +1993,8 @@ struct Tests : Rep { T.Intersect(T.ArrayClass, T.Union(T.Object, T.SmiConstant)), T.ArrayClass); CHECK( - !T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass) - ->IsInhabited()); + T.Intersect(T.Union(T.ObjectClass, T.ArrayConstant), T.ArrayClass) + ->IsInhabited()); // !!! // Constant-union CheckEqual( @@ -1716,9 +2005,9 @@ struct Tests : Rep { T.Intersect(T.SmiConstant, T.Union(T.Number, T.ObjectConstant2)), T.SmiConstant); CHECK( - !T.Intersect( + T.Intersect( T.Union(T.ArrayConstant, T.ObjectClass), T.ObjectConstant1) - ->IsInhabited()); + ->IsInhabited()); // !!! // Union-union CheckEqual( @@ -1739,16 +2028,24 @@ struct Tests : Rep { CheckEqual( T.Intersect( T.Union( - T.Union(T.ObjectConstant2, T.ObjectConstant1), T.ArrayClass), + T.ArrayClass, + T.Union(T.ObjectConstant2, T.ObjectConstant1)), T.Union( T.ObjectConstant1, T.Union(T.ArrayConstant, T.ObjectConstant2))), - T.Union(T.ObjectConstant2, T.ObjectConstant1)); + T.Union( + T.ArrayConstant, + T.Union(T.ObjectConstant2, T.ObjectConstant1))); // !!! } - void Distributivity1() { - // Distributivity: + void Distributivity() { // Union(T1, Intersect(T2, T3)) = Intersect(Union(T1, T2), Union(T1, T3)) + // This does NOT hold. For example: + // Untagged \/ (Untagged /\ Class(../Tagged)) = Untagged \/ Class(../Tagged) + // (Untagged \/ Untagged) /\ (Untagged \/ Class(../Tagged)) = + // Untagged /\ (Untagged \/ Class(../Tagged)) = Untagged + // because Untagged <= Untagged \/ Class(../Tagged) + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1764,11 +2061,14 @@ struct Tests : Rep { } } } - } + */ - void Distributivity2() { - // Distributivity: // Intersect(T1, Union(T2, T3)) = Union(Intersect(T1, T2), Intersect(T1,T3)) + // This does NOT hold. For example: + // Untagged /\ (Untagged \/ Class(../Tagged)) = Untagged + // (Untagged /\ Untagged) \/ (Untagged /\ Class(../Tagged)) = + // Untagged \/ Class(../Tagged) + /* for (TypeIterator it1 = T.types.begin(); it1 != T.types.end(); ++it1) { for (TypeIterator it2 = T.types.begin(); it2 != T.types.end(); ++it2) { for (TypeIterator it3 = T.types.begin(); it3 != T.types.end(); ++it3) { @@ -1784,6 +2084,7 @@ struct Tests : Rep { } } } + */ } template<class Type2, class TypeHandle2, class Region2, class Rep2> @@ -1815,6 +2116,13 @@ typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests; typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests; +TEST(IsSomeType) { + CcTest::InitializeVM(); + ZoneTests().IsSomeType(); + HeapTests().IsSomeType(); +} + + TEST(BitsetType) { CcTest::InitializeVM(); ZoneTests().Bitset(); @@ -1871,17 +2179,31 @@ TEST(NowOf) { } -TEST(Bounds) { +TEST(BitsetGlb) { + CcTest::InitializeVM(); + ZoneTests().BitsetGlb(); + HeapTests().BitsetGlb(); +} + + +TEST(BitsetLub) { + CcTest::InitializeVM(); + ZoneTests().BitsetLub(); + HeapTests().BitsetLub(); +} + + +TEST(Is1) { CcTest::InitializeVM(); - ZoneTests().Bounds(); - HeapTests().Bounds(); + ZoneTests().Is1(); + HeapTests().Is1(); } -TEST(Is) { +TEST(Is2) { CcTest::InitializeVM(); - ZoneTests().Is(); - HeapTests().Is(); + ZoneTests().Is2(); + HeapTests().Is2(); } @@ -1920,38 +2242,40 @@ TEST(Union1) { } +/* TEST(Union2) { CcTest::InitializeVM(); ZoneTests().Union2(); HeapTests().Union2(); } +*/ -TEST(Intersect1) { +TEST(Union3) { CcTest::InitializeVM(); - ZoneTests().Intersect1(); - HeapTests().Intersect1(); + ZoneTests().Union3(); + HeapTests().Union3(); } -TEST(Intersect2) { +TEST(Union4) { CcTest::InitializeVM(); - ZoneTests().Intersect2(); - HeapTests().Intersect2(); + ZoneTests().Union4(); + HeapTests().Union4(); } -TEST(Distributivity1) { +TEST(Intersect) { CcTest::InitializeVM(); - ZoneTests().Distributivity1(); - HeapTests().Distributivity1(); + ZoneTests().Intersect(); + HeapTests().Intersect(); } -TEST(Distributivity2) { +TEST(Distributivity) { CcTest::InitializeVM(); - ZoneTests().Distributivity2(); - HeapTests().Distributivity2(); + ZoneTests().Distributivity(); + HeapTests().Distributivity(); } diff --git a/deps/v8/test/cctest/test-utils.cc b/deps/v8/test/cctest/test-utils.cc index cf539305b3..9ea8b2b6a3 100644 --- a/deps/v8/test/cctest/test-utils.cc +++ b/deps/v8/test/cctest/test-utils.cc @@ -223,7 +223,7 @@ TEST(SequenceCollectorRegression) { // TODO(svenpanne) Unconditionally test this when our infrastructure is fixed. -#if !V8_CC_MSVC && !V8_OS_NACL +#if !V8_OS_NACL TEST(CPlusPlus11Features) { struct S { bool x; diff --git a/deps/v8/test/compiler-unittests/DEPS b/deps/v8/test/compiler-unittests/DEPS deleted file mode 100644 index 8aa02395f5..0000000000 --- a/deps/v8/test/compiler-unittests/DEPS +++ /dev/null @@ -1,6 +0,0 @@ -include_rules = [ - "+src", - "+testing/gtest", - "+testing/gtest-type-names.h", - "+testing/gmock", -] diff --git a/deps/v8/test/compiler-unittests/arm/instruction-selector-arm-unittest.cc b/deps/v8/test/compiler-unittests/arm/instruction-selector-arm-unittest.cc deleted file mode 100644 index b781ac8f9f..0000000000 --- a/deps/v8/test/compiler-unittests/arm/instruction-selector-arm-unittest.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "test/compiler-unittests/instruction-selector-unittest.h" - -namespace v8 { -namespace internal { -namespace compiler { - -class InstructionSelectorARMTest : public InstructionSelectorTest {}; - - -TARGET_TEST_F(InstructionSelectorARMTest, Int32AddP) { - StreamBuilder m(this, kMachineWord32, kMachineWord32, kMachineWord32); - m.Return(m.Int32Add(m.Parameter(0), m.Parameter(1))); - Stream s = m.Build(); - ASSERT_EQ(1U, s.size()); - EXPECT_EQ(kArmAdd, s[0]->arch_opcode()); - EXPECT_EQ(kMode_Operand2_R, s[0]->addressing_mode()); - EXPECT_EQ(2U, s[0]->InputCount()); - EXPECT_EQ(1U, s[0]->OutputCount()); -} - -} // namespace compiler -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/compiler-unittests/change-lowering-unittest.cc b/deps/v8/test/compiler-unittests/change-lowering-unittest.cc deleted file mode 100644 index 68de48013c..0000000000 --- a/deps/v8/test/compiler-unittests/change-lowering-unittest.cc +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/compiler/change-lowering.h" -#include "src/compiler/common-operator.h" -#include "src/compiler/graph.h" -#include "src/compiler/node-properties-inl.h" -#include "src/compiler/simplified-operator.h" -#include "src/factory.h" -#include "test/compiler-unittests/compiler-unittests.h" -#include "test/compiler-unittests/node-matchers.h" -#include "testing/gtest-type-names.h" - -using testing::_; - -namespace v8 { -namespace internal { -namespace compiler { - -template <typename T> -class ChangeLoweringTest : public CompilerTest { - public: - static const size_t kPointerSize = sizeof(T); - - explicit ChangeLoweringTest(int num_parameters = 1) - : graph_(zone()), common_(zone()), simplified_(zone()) { - graph()->SetStart(graph()->NewNode(common()->Start(num_parameters))); - } - virtual ~ChangeLoweringTest() {} - - protected: - Node* Parameter(int32_t index = 0) { - return graph()->NewNode(common()->Parameter(index), graph()->start()); - } - - Reduction Reduce(Node* node) { - CompilationInfo info(isolate(), zone()); - Linkage linkage(&info); - ChangeLowering<kPointerSize> reducer(graph(), &linkage); - return reducer.Reduce(node); - } - - Graph* graph() { return &graph_; } - Factory* factory() const { return isolate()->factory(); } - CommonOperatorBuilder* common() { return &common_; } - SimplifiedOperatorBuilder* simplified() { return &simplified_; } - - PrintableUnique<HeapObject> true_unique() { - return PrintableUnique<HeapObject>::CreateImmovable( - zone(), factory()->true_value()); - } - PrintableUnique<HeapObject> false_unique() { - return PrintableUnique<HeapObject>::CreateImmovable( - zone(), factory()->false_value()); - } - - private: - Graph graph_; - CommonOperatorBuilder common_; - SimplifiedOperatorBuilder simplified_; -}; - - -typedef ::testing::Types<int32_t, int64_t> ChangeLoweringTypes; -TYPED_TEST_CASE(ChangeLoweringTest, ChangeLoweringTypes); - - -TARGET_TYPED_TEST(ChangeLoweringTest, ChangeBitToBool) { - Node* val = this->Parameter(0); - Node* node = - this->graph()->NewNode(this->simplified()->ChangeBitToBool(), val); - Reduction reduction = this->Reduce(node); - ASSERT_TRUE(reduction.Changed()); - - Node* phi = reduction.replacement(); - EXPECT_THAT(phi, IsPhi(IsHeapConstant(this->true_unique()), - IsHeapConstant(this->false_unique()), _)); - - Node* merge = NodeProperties::GetControlInput(phi); - ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); - - Node* if_true = NodeProperties::GetControlInput(merge, 0); - ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); - - Node* if_false = NodeProperties::GetControlInput(merge, 1); - ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); - - Node* branch = NodeProperties::GetControlInput(if_true); - EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); - EXPECT_THAT(branch, IsBranch(val, this->graph()->start())); -} - - -TARGET_TYPED_TEST(ChangeLoweringTest, StringAdd) { - Node* node = this->graph()->NewNode(this->simplified()->StringAdd(), - this->Parameter(0), this->Parameter(1)); - Reduction reduction = this->Reduce(node); - EXPECT_FALSE(reduction.Changed()); -} - - -class ChangeLowering32Test : public ChangeLoweringTest<int32_t> { - public: - virtual ~ChangeLowering32Test() {} -}; - - -TARGET_TEST_F(ChangeLowering32Test, ChangeBoolToBit) { - Node* val = Parameter(0); - Node* node = graph()->NewNode(simplified()->ChangeBoolToBit(), val); - Reduction reduction = Reduce(node); - ASSERT_TRUE(reduction.Changed()); - - EXPECT_THAT(reduction.replacement(), - IsWord32Equal(val, IsHeapConstant(true_unique()))); -} - - -TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) { - Node* val = Parameter(0); - Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); - Reduction reduction = Reduce(node); - ASSERT_TRUE(reduction.Changed()); - - Node* phi = reduction.replacement(); - ASSERT_EQ(IrOpcode::kPhi, phi->opcode()); - - Node* smi = NodeProperties::GetValueInput(phi, 1); - ASSERT_THAT(smi, IsProjection(0, IsInt32AddWithOverflow(val, val))); - - Node* heap_number = NodeProperties::GetValueInput(phi, 0); - ASSERT_EQ(IrOpcode::kCall, heap_number->opcode()); - - Node* merge = NodeProperties::GetControlInput(phi); - ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); - - const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; - EXPECT_THAT(NodeProperties::GetControlInput(merge, 0), - IsStore(kMachineFloat64, kNoWriteBarrier, heap_number, - IsInt32Constant(kValueOffset), - IsChangeInt32ToFloat64(val), _, heap_number)); - - Node* if_true = NodeProperties::GetControlInput(heap_number); - ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); - - Node* if_false = NodeProperties::GetControlInput(merge, 1); - ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); - - Node* branch = NodeProperties::GetControlInput(if_true); - EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); - EXPECT_THAT(branch, - IsBranch(IsProjection(1, IsInt32AddWithOverflow(val, val)), - graph()->start())); -} - - -TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) { - Node* val = Parameter(0); - Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); - Reduction reduction = Reduce(node); - ASSERT_TRUE(reduction.Changed()); - - const int32_t kShiftAmount = - kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; - const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; - Node* phi = reduction.replacement(); - ASSERT_THAT( - phi, IsPhi(IsLoad(kMachineFloat64, val, IsInt32Constant(kValueOffset), _), - IsChangeInt32ToFloat64( - IsWord32Sar(val, IsInt32Constant(kShiftAmount))), - _)); - - Node* merge = NodeProperties::GetControlInput(phi); - ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); - - Node* if_true = NodeProperties::GetControlInput(merge, 0); - ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); - - Node* if_false = NodeProperties::GetControlInput(merge, 1); - ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); - - Node* branch = NodeProperties::GetControlInput(if_true); - EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); - STATIC_ASSERT(kSmiTag == 0); - STATIC_ASSERT(kSmiTagSize == 1); - EXPECT_THAT(branch, IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), - graph()->start())); -} - - -class ChangeLowering64Test : public ChangeLoweringTest<int64_t> { - public: - virtual ~ChangeLowering64Test() {} -}; - - -TARGET_TEST_F(ChangeLowering64Test, ChangeBoolToBit) { - Node* val = Parameter(0); - Node* node = graph()->NewNode(simplified()->ChangeBoolToBit(), val); - Reduction reduction = Reduce(node); - ASSERT_TRUE(reduction.Changed()); - - EXPECT_THAT(reduction.replacement(), - IsWord64Equal(val, IsHeapConstant(true_unique()))); -} - - -TARGET_TEST_F(ChangeLowering64Test, ChangeInt32ToTagged) { - Node* val = Parameter(0); - Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), val); - Reduction reduction = Reduce(node); - ASSERT_TRUE(reduction.Changed()); - - const int32_t kShiftAmount = - kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; - EXPECT_THAT(reduction.replacement(), - IsWord64Shl(val, IsInt32Constant(kShiftAmount))); -} - - -TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) { - Node* val = Parameter(0); - Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), val); - Reduction reduction = Reduce(node); - ASSERT_TRUE(reduction.Changed()); - - const int32_t kShiftAmount = - kSmiTagSize + SmiTagging<kPointerSize>::kSmiShiftSize; - const int32_t kValueOffset = HeapNumber::kValueOffset - kHeapObjectTag; - Node* phi = reduction.replacement(); - ASSERT_THAT( - phi, IsPhi(IsLoad(kMachineFloat64, val, IsInt32Constant(kValueOffset), _), - IsChangeInt32ToFloat64(IsConvertInt64ToInt32( - IsWord64Sar(val, IsInt32Constant(kShiftAmount)))), - _)); - - Node* merge = NodeProperties::GetControlInput(phi); - ASSERT_EQ(IrOpcode::kMerge, merge->opcode()); - - Node* if_true = NodeProperties::GetControlInput(merge, 0); - ASSERT_EQ(IrOpcode::kIfTrue, if_true->opcode()); - - Node* if_false = NodeProperties::GetControlInput(merge, 1); - ASSERT_EQ(IrOpcode::kIfFalse, if_false->opcode()); - - Node* branch = NodeProperties::GetControlInput(if_true); - EXPECT_EQ(branch, NodeProperties::GetControlInput(if_false)); - STATIC_ASSERT(kSmiTag == 0); - STATIC_ASSERT(kSmiTagSize == 1); - EXPECT_THAT(branch, IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), - graph()->start())); -} - -} // namespace compiler -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/compiler-unittests/compiler-unittests.cc b/deps/v8/test/compiler-unittests/compiler-unittests.cc deleted file mode 100644 index 2ce4c93ee2..0000000000 --- a/deps/v8/test/compiler-unittests/compiler-unittests.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "include/libplatform/libplatform.h" -#include "test/compiler-unittests/compiler-unittests.h" -#include "testing/gmock/include/gmock/gmock.h" - -using testing::IsNull; -using testing::NotNull; - -namespace v8 { -namespace internal { -namespace compiler { - -// static -v8::Isolate* CompilerTest::isolate_ = NULL; - - -CompilerTest::CompilerTest() - : isolate_scope_(isolate_), - handle_scope_(isolate_), - context_scope_(v8::Context::New(isolate_)), - zone_(isolate()) {} - - -CompilerTest::~CompilerTest() {} - - -// static -void CompilerTest::SetUpTestCase() { - Test::SetUpTestCase(); - EXPECT_THAT(isolate_, IsNull()); - isolate_ = v8::Isolate::New(); - ASSERT_THAT(isolate_, NotNull()); -} - - -// static -void CompilerTest::TearDownTestCase() { - ASSERT_THAT(isolate_, NotNull()); - isolate_->Dispose(); - isolate_ = NULL; - Test::TearDownTestCase(); -} - -} // namespace compiler -} // namespace internal -} // namespace v8 - - -namespace { - -class CompilerTestEnvironment V8_FINAL : public ::testing::Environment { - public: - CompilerTestEnvironment() : platform_(NULL) {} - ~CompilerTestEnvironment() {} - - virtual void SetUp() V8_OVERRIDE { - EXPECT_THAT(platform_, IsNull()); - platform_ = v8::platform::CreateDefaultPlatform(); - v8::V8::InitializePlatform(platform_); - ASSERT_TRUE(v8::V8::Initialize()); - } - - virtual void TearDown() V8_OVERRIDE { - ASSERT_THAT(platform_, NotNull()); - v8::V8::Dispose(); - v8::V8::ShutdownPlatform(); - delete platform_; - platform_ = NULL; - } - - private: - v8::Platform* platform_; -}; - -} - - -int main(int argc, char** argv) { - testing::InitGoogleMock(&argc, argv); - testing::AddGlobalTestEnvironment(new CompilerTestEnvironment); - v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - return RUN_ALL_TESTS(); -} diff --git a/deps/v8/test/compiler-unittests/compiler-unittests.gyp b/deps/v8/test/compiler-unittests/compiler-unittests.gyp deleted file mode 100644 index c1de0c4235..0000000000 --- a/deps/v8/test/compiler-unittests/compiler-unittests.gyp +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2014 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -{ - 'variables': { - 'v8_code': 1, - }, - 'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'], - 'targets': [ - { - 'target_name': 'compiler-unittests', - 'type': 'executable', - 'dependencies': [ - '../../testing/gmock.gyp:gmock', - '../../testing/gtest.gyp:gtest', - '../../tools/gyp/v8.gyp:v8_libplatform', - ], - 'include_dirs': [ - '../..', - ], - 'sources': [ ### gcmole(all) ### - 'change-lowering-unittest.cc', - 'compiler-unittests.cc', - 'instruction-selector-unittest.cc', - 'node-matchers.cc', - 'node-matchers.h', - ], - 'conditions': [ - ['v8_target_arch=="arm"', { - 'sources': [ ### gcmole(arch:arm) ### - 'arm/instruction-selector-arm-unittest.cc', - ], - }], - ['component=="shared_library"', { - # compiler-unittests can't be built against a shared library, so we - # need to depend on the underlying static target in that case. - 'conditions': [ - ['v8_use_snapshot=="true"', { - 'dependencies': ['../../tools/gyp/v8.gyp:v8_snapshot'], - }, - { - 'dependencies': [ - '../../tools/gyp/v8.gyp:v8_nosnapshot', - ], - }], - ], - }, { - 'dependencies': ['../../tools/gyp/v8.gyp:v8'], - }], - ['os_posix == 1', { - # TODO(svenpanne): This is a temporary work-around to fix the warnings - # that show up because we use -std=gnu++0x instead of -std=c++11. - 'cflags!': [ - '-pedantic', - ], - }], - ], - }, - ], -} diff --git a/deps/v8/test/compiler-unittests/compiler-unittests.h b/deps/v8/test/compiler-unittests/compiler-unittests.h deleted file mode 100644 index 091b137066..0000000000 --- a/deps/v8/test/compiler-unittests/compiler-unittests.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_COMPILER_UNITTESTS_COMPILER_UNITTESTS_H_ -#define V8_COMPILER_UNITTESTS_COMPILER_UNITTESTS_H_ - -#include "include/v8.h" -#include "src/zone.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace v8 { -namespace internal { -namespace compiler { - -// The TARGET_TEST(Case, Name) macro works just like -// TEST(Case, Name), except that the test is disabled -// if the platform is not a supported TurboFan target. -#if V8_TURBOFAN_TARGET -#define TARGET_TEST(Case, Name) TEST(Case, Name) -#else -#define TARGET_TEST(Case, Name) TEST(Case, DISABLED_##Name) -#endif - - -// The TARGET_TEST_F(Case, Name) macro works just like -// TEST_F(Case, Name), except that the test is disabled -// if the platform is not a supported TurboFan target. -#if V8_TURBOFAN_TARGET -#define TARGET_TEST_F(Case, Name) TEST_F(Case, Name) -#else -#define TARGET_TEST_F(Case, Name) TEST_F(Case, DISABLED_##Name) -#endif - - -// The TARGET_TYPED_TEST(Case, Name) macro works just like -// TYPED_TEST(Case, Name), except that the test is disabled -// if the platform is not a supported TurboFan target. -#if V8_TURBOFAN_TARGET -#define TARGET_TYPED_TEST(Case, Name) TYPED_TEST(Case, Name) -#else -#define TARGET_TYPED_TEST(Case, Name) TYPED_TEST(Case, DISABLED_##Name) -#endif - - -class CompilerTest : public ::testing::Test { - public: - CompilerTest(); - virtual ~CompilerTest(); - - Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); } - Zone* zone() { return &zone_; } - - static void SetUpTestCase(); - static void TearDownTestCase(); - - private: - static v8::Isolate* isolate_; - v8::Isolate::Scope isolate_scope_; - v8::HandleScope handle_scope_; - v8::Context::Scope context_scope_; - Zone zone_; -}; - -} // namespace compiler -} // namespace internal -} // namespace v8 - -#endif // V8_COMPILER_UNITTESTS_COMPILER_UNITTESTS_H_ diff --git a/deps/v8/test/compiler-unittests/instruction-selector-unittest.cc b/deps/v8/test/compiler-unittests/instruction-selector-unittest.cc deleted file mode 100644 index 70186529af..0000000000 --- a/deps/v8/test/compiler-unittests/instruction-selector-unittest.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "test/compiler-unittests/instruction-selector-unittest.h" - -namespace v8 { -namespace internal { -namespace compiler { - -InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build( - InstructionSelector::Features features, - InstructionSelectorTest::StreamBuilderMode mode) { - Schedule* schedule = Export(); - EXPECT_NE(0, graph()->NodeCount()); - CompilationInfo info(test_->isolate(), test_->zone()); - Linkage linkage(&info, call_descriptor()); - InstructionSequence sequence(&linkage, graph(), schedule); - SourcePositionTable source_position_table(graph()); - InstructionSelector selector(&sequence, &source_position_table, features); - selector.SelectInstructions(); - if (FLAG_trace_turbo) { - OFStream out(stdout); - out << "--- Code sequence after instruction selection ---" << endl - << sequence; - } - Stream s; - for (InstructionSequence::const_iterator i = sequence.begin(); - i != sequence.end(); ++i) { - Instruction* instr = *i; - if (instr->opcode() < 0) continue; - if (mode == kTargetInstructions) { - switch (instr->arch_opcode()) { -#define CASE(Name) \ - case k##Name: \ - break; - TARGET_ARCH_OPCODE_LIST(CASE) -#undef CASE - default: - continue; - } - } - for (size_t i = 0; i < instr->OutputCount(); ++i) { - InstructionOperand* output = instr->OutputAt(i); - EXPECT_NE(InstructionOperand::IMMEDIATE, output->kind()); - if (output->IsConstant()) { - s.constants_.insert(std::make_pair( - output->index(), sequence.GetConstant(output->index()))); - } - } - for (size_t i = 0; i < instr->InputCount(); ++i) { - InstructionOperand* input = instr->InputAt(i); - EXPECT_NE(InstructionOperand::CONSTANT, input->kind()); - if (input->IsImmediate()) { - s.immediates_.insert(std::make_pair( - input->index(), sequence.GetImmediate(input->index()))); - } - } - s.instructions_.push_back(instr); - } - return s; -} - - -TARGET_TEST_F(InstructionSelectorTest, ReturnP) { - StreamBuilder m(this, kMachineWord32, kMachineWord32); - m.Return(m.Parameter(0)); - Stream s = m.Build(kAllInstructions); - ASSERT_EQ(2U, s.size()); - EXPECT_EQ(kArchNop, s[0]->arch_opcode()); - ASSERT_EQ(1U, s[0]->OutputCount()); - EXPECT_EQ(kArchRet, s[1]->arch_opcode()); - EXPECT_EQ(1U, s[1]->InputCount()); -} - - -TARGET_TEST_F(InstructionSelectorTest, ReturnImm) { - StreamBuilder m(this, kMachineWord32); - m.Return(m.Int32Constant(0)); - Stream s = m.Build(kAllInstructions); - ASSERT_EQ(2U, s.size()); - EXPECT_EQ(kArchNop, s[0]->arch_opcode()); - ASSERT_EQ(1U, s[0]->OutputCount()); - EXPECT_EQ(InstructionOperand::CONSTANT, s[0]->OutputAt(0)->kind()); - EXPECT_EQ(0, s.ToInt32(s[0]->OutputAt(0))); - EXPECT_EQ(kArchRet, s[1]->arch_opcode()); - EXPECT_EQ(1U, s[1]->InputCount()); -} - -} // namespace compiler -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/compiler-unittests/instruction-selector-unittest.h b/deps/v8/test/compiler-unittests/instruction-selector-unittest.h deleted file mode 100644 index 3a7b590757..0000000000 --- a/deps/v8/test/compiler-unittests/instruction-selector-unittest.h +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ -#define V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ - -#include <deque> - -#include "src/compiler/instruction-selector.h" -#include "src/compiler/raw-machine-assembler.h" -#include "test/compiler-unittests/compiler-unittests.h" - -namespace v8 { -namespace internal { -namespace compiler { - -class InstructionSelectorTest : public CompilerTest { - public: - InstructionSelectorTest() {} - virtual ~InstructionSelectorTest() {} - - protected: - class Stream; - - enum StreamBuilderMode { kAllInstructions, kTargetInstructions }; - - class StreamBuilder V8_FINAL : public RawMachineAssembler { - public: - StreamBuilder(InstructionSelectorTest* test, MachineType return_type) - : RawMachineAssembler(new (test->zone()) Graph(test->zone()), - CallDescriptorBuilder(test->zone(), return_type)), - test_(test) {} - StreamBuilder(InstructionSelectorTest* test, MachineType return_type, - MachineType parameter0_type) - : RawMachineAssembler(new (test->zone()) Graph(test->zone()), - CallDescriptorBuilder(test->zone(), return_type, - parameter0_type)), - test_(test) {} - StreamBuilder(InstructionSelectorTest* test, MachineType return_type, - MachineType parameter0_type, MachineType parameter1_type) - : RawMachineAssembler( - new (test->zone()) Graph(test->zone()), - CallDescriptorBuilder(test->zone(), return_type, parameter0_type, - parameter1_type)), - test_(test) {} - - Stream Build(CpuFeature feature) { - return Build(InstructionSelector::Features(feature)); - } - Stream Build(CpuFeature feature1, CpuFeature feature2) { - return Build(InstructionSelector::Features(feature1, feature2)); - } - Stream Build(StreamBuilderMode mode = kTargetInstructions) { - return Build(InstructionSelector::Features(), mode); - } - Stream Build(InstructionSelector::Features features, - StreamBuilderMode mode = kTargetInstructions); - - private: - MachineCallDescriptorBuilder* CallDescriptorBuilder( - Zone* zone, MachineType return_type) { - return new (zone) MachineCallDescriptorBuilder(return_type, 0, NULL); - } - - MachineCallDescriptorBuilder* CallDescriptorBuilder( - Zone* zone, MachineType return_type, MachineType parameter0_type) { - MachineType* parameter_types = zone->NewArray<MachineType>(1); - parameter_types[0] = parameter0_type; - return new (zone) - MachineCallDescriptorBuilder(return_type, 1, parameter_types); - } - - MachineCallDescriptorBuilder* CallDescriptorBuilder( - Zone* zone, MachineType return_type, MachineType parameter0_type, - MachineType parameter1_type) { - MachineType* parameter_types = zone->NewArray<MachineType>(2); - parameter_types[0] = parameter0_type; - parameter_types[1] = parameter1_type; - return new (zone) - MachineCallDescriptorBuilder(return_type, 2, parameter_types); - } - - private: - InstructionSelectorTest* test_; - }; - - class Stream V8_FINAL { - public: - size_t size() const { return instructions_.size(); } - const Instruction* operator[](size_t index) const { - EXPECT_LT(index, size()); - return instructions_[index]; - } - - int32_t ToInt32(const InstructionOperand* operand) const { - return ToConstant(operand).ToInt32(); - } - - private: - Constant ToConstant(const InstructionOperand* operand) const { - ConstantMap::const_iterator i; - if (operand->IsConstant()) { - i = constants_.find(operand->index()); - EXPECT_NE(constants_.end(), i); - } else { - EXPECT_EQ(InstructionOperand::IMMEDIATE, operand->kind()); - i = immediates_.find(operand->index()); - EXPECT_NE(immediates_.end(), i); - } - EXPECT_EQ(operand->index(), i->first); - return i->second; - } - - friend class StreamBuilder; - - typedef std::map<int, Constant> ConstantMap; - - ConstantMap constants_; - ConstantMap immediates_; - std::deque<Instruction*> instructions_; - }; -}; - -} // namespace compiler -} // namespace internal -} // namespace v8 - -#endif // V8_COMPILER_UNITTESTS_INSTRUCTION_SELECTOR_UNITTEST_H_ diff --git a/deps/v8/test/compiler-unittests/node-matchers.cc b/deps/v8/test/compiler-unittests/node-matchers.cc deleted file mode 100644 index d580834113..0000000000 --- a/deps/v8/test/compiler-unittests/node-matchers.cc +++ /dev/null @@ -1,454 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "test/compiler-unittests/node-matchers.h" - -#include <ostream> // NOLINT(readability/streams) - -#include "src/compiler/node-properties-inl.h" - -using testing::MakeMatcher; -using testing::MatcherInterface; -using testing::MatchResultListener; -using testing::StringMatchResultListener; - -namespace v8 { -namespace internal { - -// TODO(bmeurer): Find a new home for these functions. -template <typename T> -inline std::ostream& operator<<(std::ostream& os, - const PrintableUnique<T>& value) { - return os << value.string(); -} - -namespace compiler { - -namespace { - -template <typename T> -bool PrintMatchAndExplain(const T& value, const char* value_name, - const Matcher<T>& value_matcher, - MatchResultListener* listener) { - StringMatchResultListener value_listener; - if (!value_matcher.MatchAndExplain(value, &value_listener)) { - *listener << "whose " << value_name << " " << value << " doesn't match"; - if (value_listener.str() != "") { - *listener << ", " << value_listener.str(); - } - return false; - } - return true; -} - - -class NodeMatcher : public MatcherInterface<Node*> { - public: - explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - if (node == NULL) { - *listener << "which is NULL"; - return false; - } - if (node->opcode() != opcode_) { - *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode()); - return false; - } - return true; - } - - private: - const IrOpcode::Value opcode_; -}; - - -class IsBranchMatcher V8_FINAL : public NodeMatcher { - public: - IsBranchMatcher(const Matcher<Node*>& value_matcher, - const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kBranch), - value_matcher_(value_matcher), - control_matcher_(control_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose value ("; - value_matcher_.DescribeTo(os); - *os << ") and control ("; - control_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), - "value", value_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetControlInput(node), - "control", control_matcher_, listener)); - } - - private: - const Matcher<Node*> value_matcher_; - const Matcher<Node*> control_matcher_; -}; - - -template <typename T> -class IsConstantMatcher V8_FINAL : public NodeMatcher { - public: - IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher) - : NodeMatcher(opcode), value_matcher_(value_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose value ("; - value_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_, - listener)); - } - - private: - const Matcher<T> value_matcher_; -}; - - -class IsPhiMatcher V8_FINAL : public NodeMatcher { - public: - IsPhiMatcher(const Matcher<Node*>& value0_matcher, - const Matcher<Node*>& value1_matcher, - const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kPhi), - value0_matcher_(value0_matcher), - value1_matcher_(value1_matcher), - control_matcher_(control_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose value0 ("; - value0_matcher_.DescribeTo(os); - *os << "), value1 ("; - value1_matcher_.DescribeTo(os); - *os << ") and control ("; - control_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), - "value0", value0_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), - "value1", value1_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetControlInput(node), - "control", control_matcher_, listener)); - } - - private: - const Matcher<Node*> value0_matcher_; - const Matcher<Node*> value1_matcher_; - const Matcher<Node*> control_matcher_; -}; - - -class IsProjectionMatcher V8_FINAL : public NodeMatcher { - public: - IsProjectionMatcher(const Matcher<int32_t>& index_matcher, - const Matcher<Node*>& base_matcher) - : NodeMatcher(IrOpcode::kProjection), - index_matcher_(index_matcher), - base_matcher_(base_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose index ("; - index_matcher_.DescribeTo(os); - *os << ") and base ("; - base_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<int32_t>(node), "index", - index_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", - base_matcher_, listener)); - } - - private: - const Matcher<int32_t> index_matcher_; - const Matcher<Node*> base_matcher_; -}; - - -class IsLoadMatcher V8_FINAL : public NodeMatcher { - public: - IsLoadMatcher(const Matcher<MachineType>& type_matcher, - const Matcher<Node*>& base_matcher, - const Matcher<Node*>& index_matcher, - const Matcher<Node*>& effect_matcher) - : NodeMatcher(IrOpcode::kLoad), - type_matcher_(type_matcher), - base_matcher_(base_matcher), - index_matcher_(index_matcher), - effect_matcher_(effect_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose type ("; - type_matcher_.DescribeTo(os); - *os << "), base ("; - base_matcher_.DescribeTo(os); - *os << "), index ("; - index_matcher_.DescribeTo(os); - *os << ") and effect ("; - effect_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<MachineType>(node), "type", - type_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", - base_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), - "index", index_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", - effect_matcher_, listener)); - } - - private: - const Matcher<MachineType> type_matcher_; - const Matcher<Node*> base_matcher_; - const Matcher<Node*> index_matcher_; - const Matcher<Node*> effect_matcher_; -}; - - -class IsStoreMatcher V8_FINAL : public NodeMatcher { - public: - IsStoreMatcher(const Matcher<MachineType>& type_matcher, - const Matcher<WriteBarrierKind> write_barrier_matcher, - const Matcher<Node*>& base_matcher, - const Matcher<Node*>& index_matcher, - const Matcher<Node*>& value_matcher, - const Matcher<Node*>& effect_matcher, - const Matcher<Node*>& control_matcher) - : NodeMatcher(IrOpcode::kStore), - type_matcher_(type_matcher), - write_barrier_matcher_(write_barrier_matcher), - base_matcher_(base_matcher), - index_matcher_(index_matcher), - value_matcher_(value_matcher), - effect_matcher_(effect_matcher), - control_matcher_(control_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose type ("; - type_matcher_.DescribeTo(os); - *os << "), write barrier ("; - write_barrier_matcher_.DescribeTo(os); - *os << "), base ("; - base_matcher_.DescribeTo(os); - *os << "), index ("; - index_matcher_.DescribeTo(os); - *os << "), value ("; - value_matcher_.DescribeTo(os); - *os << "), effect ("; - effect_matcher_.DescribeTo(os); - *os << ") and control ("; - control_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(OpParameter<StoreRepresentation>(node).rep, - "type", type_matcher_, listener) && - PrintMatchAndExplain( - OpParameter<StoreRepresentation>(node).write_barrier_kind, - "write barrier", write_barrier_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", - base_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), - "index", index_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), - "value", value_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", - effect_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetControlInput(node), - "control", control_matcher_, listener)); - } - - private: - const Matcher<MachineType> type_matcher_; - const Matcher<WriteBarrierKind> write_barrier_matcher_; - const Matcher<Node*> base_matcher_; - const Matcher<Node*> index_matcher_; - const Matcher<Node*> value_matcher_; - const Matcher<Node*> effect_matcher_; - const Matcher<Node*> control_matcher_; -}; - - -class IsBinopMatcher V8_FINAL : public NodeMatcher { - public: - IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher) - : NodeMatcher(opcode), - lhs_matcher_(lhs_matcher), - rhs_matcher_(rhs_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose lhs ("; - lhs_matcher_.DescribeTo(os); - *os << ") and rhs ("; - rhs_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", - lhs_matcher_, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs", - rhs_matcher_, listener)); - } - - private: - const Matcher<Node*> lhs_matcher_; - const Matcher<Node*> rhs_matcher_; -}; - - -class IsUnopMatcher V8_FINAL : public NodeMatcher { - public: - IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher) - : NodeMatcher(opcode), input_matcher_(input_matcher) {} - - virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE { - NodeMatcher::DescribeTo(os); - *os << " whose input ("; - input_matcher_.DescribeTo(os); - *os << ")"; - } - - virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const - V8_OVERRIDE { - return (NodeMatcher::MatchAndExplain(node, listener) && - PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), - "input", input_matcher_, listener)); - } - - private: - const Matcher<Node*> input_matcher_; -}; - -} - - -Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, - const Matcher<Node*>& control_matcher) { - return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher)); -} - - -Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) { - return MakeMatcher( - new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher)); -} - - -Matcher<Node*> IsHeapConstant( - const Matcher<PrintableUnique<HeapObject> >& value_matcher) { - return MakeMatcher(new IsConstantMatcher<PrintableUnique<HeapObject> >( - IrOpcode::kHeapConstant, value_matcher)); -} - - -Matcher<Node*> IsPhi(const Matcher<Node*>& value0_matcher, - const Matcher<Node*>& value1_matcher, - const Matcher<Node*>& merge_matcher) { - return MakeMatcher( - new IsPhiMatcher(value0_matcher, value1_matcher, merge_matcher)); -} - - -Matcher<Node*> IsProjection(const Matcher<int32_t>& index_matcher, - const Matcher<Node*>& base_matcher) { - return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); -} - - -Matcher<Node*> IsLoad(const Matcher<MachineType>& type_matcher, - const Matcher<Node*>& base_matcher, - const Matcher<Node*>& index_matcher, - const Matcher<Node*>& effect_matcher) { - return MakeMatcher(new IsLoadMatcher(type_matcher, base_matcher, - index_matcher, effect_matcher)); -} - - -Matcher<Node*> IsStore(const Matcher<MachineType>& type_matcher, - const Matcher<WriteBarrierKind>& write_barrier_matcher, - const Matcher<Node*>& base_matcher, - const Matcher<Node*>& index_matcher, - const Matcher<Node*>& value_matcher, - const Matcher<Node*>& effect_matcher, - const Matcher<Node*>& control_matcher) { - return MakeMatcher(new IsStoreMatcher( - type_matcher, write_barrier_matcher, base_matcher, index_matcher, - value_matcher, effect_matcher, control_matcher)); -} - - -#define IS_BINOP_MATCHER(Name) \ - Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ - const Matcher<Node*>& rhs_matcher) { \ - return MakeMatcher( \ - new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ - } -IS_BINOP_MATCHER(Word32And) -IS_BINOP_MATCHER(Word32Sar) -IS_BINOP_MATCHER(Word32Equal) -IS_BINOP_MATCHER(Word64And) -IS_BINOP_MATCHER(Word64Sar) -IS_BINOP_MATCHER(Word64Shl) -IS_BINOP_MATCHER(Word64Equal) -IS_BINOP_MATCHER(Int32AddWithOverflow) -#undef IS_BINOP_MATCHER - - -#define IS_UNOP_MATCHER(Name) \ - Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \ - return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \ - } -IS_UNOP_MATCHER(ConvertInt64ToInt32) -IS_UNOP_MATCHER(ChangeInt32ToFloat64) -#undef IS_UNOP_MATCHER - -} // namespace compiler -} // namespace internal -} // namespace v8 diff --git a/deps/v8/test/compiler-unittests/node-matchers.h b/deps/v8/test/compiler-unittests/node-matchers.h deleted file mode 100644 index 09da07a7f5..0000000000 --- a/deps/v8/test/compiler-unittests/node-matchers.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_COMPILER_UNITTESTS_NODE_MATCHERS_H_ -#define V8_COMPILER_UNITTESTS_NODE_MATCHERS_H_ - -#include "src/compiler/machine-operator.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace v8 { -namespace internal { - -// Forward declarations. -class HeapObject; -template <class T> -class PrintableUnique; - -namespace compiler { - -// Forward declarations. -class Node; - -using testing::Matcher; - -Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, - const Matcher<Node*>& control_matcher); -Matcher<Node*> IsHeapConstant( - const Matcher<PrintableUnique<HeapObject> >& value_matcher); -Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher); -Matcher<Node*> IsPhi(const Matcher<Node*>& value0_matcher, - const Matcher<Node*>& value1_matcher, - const Matcher<Node*>& merge_matcher); -Matcher<Node*> IsProjection(const Matcher<int32_t>& index_matcher, - const Matcher<Node*>& base_matcher); - -Matcher<Node*> IsLoad(const Matcher<MachineType>& type_matcher, - const Matcher<Node*>& base_matcher, - const Matcher<Node*>& index_matcher, - const Matcher<Node*>& effect_matcher); -Matcher<Node*> IsStore(const Matcher<MachineType>& type_matcher, - const Matcher<WriteBarrierKind>& write_barrier_matcher, - const Matcher<Node*>& base_matcher, - const Matcher<Node*>& index_matcher, - const Matcher<Node*>& value_matcher, - const Matcher<Node*>& effect_matcher, - const Matcher<Node*>& control_matcher); -Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher, - const Matcher<Node*>& rhs_matcher); -Matcher<Node*> IsConvertInt64ToInt32(const Matcher<Node*>& input_matcher); -Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher); - -} // namespace compiler -} // namespace internal -} // namespace v8 - -#endif // V8_COMPILER_UNITTESTS_NODE_MATCHERS_H_ diff --git a/deps/v8/test/compiler-unittests/testcfg.py b/deps/v8/test/compiler-unittests/testcfg.py deleted file mode 100644 index 4eec956f7e..0000000000 --- a/deps/v8/test/compiler-unittests/testcfg.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2014 the V8 project authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import os -import shutil - -from testrunner.local import commands -from testrunner.local import testsuite -from testrunner.local import utils -from testrunner.objects import testcase - - -class CompilerUnitTestsSuite(testsuite.TestSuite): - def __init__(self, name, root): - super(CompilerUnitTestsSuite, self).__init__(name, root) - - def ListTests(self, context): - shell = os.path.abspath(os.path.join(context.shell_dir, self.shell())) - if utils.IsWindows(): - shell += ".exe" - output = commands.Execute(context.command_prefix + - [shell, "--gtest_list_tests"] + - context.extra_flags) - if output.exit_code != 0: - print output.stdout - print output.stderr - return [] - tests = [] - test_case = '' - for test_desc in output.stdout.strip().split(): - if test_desc.endswith('.'): - test_case = test_desc - else: - test = testcase.TestCase(self, test_case + test_desc, dependency=None) - tests.append(test) - tests.sort() - return tests - - def GetFlagsForTestCase(self, testcase, context): - return (testcase.flags + ["--gtest_filter=" + testcase.path] + - ["--gtest_random_seed=%s" % context.random_seed] + - ["--gtest_print_time=0"] + - context.mode_flags) - - def shell(self): - return "compiler-unittests" - - -def GetSuite(name, root): - return CompilerUnitTestsSuite(name, root) diff --git a/deps/v8/test/fuzz-natives/fuzz-natives.status b/deps/v8/test/fuzz-natives/fuzz-natives.status index 7165c3845a..c81188aef8 100644 --- a/deps/v8/test/fuzz-natives/fuzz-natives.status +++ b/deps/v8/test/fuzz-natives/fuzz-natives.status @@ -33,7 +33,7 @@ # TODO(danno): Fix these internal function that are only callable form stubs # and un-blacklist them! - "CompileUnoptimized": [SKIP], + "CompileLazy": [SKIP], "NotifyDeoptimized": [SKIP], "NotifyStubFailure": [SKIP], "NewSloppyArguments": [SKIP], diff --git a/deps/v8/test/heap-unittests/heap-unittests.status b/deps/v8/test/heap-unittests/heap-unittests.status new file mode 100644 index 0000000000..d439913ccf --- /dev/null +++ b/deps/v8/test/heap-unittests/heap-unittests.status @@ -0,0 +1,6 @@ +# Copyright 2014 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +[ +] diff --git a/deps/v8/test/intl/intl.status b/deps/v8/test/intl/intl.status index 007943a323..d48d695165 100644 --- a/deps/v8/test/intl/intl.status +++ b/deps/v8/test/intl/intl.status @@ -25,10 +25,9 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# The following tests use getDefaultTimeZone(). [ [ALWAYS, { + # The following tests use getDefaultTimeZone(). 'date-format/resolved-options': [FAIL], 'date-format/timezone': [FAIL], 'general/v8Intl-exists': [FAIL], diff --git a/deps/v8/test/libplatform-unittests/libplatform-unittests.status b/deps/v8/test/libplatform-unittests/libplatform-unittests.status new file mode 100644 index 0000000000..d439913ccf --- /dev/null +++ b/deps/v8/test/libplatform-unittests/libplatform-unittests.status @@ -0,0 +1,6 @@ +# Copyright 2014 the V8 project authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +[ +] diff --git a/deps/v8/test/message/message.status b/deps/v8/test/message/message.status index 00f6e34720..234bf0f35c 100644 --- a/deps/v8/test/message/message.status +++ b/deps/v8/test/message/message.status @@ -25,10 +25,9 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# All tests in the bug directory are expected to fail. [ [ALWAYS, { + # All tests in the bug directory are expected to fail. 'bugs/*': [FAIL], }], # ALWAYS ] diff --git a/deps/v8/test/mjsunit/array-sort.js b/deps/v8/test/mjsunit/array-sort.js index 3fa623a656..62755426ad 100644 --- a/deps/v8/test/mjsunit/array-sort.js +++ b/deps/v8/test/mjsunit/array-sort.js @@ -404,3 +404,47 @@ function cmpTest(a, b) { return a.val - b.val; } arr.sort(cmpTest); + +function TestSortDoesNotDependOnObjectPrototypeHasOwnProperty() { + Array.prototype.sort.call({ + __proto__: { hasOwnProperty: null, 0: 1 }, + length: 5 + }); + + var arr = new Array(2); + Object.defineProperty(arr, 0, { get: function() {}, set: function() {} }); + arr.hasOwnProperty = null; + arr.sort(); +} + +TestSortDoesNotDependOnObjectPrototypeHasOwnProperty(); + +function TestSortDoesNotDependOnArrayPrototypePush() { + // InsertionSort is used for arrays which length <= 22 + var arr = []; + for (var i = 0; i < 22; i++) arr[i] = {}; + Array.prototype.push = function() { + fail('Should not call push'); + }; + arr.sort(); + + // Quicksort is used for arrays which length > 22 + // Arrays which length > 1000 guarantee GetThirdIndex is executed + arr = []; + for (var i = 0; i < 2000; ++i) arr[i] = {}; + arr.sort(); +} + +TestSortDoesNotDependOnArrayPrototypePush(); + +function TestSortDoesNotDependOnArrayPrototypeSort() { + var arr = []; + for (var i = 0; i < 2000; i++) arr[i] = {}; + var sortfn = Array.prototype.sort; + Array.prototype.sort = function() { + fail('Should not call sort'); + }; + sortfn.call(arr); +} + +TestSortDoesNotDependOnArrayPrototypeSort(); diff --git a/deps/v8/test/mjsunit/asm/int32array-unaligned.js b/deps/v8/test/mjsunit/asm/int32array-unaligned.js new file mode 100644 index 0000000000..698ec5e312 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/int32array-unaligned.js @@ -0,0 +1,43 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function Module(stdlib, foreign, heap) { + "use asm"; + var MEM32 = new stdlib.Int32Array(heap); + function load(i) { + i = i|0; + i = MEM32[i >> 2] | 0; + return i; + } + function store(i, v) { + i = i|0; + v = v|0; + MEM32[i >> 2] = v; + } + return { load: load, store: store }; +} + +var m = Module(this, {}, new ArrayBuffer(1024)); + +m.store(0, 0x12345678); +m.store(4, -1); +m.store(8, -1); +for (var i = 0; i < 4; ++i) { + assertEquals(0x12345678, m.load(i)); +} +for (var i = 4; i < 12; ++i) { + assertEquals(-1, m.load(i)); +} +for (var j = 4; j < 8; ++j) { + m.store(j, 0x11223344); + for (var i = 0; i < 4; ++i) { + assertEquals(0x12345678, m.load(i)); + } + for (var i = 4; i < 8; ++i) { + assertEquals(0x11223344, m.load(i)); + } + for (var i = 8; i < 12; ++i) { + assertEquals(-1, m.load(i)); + } +} diff --git a/deps/v8/test/mjsunit/asm/math-abs.js b/deps/v8/test/mjsunit/asm/math-abs.js new file mode 100644 index 0000000000..6387749e03 --- /dev/null +++ b/deps/v8/test/mjsunit/asm/math-abs.js @@ -0,0 +1,84 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function Module(stdlib) { + "use asm"; + + var abs = stdlib.Math.abs; + + // f: double -> double + function f(a) { + a = +a; + return +abs(a); + } + + // g: unsigned -> double + function g(a) { + a = a>>>0; + return +abs(a); + } + + // h: signed -> double + function h(a) { + a = a|0; + return +abs(a); + } + + return { f: f, g: g, h: h }; +} + +var m = Module({ Math: Math }); +var f = m.f; +var g = m.g; +var h = m.h; + +assertTrue(isNaN(f(NaN))); +assertTrue(isNaN(f(undefined))); +assertTrue(isNaN(f(function() {}))); + +assertEquals("Infinity", String(1/f(0))); +assertEquals("Infinity", String(1/f(-0))); +assertEquals("Infinity", String(f(Infinity))); +assertEquals("Infinity", String(f(-Infinity))); + +assertEquals(0, f(0)); +assertEquals(0.1, f(0.1)); +assertEquals(0.5, f(0.5)); +assertEquals(0.1, f(-0.1)); +assertEquals(0.5, f(-0.5)); +assertEquals(1, f(1)); +assertEquals(1.1, f(1.1)); +assertEquals(1.5, f(1.5)); +assertEquals(1, f(-1)); +assertEquals(1.1, f(-1.1)); +assertEquals(1.5, f(-1.5)); + +assertEquals(0, g(0)); +assertEquals(0, g(0.1)); +assertEquals(0, g(0.5)); +assertEquals(0, g(-0.1)); +assertEquals(0, g(-0.5)); +assertEquals(1, g(1)); +assertEquals(1, g(1.1)); +assertEquals(1, g(1.5)); +assertEquals(4294967295, g(-1)); +assertEquals(4294967295, g(-1.1)); +assertEquals(4294967295, g(-1.5)); + +assertEquals(0, h(0)); +assertEquals(0, h(0.1)); +assertEquals(0, h(0.5)); +assertEquals(0, h(-0.1)); +assertEquals(0, h(-0.5)); +assertEquals(1, h(1)); +assertEquals(1, h(1.1)); +assertEquals(1, h(1.5)); +assertEquals(1, h(-1)); +assertEquals(1, h(-1.1)); +assertEquals(1, h(-1.5)); + +assertEquals(Number.MIN_VALUE, f(Number.MIN_VALUE)); +assertEquals(Number.MIN_VALUE, f(-Number.MIN_VALUE)); +assertEquals(Number.MAX_VALUE, f(Number.MAX_VALUE)); +assertEquals(Number.MAX_VALUE, f(-Number.MAX_VALUE)); diff --git a/deps/v8/test/mjsunit/asm/math-fround.js b/deps/v8/test/mjsunit/asm/math-fround.js new file mode 100644 index 0000000000..b1d37e904e --- /dev/null +++ b/deps/v8/test/mjsunit/asm/math-fround.js @@ -0,0 +1,38 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function Module(stdlib) { + "use asm"; + + var fround = stdlib.Math.fround; + + // f: double -> float + function f(a) { + a = +a; + return fround(a); + } + + return { f: f }; +} + +var f = Module({ Math: Math }).f; + +assertTrue(isNaN(f(NaN))); +assertTrue(isNaN(f(undefined))); +assertTrue(isNaN(f(function() {}))); + +assertEquals("Infinity", String(1/f(0))); +assertEquals("-Infinity", String(1/f(-0))); +assertEquals("Infinity", String(f(Infinity))); +assertEquals("-Infinity", String(f(-Infinity))); +assertEquals("Infinity", String(f(1E200))); +assertEquals("-Infinity", String(f(-1E200))); +assertEquals("Infinity", String(1/f(1E-300))); +assertEquals("-Infinity", String(1/f(-1E-300))); + +assertEquals(0, f(0)); +assertEquals(1, f(1)); +assertEquals(1.5, f(1.5)); +assertEquals(1.3370000123977661, f(1.337)); +assertEquals(-4.300000190734863, f(-4.3)); diff --git a/deps/v8/test/mjsunit/compiler/opt-next-call.js b/deps/v8/test/mjsunit/compiler/opt-next-call.js new file mode 100644 index 0000000000..6366c7d72e --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/opt-next-call.js @@ -0,0 +1,13 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function foo() { + return "fooed"; +} + +%OptimizeFunctionOnNextCall(foo); +assertEquals("fooed", foo()); +assertOptimized(foo); diff --git a/deps/v8/test/mjsunit/compiler/osr-warm.js b/deps/v8/test/mjsunit/compiler/osr-warm.js index 65ada1e114..73e1fd5cd2 100644 --- a/deps/v8/test/mjsunit/compiler/osr-warm.js +++ b/deps/v8/test/mjsunit/compiler/osr-warm.js @@ -35,7 +35,7 @@ function f1(x) { } assertEquals(0, f1(1)); -assertEquals(0, f1(10000000)); +assertEquals(0, f1(200000)); function f2(x) { var sum = 1; @@ -47,4 +47,4 @@ function f2(x) { } assertEquals(2, f2(1)); -assertEquals(10000001, f2(10000000)); +assertEquals(200001, f2(200000)); diff --git a/deps/v8/test/cctest/test-libplatform-worker-thread.cc b/deps/v8/test/mjsunit/compiler/regress-411262.js index ba6b51fd02..ffbfe2e823 100644 --- a/deps/v8/test/cctest/test-libplatform-worker-thread.cc +++ b/deps/v8/test/mjsunit/compiler/regress-411262.js @@ -1,4 +1,4 @@ -// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright 2014 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,41 +25,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "src/v8.h" +// Flags: --allow-natives-syntax -#include "src/libplatform/task-queue.h" -#include "src/libplatform/worker-thread.h" -#include "test/cctest/cctest.h" -#include "test/cctest/test-libplatform.h" - -using namespace v8::internal; -using namespace v8::platform; - - -TEST(WorkerThread) { - TaskQueue queue; - TaskCounter task_counter; - - TestTask* task1 = new TestTask(&task_counter, true); - TestTask* task2 = new TestTask(&task_counter, true); - TestTask* task3 = new TestTask(&task_counter, true); - TestTask* task4 = new TestTask(&task_counter, true); - - WorkerThread* thread1 = new WorkerThread(&queue); - WorkerThread* thread2 = new WorkerThread(&queue); - - CHECK_EQ(4, task_counter.GetCount()); - - queue.Append(task1); - queue.Append(task2); - queue.Append(task3); - queue.Append(task4); - - // TaskQueue DCHECKs that it is empty in its destructor. - queue.Terminate(); - - delete thread1; - delete thread2; - - CHECK_EQ(0, task_counter.GetCount()); +function b() { +} +function f() { + b.apply(this, arguments); } + +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/compiler/shift-shr.js b/deps/v8/test/mjsunit/compiler/shift-shr.js new file mode 100644 index 0000000000..a300b2a5c9 --- /dev/null +++ b/deps/v8/test/mjsunit/compiler/shift-shr.js @@ -0,0 +1,26 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --noopt-safe-uint32-operations + +// Check the results of `left >>> right`. The result is always unsigned (and +// therefore positive). +function test_shr(left) { + var errors = 0; + + for (var i = 1; i < 1024; i++) { + var temp = left >>> i; + if (temp < 0) { + errors++; + } + } + + return errors; +} + +assertEquals(0, test_shr(1)); +%OptimizeFunctionOnNextCall(test_shr); +for (var i = 5; i >= -5; i--) { + assertEquals(0, test_shr(i)); +} diff --git a/deps/v8/test/mjsunit/cross-realm-filtering.js b/deps/v8/test/mjsunit/cross-realm-filtering.js index 902cceb58f..9523e8cc1a 100644 --- a/deps/v8/test/mjsunit/cross-realm-filtering.js +++ b/deps/v8/test/mjsunit/cross-realm-filtering.js @@ -70,72 +70,3 @@ assertSame(Realm.shared.caller_1, Realm.shared.result_1); Realm.eval(realms[0], script); assertSame(Realm.shared.caller_0, Realm.shared.result_0); assertSame(null, Realm.shared.result_1); - - -// Check function constructor. -var ctor_script = "Function.constructor"; -var ctor_a_script = - "(function() { return Function.constructor.apply(this, ['return 1;']); })"; -var ctor_b_script = "Function.constructor.bind(this, 'return 1;')"; -var ctor_c_script = - "(function() { return Function.constructor.call(this, 'return 1;'); })"; -Realm.shared = { - ctor_0 : Realm.eval(realms[0], ctor_script), - ctor_1 : Realm.eval(realms[1], ctor_script), - ctor_a_0 : Realm.eval(realms[0], ctor_a_script), - ctor_a_1 : Realm.eval(realms[1], ctor_a_script), - ctor_b_0 : Realm.eval(realms[0], ctor_b_script), - ctor_b_1 : Realm.eval(realms[1], ctor_b_script), - ctor_c_0 : Realm.eval(realms[0], ctor_c_script), - ctor_c_1 : Realm.eval(realms[1], ctor_c_script), -} - -var script_0 = " \ - var ctor_0 = Realm.shared.ctor_0; \ - Realm.shared.direct_0 = ctor_0('return 1'); \ - Realm.shared.indirect_0 = (function() { return ctor_0('return 1;'); })(); \ - Realm.shared.apply_0 = ctor_0.apply(this, ['return 1']); \ - Realm.shared.bind_0 = ctor_0.bind(this, 'return 1')(); \ - Realm.shared.call_0 = ctor_0.call(this, 'return 1'); \ - Realm.shared.a_0 = Realm.shared.ctor_a_0(); \ - Realm.shared.b_0 = Realm.shared.ctor_b_0(); \ - Realm.shared.c_0 = Realm.shared.ctor_c_0(); \ -"; - -script = script_0 + script_0.replace(/_0/g, "_1"); - -Realm.eval(realms[0], script); -assertSame(1, Realm.shared.direct_0()); -assertSame(1, Realm.shared.indirect_0()); -assertSame(1, Realm.shared.apply_0()); -assertSame(1, Realm.shared.bind_0()); -assertSame(1, Realm.shared.call_0()); -assertSame(1, Realm.shared.a_0()); -assertSame(1, Realm.shared.b_0()); -assertSame(1, Realm.shared.c_0()); -assertSame(undefined, Realm.shared.direct_1); -assertSame(undefined, Realm.shared.indirect_1); -assertSame(undefined, Realm.shared.apply_1); -assertSame(undefined, Realm.shared.bind_1); -assertSame(undefined, Realm.shared.call_1); -assertSame(1, Realm.shared.a_1()); -assertSame(undefined, Realm.shared.b_1); -assertSame(1, Realm.shared.c_1()); - -Realm.eval(realms[1], script); -assertSame(undefined, Realm.shared.direct_0); -assertSame(undefined, Realm.shared.indirect_0); -assertSame(undefined, Realm.shared.apply_0); -assertSame(undefined, Realm.shared.bind_0); -assertSame(undefined, Realm.shared.call_0); -assertSame(1, Realm.shared.a_0()); -assertSame(undefined, Realm.shared.b_0); -assertSame(1, Realm.shared.c_1()); -assertSame(1, Realm.shared.direct_1()); -assertSame(1, Realm.shared.indirect_1()); -assertSame(1, Realm.shared.apply_1()); -assertSame(1, Realm.shared.bind_1()); -assertSame(1, Realm.shared.call_1()); -assertSame(1, Realm.shared.a_1()); -assertSame(1, Realm.shared.b_1()); -assertSame(1, Realm.shared.c_1()); diff --git a/deps/v8/test/mjsunit/debug-backtrace-text.js b/deps/v8/test/mjsunit/debug-backtrace-text.js index 61648fa4e2..3bfaeb0dad 100644 --- a/deps/v8/test/mjsunit/debug-backtrace-text.js +++ b/deps/v8/test/mjsunit/debug-backtrace-text.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --expose-debug-as debug +// Flags: --expose-debug-as debug --turbo-deoptimization // The functions used for testing backtraces. function Point(x, y) { diff --git a/deps/v8/test/mjsunit/debug-break-inline.js b/deps/v8/test/mjsunit/debug-break-inline.js index 4418fa8d1b..3ef4d4eafe 100644 --- a/deps/v8/test/mjsunit/debug-break-inline.js +++ b/deps/v8/test/mjsunit/debug-break-inline.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --expose-debug-as debug --allow-natives-syntax +// Flags: --expose-debug-as debug --allow-natives-syntax --turbo-deoptimization // This test tests that deoptimization due to debug breaks works for // inlined functions where the full-code is generated before the diff --git a/deps/v8/test/mjsunit/debug-clearbreakpointgroup.js b/deps/v8/test/mjsunit/debug-clearbreakpointgroup.js index 0cfc5c9583..137dfecbec 100644 --- a/deps/v8/test/mjsunit/debug-clearbreakpointgroup.js +++ b/deps/v8/test/mjsunit/debug-clearbreakpointgroup.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization // Get the Debug object exposed from the debug context global object. var Debug = debug.Debug diff --git a/deps/v8/test/mjsunit/debug-evaluate-arguments.js b/deps/v8/test/mjsunit/debug-evaluate-arguments.js index 92b745f1da..9765f19370 100644 --- a/deps/v8/test/mjsunit/debug-evaluate-arguments.js +++ b/deps/v8/test/mjsunit/debug-evaluate-arguments.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --expose-debug-as debug +// Flags: --expose-debug-as debug --turbo-deoptimization // Get the Debug object exposed from the debug context global object. Debug = debug.Debug diff --git a/deps/v8/test/mjsunit/debug-evaluate-closure.js b/deps/v8/test/mjsunit/debug-evaluate-closure.js index 778defd0ab..cf507b57d2 100644 --- a/deps/v8/test/mjsunit/debug-evaluate-closure.js +++ b/deps/v8/test/mjsunit/debug-evaluate-closure.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug --allow-natives-syntax +// Flags: --turbo-deoptimization Debug = debug.Debug; var listened = false; diff --git a/deps/v8/test/mjsunit/debug-evaluate-with.js b/deps/v8/test/mjsunit/debug-evaluate-with.js index c19a707432..3f3310f9f5 100644 --- a/deps/v8/test/mjsunit/debug-evaluate-with.js +++ b/deps/v8/test/mjsunit/debug-evaluate-with.js @@ -26,6 +26,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization + // Get the Debug object exposed from the debug context global object. Debug = debug.Debug diff --git a/deps/v8/test/mjsunit/debug-receiver.js b/deps/v8/test/mjsunit/debug-receiver.js index 21cdde84a2..2d5d2e08de 100644 --- a/deps/v8/test/mjsunit/debug-receiver.js +++ b/deps/v8/test/mjsunit/debug-receiver.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --expose-debug-as debug +// Flags: --expose-debug-as debug --turbo-deoptimization // Get the Debug object exposed from the debug context global object. Debug = debug.Debug; diff --git a/deps/v8/test/mjsunit/debug-scopes.js b/deps/v8/test/mjsunit/debug-scopes.js index ce37d24023..4823496e3c 100644 --- a/deps/v8/test/mjsunit/debug-scopes.js +++ b/deps/v8/test/mjsunit/debug-scopes.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --expose-debug-as debug --allow-natives-syntax +// Flags: --expose-debug-as debug --allow-natives-syntax --turbo-deoptimization // The functions used for testing backtraces. They are at the top to make the // testing of source line/column easier. diff --git a/deps/v8/test/mjsunit/debug-script.js b/deps/v8/test/mjsunit/debug-script.js index 5b5e75962f..5ffada11ba 100644 --- a/deps/v8/test/mjsunit/debug-script.js +++ b/deps/v8/test/mjsunit/debug-script.js @@ -59,7 +59,7 @@ for (i = 0; i < scripts.length; i++) { } // This has to be updated if the number of native scripts change. -assertTrue(named_native_count == 25 || named_native_count == 26); +assertTrue(named_native_count == 26 || named_native_count == 27); // Only the 'gc' extension is loaded. assertEquals(1, extension_count); // This script and mjsunit.js has been loaded. If using d8, d8 loads diff --git a/deps/v8/test/mjsunit/debug-step-2.js b/deps/v8/test/mjsunit/debug-step-2.js index 502b426ee2..5fe7466cb7 100644 --- a/deps/v8/test/mjsunit/debug-step-2.js +++ b/deps/v8/test/mjsunit/debug-step-2.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization // This test tests that full code compiled without debug break slots // is recompiled with debug break slots when debugging is started. diff --git a/deps/v8/test/mjsunit/debug-stepin-property-function-call.js b/deps/v8/test/mjsunit/debug-stepin-property-function-call.js new file mode 100644 index 0000000000..081fb24fb7 --- /dev/null +++ b/deps/v8/test/mjsunit/debug-stepin-property-function-call.js @@ -0,0 +1,153 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --expose-debug-as debug --nocrankshaft +// Get the Debug object exposed from the debug context global object. +Debug = debug.Debug + +var exception = null; +var state = 1; + +// Simple debug event handler which first time will cause 'step in' action +// to get into g.call and than check that execution is stopped inside +// function 'g'. +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + if (state == 1) { + exec_state.prepareStep(Debug.StepAction.StepIn, 3); + state = 2; + } else if (state == 2) { + assertTrue(event_data.sourceLineText().indexOf("Expected to step") > 0, + "source line: \"" + event_data.sourceLineText() + "\""); + state = 3; + } + } + } catch(e) { + print("Exception: " + e); + exception = e; + } +}; + +// Add the debug event listener. +Debug.setListener(listener); + +var count = 0; +var obj = { + fun: function() { + ++count; + return count; // Expected to step + } +}; +obj.fun2 = obj.fun; + +function testCall_Dots() { + debugger; + obj.fun(); +} + +function testCall_Quotes() { + debugger; + obj["fun"](); +} + +function testCall_Call() { + debugger; + obj.fun.call(obj); +} + +function testCall_Apply() { + debugger; + obj.fun.apply(obj); +} + +function testCall_Variable() { + var functionName = "fun"; + debugger; + obj[functionName](); +} + +function testCall_Fun2() { + debugger; + obj.fun2(); +} + +function testCall_InternStrings() { + var cache = { "fun": "fun" }; + var functionName = "fu" + "n"; + debugger; + obj[cache[functionName]](); +} + +function testCall_ViaFunRef() { + var functionName = "fu" + "n"; + var funRef = obj[functionName]; + debugger; + funRef(); +} + +// bug 2888 +function testCall_RuntimeVariable1() { + var functionName = "fu" + "n"; + debugger; + obj[functionName](); +} + +// bug 2888 +function testCall_RuntimeVariable2() { + var functionName = "un".replace(/u/, "fu"); + debugger; + obj[functionName](); +} + +// bug 2888 +function testCall_RuntimeVariable3() { + var expr = "fu" + "n"; + const functionName = expr; + assertEquals("fun", functionName); + debugger; + obj[functionName](); +} + +var functionsCalled = 0; +for (var n in this) { + if (n.substr(0, 4) != 'test' || typeof this[n] !== "function") { + continue; + } + state = 1; + print("Running " + n + "..."); + this[n](); + ++functionsCalled; + assertNull(exception, n); + assertEquals(3, state, n); + assertEquals(functionsCalled, count, n); +} + +assertEquals(11, functionsCalled); + +// Get rid of the debug event listener. +Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/deopt-global-accessor.js b/deps/v8/test/mjsunit/deopt-global-accessor.js new file mode 100644 index 0000000000..5c544a0fa0 --- /dev/null +++ b/deps/v8/test/mjsunit/deopt-global-accessor.js @@ -0,0 +1,23 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +x = 1; +x = 2; +x = 3; + +function f() { + return x; +} + +f(); +f(); +f(); +%OptimizeFunctionOnNextCall(f); +f(); + +Object.defineProperty(this, "x", {get:function() { return 100; }}); + +assertEquals(100, f()); diff --git a/deps/v8/test/mjsunit/es6/arguments-iterator.js b/deps/v8/test/mjsunit/es6/arguments-iterator.js new file mode 100644 index 0000000000..a65bf8bad5 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/arguments-iterator.js @@ -0,0 +1,230 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + + +// Note in general that "arguments.foo" and "var o = arguments; o.foo" +// are treated differently by full-codegen, and so both cases need to be +// tested. + +function TestDirectArgumentsIteratorProperty() { + assertTrue(arguments.hasOwnProperty(Symbol.iterator)); + assertFalse(arguments.propertyIsEnumerable(Symbol.iterator)); + var descriptor = Object.getOwnPropertyDescriptor(arguments, Symbol.iterator); + assertTrue(descriptor.writable); + assertFalse(descriptor.enumerable); + assertTrue(descriptor.configurable); + assertEquals(descriptor.value, [].values); + assertEquals(arguments[Symbol.iterator], [].values); +} +TestDirectArgumentsIteratorProperty(); + + +function TestIndirectArgumentsIteratorProperty() { + var o = arguments; + assertTrue(o.hasOwnProperty(Symbol.iterator)); + assertFalse(o.propertyIsEnumerable(Symbol.iterator)); + assertEquals(o[Symbol.iterator], [].values); +} +TestIndirectArgumentsIteratorProperty(); + + +function assertIteratorResult(value, done, result) { + assertEquals({value: value, done: done}, result); +} + + +function TestDirectValues1(a, b, c) { + var iterator = arguments[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + assertIteratorResult(c, false, iterator.next()); + assertIteratorResult(undefined, true, iterator.next()); +} +TestDirectValues1(1, 2, 3); + + +function TestIndirectValues1(a, b, c) { + var args = arguments; + var iterator = args[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + assertIteratorResult(c, false, iterator.next()); + assertIteratorResult(undefined, true, iterator.next()); +} +TestIndirectValues1(1, 2, 3); + + +function TestDirectValues2(a, b, c) { + var iterator = arguments[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + assertIteratorResult(c, false, iterator.next()); + assertIteratorResult(undefined, true, iterator.next()); + + arguments[3] = 4; + arguments.length = 4; + assertIteratorResult(undefined, true, iterator.next()); +} +TestDirectValues2(1, 2, 3); + + +function TestIndirectValues2(a, b, c) { + var args = arguments; + var iterator = args[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + assertIteratorResult(c, false, iterator.next()); + assertIteratorResult(undefined, true, iterator.next()); + + arguments[3] = 4; + arguments.length = 4; + assertIteratorResult(undefined, true, iterator.next()); +} +TestIndirectValues2(1, 2, 3); + + +function TestDirectValues3(a, b, c) { + var iterator = arguments[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + + arguments.length = 2; + assertIteratorResult(undefined, true, iterator.next()); +} +TestDirectValues3(1, 2, 3); + + +function TestIndirectValues3(a, b, c) { + var args = arguments; + var iterator = args[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + + arguments.length = 2; + assertIteratorResult(undefined, true, iterator.next()); +} +TestIndirectValues3(1, 2, 3); + + +function TestDirectValues4(a, b, c) { + var iterator = arguments[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + assertIteratorResult(c, false, iterator.next()); + + arguments.length = 4; + assertIteratorResult(undefined, false, iterator.next()); + assertIteratorResult(undefined, true, iterator.next()); +} +TestDirectValues4(1, 2, 3); + + +function TestIndirectValues4(a, b, c) { + var args = arguments; + var iterator = args[Symbol.iterator](); + assertIteratorResult(a, false, iterator.next()); + assertIteratorResult(b, false, iterator.next()); + assertIteratorResult(c, false, iterator.next()); + + arguments.length = 4; + assertIteratorResult(undefined, false, iterator.next()); + assertIteratorResult(undefined, true, iterator.next()); +} +TestIndirectValues4(1, 2, 3); + + +function TestForOf() { + var i = 0; + for (var value of arguments) { + assertEquals(arguments[i++], value); + } + + assertEquals(arguments.length, i); +} +TestForOf(1, 2, 3, 4, 5); + + +function TestAssignmentToIterator() { + var i = 0; + arguments[Symbol.iterator] = [].entries; + for (var entry of arguments) { + assertEquals([i, arguments[i]], entry); + i++; + } + + assertEquals(arguments.length, i); +} +TestAssignmentToIterator(1, 2, 3, 4, 5); + + +function TestArgumentsMutation() { + var i = 0; + for (var x of arguments) { + assertEquals(arguments[i], x); + arguments[i+1] *= 2; + i++; + } + + assertEquals(arguments.length, i); +} +TestArgumentsMutation(1, 2, 3, 4, 5); + + +function TestSloppyArgumentsAliasing(a0, a1, a2, a3, a4) { + var i = 0; + for (var x of arguments) { + assertEquals(arguments[i], x); + a0 = a1; a1 = a2; a3 = a4; + i++; + } + + assertEquals(arguments.length, i); +} +TestSloppyArgumentsAliasing(1, 2, 3, 4, 5); + + +function TestStrictArgumentsAliasing(a0, a1, a2, a3, a4) { + "use strict"; + var i = 0; + for (var x of arguments) { + a0 = a1; a1 = a2; a3 = a4; + assertEquals(arguments[i], x); + i++; + } + + assertEquals(arguments.length, i); +} +TestStrictArgumentsAliasing(1, 2, 3, 4, 5); + + +function TestArgumentsAsProto() { + "use strict"; + + var o = {__proto__:arguments}; + assertSame([].values, o[Symbol.iterator]); + // Make o dict-mode. + %OptimizeObjectForAddingMultipleProperties(o, 0); + assertFalse(o.hasOwnProperty(Symbol.iterator)); + assertSame([].values, o[Symbol.iterator]); + o[Symbol.iterator] = 10; + assertTrue(o.hasOwnProperty(Symbol.iterator)); + assertEquals(10, o[Symbol.iterator]); + assertSame([].values, arguments[Symbol.iterator]); + + // Frozen o. + o = Object.freeze({__proto__:arguments}); + assertSame([].values, o[Symbol.iterator]); + assertFalse(o.hasOwnProperty(Symbol.iterator)); + assertSame([].values, o[Symbol.iterator]); + // This should throw, but currently it doesn't, because + // ExecutableAccessorInfo callbacks don't see the current strict mode. + // See note in accessors.cc:SetPropertyOnInstanceIfInherited. + o[Symbol.iterator] = 10; + assertFalse(o.hasOwnProperty(Symbol.iterator)); + assertEquals([].values, o[Symbol.iterator]); + assertSame([].values, arguments[Symbol.iterator]); +} +TestArgumentsAsProto(); diff --git a/deps/v8/test/mjsunit/es6/array-iterator.js b/deps/v8/test/mjsunit/es6/array-iterator.js index 63a7415b96..b24ee5712f 100644 --- a/deps/v8/test/mjsunit/es6/array-iterator.js +++ b/deps/v8/test/mjsunit/es6/array-iterator.js @@ -175,10 +175,9 @@ function TestForArrayValues() { assertEquals(8, buffer.length); - for (var i = 0; i < buffer.length - 1; i++) { + for (var i = 0; i < buffer.length; i++) { assertSame(array[i], buffer[i]); } - assertTrue(isNaN(buffer[buffer.length - 1])); } TestForArrayValues(); @@ -210,10 +209,9 @@ function TestForArrayEntries() { assertEquals(8, buffer.length); - for (var i = 0; i < buffer.length - 1; i++) { + for (var i = 0; i < buffer.length; i++) { assertSame(array[i], buffer[i][1]); } - assertTrue(isNaN(buffer[buffer.length - 1][1])); for (var i = 0; i < buffer.length; i++) { assertEquals(i, buffer[i][0]); @@ -232,10 +230,9 @@ function TestForArray() { assertEquals(8, buffer.length); - for (var i = 0; i < buffer.length - 1; i++) { + for (var i = 0; i < buffer.length; i++) { assertSame(array[i], buffer[i]); } - assertTrue(isNaN(buffer[buffer.length - 1])); } TestForArrayValues(); diff --git a/deps/v8/test/mjsunit/es6/collections.js b/deps/v8/test/mjsunit/es6/collections.js index 1e2f232ee8..940c0b9d1f 100644 --- a/deps/v8/test/mjsunit/es6/collections.js +++ b/deps/v8/test/mjsunit/es6/collections.js @@ -117,7 +117,8 @@ function TestMapBehavior2(m) { TestMapping(m, i / 10, new Object); TestMapping(m, 'key-' + i, new Object); } - var keys = [ +0, -0, +Infinity, -Infinity, true, false, null, undefined ]; + // -0 is handled in TestMinusZeroMap + var keys = [ 0, +Infinity, -Infinity, true, false, null, undefined ]; for (var i = 0; i < keys.length; i++) { TestMapping(m, keys[i], new Object); } @@ -495,24 +496,26 @@ for (var i = 9; i >= 0; i--) { (function TestMinusZeroSet() { - var m = new Set(); - m.add(0); - m.add(-0); - assertEquals(1, m.size); - assertTrue(m.has(0)); - assertTrue(m.has(-0)); + var s = new Set(); + s.add(-0); + assertSame(0, s.values().next().value); + s.add(0); + assertEquals(1, s.size); + assertTrue(s.has(0)); + assertTrue(s.has(-0)); })(); (function TestMinusZeroMap() { var m = new Map(); - m.set(0, 'plus'); m.set(-0, 'minus'); + assertSame(0, m.keys().next().value); + m.set(0, 'plus'); assertEquals(1, m.size); assertTrue(m.has(0)); assertTrue(m.has(-0)); - assertEquals('minus', m.get(0)); - assertEquals('minus', m.get(-0)); + assertEquals('plus', m.get(0)); + assertEquals('plus', m.get(-0)); })(); @@ -1015,6 +1018,9 @@ function TestSetConstructor(ctor) { assertThrows(function() { new ctor({}); }, TypeError); + assertThrows(function() { + new ctor(true); + }, TypeError); // @@iterator not callable assertThrows(function() { @@ -1141,6 +1147,46 @@ TestSetConstructorNextNotAnObject(Set); TestSetConstructorNextNotAnObject(WeakSet); +(function TestWeakSetConstructorNonObjectKeys() { + assertThrows(function() { + new WeakSet([1]); + }, TypeError); +})(); + + +function TestSetConstructorIterableValue(ctor) { + 'use strict'; + // Strict mode is required to prevent implicit wrapping in the getter. + Object.defineProperty(Number.prototype, Symbol.iterator, { + get: function() { + assertEquals('object', typeof this); + return function() { + return oneAndTwo.keys(); + }; + }, + configurable: true + }); + + var set = new ctor(42); + assertSize(2, set); + assertTrue(set.has(k1)); + assertTrue(set.has(k2)); + + delete Number.prototype[Symbol.iterator]; +} +TestSetConstructorIterableValue(Set); +TestSetConstructorIterableValue(WeakSet); + + +(function TestSetConstructorStringValue() { + var s = new Set('abc'); + assertSize(3, s); + assertTrue(s.has('a')); + assertTrue(s.has('b')); + assertTrue(s.has('c')); +})(); + + function TestMapConstructor(ctor) { var m = new ctor(null); assertSize(0, m); @@ -1152,6 +1198,9 @@ function TestMapConstructor(ctor) { assertThrows(function() { new ctor({}); }, TypeError); + assertThrows(function() { + new ctor(true); + }, TypeError); // @@iterator not callable assertThrows(function() { @@ -1286,3 +1335,34 @@ function TestMapConstructorIteratorNotObjectValues(ctor) { } TestMapConstructorIteratorNotObjectValues(Map); TestMapConstructorIteratorNotObjectValues(WeakMap); + + +(function TestWeakMapConstructorNonObjectKeys() { + assertThrows(function() { + new WeakMap([[1, 2]]) + }, TypeError); +})(); + + +function TestMapConstructorIterableValue(ctor) { + 'use strict'; + // Strict mode is required to prevent implicit wrapping in the getter. + Object.defineProperty(Number.prototype, Symbol.iterator, { + get: function() { + assertEquals('object', typeof this); + return function() { + return oneAndTwo.entries(); + }; + }, + configurable: true + }); + + var map = new ctor(42); + assertSize(2, map); + assertEquals(1, map.get(k1)); + assertEquals(2, map.get(k2)); + + delete Number.prototype[Symbol.iterator]; +} +TestMapConstructorIterableValue(Map); +TestMapConstructorIterableValue(WeakMap); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-by-default-reject-handler.js b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-by-default-reject-handler.js new file mode 100644 index 0000000000..63151df016 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/debug-promises/reject-caught-by-default-reject-handler.js @@ -0,0 +1,86 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug --allow-natives-syntax + +// Test debug events when we only listen to uncaught exceptions and +// there is only a default reject handler for the to-be-rejected Promise. +// We expect two Exception debug events: +// - when the first Promise is rejected and only has default reject handlers. +// - when the default reject handler passes the rejection on. + +Debug = debug.Debug; + +var expected_events = 2; +var log = []; + +var resolve, reject; +var p0 = new Promise(function(res, rej) { resolve = res; reject = rej; }); +var p1 = p0.then(function() { + log.push("p0.then"); + return Promise.reject(new Error("123")); +}); +var p2 = p1.then(function() { + log.push("p1.then"); +}); + +var q = new Promise(function(res, rej) { + log.push("resolve q"); + res(); +}); + +q.then(function() { + log.push("resolve p"); + resolve(); +}) + + +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Exception) { + expected_events--; + assertTrue(expected_events >= 0); + assertTrue(event_data.uncaught()); + assertTrue(event_data.promise() instanceof Promise); + if (expected_events == 1) { + // p1 is rejected, uncaught except for its default reject handler. + assertEquals(0, exec_state.frameCount()); + assertSame(p1, event_data.promise()); + } else { + // p2 is rejected by p1's default reject handler. + assertEquals(0, exec_state.frameCount()); + assertSame(p2, event_data.promise()); + } + } + } catch (e) { + %AbortJS(e + "\n" + e.stack); + } +} + +Debug.setBreakOnUncaughtException(); +Debug.setListener(listener); + +log.push("end main"); + +function testDone(iteration) { + function checkResult() { + try { + assertTrue(iteration < 10); + if (expected_events === 0) { + assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log); + } else { + testDone(iteration + 1); + } + } catch (e) { + %AbortJS(e + "\n" + e.stack); + } + } + + // Run testDone through the Object.observe processing loop. + var dummy = {}; + Object.observe(dummy, checkResult); + dummy.dummy = dummy; +} + +testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.js new file mode 100644 index 0000000000..36b5565e5f --- /dev/null +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-caught-by-default-reject-handler.js @@ -0,0 +1,87 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug --allow-natives-syntax + +// Test debug events when we only listen to uncaught exceptions and +// there is only a default reject handler for the to-be-rejected Promise. +// We expect two Exception debug events: +// - when the first Promise is rejected and only has default reject handlers. +// - when the default reject handler passes the rejection on. + +Debug = debug.Debug; + +var expected_events = 2; +var log = []; + +var resolve, reject; +var p0 = new Promise(function(res, rej) { resolve = res; reject = rej; }); +var p1 = p0.then(function() { + log.push("p0.then"); + throw new Error("123"); // event +}); +var p2 = p1.then(function() { + log.push("p1.then"); +}); + +var q = new Promise(function(res, rej) { + log.push("resolve q"); + res(); +}); + +q.then(function() { + log.push("resolve p"); + resolve(); +}) + + +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Exception) { + expected_events--; + assertTrue(expected_events >= 0); + assertTrue(event_data.uncaught()); + assertTrue(event_data.promise() instanceof Promise); + if (expected_events == 1) { + // p1 is rejected, uncaught except for its default reject handler. + assertTrue( + exec_state.frame(0).sourceLineText().indexOf("// event") > 0); + assertSame(p1, event_data.promise()); + } else { + // p2 is rejected by p1's default reject handler. + assertEquals(0, exec_state.frameCount()); + assertSame(p2, event_data.promise()); + } + } + } catch (e) { + %AbortJS(e + "\n" + e.stack); + } +} + +Debug.setBreakOnUncaughtException(); +Debug.setListener(listener); + +log.push("end main"); + +function testDone(iteration) { + function checkResult() { + try { + assertTrue(iteration < 10); + if (expected_events === 0) { + assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log); + } else { + testDone(iteration + 1); + } + } catch (e) { + %AbortJS(e + "\n" + e.stack); + } + } + + // Run testDone through the Object.observe processing loop. + var dummy = {}; + Object.observe(dummy, checkResult); + dummy.dummy = dummy; +} + +testDone(0); diff --git a/deps/v8/test/mjsunit/es6/debug-promises/throw-eventually-caught.js b/deps/v8/test/mjsunit/es6/debug-promises/throw-eventually-caught.js new file mode 100644 index 0000000000..19610f77e8 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/debug-promises/throw-eventually-caught.js @@ -0,0 +1,42 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug --allow-natives-syntax + +// Test debug events when we only listen to uncaught exceptions and +// there is a catch handler for the to-be-rejected Promise. +// We expect no Exception debug events, since the default reject handler passes +// the rejection on to a user-defined reject handler. + +Debug = debug.Debug; + +var resolve, reject; +var p0 = new Promise(function(res, rej) { resolve = res; reject = rej; }); + +var p1 = p0.then(function() { + throw new Error(); +}); + +var p2 = p1.then(function() { }); +var p3 = p2.catch(function() { }); + +var q = new Promise(function(res, rej) { + res(); +}); + +q.then(function() { + resolve(); +}) + + +function listener(event, exec_state, event_data, data) { + try { + assertTrue(event != Debug.DebugEvent.Exception); + } catch (e) { + %AbortJS(e + "\n" + e.stack); + } +} + +Debug.setBreakOnUncaughtException(); +Debug.setListener(listener); diff --git a/deps/v8/test/mjsunit/es6/debug-stepin-generators.js b/deps/v8/test/mjsunit/es6/debug-stepin-generators.js new file mode 100644 index 0000000000..f48c5ef75f --- /dev/null +++ b/deps/v8/test/mjsunit/es6/debug-stepin-generators.js @@ -0,0 +1,45 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug + +Debug = debug.Debug +var exception = null; +var yields = 0; + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + try { + var source = exec_state.frame(0).sourceLineText(); + print(source); + if (/stop stepping/.test(source)) return; + if (/yield/.test(source)) yields++; + exec_state.prepareStep(Debug.StepAction.StepIn, 1); + } catch (e) { + print(e, e.stack); + exception = e; + } +}; + +Debug.setListener(listener); + +function* g() { + for (var i = 0; i < 3; ++i) { + yield i; + } +} + +var i = g(); +debugger; +for (var num of g()) {} +i.next(); + +print(); // stop stepping + +// Not stepped into. +i.next(); +i.next(); + +assertNull(exception); +assertEquals(4, yields); diff --git a/deps/v8/test/mjsunit/harmony/generators-debug-liveedit.js b/deps/v8/test/mjsunit/es6/generators-debug-liveedit.js index 341ef483c5..6f0c443afc 100644 --- a/deps/v8/test/mjsunit/harmony/generators-debug-liveedit.js +++ b/deps/v8/test/mjsunit/es6/generators-debug-liveedit.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --harmony-generators +// Flags: --expose-debug-as debug var Debug = debug.Debug; var LiveEdit = Debug.LiveEdit; diff --git a/deps/v8/test/mjsunit/harmony/generators-debug-scopes.js b/deps/v8/test/mjsunit/es6/generators-debug-scopes.js index ad0ea53de5..d55e5612de 100644 --- a/deps/v8/test/mjsunit/harmony/generators-debug-scopes.js +++ b/deps/v8/test/mjsunit/es6/generators-debug-scopes.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --harmony-generators +// Flags: --expose-debug-as debug var Debug = debug.Debug; diff --git a/deps/v8/test/mjsunit/harmony/generators-iteration.js b/deps/v8/test/mjsunit/es6/generators-iteration.js index 1a793678d9..b6fcdaa487 100644 --- a/deps/v8/test/mjsunit/harmony/generators-iteration.js +++ b/deps/v8/test/mjsunit/es6/generators-iteration.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-generators --expose-gc +// Flags: --expose-gc // Test generator iteration. diff --git a/deps/v8/test/mjsunit/es6/generators-mirror.js b/deps/v8/test/mjsunit/es6/generators-mirror.js new file mode 100644 index 0000000000..6925285882 --- /dev/null +++ b/deps/v8/test/mjsunit/es6/generators-mirror.js @@ -0,0 +1,84 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug +// Test the mirror object for functions. + +function *generator(f) { + "use strict"; + yield; + f(); + yield; +} + +function MirrorRefCache(json_refs) { + var tmp = eval('(' + json_refs + ')'); + this.refs_ = []; + for (var i = 0; i < tmp.length; i++) { + this.refs_[tmp[i].handle] = tmp[i]; + } +} + +MirrorRefCache.prototype.lookup = function(handle) { + return this.refs_[handle]; +} + +function TestGeneratorMirror(g, test) { + // Create mirror and JSON representation. + var mirror = debug.MakeMirror(g); + var serializer = debug.MakeMirrorSerializer(); + var json = JSON.stringify(serializer.serializeValue(mirror)); + var refs = new MirrorRefCache( + JSON.stringify(serializer.serializeReferencedObjects())); + + // Check the mirror hierachy. + assertTrue(mirror instanceof debug.Mirror); + assertTrue(mirror instanceof debug.ValueMirror); + assertTrue(mirror instanceof debug.ObjectMirror); + assertTrue(mirror instanceof debug.GeneratorMirror); + + // Check the mirror properties. + assertTrue(mirror.isGenerator()); + assertEquals('generator', mirror.type()); + assertFalse(mirror.isPrimitive()); + assertEquals('Generator', mirror.className()); + + assertTrue(mirror.receiver().isUndefined()); + assertEquals(generator, mirror.func().value()); + + test(mirror); +} + +var iter = generator(function () { + assertEquals('running', debug.MakeMirror(iter).status()); +}) + +// Note that line numbers are 0-based, not 1-based. +function assertSourceLocation(loc, line, column) { + assertEquals(line, loc.line); + assertEquals(column, loc.column); +} + +TestGeneratorMirror(iter, function (mirror) { + assertEquals('suspended', mirror.status()) + assertSourceLocation(mirror.sourceLocation(), 7, 19); +}); + +iter.next(); +TestGeneratorMirror(iter, function (mirror) { + assertEquals('suspended', mirror.status()) + assertSourceLocation(mirror.sourceLocation(), 9, 2); +}); + +iter.next(); +TestGeneratorMirror(iter, function (mirror) { + assertEquals('suspended', mirror.status()) + assertSourceLocation(mirror.sourceLocation(), 11, 2); +}); + +iter.next(); +TestGeneratorMirror(iter, function (mirror) { + assertEquals('closed', mirror.status()) + assertEquals(undefined, mirror.sourceLocation()); +}); diff --git a/deps/v8/test/mjsunit/harmony/generators-objects.js b/deps/v8/test/mjsunit/es6/generators-objects.js index c1cda07db4..8a052ff5e6 100644 --- a/deps/v8/test/mjsunit/harmony/generators-objects.js +++ b/deps/v8/test/mjsunit/es6/generators-objects.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-generators --harmony-scoping --allow-natives-syntax +// Flags: --harmony-scoping --allow-natives-syntax // Test instantations of generators. diff --git a/deps/v8/test/mjsunit/harmony/generators-parsing.js b/deps/v8/test/mjsunit/es6/generators-parsing.js index 21790b0e13..e4408365d3 100644 --- a/deps/v8/test/mjsunit/harmony/generators-parsing.js +++ b/deps/v8/test/mjsunit/es6/generators-parsing.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-generators - // Test basic generator syntax. // Yield statements. diff --git a/deps/v8/test/mjsunit/harmony/generators-poisoned-properties.js b/deps/v8/test/mjsunit/es6/generators-poisoned-properties.js index 39a583ec97..44d823a503 100644 --- a/deps/v8/test/mjsunit/harmony/generators-poisoned-properties.js +++ b/deps/v8/test/mjsunit/es6/generators-poisoned-properties.js @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-generators - function assertIteratorResult(value, done, result) { assertEquals({value: value, done: done}, result); } diff --git a/deps/v8/test/mjsunit/harmony/generators-relocation.js b/deps/v8/test/mjsunit/es6/generators-relocation.js index 4074235c82..6babb148be 100644 --- a/deps/v8/test/mjsunit/harmony/generators-relocation.js +++ b/deps/v8/test/mjsunit/es6/generators-relocation.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --harmony-generators +// Flags: --expose-debug-as debug var Debug = debug.Debug; diff --git a/deps/v8/test/mjsunit/harmony/generators-runtime.js b/deps/v8/test/mjsunit/es6/generators-runtime.js index 9fb7075492..8fa70b62e0 100644 --- a/deps/v8/test/mjsunit/harmony/generators-runtime.js +++ b/deps/v8/test/mjsunit/es6/generators-runtime.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-generators - // Test aspects of the generator runtime. // See: diff --git a/deps/v8/test/mjsunit/es6/iteration-semantics.js b/deps/v8/test/mjsunit/es6/iteration-semantics.js index 7849b29abe..544c94d915 100644 --- a/deps/v8/test/mjsunit/es6/iteration-semantics.js +++ b/deps/v8/test/mjsunit/es6/iteration-semantics.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-generators --harmony-scoping --harmony-proxies +// Flags: --harmony-scoping --harmony-proxies // Test for-of semantics. diff --git a/deps/v8/test/mjsunit/es6/math-expm1.js b/deps/v8/test/mjsunit/es6/math-expm1.js index b4e31a959b..7cbb1b485f 100644 --- a/deps/v8/test/mjsunit/es6/math-expm1.js +++ b/deps/v8/test/mjsunit/es6/math-expm1.js @@ -8,19 +8,22 @@ assertTrue(isNaN(Math.expm1(NaN))); assertTrue(isNaN(Math.expm1(function() {}))); assertTrue(isNaN(Math.expm1({ toString: function() { return NaN; } }))); assertTrue(isNaN(Math.expm1({ valueOf: function() { return "abc"; } }))); -assertEquals("Infinity", String(1/Math.expm1(0))); -assertEquals("-Infinity", String(1/Math.expm1(-0))); -assertEquals("Infinity", String(Math.expm1(Infinity))); +assertEquals(Infinity, 1/Math.expm1(0)); +assertEquals(-Infinity, 1/Math.expm1(-0)); +assertEquals(Infinity, Math.expm1(Infinity)); assertEquals(-1, Math.expm1(-Infinity)); -for (var x = 0.1; x < 700; x += 0.1) { + +// Sanity check: +// Math.expm1(x) stays reasonably close to Math.exp(x) - 1 for large values. +for (var x = 1; x < 700; x += 0.25) { var expected = Math.exp(x) - 1; - assertEqualsDelta(expected, Math.expm1(x), expected * 1E-14); + assertEqualsDelta(expected, Math.expm1(x), expected * 1E-15); expected = Math.exp(-x) - 1; - assertEqualsDelta(expected, Math.expm1(-x), -expected * 1E-14); + assertEqualsDelta(expected, Math.expm1(-x), -expected * 1E-15); } -// Values close to 0: +// Approximation for values close to 0: // Use six terms of Taylor expansion at 0 for exp(x) as test expectation: // exp(x) - 1 == exp(0) + exp(0) * x + x * x / 2 + ... - 1 // == x + x * x / 2 + x * x * x / 6 + ... @@ -32,7 +35,44 @@ function expm1(x) { 1/362880 + x * (1/3628800)))))))))); } +// Sanity check: +// Math.expm1(x) stays reasonabliy close to the Taylor series for small values. for (var x = 1E-1; x > 1E-300; x *= 0.8) { var expected = expm1(x); - assertEqualsDelta(expected, Math.expm1(x), expected * 1E-14); + assertEqualsDelta(expected, Math.expm1(x), expected * 1E-15); } + + +// Tests related to the fdlibm implementation. +// Test overflow. +assertEquals(Infinity, Math.expm1(709.8)); +// Test largest double value. +assertEquals(Infinity, Math.exp(1.7976931348623157e308)); +// Cover various code paths. +assertEquals(-1, Math.expm1(-56 * Math.LN2)); +assertEquals(-1, Math.expm1(-50)); +// Test most negative double value. +assertEquals(-1, Math.expm1(-1.7976931348623157e308)); +// Test argument reduction. +// Cases for 0.5*log(2) < |x| < 1.5*log(2). +assertEquals(Math.E - 1, Math.expm1(1)); +assertEquals(1/Math.E - 1, Math.expm1(-1)); +// Cases for 1.5*log(2) < |x|. +assertEquals(6.38905609893065, Math.expm1(2)); +assertEquals(-0.8646647167633873, Math.expm1(-2)); +// Cases where Math.expm1(x) = x. +assertEquals(0, Math.expm1(0)); +assertEquals(Math.pow(2,-55), Math.expm1(Math.pow(2,-55))); +// Tests for the case where argument reduction has x in the primary range. +// Test branch for k = 0. +assertEquals(0.18920711500272105, Math.expm1(0.25 * Math.LN2)); +// Test branch for k = -1. +assertEquals(-0.5, Math.expm1(-Math.LN2)); +// Test branch for k = 1. +assertEquals(1, Math.expm1(Math.LN2)); +// Test branch for k <= -2 || k > 56. k = -3. +assertEquals(1.4411518807585582e17, Math.expm1(57 * Math.LN2)); +// Test last branch for k < 20, k = 19. +assertEquals(524286.99999999994, Math.expm1(19 * Math.LN2)); +// Test the else branch, k = 20. +assertEquals(1048575, Math.expm1(20 * Math.LN2)); diff --git a/deps/v8/test/mjsunit/es6/math-hyperbolic.js b/deps/v8/test/mjsunit/es6/math-hyperbolic.js index 1ceb95182b..8970f6ef65 100644 --- a/deps/v8/test/mjsunit/es6/math-hyperbolic.js +++ b/deps/v8/test/mjsunit/es6/math-hyperbolic.js @@ -25,6 +25,9 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// TODO(3468): we rely on a precise Math.exp. +// Flags: --no-fast-math + [Math.sinh, Math.cosh, Math.tanh, Math.asinh, Math.acosh, Math.atanh]. forEach(function(fun) { assertTrue(isNaN(fun(NaN))); @@ -66,14 +69,14 @@ function test_id(fun, rev, value) { }); -assertEquals("Infinity", String(Math.cosh(-Infinity))); -assertEquals("Infinity", String(Math.cosh(Infinity))); -assertEquals("Infinity", String(Math.cosh("-Infinity"))); -assertEquals("Infinity", String(Math.cosh("Infinity"))); +assertEquals(Infinity, Math.cosh(-Infinity)); +assertEquals(Infinity, Math.cosh(Infinity)); +assertEquals(Infinity, Math.cosh("-Infinity")); +assertEquals(Infinity, Math.cosh("Infinity")); -assertEquals("-Infinity", String(Math.atanh(-1))); -assertEquals("Infinity", String(Math.atanh(1))); +assertEquals(-Infinity, Math.atanh(-1)); +assertEquals(Infinity, Math.atanh(1)); // Math.atanh(x) is NaN for |x| > 1 and NaN [1.000000000001, Math.PI, 10000000, 2, Infinity, NaN].forEach(function(x) { @@ -82,6 +85,8 @@ assertEquals("Infinity", String(Math.atanh(1))); }); +assertEquals(0, Math.sinh(0)); +assertEquals(-Infinity, 1/Math.sinh(-0)); assertEquals(1, Math.tanh(Infinity)); assertEquals(-1, Math.tanh(-Infinity)); assertEquals(1, Math.cosh(0)); @@ -97,15 +102,13 @@ assertEquals("Infinity", String(Math.acosh(Infinity))); // Some random samples. -assertEqualsDelta(0.5210953054937, Math.sinh(0.5), 1E-12); -assertEqualsDelta(74.203210577788, Math.sinh(5), 1E-12); -assertEqualsDelta(-0.5210953054937, Math.sinh(-0.5), 1E-12); -assertEqualsDelta(-74.203210577788, Math.sinh(-5), 1E-12); +assertEqualsDelta(74.20321057778875, Math.sinh(5), 1E-12); +assertEqualsDelta(-74.20321057778875, Math.sinh(-5), 1E-12); -assertEqualsDelta(1.1276259652063, Math.cosh(0.5), 1E-12); -assertEqualsDelta(74.209948524787, Math.cosh(5), 1E-12); -assertEqualsDelta(1.1276259652063, Math.cosh(-0.5), 1E-12); -assertEqualsDelta(74.209948524787, Math.cosh(-5), 1E-12); +assertEqualsDelta(1.1276259652063807, Math.cosh(0.5), 1E-12); +assertEqualsDelta(74.20994852478785, Math.cosh(5), 1E-12); +assertEqualsDelta(1.1276259652063807, Math.cosh(-0.5), 1E-12); +assertEqualsDelta(74.20994852478785, Math.cosh(-5), 1E-12); assertEqualsDelta(0.4621171572600, Math.tanh(0.5), 1E-12); assertEqualsDelta(0.9999092042625, Math.tanh(5), 1E-12); @@ -134,3 +137,52 @@ assertEqualsDelta(-0.1003353477311, Math.atanh(-0.1), 1E-12); [1-(1E-16), 0, 1E-10, 1E-50].forEach(function(x) { assertEqualsDelta(Math.atanh(x), -Math.atanh(-x), 1E-12); }); + + +// Implementation-specific tests for sinh. +// Case |x| < 2^-28 +assertEquals(Math.pow(2, -29), Math.sinh(Math.pow(2, -29))); +assertEquals(-Math.pow(2, -29), Math.sinh(-Math.pow(2, -29))); +// Case |x| < 1 +assertEquals(0.5210953054937474, Math.sinh(0.5)); +assertEquals(-0.5210953054937474, Math.sinh(-0.5)); +// sinh(10*log(2)) = 1048575/2048, case |x| < 22 +assertEquals(1048575/2048, Math.sinh(10*Math.LN2)); +assertEquals(-1048575/2048, Math.sinh(-10*Math.LN2)); +// Case |x| < 22 +assertEquals(11013.232874703393, Math.sinh(10)); +assertEquals(-11013.232874703393, Math.sinh(-10)); +// Case |x| in [22, log(maxdouble)] +assertEquals(2.1474836479999983e9, Math.sinh(32*Math.LN2)); +assertEquals(-2.1474836479999983e9, Math.sinh(-32*Math.LN2)); +// Case |x| in [22, log(maxdouble)] +assertEquals(1.3440585709080678e43, Math.sinh(100)); +assertEquals(-1.3440585709080678e43, Math.sinh(-100)); +// No overflow, case |x| in [log(maxdouble), threshold] +assertEquals(1.7976931348621744e308, Math.sinh(710.4758600739439)); +assertEquals(-1.7976931348621744e308, Math.sinh(-710.4758600739439)); +// Overflow, case |x| > threshold +assertEquals(Infinity, Math.sinh(710.475860073944)); +assertEquals(-Infinity, Math.sinh(-710.475860073944)); +assertEquals(Infinity, Math.sinh(1000)); +assertEquals(-Infinity, Math.sinh(-1000)); + +// Implementation-specific tests for cosh. +// Case |x| < 2^-55 +assertEquals(1, Math.cosh(Math.pow(2, -56))); +assertEquals(1, Math.cosh(-Math.pow(2, -56))); +// Case |x| < 1/2*log(2). cosh(Math.LN2/4) = (sqrt(2)+1)/2^(5/4) +assertEquals(1.0150517651282178, Math.cosh(Math.LN2/4)); +assertEquals(1.0150517651282178, Math.cosh(-Math.LN2/4)); +// Case 1/2*log(2) < |x| < 22. cosh(10*Math.LN2) = 1048577/2048 +assertEquals(512.00048828125, Math.cosh(10*Math.LN2)); +assertEquals(512.00048828125, Math.cosh(-10*Math.LN2)); +// Case 22 <= |x| < log(maxdouble) +assertEquals(2.1474836479999983e9, Math.cosh(32*Math.LN2)); +assertEquals(2.1474836479999983e9, Math.cosh(-32*Math.LN2)); +// Case log(maxdouble) <= |x| <= overflowthreshold +assertEquals(1.7976931348621744e308, Math.cosh(710.4758600739439)); +assertEquals(1.7976931348621744e308, Math.cosh(-710.4758600739439)); +// Overflow. +assertEquals(Infinity, Math.cosh(710.475860073944)); +assertEquals(Infinity, Math.cosh(-710.475860073944)); diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-2681.js b/deps/v8/test/mjsunit/es6/regress/regress-2681.js index 9841d84843..8d8e4adb38 100644 --- a/deps/v8/test/mjsunit/harmony/regress/regress-2681.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-2681.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --expose-gc --noincremental-marking --harmony-generators +// Flags: --expose-gc --noincremental-marking // Check that we are not flushing code for generators. diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-2691.js b/deps/v8/test/mjsunit/es6/regress/regress-2691.js index e17be10814..d7d0c4f175 100644 --- a/deps/v8/test/mjsunit/harmony/regress/regress-2691.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-2691.js @@ -25,8 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --harmony-generators - // Check that yield* on non-objects raises a TypeError. assertThrows('(function*() { yield* 10 })().next()', TypeError); diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-3280.js b/deps/v8/test/mjsunit/es6/regress/regress-3280.js index 2fc72cc867..2dadd02840 100644 --- a/deps/v8/test/mjsunit/harmony/regress/regress-3280.js +++ b/deps/v8/test/mjsunit/es6/regress/regress-3280.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-generators --expose-debug-as debug +// Flags: --expose-debug-as debug var Debug = debug.Debug; diff --git a/deps/v8/test/mjsunit/es6/symbols.js b/deps/v8/test/mjsunit/es6/symbols.js index 0b07002700..60737af4b9 100644 --- a/deps/v8/test/mjsunit/es6/symbols.js +++ b/deps/v8/test/mjsunit/es6/symbols.js @@ -112,7 +112,8 @@ TestValueOf() function TestToString() { for (var i in symbols) { - assertThrows(function() { String(symbols[i]) }, TypeError) + assertThrows(function() { new String(symbols[i]) }, TypeError) + assertEquals(symbols[i].toString(), String(symbols[i])) assertThrows(function() { symbols[i] + "" }, TypeError) assertThrows(function() { String(Object(symbols[i])) }, TypeError) assertTrue(isValidSymbolString(symbols[i].toString())) diff --git a/deps/v8/test/mjsunit/es6/unscopables.js b/deps/v8/test/mjsunit/es6/unscopables.js index 678536dba4..36365d2d82 100644 --- a/deps/v8/test/mjsunit/es6/unscopables.js +++ b/deps/v8/test/mjsunit/es6/unscopables.js @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-unscopables -// Flags: --harmony-collections - var global = this; var globalProto = Object.getPrototypeOf(global); diff --git a/deps/v8/test/mjsunit/harmony/array-of.js b/deps/v8/test/mjsunit/harmony/array-of.js new file mode 100644 index 0000000000..c0a8ed183e --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/array-of.js @@ -0,0 +1,164 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/source/js/src/jit-test/tests/collections + +// Flags: --harmony-arrays + + + +// Array.of makes real arrays. + +function check(a) { + assertEquals(Object.getPrototypeOf(a), Array.prototype); + assertEquals(Array.isArray(a), true); + a[9] = 9; + assertEquals(a.length, 10); +} + + +check(Array.of()); +check(Array.of(0)); +check(Array.of(0, 1, 2)); +var f = Array.of; +check(f()); + + +// Array.of basics + +var a = Array.of(); + +assertEquals(a.length, 0); +a = Array.of(undefined, null, 3.14, []); +assertEquals(a, [undefined, null, 3.14, []]); +a = []; +for (var i = 0; i < 1000; i++) + a[i] = i; +assertEquals(Array.of.apply(null, a), a); + + +// Array.of does not leave holes + +assertEquals(Array.of(undefined), [undefined]); +assertEquals(Array.of(undefined, undefined), [undefined, undefined]); +assertEquals(Array.of.apply(null, [,,undefined]), [undefined, undefined, undefined]); +assertEquals(Array.of.apply(null, Array(4)), [undefined, undefined, undefined, undefined]); + + +// Array.of can be transplanted to other classes. + +var hits = 0; +function Bag() { + hits++; +} +Bag.of = Array.of; + +hits = 0; +var actual = Bag.of("zero", "one"); +assertEquals(hits, 1); + +hits = 0; +var expected = new Bag; +expected[0] = "zero"; +expected[1] = "one"; +expected.length = 2; +assertEquals(areSame(actual, expected), true); + +hits = 0; +actual = Array.of.call(Bag, "zero", "one"); +assertEquals(hits, 1); +assertEquals(areSame(actual, expected), true); + +function areSame(object, array) { + var result = object.length == array.length; + for (var i = 0; i < object.length; i++) { + result = result && object[i] == array[i]; + } + return result; +} + + +// Array.of does not trigger prototype setters. +// (It defines elements rather than assigning to them.) + +var status = "pass"; +Object.defineProperty(Array.prototype, "0", {set: function(v) {status = "FAIL 1"}}); +assertEquals(Array.of(1)[0], 1); +assertEquals(status, "pass"); + +Object.defineProperty(Bag.prototype, "0", {set: function(v) {status = "FAIL 2"}}); +assertEquals(Bag.of(1)[0], 1); +assertEquals(status, "pass"); + + +// Array.of passes the number of arguments to the constructor it calls. + +var hits = 0; + +function Herd(n) { + assertEquals(arguments.length, 1); + assertEquals(n, 5); + hits++; +} + +Herd.of = Array.of; +Herd.of("sheep", "cattle", "elephants", "whales", "seals"); +assertEquals(hits, 1); + + +// Array.of calls a "length" setter if one is present. + +var hits = 0; +var lastObj = null, lastVal = undefined; +function setter(v) { + hits++; + lastObj = this; + lastVal = v; +} + +// when the setter is on the new object +function Pack() { + Object.defineProperty(this, "length", {set: setter}); +} +Pack.of = Array.of; +var pack = Pack.of("wolves", "cards", "cigarettes", "lies"); +assertEquals(lastObj, pack); +assertEquals(lastVal, 4); + +// when the setter is on the new object's prototype +function Bevy() {} +Object.defineProperty(Bevy.prototype, "length", {set: setter}); +Bevy.of = Array.of; +var bevy = Bevy.of("quail"); +assertEquals(lastObj, bevy); +assertEquals(lastVal, 1); + + +// Array.of does a strict assignment to the new object's .length. +// The assignment is strict even if the code we're calling from is not strict. + +function Empty() {} +Empty.of = Array.of; +Object.defineProperty(Empty.prototype, "length", {get: function() { return 0; }}); + +var nothing = new Empty; +nothing.length = 2; // no exception; this is not a strict mode assignment + +assertThrows(function() { Empty.of(); }, TypeError); + + +// Check superficial features of Array.of. + +var desc = Object.getOwnPropertyDescriptor(Array, "of"); + +assertEquals(desc.configurable, true); +assertEquals(desc.enumerable, false); +assertEquals(desc.writable, true); +assertEquals(Array.of.length, 0); +assertThrows(function() { new Array.of() }, TypeError); // not a constructor + +// When the this-value passed in is not a constructor, the result is an array. +[undefined, null, false, "cow"].forEach(function(val) { + assertEquals(Array.isArray(Array.of(val)), true); +}); diff --git a/deps/v8/test/mjsunit/harmony/arrow-functions.js b/deps/v8/test/mjsunit/harmony/arrow-functions.js index 22b1c94f7f..0ffa936991 100644 --- a/deps/v8/test/mjsunit/harmony/arrow-functions.js +++ b/deps/v8/test/mjsunit/harmony/arrow-functions.js @@ -8,7 +8,8 @@ // "new" operator on them. assertEquals("function", typeof (() => {})); assertEquals(Function.prototype, Object.getPrototypeOf(() => {})); -assertThrows("new (() => {})", TypeError); +assertThrows(function() { new (() => {}); }, TypeError); +assertFalse("prototype" in (() => {})); // Check the different syntax variations assertEquals(1, (() => 1)()); diff --git a/deps/v8/test/mjsunit/harmony/object-literals-method.js b/deps/v8/test/mjsunit/harmony/object-literals-method.js new file mode 100644 index 0000000000..71f44d10bc --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/object-literals-method.js @@ -0,0 +1,248 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --harmony-object-literals --allow-natives-syntax + + +(function TestBasics() { + var object = { + method() { + return 42; + } + }; + assertEquals(42, object.method()); +})(); + + +(function TestThis() { + var object = { + method() { + assertEquals(object, this); + } + }; + object.method(); +})(); + + +(function TestDescriptor() { + var object = { + method() { + return 42; + } + }; + + var desc = Object.getOwnPropertyDescriptor(object, 'method'); + assertTrue(desc.enumerable); + assertTrue(desc.configurable); + assertTrue(desc.writable); + assertEquals('function', typeof desc.value); + + assertEquals(42, desc.value()); +})(); + + +(function TestProto() { + var object = { + method() {} + }; + + assertEquals(Function.prototype, Object.getPrototypeOf(object.method)); +})(); + + +(function TestNotConstructable() { + var object = { + method() {} + }; + + assertThrows(function() { + new object.method; + }); +})(); + + +(function TestFunctionName() { + var object = { + method() {}, + 1() {}, + 2.0() {} + }; + var f = object.method; + assertEquals('method', f.name); + var g = object[1]; + assertEquals('1', g.name); + var h = object[2]; + assertEquals('2', h.name); +})(); + + +(function TestNoBinding() { + var method = 'local'; + var calls = 0; + var object = { + method() { + calls++; + assertEquals('local', method); + } + }; + object.method(); + assertEquals(1, calls); +})(); + + +(function TestNoPrototype() { + var object = { + method() {} + }; + var f = object.method; + assertFalse(f.hasOwnProperty('prototype')); + assertEquals(undefined, f.prototype); + + f.prototype = 42; + assertEquals(42, f.prototype); +})(); + + +(function TestToString() { + var object = { + method() { 42; } + }; + assertEquals('method() { 42; }', object.method.toString()); +})(); + + +(function TestOptimized() { + var object = { + method() { return 42; } + }; + assertEquals(42, object.method()); + assertEquals(42, object.method()); + %OptimizeFunctionOnNextCall(object.method); + assertEquals(42, object.method()); + assertFalse(object.method.hasOwnProperty('prototype')); +})(); + + +/////////////////////////////////////////////////////////////////////////////// + + +var GeneratorFunction = function*() {}.__proto__.constructor; + + +function assertIteratorResult(value, done, result) { + assertEquals({value: value, done: done}, result); +} + + +(function TestGeneratorBasics() { + var object = { + *method() { + yield 1; + } + }; + var g = object.method(); + assertIteratorResult(1, false, g.next()); + assertIteratorResult(undefined, true, g.next()); +})(); + + +(function TestGeneratorThis() { + var object = { + *method() { + yield this; + } + }; + var g = object.method(); + assertIteratorResult(object, false, g.next()); + assertIteratorResult(undefined, true, g.next()); +})(); + + +(function TestGeneratorSymbolIterator() { + var object = { + *method() {} + }; + var g = object.method(); + assertEquals(g, g[Symbol.iterator]()); +})(); + + +(function TestGeneratorDescriptor() { + var object = { + *method() { + yield 1; + } + }; + + var desc = Object.getOwnPropertyDescriptor(object, 'method'); + assertTrue(desc.enumerable); + assertTrue(desc.configurable); + assertTrue(desc.writable); + assertEquals('function', typeof desc.value); + + var g = desc.value(); + assertIteratorResult(1, false, g.next()); + assertIteratorResult(undefined, true, g.next()); +})(); + + +(function TestGeneratorProto() { + var object = { + *method() {} + }; + + assertEquals(GeneratorFunction.prototype, + Object.getPrototypeOf(object.method)); +})(); + + +(function TestGeneratorConstructable() { + var object = { + *method() { + yield 1; + } + }; + + var g = new object.method(); + assertIteratorResult(1, false, g.next()); + assertIteratorResult(undefined, true, g.next()); +})(); + + +(function TestGeneratorName() { + var object = { + *method() {}, + *1() {}, + *2.0() {} + }; + var f = object.method; + assertEquals('method', f.name); + var g = object[1]; + assertEquals('1', g.name); + var h = object[2]; + assertEquals('2', h.name); +})(); + + +(function TestGeneratorNoBinding() { + var method = 'local'; + var calls = 0; + var object = { + *method() { + calls++; + assertEquals('local', method); + } + }; + var g = object.method(); + assertIteratorResult(undefined, true, g.next()); + assertEquals(1, calls); +})(); + + +(function TestGeneratorToString() { + var object = { + *method() { yield 1; } + }; + assertEquals('*method() { yield 1; }', object.method.toString()); +})(); diff --git a/deps/v8/test/mjsunit/harmony/private.js b/deps/v8/test/mjsunit/harmony/private.js index 4b29fd863e..218094c3d5 100644 --- a/deps/v8/test/mjsunit/harmony/private.js +++ b/deps/v8/test/mjsunit/harmony/private.js @@ -83,7 +83,8 @@ TestConstructor() function TestToString() { for (var i in symbols) { - assertThrows(function() { String(symbols[i]) }, TypeError) + assertThrows(function() {new String(symbols[i]) }, TypeError) + assertEquals(symbols[i].toString(), String(symbols[i])) assertThrows(function() { symbols[i] + "" }, TypeError) assertTrue(isValidSymbolString(symbols[i].toString())) assertTrue(isValidSymbolString(Object(symbols[i]).toString())) diff --git a/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js b/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js index b982480feb..191bad301e 100644 --- a/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js +++ b/deps/v8/test/mjsunit/harmony/proxies-with-unscopables.js @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --harmony-unscopables // Flags: --harmony-proxies diff --git a/deps/v8/test/mjsunit/harmony/regexp-sticky.js b/deps/v8/test/mjsunit/harmony/regexp-sticky.js new file mode 100644 index 0000000000..bd7f646d00 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/regexp-sticky.js @@ -0,0 +1,132 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-regexps + +var re = /foo.bar/; + +assertTrue(!!"foo*bar".match(re)); +assertTrue(!!"..foo*bar".match(re)); + +var plain = /foobar/; + +assertTrue(!!"foobar".match(plain)); +assertTrue(!!"..foobar".match(plain)); + +var sticky = /foo.bar/y; + +assertTrue(!!"foo*bar".match(sticky)); +assertEquals(0, sticky.lastIndex); +assertFalse(!!"..foo*bar".match(sticky)); + +var stickyplain = /foobar/y; + +assertTrue(!!"foobar".match(stickyplain)); +assertEquals(0, stickyplain.lastIndex); +assertFalse(!!"..foobar".match(stickyplain)); + +var global = /foo.bar/g; + +assertTrue(global.test("foo*bar")); +assertFalse(global.test("..foo*bar")); +global.lastIndex = 0; +assertTrue(global.test("..foo*bar")); + +var plainglobal = /foobar/g; + +assertTrue(plainglobal.test("foobar")); +assertFalse(plainglobal.test("foobar")); +plainglobal.lastIndex = 0; +assertTrue(plainglobal.test("foobar")); + +var stickyglobal = /foo.bar/gy; + +assertTrue(stickyglobal.test("foo*bar")); +assertEquals(7, stickyglobal.lastIndex); +assertFalse(stickyglobal.test("..foo*bar")); +stickyglobal.lastIndex = 0; +assertFalse(stickyglobal.test("..foo*bar")); +stickyglobal.lastIndex = 2; +assertTrue(stickyglobal.test("..foo*bar")); +assertEquals(9, stickyglobal.lastIndex); + +var stickyplainglobal = /foobar/yg; +assertTrue(stickyplainglobal.sticky); +stickyplainglobal.sticky = false; + +assertTrue(stickyplainglobal.test("foobar")); +assertEquals(6, stickyplainglobal.lastIndex); +assertFalse(stickyplainglobal.test("..foobar")); +stickyplainglobal.lastIndex = 0; +assertFalse(stickyplainglobal.test("..foobar")); +stickyplainglobal.lastIndex = 2; +assertTrue(stickyplainglobal.test("..foobar")); +assertEquals(8, stickyplainglobal.lastIndex); + +assertEquals("/foo.bar/gy", "" + stickyglobal); +assertEquals("/foo.bar/g", "" + global); + +assertTrue(stickyglobal.sticky); +stickyglobal.sticky = false; +assertTrue(stickyglobal.sticky); + +var stickyglobal2 = new RegExp("foo.bar", "gy"); +assertTrue(stickyglobal2.test("foo*bar")); +assertEquals(7, stickyglobal2.lastIndex); +assertFalse(stickyglobal2.test("..foo*bar")); +stickyglobal2.lastIndex = 0; +assertFalse(stickyglobal2.test("..foo*bar")); +stickyglobal2.lastIndex = 2; +assertTrue(stickyglobal2.test("..foo*bar")); +assertEquals(9, stickyglobal2.lastIndex); + +assertEquals("/foo.bar/gy", "" + stickyglobal2); + +assertTrue(stickyglobal2.sticky); +stickyglobal2.sticky = false; +assertTrue(stickyglobal2.sticky); + +sticky.lastIndex = -1; // Causes sticky regexp to fail fast +assertFalse(sticky.test("..foo.bar")); +assertEquals(0, sticky.lastIndex); + +sticky.lastIndex = -1; // Causes sticky regexp to fail fast +assertFalse(!!sticky.exec("..foo.bar")); +assertEquals(0, sticky.lastIndex); + +// ES6 draft says: Even when the y flag is used with a pattern, ^ always +// matches only at the beginning of Input, or (if Multiline is true) at the +// beginning of a line. +var hat = /^foo/y; +hat.lastIndex = 2; +assertFalse(hat.test("..foo")); + +var mhat = /^foo/my; +mhat.lastIndex = 2; +assertFalse(mhat.test("..foo")); +mhat.lastIndex = 2; +assertTrue(mhat.test(".\nfoo")); diff --git a/deps/v8/test/mjsunit/harmony/regress/regress-405844.js b/deps/v8/test/mjsunit/harmony/regress/regress-405844.js new file mode 100644 index 0000000000..fbe7310d79 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/regress/regress-405844.js @@ -0,0 +1,13 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Flags: --harmony-proxies + +var proxy = Proxy.create({ fix: function() { return {}; } }); +Object.preventExtensions(proxy); +Object.observe(proxy, function(){}); + +var functionProxy = Proxy.createFunction({ fix: function() { return {}; } }, function(){}); +Object.preventExtensions(functionProxy); +Object.observe(functionProxy, function(){}); diff --git a/deps/v8/test/mjsunit/harmony/super.js b/deps/v8/test/mjsunit/harmony/super.js new file mode 100644 index 0000000000..809ba1071d --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/super.js @@ -0,0 +1,234 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Flags: --harmony-classes + + +(function TestSuperNamedLoads() { + function Base() { } + function Derived() { + this.derivedDataProperty = "xxx"; + } + Derived.prototype = Object.create(Base.prototype); + + function fBase() { return "Base " + this.toString(); } + + Base.prototype.f = fBase.toMethod(Base.prototype); + + function fDerived() { + assertEquals("Base this is Derived", super.f()); + var a = super.x; + assertEquals(15, a); + assertEquals(15, super.x); + assertEquals(27, this.x); + + return "Derived" + } + + Base.prototype.x = 15; + Base.prototype.toString = function() { return "this is Base"; }; + Derived.prototype.toString = function() { return "this is Derived"; }; + Derived.prototype.x = 27; + Derived.prototype.f = fDerived.toMethod(Derived.prototype); + + assertEquals("Base this is Base", new Base().f()); + assertEquals("Derived", new Derived().f()); +}()); + + +(function TestSuperKeywordNonMethod() { + function f() { + super.unknown(); + } + + assertThrows(f, ReferenceError); +}()); + + +(function TestGetter() { + function Base() {} + var derived; + Base.prototype = { + constructor: Base, + get x() { + assertSame(this, derived); + return this._x; + }, + _x: 'base' + }; + + function Derived() {} + Derived.__proto__ = Base; + Derived.prototype = { + __proto__: Base.prototype, + constructor: Derived, + _x: 'derived' + }; + Derived.prototype.testGetter = function() { + return super.x; + }.toMethod(Derived.prototype); + Derived.prototype.testGetterStrict = function() { + 'use strict'; + return super.x; + }.toMethod(Derived.prototype); + derived = new Derived(); + assertEquals('derived', derived.testGetter()); + derived = new Derived(); + assertEquals('derived', derived.testGetterStrict()); +}()); + + +(function TestSetter() { + function Base() {} + Base.prototype = { + constructor: Base, + get x() { + return this._x; + }, + set x(v) { + this._x = v; + }, + _x: 'base' + }; + + function Derived() {} + Derived.__proto__ = Base; + Derived.prototype = { + __proto__: Base.prototype, + constructor: Derived, + _x: 'derived' + }; + Derived.prototype.testSetter = function() { + assertEquals('foobar', super.x = 'foobar'); + assertEquals('foobarabc', super.x += 'abc'); + }.toMethod(Derived.prototype); + var d = new Derived(); + d.testSetter(); + assertEquals('base', Base.prototype._x); + assertEquals('foobarabc', d._x); + d._x = ''; + Derived.prototype.testSetterStrict = function() { + 'use strict'; + assertEquals('foobar', super.x = 'foobar'); + assertEquals('foobarabc', super.x += 'abc'); + }.toMethod(Derived.prototype); + d.testSetterStrict(); + assertEquals('base', Base.prototype._x); + assertEquals('foobarabc', d._x); +}()); + + +(function TestAccessorsOnPrimitives() { + var getCalled = false; + var setCalled = false; + function Base() {} + Base.prototype = { + constructor: Base, + get x() { + getCalled = true; + return 1; + }, + set x(v) { + setCalled = true; + return v; + }, + }; + + function Derived() {} + Derived.prototype = { + __proto__: Base.prototype, + constructor: Derived, + }; + Derived.prototype.testSetter = function() { + assertTrue(42 == this); + getCalled = false; + setCalled = false; + assertEquals(1, super.x); + assertTrue(getCalled); + assertFalse(setCalled); + + setCalled = false; + getCalled = false; + assertEquals(5, super.x = 5); + assertFalse(getCalled); + assertTrue(setCalled); + + getCalled = false; + setCalled = false; + assertEquals(6, super.x += 5); + assertTrue(getCalled); + assertTrue(setCalled); + }.toMethod(Derived.prototype); + + Derived.prototype.testSetterStrict = function() { + 'use strict'; + assertTrue(42 == this); + getCalled = false; + setCalled = false; + assertEquals(1, super.x); + assertTrue(getCalled); + assertFalse(setCalled); + + setCalled = false; + getCalled = false; + assertEquals(5, super.x = 5); + assertFalse(getCalled); + assertTrue(setCalled); + + getCalled = false; + setCalled = false; + assertEquals(6, super.x += 5); + assertTrue(getCalled); + assertTrue(setCalled); + }.toMethod(Derived.prototype); + + Derived.prototype.testSetter.call(42); + Derived.prototype.testSetterStrict.call(42); + + function DerivedFromString() {} + DerivedFromString.prototype = Object.create(String.prototype); + + function f() { + 'use strict'; + assertTrue(42 == this); + assertEquals(String.prototype.toString, super.toString); + var except = false; + try { + super.toString(); + } catch(e) { except = true; } + assertTrue(except); + } + f.toMethod(DerivedFromString.prototype).call(42); +}()); + + +(function TestSetterFailures() { + function Base() {} + function Derived() {} + Derived.prototype = { __proto__ : Base.prototype }; + Derived.prototype.mSloppy = function () { + super.x = 10; + assertEquals(undefined, super.x); + }.toMethod(Derived.prototype); + + Derived.prototype.mStrict = function () { + "use strict"; + super.x = 10; + }.toMethod(Derived.prototype); + var d = new Derived(); + d.mSloppy(); + assertEquals(undefined, d.x); + var d1 = new Derived(); + assertThrows(function() { d.mStrict(); }, ReferenceError); + assertEquals(undefined, d.x); +}()); + + +(function TestUnsupportedCases() { + function f1(x) { return super[x]; } + var o = {} + assertThrows(function(){f1.toMethod(o)(x);}, ReferenceError); + function f2() { super.x++; } + assertThrows(function(){f2.toMethod(o)();}, ReferenceError); +}()); diff --git a/deps/v8/test/mjsunit/harmony/toMethod.js b/deps/v8/test/mjsunit/harmony/toMethod.js new file mode 100644 index 0000000000..ad51b2ff38 --- /dev/null +++ b/deps/v8/test/mjsunit/harmony/toMethod.js @@ -0,0 +1,115 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Flags: --harmony-classes --allow-natives-syntax + + +(function TestSingleClass() { + function f(x) { + var a = [0, 1, 2] + return a[x]; + } + + function ClassD() { } + + assertEquals(1, f(1)); + var g = f.toMethod(ClassD.prototype); + assertEquals(1, g(1)); + assertEquals(undefined, f[%HomeObjectSymbol()]); + assertEquals(ClassD.prototype, g[%HomeObjectSymbol()]); +}()); + + +(function TestClassHierarchy() { + function f(x) { + return function g(y) { x++; return x + y; }; + } + + function Base() {} + function Derived() { } + Derived.prototype = Object.create(Base.prototype); + + var q = f(0); + assertEquals(2, q(1)); + assertEquals(3, q(1)); + var g = q.toMethod(Derived.prototype); + assertFalse(g === q); + assertEquals(4, g(1)); + assertEquals(5, q(1)); +}()); + + +(function TestErrorCases() { + var sFun = Function.prototype.toMethod; + assertThrows(function() { sFun.call({}); }, TypeError); + assertThrows(function() { sFun.call({}, {}); }, TypeError); + function f(){}; + assertThrows(function() { f.toMethod(1); }, TypeError); +}()); + + +(function TestPrototypeChain() { + var o = {}; + var o1 = {}; + function f() { } + + function g() { } + + var fMeth = f.toMethod(o); + assertEquals(o, fMeth[%HomeObjectSymbol()]); + g.__proto__ = fMeth; + assertEquals(undefined, g[%HomeObjectSymbol()]); + var gMeth = g.toMethod(o1); + assertEquals(fMeth, gMeth.__proto__); + assertEquals(o, fMeth[%HomeObjectSymbol()]); + assertEquals(o1, gMeth[%HomeObjectSymbol()]); +}()); + + +(function TestBoundFunction() { + var o = {}; + var p = {}; + + + function f(x, y, z, w) { + assertEquals(o, this); + assertEquals(1, x); + assertEquals(2, y); + assertEquals(3, z); + assertEquals(4, w); + return x+y+z+w; + } + + var fBound = f.bind(o, 1, 2, 3); + var fMeth = fBound.toMethod(p); + assertEquals(10, fMeth(4)); + assertEquals(10, fMeth.call(p, 4)); + var fBound1 = fBound.bind(o, 4); + assertEquals(10, fBound1()); + var fMethBound = fMeth.bind(o, 4); + assertEquals(10, fMethBound()); +}()); + +(function TestOptimized() { + function f(o) { + return o.x; + } + var o = {x : 15}; + assertEquals(15, f(o)); + assertEquals(15, f(o)); + %OptimizeFunctionOnNextCall(f); + assertEquals(15, f(o)); + var g = f.toMethod({}); + var o1 = {y : 1024, x : "abc"}; + assertEquals("abc", f(o1)); + assertEquals("abc", g(o1)); +} ()); + +(function TestExtensibility() { + function f() {} + Object.preventExtensions(f); + assertFalse(Object.isExtensible(f)); + var m = f.toMethod({}); + assertTrue(Object.isExtensible(m)); +}()); diff --git a/deps/v8/test/mjsunit/keyed-named-access.js b/deps/v8/test/mjsunit/keyed-named-access.js new file mode 100644 index 0000000000..11f8fb50d8 --- /dev/null +++ b/deps/v8/test/mjsunit/keyed-named-access.js @@ -0,0 +1,72 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var k = "x"; +var o1 = {x: 10}; +var o2 = {x: 11, y: 20}; +var o3 = {x: 12, y: 20, z: 100}; + +function f(o) { + var result = 0; + for (var i = 0; i < 100; i++) { + result += o[k]; + } + return result; +} + +f(o1); +f(o1); +f(o1); +%OptimizeFunctionOnNextCall(f); +assertEquals(1000, f(o1)); + +f(o2); +f(o2); +f(o2); +%OptimizeFunctionOnNextCall(f); +assertEquals(1100, f(o2)); + +f(o3); +f(o3); +f(o3); +%OptimizeFunctionOnNextCall(f); +assertEquals(1200, f(o3)); + +(function CountOperationDeoptimizationGetter() { + var global = {}; + global.__defineGetter__("A", function () { return "x"; }); + + function h() { + return "A"; + } + + function g(a, b, c) { + try { + return a + b.toString() + c; + } catch (e) { } + } + + function test(o) { + return g(1, o[h()]--, 10); + } + + test(global); + test(global); + %OptimizeFunctionOnNextCall(test); + print(test(global)); +})(); + + +(function CountOperationDeoptimizationPoint() { + function test() { + this[0, ""]--; + } + + test(); + test(); + %OptimizeFunctionOnNextCall(test); + test(); +})(); diff --git a/deps/v8/test/mjsunit/lithium/SeqStringSetChar.js b/deps/v8/test/mjsunit/lithium/SeqStringSetChar.js index 3c890a8489..c5bd1450f9 100644 --- a/deps/v8/test/mjsunit/lithium/SeqStringSetChar.js +++ b/deps/v8/test/mjsunit/lithium/SeqStringSetChar.js @@ -29,13 +29,13 @@ function MyStringFromCharCode(code, i) { var one_byte = %NewString(3, true); - %_OneByteSeqStringSetChar(one_byte, 0, code); - %_OneByteSeqStringSetChar(one_byte, 1, code); - %_OneByteSeqStringSetChar(one_byte, i, code); + %_OneByteSeqStringSetChar(0, code, one_byte); + %_OneByteSeqStringSetChar(1, code, one_byte); + %_OneByteSeqStringSetChar(i, code, one_byte); var two_byte = %NewString(3, false); - %_TwoByteSeqStringSetChar(two_byte, 0, code); - %_TwoByteSeqStringSetChar(two_byte, 1, code); - %_TwoByteSeqStringSetChar(two_byte, i, code); + %_TwoByteSeqStringSetChar(0, code, two_byte); + %_TwoByteSeqStringSetChar(1, code, two_byte); + %_TwoByteSeqStringSetChar(i, code, two_byte); return one_byte + two_byte; } diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index 228d243643..04c09777f6 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -51,6 +51,10 @@ # Issue 3389: deopt_every_n_garbage_collections is unsafe 'regress/regress-2653': [SKIP], + # This test relies on --noopt-safe-uint32-operations, which is broken. See + # issue 3487 for details. + 'compiler/shift-shr': [SKIP], + ############################################################################## # TurboFan compiler failures. @@ -59,53 +63,38 @@ # from the deoptimizer to do that. 'arguments-indirect': [PASS, NO_VARIANTS], - # TODO(mstarzinger): Sometimes the try-catch blacklist fails. - 'debug-references': [PASS, NO_VARIANTS], - 'regress/regress-263': [PASS, NO_VARIANTS], + # TODO(rossberg): Typer doesn't like contexts very much. + 'harmony/block-conflicts': [PASS, NO_VARIANTS], + 'harmony/block-for': [PASS, NO_VARIANTS], + 'harmony/block-leave': [PASS, NO_VARIANTS], + 'harmony/block-let-crankshaft': [PASS, NO_VARIANTS], + 'harmony/empty-for': [PASS, NO_VARIANTS], - # Some tests are over-restrictive about object layout. + # TODO(verwaest): Some tests are over-restrictive about object layout. 'array-constructor-feedback': [PASS, NO_VARIANTS], 'array-feedback': [PASS, NO_VARIANTS], + 'compare-known-objects-slow': [PASS, NO_VARIANTS], + 'elements-kind': [PASS, NO_VARIANTS], # Some tests are just too slow to run for now. - 'big-object-literal': [PASS, NO_VARIANTS], 'bit-not': [PASS, NO_VARIANTS], 'json2': [PASS, NO_VARIANTS], 'packed-elements': [PASS, NO_VARIANTS], 'unbox-double-arrays': [PASS, NO_VARIANTS], 'whitespaces': [PASS, NO_VARIANTS], - 'compiler/optimized-for-in': [PASS, NO_VARIANTS], 'compiler/osr-assert': [PASS, NO_VARIANTS], - 'compiler/osr-regress-max-locals': [PASS, NO_VARIANTS], - 'es7/object-observe': [PASS, NO_VARIANTS], 'regress/regress-2185-2': [PASS, NO_VARIANTS], - 'regress/regress-284': [PASS, NO_VARIANTS], - 'regress/string-set-char-deopt': [PASS, NO_VARIANTS], - 'tools/profviz': [PASS, NO_VARIANTS], - - # Support for breakpoints requires special relocation info for DebugBreak. - 'debug-clearbreakpointgroup': [PASS, NO_VARIANTS], - 'debug-step-2': [PASS, NO_VARIANTS], - 'regress/regress-debug-deopt-while-recompile': [PASS, NO_VARIANTS], - 'regress/regress-opt-after-debug-deopt': [PASS, NO_VARIANTS], # Support for %GetFrameDetails is missing and requires checkpoints. - 'debug-backtrace-text': [PASS, NO_VARIANTS], - 'debug-break-inline': [PASS, NO_VARIANTS], - 'debug-evaluate-arguments': [PASS, NO_VARIANTS], 'debug-evaluate-bool-constructor': [PASS, NO_VARIANTS], - 'debug-evaluate-closure': [PASS, NO_VARIANTS], 'debug-evaluate-const': [PASS, NO_VARIANTS], 'debug-evaluate-locals-optimized-double': [PASS, NO_VARIANTS], 'debug-evaluate-locals-optimized': [PASS, NO_VARIANTS], 'debug-evaluate-locals': [PASS, NO_VARIANTS], 'debug-evaluate-with-context': [PASS, NO_VARIANTS], - 'debug-evaluate-with': [PASS, NO_VARIANTS], 'debug-liveedit-double-call': [PASS, NO_VARIANTS], 'debug-liveedit-restart-frame': [PASS, NO_VARIANTS], - 'debug-receiver': [PASS, NO_VARIANTS], 'debug-return-value': [PASS, NO_VARIANTS], - 'debug-scopes': [PASS, NO_VARIANTS], 'debug-set-variable-value': [PASS, NO_VARIANTS], 'debug-step-stub-callfunction': [PASS, NO_VARIANTS], 'debug-stepin-accessor': [PASS, NO_VARIANTS], @@ -127,37 +116,14 @@ 'es6/debug-promises/throw-uncaught-all': [PASS, NO_VARIANTS], 'es6/debug-promises/throw-uncaught-uncaught': [PASS, NO_VARIANTS], 'es6/debug-promises/reject-uncaught-late': [PASS, NO_VARIANTS], + 'es6/debug-promises/throw-caught-by-default-reject-handler': [PASS, NO_VARIANTS], + 'es6/generators-debug-scopes': [PASS, NO_VARIANTS], 'harmony/debug-blockscopes': [PASS, NO_VARIANTS], - 'harmony/generators-debug-scopes': [PASS, NO_VARIANTS], 'regress/regress-1081309': [PASS, NO_VARIANTS], - 'regress/regress-1170187': [PASS, NO_VARIANTS], - 'regress/regress-119609': [PASS, NO_VARIANTS], - 'regress/regress-131994': [PASS, NO_VARIANTS], 'regress/regress-269': [PASS, NO_VARIANTS], - 'regress/regress-325676': [PASS, NO_VARIANTS], - 'regress/regress-crbug-107996': [PASS, NO_VARIANTS], - 'regress/regress-crbug-171715': [PASS, NO_VARIANTS], - 'regress/regress-crbug-222893': [PASS, NO_VARIANTS], 'regress/regress-crbug-259300': [PASS, NO_VARIANTS], 'regress/regress-frame-details-null-receiver': [PASS, NO_VARIANTS], - # Support for ES6 generators is missing. - 'regress-3225': [PASS, NO_VARIANTS], - 'harmony/generators-debug-liveedit': [PASS, NO_VARIANTS], - 'harmony/generators-iteration': [PASS, NO_VARIANTS], - 'harmony/generators-parsing': [PASS, NO_VARIANTS], - 'harmony/generators-poisoned-properties': [PASS, NO_VARIANTS], - 'harmony/generators-relocation': [PASS, NO_VARIANTS], - 'harmony/regress/regress-2681': [PASS, NO_VARIANTS], - 'harmony/regress/regress-2691': [PASS, NO_VARIANTS], - 'harmony/regress/regress-3280': [PASS, NO_VARIANTS], - - # Support for ES6 for-of iteration is missing. - 'es6/array-iterator': [PASS, NO_VARIANTS], - 'es6/iteration-semantics': [PASS, NO_VARIANTS], - 'es6/string-iterator': [PASS, NO_VARIANTS], - 'es6/typed-array-iterator': [PASS, NO_VARIANTS], - ############################################################################## # Too slow in debug mode with --stress-opt mode. 'compiler/regress-stacktrace-methods': [PASS, ['mode == debug', SKIP]], @@ -267,36 +233,10 @@ # TODO(mstarzinger): Takes too long with TF. 'array-sort': [PASS, NO_VARIANTS], + 'regress/regress-91008': [PASS, NO_VARIANTS], }], # 'gc_stress == True' ############################################################################## -['no_i18n', { - # Don't call runtime functions that don't exist without i18n support. - 'runtime-gen/availablelocalesof': [SKIP], - 'runtime-gen/breakiteratoradopttext': [SKIP], - 'runtime-gen/breakiteratorbreaktype': [SKIP], - 'runtime-gen/breakiteratorbreaktype': [SKIP], - 'runtime-gen/breakiteratorcurrent': [SKIP], - 'runtime-gen/breakiteratorfirst': [SKIP], - 'runtime-gen/breakiteratornext': [SKIP], - 'runtime-gen/canonicalizelanguagetag': [SKIP], - 'runtime-gen/createbreakiterator': [SKIP], - 'runtime-gen/createcollator': [SKIP], - 'runtime-gen/getdefaulticulocale': [SKIP], - 'runtime-gen/getimplfrominitializedintlobject': [SKIP], - 'runtime-gen/getlanguagetagvariants': [SKIP], - 'runtime-gen/internalcompare': [SKIP], - 'runtime-gen/internaldateformat': [SKIP], - 'runtime-gen/internaldateparse': [SKIP], - 'runtime-gen/internalnumberformat': [SKIP], - 'runtime-gen/internalnumberparse': [SKIP], - 'runtime-gen/isinitializedintlobject': [SKIP], - 'runtime-gen/isinitializedintlobjectoftype': [SKIP], - 'runtime-gen/markasinitializedintlobjectoftype': [SKIP], - 'runtime-gen/stringnormalize': [SKIP], -}], - -############################################################################## ['arch == arm64 or arch == android_arm64', { # arm64 TF timeout. @@ -348,7 +288,6 @@ 'bit-not': [PASS, SLOW], 'compiler/alloc-number': [PASS, SLOW], 'compiler/osr-assert': [PASS, SLOW], - 'compiler/osr-warm': [PASS, TIMEOUT, SLOW], 'compiler/osr-with-args': [PASS, SLOW], 'debug-scopes': [PASS, SLOW], 'generated-transition-stub': [PASS, SLOW], @@ -473,9 +412,6 @@ # Currently always deopt on minus zero 'math-floor-of-div-minus-zero': [SKIP], - - # BUG(v8:3457). - 'deserialize-reference': [SKIP], }], # 'arch == mipsel or arch == mips' ############################################################################## @@ -527,9 +463,6 @@ # Currently always deopt on minus zero 'math-floor-of-div-minus-zero': [SKIP], - - # BUG(v8:3457). - 'deserialize-reference': [SKIP], }], # 'arch == mips64el' ['arch == mips64el and simulator_run == False', { @@ -538,6 +471,9 @@ }], ############################################################################## ['system == windows', { + # TODO(mstarzinger): Too slow with turbo fan. + 'big-object-literal': [PASS, ['mode == debug', SKIP]], + # BUG(v8:3435) 'debug-script-breakpoints': [PASS, FAIL], }], # 'system == windows' @@ -574,6 +510,18 @@ # Skip long running test that times out in debug mode and goes OOM on NaCl. 'regress/regress-crbug-160010': [SKIP], + # Skip tests that timout with turbofan. + 'regress/regress-1257': [PASS, NO_VARIANTS], + 'regress/regress-2618': [PASS, NO_VARIANTS], + 'regress/regress-298269': [PASS, NO_VARIANTS], + 'regress/regress-634': [PASS, NO_VARIANTS], + 'regress/regress-91008': [PASS, NO_VARIANTS], + 'compiler/osr-alignment': [PASS, NO_VARIANTS], + 'compiler/osr-one': [PASS, NO_VARIANTS], + 'compiler/osr-two': [PASS, NO_VARIANTS], + 'stack-traces-overflow': [PASS, NO_VARIANTS], + 'mirror-object': [PASS, NO_VARIANTS], + # Bug(v8:2978). 'lithium/MathExp': [PASS, FAIL], diff --git a/deps/v8/test/mjsunit/new-string-add.js b/deps/v8/test/mjsunit/new-string-add.js deleted file mode 100644 index f5b7cbfbf2..0000000000 --- a/deps/v8/test/mjsunit/new-string-add.js +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Flags: --new-string-add - -assertEquals("ab", "a" + "b", "ll"); - -assertEquals("12", "1" + "2", "dd"); -assertEquals("123", "1" + "2" + "3", "ddd"); -assertEquals("123", 1 + "2" + "3", "ndd"); -assertEquals("123", "1" + 2 + "3", "dnd"); -assertEquals("123", "1" + "2" + 3, "ddn"); - -assertEquals("123", "1" + 2 + 3, "dnn"); -assertEquals("123", 1 + "2" + 3, "ndn"); -assertEquals("33", 1 + 2 + "3", "nnd"); - -var x = "1"; -assertEquals("12", x + 2, "vn"); -assertEquals("12", x + "2", "vd"); -assertEquals("21", 2 + x, "nv"); -assertEquals("21", "2" + x, "dv"); - -var y = "2"; -assertEquals("12", x + y, "vdvd"); - -x = 1; -assertEquals("12", x + y, "vnvd"); - -y = 2; -assertEquals(3, x + y, "vnvn"); - -x = "1"; -assertEquals("12", x + y, "vdvn"); - -y = "2"; -assertEquals("12", x + y, "vdvd2"); - -(function(x, y) { - var z = "3"; - var w = "4"; - - assertEquals("11", x + x, "xx"); - assertEquals("12", x + y, "xy"); - assertEquals("13", x + z, "xz"); - assertEquals("14", x + w, "xw"); - - assertEquals("21", y + x, "yx"); - assertEquals("22", y + y, "yy"); - assertEquals("23", y + z, "yz"); - assertEquals("24", y + w, "yw"); - - assertEquals("31", z + x, "zx"); - assertEquals("32", z + y, "zy"); - assertEquals("33", z + z, "zz"); - assertEquals("34", z + w, "zw"); - - assertEquals("41", w + x, "wx"); - assertEquals("42", w + y, "wy"); - assertEquals("43", w + z, "wz"); - assertEquals("44", w + w, "ww"); - - (function(){x = 1; z = 3;})(); - - assertEquals(2, x + x, "x'x"); - assertEquals("12", x + y, "x'y"); - assertEquals(4, x + z, "x'z'"); - assertEquals("14", x + w, "x'w"); - - assertEquals("21", y + x, "yx'"); - assertEquals("22", y + y, "yy"); - assertEquals("23", y + z, "yz'"); - assertEquals("24", y + w, "yw"); - - assertEquals(4, z + x, "z'x'"); - assertEquals("32", z + y, "z'y"); - assertEquals(6, z + z, "z'z'"); - assertEquals("34", z + w, "z'w"); - - assertEquals("41", w + x, "wx'"); - assertEquals("42", w + y, "wy"); - assertEquals("43", w + z, "wz'"); - assertEquals("44", w + w, "ww"); -})("1", "2"); - -assertEquals("142", "1" + new Number(42), "sN"); -assertEquals("421", new Number(42) + "1", "Ns"); -assertEquals(84, new Number(42) + new Number(42), "NN"); - -assertEquals("142", "1" + new String("42"), "sS"); -assertEquals("421", new String("42") + "1", "Ss"); -assertEquals("142", "1" + new String("42"), "sS"); -assertEquals("4242", new String("42") + new String("42"), "SS"); - -assertEquals("1true", "1" + true, "sb"); -assertEquals("true1", true + "1", "bs"); -assertEquals(2, true + true, "bs"); - -assertEquals("1true", "1" + new Boolean(true), "sB"); -assertEquals("true1", new Boolean(true) + "1", "Bs"); -assertEquals(2, new Boolean(true) + new Boolean(true), "Bs"); - -assertEquals("1undefined", "1" + void 0, "sv"); -assertEquals("undefined1", (void 0) + "1", "vs"); -assertTrue(isNaN(void 0 + void 0), "vv"); - -assertEquals("1null", "1" + null, "su"); -assertEquals("null1", null + "1", "us"); -assertEquals(0, null + null, "uu"); - -(function (i) { - // Check that incoming frames are merged correctly. - var x; - var y; - var z; - var w; - switch (i) { - case 1: x = 42; y = "stry"; z = "strz"; w = 42; break; - default: x = "strx", y = 42; z = "strz"; w = 42; break; - } - var resxx = x + x; - var resxy = x + y; - var resxz = x + z; - var resxw = x + w; - var resyx = y + x; - var resyy = y + y; - var resyz = y + z; - var resyw = y + w; - var reszx = z + x; - var reszy = z + y; - var reszz = z + z; - var reszw = z + w; - var reswx = w + x; - var reswy = w + y; - var reswz = w + z; - var resww = w + w; - assertEquals(84, resxx, "swxx"); - assertEquals("42stry", resxy, "swxy"); - assertEquals("42strz", resxz, "swxz"); - assertEquals(84, resxw, "swxw"); - assertEquals("stry42", resyx, "swyx"); - assertEquals("strystry", resyy, "swyy"); - assertEquals("strystrz", resyz, "swyz"); - assertEquals("stry42", resyw, "swyw"); - assertEquals("strz42", reszx, "swzx"); - assertEquals("strzstry", reszy, "swzy"); - assertEquals("strzstrz", reszz, "swzz"); - assertEquals("strz42", reszw, "swzw"); - assertEquals(84, reswx, "swwx"); - assertEquals("42stry", reswy, "swwy"); - assertEquals("42strz", reswz, "swwz"); - assertEquals(84, resww, "swww"); -})(1); - -// Generate ascii and non ascii strings from length 0 to 20. -var ascii = 'aaaaaaaaaaaaaaaaaaaa'; -var non_ascii = '\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234\u1234'; -assertEquals(20, ascii.length); -assertEquals(20, non_ascii.length); -var a = Array(21); -var b = Array(21); -for (var i = 0; i <= 20; i++) { - a[i] = ascii.substring(0, i); - b[i] = non_ascii.substring(0, i); -} - -// Add ascii and non-ascii strings generating strings with length from 0 to 20. -for (var i = 0; i <= 20; i++) { - for (var j = 0; j < i; j++) { - assertEquals(a[i], a[j] + a[i - j]) - assertEquals(b[i], b[j] + b[i - j]) - } -} diff --git a/deps/v8/test/mjsunit/number-literal.js b/deps/v8/test/mjsunit/number-literal.js new file mode 100644 index 0000000000..7191a1c76f --- /dev/null +++ b/deps/v8/test/mjsunit/number-literal.js @@ -0,0 +1,33 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function test(message, a, b, skipStrictMode) { + assertSame(eval(a), eval(b), message); + if (!skipStrictMode) { + (function() { + 'use strict'; + assertSame(eval(a), eval(b), message); + })(); + } +} + +test('hex-int', '0x20', '32'); +test('oct-int', '040', '32', true); // Octals disallowed in strict mode. +test('dec-int', '32.00', '32'); +test('dec-underflow-int', '32.00000000000000000000000000000000000000001', '32'); +test('exp-int', '3.2e1', '32'); +test('exp-int', '3200e-2', '32'); +test('overflow-inf', '1e2000', 'Infinity'); +test('overflow-inf-exact', '1.797693134862315808e+308', 'Infinity'); +test('non-overflow-inf-exact', '1.797693134862315807e+308', + '1.7976931348623157e+308'); +test('underflow-0', '1e-2000', '0'); +test('underflow-0-exact', '2.4703282292062E-324', '0'); +test('non-underflow-0-exact', '2.4703282292063E-324', '5e-324'); +test('precission-loss-high', '9007199254740992', '9007199254740993'); +test('precission-loss-low', '1.9999999999999998', '1.9999999999999997'); +test('non-canonical-literal-int', '1.0', '1'); +test('non-canonical-literal-frac', '1.50', '1.5'); +test('rounding-down', '1.12512512512512452', '1.1251251251251244'); +test('rounding-up', '1.12512512512512453', '1.1251251251251246'); diff --git a/deps/v8/test/mjsunit/object-literal.js b/deps/v8/test/mjsunit/object-literal.js index 3d0b33bd99..53188d15b8 100644 --- a/deps/v8/test/mjsunit/object-literal.js +++ b/deps/v8/test/mjsunit/object-literal.js @@ -190,3 +190,73 @@ function testKeywordProperty(keyword) { for (var i = 0; i < keywords.length; i++) { testKeywordProperty(keywords[i]); } + + +(function TestNumericNames() { + var o = { + 1: 1, + 2.: 2, + 3.0: 3, + 4e0: 4, + 5E0: 5, + 6e-0: 6, + 7E-0: 7, + 0x8: 8, + 0X9: 9, + } + assertEquals(['1', '2', '3', '4', '5', '6', '7', '8', '9'], Object.keys(o)); + + o = { + 1.2: 1.2, + 1.30: 1.3 + }; + assertEquals(['1.2', '1.3'], Object.keys(o)); +})(); + + +function TestNumericNamesGetter(expectedKeys, object) { + assertEquals(expectedKeys, Object.keys(object)); + expectedKeys.forEach(function(key) { + var descr = Object.getOwnPropertyDescriptor(object, key); + assertEquals(key, descr.get.name); + }); +} +TestNumericNamesGetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], { + get 1() {}, + get 2.() {}, + get 3.0() {}, + get 4e0() {}, + get 5E0() {}, + get 6e-0() {}, + get 7E-0() {}, + get 0x8() {}, + get 0X9() {}, +}); +TestNumericNamesGetter(['1.2', '1.3'], { + get 1.2() {}, + get 1.30() {} +}); + + +function TestNumericNamesSetter(expectedKeys, object) { + assertEquals(expectedKeys, Object.keys(object)); + expectedKeys.forEach(function(key) { + var descr = Object.getOwnPropertyDescriptor(object, key); + assertEquals(key, descr.set.name); + }); +} +TestNumericNamesSetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], { + set 1(_) {}, + set 2.(_) {}, + set 3.0(_) {}, + set 4e0(_) {}, + set 5E0(_) {}, + set 6e-0(_) {}, + set 7E-0(_) {}, + set 0x8(_) {}, + set 0X9(_) {}, +}); +TestNumericNamesSetter(['1.2', '1.3'], { + set 1.2(_) {; }, + set 1.30(_) {; } +}); diff --git a/deps/v8/test/cctest/test-libplatform-task-queue.cc b/deps/v8/test/mjsunit/regexp-not-sticky-yet.js index 630686b459..4186a63fef 100644 --- a/deps/v8/test/cctest/test-libplatform-task-queue.cc +++ b/deps/v8/test/mjsunit/regexp-not-sticky-yet.js @@ -1,4 +1,4 @@ -// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright 2014 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,72 +25,41 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "src/v8.h" +// Test that sticky regexp support is not affecting V8 when the +// --harmony-regexps flag is not on. -#include "src/libplatform/task-queue.h" -#include "test/cctest/cctest.h" -#include "test/cctest/test-libplatform.h" +assertThrows(function() { eval("/foo.bar/y"); }, SyntaxError); +assertThrows(function() { eval("/foobar/y"); }, SyntaxError); +assertThrows(function() { eval("/foo.bar/gy"); }, SyntaxError); +assertThrows(function() { eval("/foobar/gy"); }, SyntaxError); +assertThrows(function() { new RegExp("foo.bar", "y"); }, SyntaxError); +assertThrows(function() { new RegExp("foobar", "y"); }, SyntaxError); +assertThrows(function() { new RegExp("foo.bar", "gy"); }, SyntaxError); +assertThrows(function() { new RegExp("foobar", "gy"); }, SyntaxError); -using namespace v8::internal; -using namespace v8::platform; +var re = /foo.bar/; +assertEquals("/foo.bar/", "" + re); +var plain = /foobar/; +assertEquals("/foobar/", "" + plain); +re.compile("foo.bar"); +assertEquals(void 0, re.sticky); -TEST(TaskQueueBasic) { - TaskCounter task_counter; +var global = /foo.bar/g; +assertEquals("/foo.bar/g", "" + global); +var plainglobal = /foobar/g; +assertEquals("/foobar/g", "" + plainglobal); - TaskQueue queue; +assertEquals(void 0, re.sticky); +re.sticky = true; // Has no effect on the regexp, just sets a property. +assertTrue(re.sticky); - TestTask* task = new TestTask(&task_counter); - queue.Append(task); - CHECK_EQ(1, task_counter.GetCount()); - CHECK_EQ(task, queue.GetNext()); - delete task; - CHECK_EQ(0, task_counter.GetCount()); +assertTrue(re.test("..foo.bar")); - queue.Terminate(); - CHECK_EQ(NULL, queue.GetNext()); -} +re.lastIndex = -1; // Ignored for non-global, non-sticky. +assertTrue(re.test("..foo.bar")); +assertEquals(-1, re.lastIndex); - -class ReadQueueTask : public TestTask { - public: - ReadQueueTask(TaskCounter* task_counter, TaskQueue* queue) - : TestTask(task_counter, true), queue_(queue) {} - virtual ~ReadQueueTask() {} - - virtual void Run() V8_OVERRIDE { - TestTask::Run(); - CHECK_EQ(NULL, queue_->GetNext()); - } - - private: - TaskQueue* queue_; - - DISALLOW_COPY_AND_ASSIGN(ReadQueueTask); -}; - - -TEST(TaskQueueTerminateMultipleReaders) { - TaskQueue queue; - TaskCounter task_counter; - ReadQueueTask* read1 = new ReadQueueTask(&task_counter, &queue); - ReadQueueTask* read2 = new ReadQueueTask(&task_counter, &queue); - - TestWorkerThread thread1(read1); - TestWorkerThread thread2(read2); - - thread1.Start(); - thread2.Start(); - - CHECK_EQ(2, task_counter.GetCount()); - - thread1.Signal(); - thread2.Signal(); - - queue.Terminate(); - - thread1.Join(); - thread2.Join(); - - CHECK_EQ(0, task_counter.GetCount()); -} +re.lastIndex = -1; // Ignored for non-global, non-sticky. +assertTrue(!!re.exec("..foo.bar")); +assertEquals(-1, re.lastIndex); diff --git a/deps/v8/test/mjsunit/regress-3225.js b/deps/v8/test/mjsunit/regress-3225.js index 357f94b24c..fe44b85110 100644 --- a/deps/v8/test/mjsunit/regress-3225.js +++ b/deps/v8/test/mjsunit/regress-3225.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --expose-debug-as debug --harmony-generators +// Flags: --expose-debug-as debug Debug = debug.Debug diff --git a/deps/v8/test/mjsunit/regress/poly_count_operation.js b/deps/v8/test/mjsunit/regress/poly_count_operation.js index a8a1ed2ebc..99f041b6f1 100644 --- a/deps/v8/test/mjsunit/regress/poly_count_operation.js +++ b/deps/v8/test/mjsunit/regress/poly_count_operation.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --turbo-deoptimization var o1 = {x:1}; var o2 = {}; diff --git a/deps/v8/test/mjsunit/regress/regress-1170187.js b/deps/v8/test/mjsunit/regress/regress-1170187.js index 5e82f8a83b..3621bc44a8 100644 --- a/deps/v8/test/mjsunit/regress/regress-1170187.js +++ b/deps/v8/test/mjsunit/regress/regress-1170187.js @@ -26,6 +26,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization + // Make sure that the retreival of local variables are performed correctly even // when an adapter frame is present. diff --git a/deps/v8/test/mjsunit/regress/regress-119609.js b/deps/v8/test/mjsunit/regress/regress-119609.js index 99041adaf4..0c85063ac7 100644 --- a/deps/v8/test/mjsunit/regress/regress-119609.js +++ b/deps/v8/test/mjsunit/regress/regress-119609.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization Debug = debug.Debug; diff --git a/deps/v8/test/mjsunit/regress/regress-131994.js b/deps/v8/test/mjsunit/regress/regress-131994.js index 7f600959da..3de3813eac 100644 --- a/deps/v8/test/mjsunit/regress/regress-131994.js +++ b/deps/v8/test/mjsunit/regress/regress-131994.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization // Test that a variable in the local scope that shadows a context-allocated // variable is correctly resolved when being evaluated in the debugger. diff --git a/deps/v8/test/mjsunit/regress/regress-325676.js b/deps/v8/test/mjsunit/regress/regress-325676.js index 427bbc38dc..7450a6d12c 100644 --- a/deps/v8/test/mjsunit/regress/regress-325676.js +++ b/deps/v8/test/mjsunit/regress/regress-325676.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization // If a function parameter is forced to be context allocated, // debug evaluate need to resolve it to a context slot instead of diff --git a/deps/v8/test/mjsunit/regress/regress-3564.js b/deps/v8/test/mjsunit/regress/regress-3564.js new file mode 100644 index 0000000000..a0b9eb2994 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-3564.js @@ -0,0 +1,24 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function MyWrapper(v) { + return { valueOf: function() { return v } }; +} + +function f() { + assertTrue("a" < "x"); + assertTrue("a" < new String("y")); + assertTrue("a" < new MyWrapper("z")); + + assertFalse("a" > "x"); + assertFalse("a" > new String("y")); + assertFalse("a" > new MyWrapper("z")); +} + +f(); +f(); +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-403292.js b/deps/v8/test/mjsunit/regress/regress-403292.js new file mode 100644 index 0000000000..4e7ba283f7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-403292.js @@ -0,0 +1,53 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-natives-as=builtins --expose-gc + +var __v_7 = []; +var __v_8 = {}; +var __v_10 = {}; +var __v_11 = this; +var __v_12 = {}; +var __v_13 = {}; +var __v_14 = ""; +var __v_15 = {}; +try { +__v_1 = {x:0}; +%OptimizeFunctionOnNextCall(__f_1); +assertEquals("good", __f_1()); +delete __v_1.x; +assertEquals("good", __f_1()); +} catch(e) { print("Caught: " + e); } +try { +__v_3 = new Set(); +__v_5 = new builtins.SetIterator(__v_3, -12); +__v_4 = new Map(); +__v_6 = new builtins.MapIterator(__v_4, 2); +__f_3(Array); +} catch(e) { print("Caught: " + e); } +function __f_4(__v_8, filter) { + function __f_6(v) { + for (var __v_4 in v) { + for (var __v_4 in v) {} + } + %OptimizeFunctionOnNextCall(filter); + return filter(v); + } + var __v_7 = eval(__v_8); + gc(); + return __f_6(__v_7); +} +function __f_5(__v_6) { + var __v_5 = new Array(__v_6); + for (var __v_4 = 0; __v_4 < __v_6; __v_4++) __v_5.push('{}'); + return __v_5; +} +try { +try { + __v_8.test("\x80"); + assertUnreachable(); +} catch (e) { +} +gc(); +} catch(e) { print("Caught: " + e); } diff --git a/deps/v8/test/mjsunit/regress/regress-404981.js b/deps/v8/test/mjsunit/regress/regress-404981.js new file mode 100644 index 0000000000..5508d6fea7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-404981.js @@ -0,0 +1,6 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var large_object = new Array(5000001); +large_object.length = 23; diff --git a/deps/v8/test/mjsunit/regress/regress-408036.js b/deps/v8/test/mjsunit/regress/regress-408036.js new file mode 100644 index 0000000000..a4dfade25d --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-408036.js @@ -0,0 +1,5 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-natives-as 1 diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-387627.js b/deps/v8/test/mjsunit/regress/regress-409533.js index 5c6389b5f1..e51065e4bf 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-387627.js +++ b/deps/v8/test/mjsunit/regress/regress-409533.js @@ -4,9 +4,9 @@ // Flags: --allow-natives-syntax -function f() {} -%FunctionBindArguments(f, {}, undefined, 1); - +function f() { + %_RegExpConstructResult(0, {}, {}); +} f(); f(); %OptimizeFunctionOnNextCall(f); diff --git a/deps/v8/test/mjsunit/regress/regress-410912.js b/deps/v8/test/mjsunit/regress/regress-410912.js new file mode 100644 index 0000000000..98367bdf20 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-410912.js @@ -0,0 +1,206 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc + +var assertDoesNotThrow; +var assertInstanceof; +var assertUnreachable; +var assertOptimized; +var assertUnoptimized; +function classOf(object) { var string = Object.prototype.toString.call(object); return string.substring(8, string.length - 1); } +function PrettyPrint(value) { return ""; } +function PrettyPrintArrayElement(value, index, array) { return ""; } +function fail(expectedText, found, name_opt) { } +function deepObjectEquals(a, b) { var aProps = Object.keys(a); aProps.sort(); var bProps = Object.keys(b); bProps.sort(); if (!deepEquals(aProps, bProps)) { return false; } for (var i = 0; i < aProps.length; i++) { if (!deepEquals(a[aProps[i]], b[aProps[i]])) { return false; } } return true; } +function deepEquals(a, b) { if (a === b) { if (a === 0) return (1 / a) === (1 / b); return true; } if (typeof a != typeof b) return false; if (typeof a == "number") return isNaN(a) && isNaN(b); if (typeof a !== "object" && typeof a !== "function") return false; var objectClass = classOf(a); if (objectClass !== classOf(b)) return false; if (objectClass === "RegExp") { return (a.toString() === b.toString()); } if (objectClass === "Function") return false; if (objectClass === "Array") { var elementCount = 0; if (a.length != b.length) { return false; } for (var i = 0; i < a.length; i++) { if (!deepEquals(a[i], b[i])) return false; } return true; } if (objectClass == "String" || objectClass == "Number" || objectClass == "Boolean" || objectClass == "Date") { if (a.valueOf() !== b.valueOf()) return false; } return deepObjectEquals(a, b); } +assertSame = function assertSame(expected, found, name_opt) { if (found === expected) { if (expected !== 0 || (1 / expected) == (1 / found)) return; } else if ((expected !== expected) && (found !== found)) { return; } fail(PrettyPrint(expected), found, name_opt); }; assertEquals = function assertEquals(expected, found, name_opt) { if (!deepEquals(found, expected)) { fail(PrettyPrint(expected), found, name_opt); } }; +assertEqualsDelta = function assertEqualsDelta(expected, found, delta, name_opt) { assertTrue(Math.abs(expected - found) <= delta, name_opt); }; +assertArrayEquals = function assertArrayEquals(expected, found, name_opt) { var start = ""; if (name_opt) { start = name_opt + " - "; } assertEquals(expected.length, found.length, start + "array length"); if (expected.length == found.length) { for (var i = 0; i < expected.length; ++i) { assertEquals(expected[i], found[i], start + "array element at index " + i); } } }; +assertPropertiesEqual = function assertPropertiesEqual(expected, found, name_opt) { if (!deepObjectEquals(expected, found)) { fail(expected, found, name_opt); } }; +assertToStringEquals = function assertToStringEquals(expected, found, name_opt) { if (expected != String(found)) { fail(expected, found, name_opt); } }; +assertTrue = function assertTrue(value, name_opt) { assertEquals(true, value, name_opt); }; +assertFalse = function assertFalse(value, name_opt) { assertEquals(false, value, name_opt); }; +assertNull = function assertNull(value, name_opt) { if (value !== null) { fail("null", value, name_opt); } }; +assertNotNull = function assertNotNull(value, name_opt) { if (value === null) { fail("not null", value, name_opt); } }; +var __v_39 = {}; +var __v_40 = {}; +var __v_41 = {}; +var __v_42 = {}; +var __v_43 = {}; +var __v_44 = {}; +try { +__v_0 = [1.5,,1.7]; +__v_1 = {__v_0:1.8}; +} catch(e) { print("Caught: " + e); } +function __f_0(__v_1,__v_0,i) { + __v_1.a = __v_0[i]; + gc(); +} +try { +__f_0(__v_1,__v_0,0); +__f_0(__v_1,__v_0,0); +%OptimizeFunctionOnNextCall(__f_0); +__f_0(__v_1,__v_0,1); +assertEquals(undefined, __v_1.a); +__v_0 = [1,,3]; +__v_1 = {ab:5}; +} catch(e) { print("Caught: " + e); } +function __f_1(__v_1,__v_0,i) { + __v_1.ab = __v_0[i]; +} +try { +__f_1(__v_1,__v_0,1); +} catch(e) { print("Caught: " + e); } +function __f_5(x) { + return ~x; +} +try { +__f_5(42); +assertEquals(~12, __f_5(12.45)); +assertEquals(~46, __f_5(42.87)); +__v_2 = 1, __v_4 = 2, __v_3 = 4, __v_6 = 8; +} catch(e) { print("Caught: " + e); } +function __f_4() { + return __v_2 | (__v_4 | (__v_3 | __v_6)); +} +try { +__f_4(); +__v_3 = "16"; +assertEquals(17 | -13 | 0 | -5, __f_4()); +} catch(e) { print("Caught: " + e); } +function __f_6() { + return __f_4(); +} +try { +assertEquals(1 | 2 | 16 | 8, __f_6()); +__f_4 = function() { return 42; }; +assertEquals(42, __f_6()); +__v_5 = {}; +__v_5.__f_4 = __f_4; +} catch(e) { print("Caught: " + e); } +function __f_7(o) { + return o.__f_4(); +} +try { +for (var __v_7 = 0; __v_7 < 5; __v_7++) __f_7(__v_5); +%OptimizeFunctionOnNextCall(__f_7); +__f_7(__v_5); +assertEquals(42, __f_7(__v_5)); +assertEquals(87, __f_7({__f_4: function() { return 87; }})); +} catch(e) { print("Caught: " + e); } +function __f_8(x,y) { + x = 42; + y = 1; + y = y << "0"; + return x | y; +} +try { +assertEquals(43, __f_8(0,0)); +} catch(e) { print("Caught: " + e); } +function __f_2(x) { + return 'lit[' + (x + ']'); +} +try { +assertEquals('lit[-87]', __f_2(-87)); +assertEquals('lit[0]', __f_2(0)); +assertEquals('lit[42]', __f_2(42)); +__v_9 = "abc"; +gc(); +var __v_8; +} catch(e) { print("Caught: " + e); } +function __f_9(n) { return __v_9.charAt(n); } +try { +for (var __v_7 = 0; __v_7 < 5; __v_7++) { + __v_8 = __f_9(0); +} +%OptimizeFunctionOnNextCall(__f_9); +__v_8 = __f_9(0); +} catch(e) { print("Caught: " + e); } +function __f_3(__v_2,__v_4,__v_3,__v_6) { + return __v_2+__v_4+__v_3+__v_6; +} +try { +assertEquals(0x40000003, __f_3(1,1,2,0x3fffffff)); +} catch(e) { print("Caught: " + e); } +try { +__v_19 = { + fast_smi_only : 'fast smi only elements', + fast : 'fast elements', + fast_double : 'fast double elements', + dictionary : 'dictionary elements', + external_int32 : 'external int8 elements', + external_uint8 : 'external uint8 elements', + external_int16 : 'external int16 elements', + external_uint16 : 'external uint16 elements', + external_int32 : 'external int32 elements', + external_uint32 : 'external uint32 elements', + external_float32 : 'external float32 elements', + external_float64 : 'external float64 elements', + external_uint8_clamped : 'external uint8_clamped elements', + fixed_int32 : 'fixed int8 elements', + fixed_uint8 : 'fixed uint8 elements', + fixed_int16 : 'fixed int16 elements', + fixed_uint16 : 'fixed uint16 elements', + fixed_int32 : 'fixed int32 elements', + fixed_uint32 : 'fixed uint32 elements', + fixed_float32 : 'fixed float32 elements', + fixed_float64 : 'fixed float64 elements', + fixed_uint8_clamped : 'fixed uint8_clamped elements' +} +} catch(e) { print("Caught: " + e); } +function __f_12() { +} +__v_10 = {}; +__v_10.dance = 0xD15C0; +__v_10.drink = 0xC0C0A; +__f_12(__v_19.fast, __v_10); +__v_24 = [1,2,3]; +__f_12(__v_19.fast_smi_only, __v_24); +__v_24.dance = 0xD15C0; +__v_24.drink = 0xC0C0A; +__f_12(__v_19.fast_smi_only, __v_24); +function __f_18() { + var __v_27 = new Array(); + __f_12(__v_19.fast_smi_only, __v_27); + for (var __v_18 = 0; __v_18 < 1337; __v_18++) { + var __v_16 = __v_18; + if (__v_18 == 1336) { + __f_12(__v_19.fast_smi_only, __v_27); + __v_16 = new Object(); + } + __v_27[__v_18] = __v_16; + } + __f_12(__v_19.fast, __v_27); + var __v_15 = []; + __v_15[912570] = 7; + __f_12(__v_19.dictionary, __v_15); + var __v_26 = new Array(912561); + %SetAllocationTimeout(100000000, 10000000); + for (var __v_18 = 0; __v_18 < 0x20000; __v_18++) { + __v_26[0] = __v_18 / 2; + } + __f_12(__v_19.fixed_int8, new Int8Array(007)); + __f_12(__v_19.fixed_uint8, new Uint8Array(007)); + __f_12(__v_19.fixed_int16, new Int16Array(666)); + __f_12(__v_19.fixed_uint16, new Uint16Array(42)); + __f_12(__v_19.fixed_int32, new Int32Array(0xF)); + __f_12(__v_19.fixed_uint32, new Uint32Array(23)); + __f_12(__v_19.fixed_float32, new Float32Array(7)); + __f_12(__v_19.fixed_float64, new Float64Array(0)); + __f_12(__v_19.fixed_uint8_clamped, new Uint8ClampedArray(512)); + var __v_13 = new ArrayBuffer(128); + __f_12(__v_19.external_int8, new Int8Array(__v_13)); + __f_12(__v_37.external_uint8, new Uint8Array(__v_13)); + __f_12(__v_19.external_int16, new Int16Array(__v_13)); + __f_12(__v_19.external_uint16, new Uint16Array(__v_13)); + __f_12(__v_19.external_int32, new Int32Array(__v_13)); + __f_12(__v_19.external_uint32, new Uint32Array(__v_13)); + __f_12(__v_19.external_float32, new Float32Array(__v_13)); + __f_12(__v_19.external_float64, new Float64Array(__v_13)); + __f_12(__v_19.external_uint8_clamped, new Uint8ClampedArray(__v_13)); +} +try { +__f_18(); +} catch(e) { } diff --git a/deps/v8/test/mjsunit/regress/regress-411210.js b/deps/v8/test/mjsunit/regress/regress-411210.js new file mode 100644 index 0000000000..2dbc5ff70c --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-411210.js @@ -0,0 +1,22 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --gc-interval=439 --random-seed=-423594851 + +var __v_3; +function __f_2() { + var __v_1 = new Array(3); + __v_1[0] = 10; + __v_1[1] = 15.5; + __v_3 = __f_2(); + __v_1[2] = 20; + return __v_1; +} + +try { + for (var __v_2 = 0; __v_2 < 3; ++__v_2) { + __v_3 = __f_2(); + } +} +catch (e) { } diff --git a/deps/v8/test/mjsunit/regress/regress-411237.js b/deps/v8/test/mjsunit/regress/regress-411237.js new file mode 100644 index 0000000000..8b75ba3015 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-411237.js @@ -0,0 +1,15 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --harmony + +try { + %OptimizeFunctionOnNextCall(print); +} catch(e) { } + +try { + function* f() { + } + %OptimizeFunctionOnNextCall(f); +} catch(e) { } diff --git a/deps/v8/test/mjsunit/regress/regress-412162.js b/deps/v8/test/mjsunit/regress/regress-412162.js new file mode 100644 index 0000000000..6a7ad0c57f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-412162.js @@ -0,0 +1,14 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function test() { + Math.abs(-NaN).toString(); +} + +test(); +test(); +%OptimizeFunctionOnNextCall(test); +test(); diff --git a/deps/v8/test/mjsunit/regress/regress-416416.js b/deps/v8/test/mjsunit/regress/regress-416416.js new file mode 100644 index 0000000000..66e882e0fc --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-416416.js @@ -0,0 +1,14 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function foo() { + try { + String.prototype.length.x(); + } catch (e) { + } +} + +foo(); +foo(); +foo(); diff --git a/deps/v8/test/mjsunit/regress/regress-416730.js b/deps/v8/test/mjsunit/regress/regress-416730.js new file mode 100644 index 0000000000..8d7f207fd9 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-416730.js @@ -0,0 +1,24 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var d = {x: undefined, y: undefined}; + +function Crash(left, right) { + var c = { + x: right.x - left.x, + y: right.y - left.y + }; + return c.x * c.y; +} + +var a = {x: 0.5, y: 0}; +var b = {x: 1, y: 0}; + +for (var i = 0; i < 3; i++) Crash(a, b); +%OptimizeFunctionOnNextCall(Crash); +Crash(a, b); + +Crash({x: 0, y: 0.5}, b); diff --git a/deps/v8/test/mjsunit/regress/regress-conditional-position.js b/deps/v8/test/mjsunit/regress/regress-conditional-position.js index cd8f7bd745..ae5a3acb58 100644 --- a/deps/v8/test/mjsunit/regress/regress-conditional-position.js +++ b/deps/v8/test/mjsunit/regress/regress-conditional-position.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --always-full-compiler +// Flags: --nocrankshaft var functionToCatch; var lineNumber; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-107996.js b/deps/v8/test/mjsunit/regress/regress-crbug-107996.js index dfe07e59de..b4907f3bb8 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-107996.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-107996.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization Debug = debug.Debug; diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-171715.js b/deps/v8/test/mjsunit/regress/regress-crbug-171715.js index 040c381e39..309f50a01b 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-171715.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-171715.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization Debug = debug.Debug diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-222893.js b/deps/v8/test/mjsunit/regress/regress-crbug-222893.js index 39363bc912..75e17289fd 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-222893.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-222893.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug +// Flags: --turbo-deoptimization Debug = debug.Debug diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-320922.js b/deps/v8/test/mjsunit/regress/regress-crbug-320922.js index 4a5b5813e0..9ba759a43e 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-320922.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-320922.js @@ -30,7 +30,7 @@ var string = "hello world"; var expected = "Hello " + "world"; function Capitalize() { - %_OneByteSeqStringSetChar(string, 0, 0x48); + %_OneByteSeqStringSetChar(0, 0x48, string); } Capitalize(); assertEquals(expected, string); @@ -40,7 +40,7 @@ assertEquals(expected, string); var twobyte = "\u20ACello world"; function TwoByteCapitalize() { - %_TwoByteSeqStringSetChar(twobyte, 0, 0x48); + %_TwoByteSeqStringSetChar(0, 0x48, twobyte); } TwoByteCapitalize(); assertEquals(expected, twobyte); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-323936.js b/deps/v8/test/mjsunit/regress/regress-crbug-323936.js new file mode 100644 index 0000000000..d896eadcc4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-323936.js @@ -0,0 +1,46 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug + +Debug = debug.Debug; + +var step = 0; +var exception = null; + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + try { + if (step == 0) { + assertEquals("error", exec_state.frame(0).evaluate("e").value()); + exec_state.frame(0).evaluate("e = 'foo'"); + exec_state.frame(0).evaluate("x = 'modified'"); + } else { + assertEquals("argument", exec_state.frame(0).evaluate("e").value()); + exec_state.frame(0).evaluate("e = 'bar'"); + } + step++; + } catch (e) { + print(e + e.stack); + exception = e; + } +} + +Debug.setListener(listener); + +function f(e, x) { + try { + throw "error"; + } catch(e) { + debugger; + assertEquals("foo", e); + } + debugger; + assertEquals("bar", e); + assertEquals("modified", x); +} + +f("argument") +assertNull(exception); +assertEquals(2, step); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-357052.js b/deps/v8/test/mjsunit/regress/regress-crbug-357052.js index 9cde1b66c2..7a58396407 100644 --- a/deps/v8/test/mjsunit/regress/regress-crbug-357052.js +++ b/deps/v8/test/mjsunit/regress/regress-crbug-357052.js @@ -7,5 +7,6 @@ function f() { for (var i = 0; i < 30; i++) { str += "abcdefgh12345678" + str; } + return str; } assertThrows(f); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-403409.js b/deps/v8/test/mjsunit/regress/regress-crbug-403409.js new file mode 100644 index 0000000000..ffd100b468 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-403409.js @@ -0,0 +1,18 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +Array.prototype[0] = 777; +var kElements = 10; + +var input_array = []; +for (var i = 1; i < kElements; i++) { + input_array[i] = 0.5; +} +var output_array = input_array.concat(0.5); + +assertEquals(kElements + 1, output_array.length); +assertEquals(777, output_array[0]); +for (var j = 1; j < kElements; j++) { + assertEquals(0.5, output_array[j]); +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-405491.js b/deps/v8/test/mjsunit/regress/regress-crbug-405491.js new file mode 100644 index 0000000000..b63378113f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-405491.js @@ -0,0 +1,5 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as 1 diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-405517.js b/deps/v8/test/mjsunit/regress/regress-crbug-405517.js new file mode 100644 index 0000000000..36c3f4f7f7 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-405517.js @@ -0,0 +1,16 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --gc-interval=203 + +function f() { + var e = [0]; + %PreventExtensions(e); + for (var i = 0; i < 4; i++) e.shift(); +} + +f(); +f(); +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-405922.js b/deps/v8/test/mjsunit/regress/regress-crbug-405922.js new file mode 100644 index 0000000000..9f76a862db --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-405922.js @@ -0,0 +1,27 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-debug-as debug + +Debug = debug.Debug + +function listener(event, exec_state, event_data, data) { + try { + if (event == Debug.DebugEvent.Break) { + exec_state.prepareStep(Debug.StepAction.StepIn, 3); + } + } catch (e) { + } +} + +Debug.setListener(listener); + +function f(x) { + if (x > 0) %_CallFunction(null, x-1, f); +} + +debugger; +f(2); + +Debug.setListener(null); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-407946.js b/deps/v8/test/mjsunit/regress/regress-crbug-407946.js new file mode 100644 index 0000000000..d5687cca34 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-407946.js @@ -0,0 +1,12 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function f(n) { return [0].indexOf((n - n) + 0); } + +assertEquals(0, f(.1)); +assertEquals(0, f(.1)); +%OptimizeFunctionOnNextCall(f); +assertEquals(0, f(.1)); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-412203.js b/deps/v8/test/mjsunit/regress/regress-crbug-412203.js new file mode 100644 index 0000000000..f15085954f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-412203.js @@ -0,0 +1,36 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var b = []; +b[10000] = 1; +// Required to reproduce the bug. +assertTrue(%HasDictionaryElements(b)); + +var a1 = [1.5]; +b.__proto__ = a1; +assertEquals(1.5, ([].concat(b))[0]); + +var a2 = new Int32Array(2); +a2[0] = 3; +b.__proto__ = a2 +assertEquals(3, ([].concat(b))[0]); + +function foo(x, y) { + var a = []; + a[10000] = 1; + assertTrue(%HasDictionaryElements(a)); + + a.__proto__ = arguments; + var c = [].concat(a); + for (var i = 0; i < arguments.length; i++) { + assertEquals(i + 2, c[i]); + } + assertEquals(undefined, c[arguments.length]); + assertEquals(undefined, c[arguments.length + 1]); +} +foo(2); +foo(2, 3); +foo(2, 3, 4); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-412208.js b/deps/v8/test/mjsunit/regress/regress-crbug-412208.js new file mode 100644 index 0000000000..a194f855b4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-412208.js @@ -0,0 +1,16 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var non_const_true = true; + +function f() { + return non_const_true || (f() = this); +} + +assertTrue(f()); +assertTrue(f()); +%OptimizeFunctionOnNextCall(f); +assertTrue(f()); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-412210.js b/deps/v8/test/mjsunit/regress/regress-crbug-412210.js new file mode 100644 index 0000000000..6ec7d62379 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-412210.js @@ -0,0 +1,12 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function f(x) { + return (x ? "" >> 0 : "") + /a/; +}; + +%OptimizeFunctionOnNextCall(f); +f(); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-412215.js b/deps/v8/test/mjsunit/regress/regress-crbug-412215.js new file mode 100644 index 0000000000..ad926fc4a2 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-412215.js @@ -0,0 +1,33 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var dummy = {foo: "true"}; + +var a = {y:0.5}; +a.y = 357; +var b = a.y; + +var d; +function f( ) { + d = 357; + return {foo: b}; +} +f(); +f(); +%OptimizeFunctionOnNextCall(f); +var x = f(); + +// With the bug, x is now an invalid object; the code below +// triggers a crash. + +function g(obj) { + return obj.foo.length; +} + +g(dummy); +g(dummy); +%OptimizeFunctionOnNextCall(g); +g(x); diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-412319.js b/deps/v8/test/mjsunit/regress/regress-crbug-412319.js new file mode 100644 index 0000000000..21386e3bd6 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-412319.js @@ -0,0 +1,19 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +function __f_6() { + var __v_7 = [0]; + %PreventExtensions(__v_7); + for (var __v_6 = -2; __v_6 < 19; __v_6++) __v_7.shift(); + __f_7(__v_7); +} +__f_6(); +__f_6(); +%OptimizeFunctionOnNextCall(__f_6); +__f_6(); +function __f_7(__v_7) { + __v_7.push(Infinity); +} diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-416558.js b/deps/v8/test/mjsunit/regress/regress-crbug-416558.js new file mode 100644 index 0000000000..375ad406ea --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-416558.js @@ -0,0 +1,115 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = /x/; + store(c); + function get_hole() { + var b = /x/; + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = new Date(); + store(c); + function get_hole() { + var b = new Date(); + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = new Number(1); + store(c); + function get_hole() { + var b = new Number(1); + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = new Boolean(); + store(c); + function get_hole() { + var b = new Boolean(); + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = new Map(); + store(c); + function get_hole() { + var b = new Map(); + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = new Set(); + store(c); + function get_hole() { + var b = new Set(); + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = new WeakMap(); + store(c); + function get_hole() { + var b = new WeakMap(); + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); + +(function() { + function store(x) { x[0] = 0; } + store([]); + var c = new WeakSet(); + store(c); + function get_hole() { + var b = new WeakSet(); + store(b); + return b[1]; + } + assertEquals(undefined, get_hole()); + assertEquals(undefined, get_hole()); +})(); diff --git a/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js b/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js index 52c32e9cc3..ce5220a2b8 100644 --- a/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js +++ b/deps/v8/test/mjsunit/regress/regress-debug-deopt-while-recompile.js @@ -26,6 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Flags: --expose-debug-as debug --allow-natives-syntax +// Flags: --turbo-deoptimization Debug = debug.Debug; diff --git a/deps/v8/test/mjsunit/regress/regress-force-constant-representation.js b/deps/v8/test/mjsunit/regress/regress-force-constant-representation.js new file mode 100644 index 0000000000..4ec2a6a799 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-force-constant-representation.js @@ -0,0 +1,18 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +// Test push double as tagged. +var a = [{}]; +function f(a) { + a.push(Infinity); +} + +f(a); +f(a); +f(a); +%OptimizeFunctionOnNextCall(f); +f(a); +assertEquals([{}, Infinity, Infinity, Infinity, Infinity], a); diff --git a/deps/v8/test/mjsunit/regress/regress-inline-constant-load.js b/deps/v8/test/mjsunit/regress/regress-inline-constant-load.js new file mode 100644 index 0000000000..303639c74f --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-inline-constant-load.js @@ -0,0 +1,27 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +var o1 = {}; +var o2 = {}; + +function foo(x) { + return x.bar; +} + +Object.defineProperty(o1, "bar", {value:200}); +foo(o1); +foo(o1); + +function f(b) { + var o = o2; + if (b) { return foo(o) } +} + +f(false); +%OptimizeFunctionOnNextCall(f); +assertEquals(undefined, f(false)); +Object.defineProperty(o2, "bar", {value: 100}); +assertEquals(100, f(true)); diff --git a/deps/v8/test/mjsunit/regress/regress-json-parse-index.js b/deps/v8/test/mjsunit/regress/regress-json-parse-index.js new file mode 100644 index 0000000000..d1a785aaf1 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-json-parse-index.js @@ -0,0 +1,6 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var o = JSON.parse('{"\\u0030":100}'); +assertEquals(100, o[0]); diff --git a/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js b/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js index c637be5497..5cbaabca55 100644 --- a/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js +++ b/deps/v8/test/mjsunit/regress/regress-opt-after-debug-deopt.js @@ -27,6 +27,7 @@ // Flags: --expose-debug-as debug --allow-natives-syntax // Flags: --concurrent-recompilation --block-concurrent-recompilation +// Flags: --turbo-deoptimization if (!%IsConcurrentRecompilationSupported()) { print("Concurrent recompilation is disabled. Skipping this test."); diff --git a/deps/v8/test/mjsunit/regress/regress-reset-dictionary-elements.js b/deps/v8/test/mjsunit/regress/regress-reset-dictionary-elements.js new file mode 100644 index 0000000000..d3d093ec09 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-reset-dictionary-elements.js @@ -0,0 +1,14 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +var a = []; +a[10000] = 1; +a.length = 0; +a[1] = 1; +a.length = 0; +assertEquals(undefined, a[1]); + +var o = {}; +Object.freeze(o); +assertEquals(undefined, o[1]); diff --git a/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex1.js b/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex1.js index c85cf56e0c..1fd8d810b3 100644 --- a/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex1.js +++ b/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex1.js @@ -47,7 +47,7 @@ function StringFromCharCode(code) { var two_byte = %NewString(n - i, false); for (var j = 0; i < n; i++, j++) { var code = %_Arguments(i); - %_TwoByteSeqStringSetChar(two_byte, j, code); + %_TwoByteSeqStringSetChar(j, code, two_byte); } return one_byte + two_byte; } diff --git a/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex3.js b/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex3.js index 43d2b08352..0a6b211648 100644 --- a/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex3.js +++ b/deps/v8/test/mjsunit/regress/regress-seqstrsetchar-ex3.js @@ -30,8 +30,8 @@ function test() { var string = %NewString(10, true); for (var i = 0; i < 10; i++) { - %_OneByteSeqStringSetChar(string, i, 65); - %_OneByteSeqStringSetChar(string, i, 66); + %_OneByteSeqStringSetChar(i, 65, string); + %_OneByteSeqStringSetChar(i, 66, string); } for (var i = 0; i < 10; i++) { assertEquals("B", string[i]); diff --git a/deps/v8/test/mjsunit/regress/regress-sliced-external-cons-regexp.js b/deps/v8/test/mjsunit/regress/regress-sliced-external-cons-regexp.js new file mode 100644 index 0000000000..145c831896 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-sliced-external-cons-regexp.js @@ -0,0 +1,21 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-externalize-string --expose-gc + +var re = /(B)/; +var cons1 = "0123456789" + "ABCDEFGHIJ"; +var cons2 = "0123456789\u1234" + "ABCDEFGHIJ"; +gc(); +gc(); // Promote cons. + +try { externalizeString(cons1, false); } catch (e) { } +try { externalizeString(cons2, true); } catch (e) { } + +var slice1 = cons1.slice(1,-1); +var slice2 = cons2.slice(1,-1); +for (var i = 0; i < 10; i++) { + assertEquals(["B", "B"], re.exec(slice1)); + assertEquals(["B", "B"], re.exec(slice2)); +} diff --git a/deps/v8/test/mjsunit/regress/string-compare-memcmp.js b/deps/v8/test/mjsunit/regress/string-compare-memcmp.js new file mode 100644 index 0000000000..45f47343ee --- /dev/null +++ b/deps/v8/test/mjsunit/regress/string-compare-memcmp.js @@ -0,0 +1,7 @@ +// Copyright 2012 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax + +assertEquals(-1, %StringCompare("abc\u0102", "abc\u0201")); diff --git a/deps/v8/test/mjsunit/regress/string-set-char-deopt.js b/deps/v8/test/mjsunit/regress/string-set-char-deopt.js index 9f6d434538..c8e8538e16 100644 --- a/deps/v8/test/mjsunit/regress/string-set-char-deopt.js +++ b/deps/v8/test/mjsunit/regress/string-set-char-deopt.js @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --turbo-deoptimization (function OneByteSeqStringSetCharDeoptOsr() { function deopt() { @@ -34,7 +34,7 @@ function f(string, osr) { var world = " world"; - %_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48)); + %_OneByteSeqStringSetChar(0, (deopt(), 0x48), string); if (osr) while (%GetOptimizationStatus(f) == 2) {} @@ -56,7 +56,7 @@ } function f(string) { - g(%_OneByteSeqStringSetChar(string, 0, (deopt(), 0x48))); + g(%_OneByteSeqStringSetChar(0, (deopt(), 0x48), string)); return string; } @@ -75,7 +75,7 @@ } function f(string) { - g(%_TwoByteSeqStringSetChar(string, 0, (deopt(), 0x48))); + g(%_TwoByteSeqStringSetChar(0, (deopt(), 0x48), string)); return string; } diff --git a/deps/v8/test/mjsunit/runtime-gen/apply.js b/deps/v8/test/mjsunit/runtime-gen/apply.js deleted file mode 100644 index 94c4753cb9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/apply.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = function() {}; -var _receiver = new Object(); -var _arguments = new Object(); -var _offset = 1; -var _argc = 1; -%Apply(arg0, _receiver, _arguments, _offset, _argc); diff --git a/deps/v8/test/mjsunit/runtime-gen/arraybuffergetbytelength.js b/deps/v8/test/mjsunit/runtime-gen/arraybuffergetbytelength.js deleted file mode 100644 index 8aff9ac073..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arraybuffergetbytelength.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new ArrayBuffer(8); -%ArrayBufferGetByteLength(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/arraybufferinitialize.js b/deps/v8/test/mjsunit/runtime-gen/arraybufferinitialize.js deleted file mode 100644 index c4520c6a64..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arraybufferinitialize.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new ArrayBuffer(8); -var _byteLength = 1.5; -%ArrayBufferInitialize(_holder, _byteLength); diff --git a/deps/v8/test/mjsunit/runtime-gen/arraybufferisview.js b/deps/v8/test/mjsunit/runtime-gen/arraybufferisview.js deleted file mode 100644 index 46cc5ba995..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arraybufferisview.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%ArrayBufferIsView(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/arraybufferneuter.js b/deps/v8/test/mjsunit/runtime-gen/arraybufferneuter.js deleted file mode 100644 index 89e9ee96b7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arraybufferneuter.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _array_buffer = new ArrayBuffer(8); -%ArrayBufferNeuter(_array_buffer); diff --git a/deps/v8/test/mjsunit/runtime-gen/arraybuffersliceimpl.js b/deps/v8/test/mjsunit/runtime-gen/arraybuffersliceimpl.js deleted file mode 100644 index cb02bb069c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arraybuffersliceimpl.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _source = new ArrayBuffer(8); -var _target = new ArrayBuffer(8); -var arg2 = 0; -%ArrayBufferSliceImpl(_source, _target, arg2); diff --git a/deps/v8/test/mjsunit/runtime-gen/arraybufferviewgetbytelength.js b/deps/v8/test/mjsunit/runtime-gen/arraybufferviewgetbytelength.js deleted file mode 100644 index e32ea0d4e7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arraybufferviewgetbytelength.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Int32Array(2); -%ArrayBufferViewGetByteLength(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/arraybufferviewgetbyteoffset.js b/deps/v8/test/mjsunit/runtime-gen/arraybufferviewgetbyteoffset.js deleted file mode 100644 index 4c64ff206d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arraybufferviewgetbyteoffset.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Int32Array(2); -%ArrayBufferViewGetByteOffset(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/arrayconcat.js b/deps/v8/test/mjsunit/runtime-gen/arrayconcat.js deleted file mode 100644 index 09487a6073..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/arrayconcat.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = [1, 'a']; -%ArrayConcat(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/availablelocalesof.js b/deps/v8/test/mjsunit/runtime-gen/availablelocalesof.js deleted file mode 100644 index a59c9b077c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/availablelocalesof.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _service = "foo"; -%AvailableLocalesOf(_service); diff --git a/deps/v8/test/mjsunit/runtime-gen/basicjsonstringify.js b/deps/v8/test/mjsunit/runtime-gen/basicjsonstringify.js deleted file mode 100644 index 55d197831e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/basicjsonstringify.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%BasicJSONStringify(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/booleanize.js b/deps/v8/test/mjsunit/runtime-gen/booleanize.js deleted file mode 100644 index 8685368e4f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/booleanize.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _value_raw = new Object(); -var _token_raw = 1; -%Booleanize(_value_raw, _token_raw); diff --git a/deps/v8/test/mjsunit/runtime-gen/boundfunctiongetbindings.js b/deps/v8/test/mjsunit/runtime-gen/boundfunctiongetbindings.js deleted file mode 100644 index 9221d3dd28..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/boundfunctiongetbindings.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _callable = new Object(); -%BoundFunctionGetBindings(_callable); diff --git a/deps/v8/test/mjsunit/runtime-gen/break.js b/deps/v8/test/mjsunit/runtime-gen/break.js deleted file mode 100644 index 4b600d8e3d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/break.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%Break(); diff --git a/deps/v8/test/mjsunit/runtime-gen/breakiteratoradopttext.js b/deps/v8/test/mjsunit/runtime-gen/breakiteratoradopttext.js deleted file mode 100644 index 64b6059da3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/breakiteratoradopttext.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.v8BreakIterator()); -var _text = "foo"; -%BreakIteratorAdoptText(arg0, _text); diff --git a/deps/v8/test/mjsunit/runtime-gen/breakiteratorbreaktype.js b/deps/v8/test/mjsunit/runtime-gen/breakiteratorbreaktype.js deleted file mode 100644 index 08cceb87f8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/breakiteratorbreaktype.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.v8BreakIterator()); -%BreakIteratorBreakType(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/breakiteratorcurrent.js b/deps/v8/test/mjsunit/runtime-gen/breakiteratorcurrent.js deleted file mode 100644 index 42000a846c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/breakiteratorcurrent.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.v8BreakIterator()); -%BreakIteratorCurrent(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/breakiteratorfirst.js b/deps/v8/test/mjsunit/runtime-gen/breakiteratorfirst.js deleted file mode 100644 index 3fad88c9e3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/breakiteratorfirst.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.v8BreakIterator()); -%BreakIteratorFirst(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/breakiteratornext.js b/deps/v8/test/mjsunit/runtime-gen/breakiteratornext.js deleted file mode 100644 index be72ffc1d6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/breakiteratornext.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.v8BreakIterator()); -%BreakIteratorNext(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/canonicalizelanguagetag.js b/deps/v8/test/mjsunit/runtime-gen/canonicalizelanguagetag.js deleted file mode 100644 index 45df230a40..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/canonicalizelanguagetag.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _locale_id_str = "foo"; -%CanonicalizeLanguageTag(_locale_id_str); diff --git a/deps/v8/test/mjsunit/runtime-gen/changebreakonexception.js b/deps/v8/test/mjsunit/runtime-gen/changebreakonexception.js deleted file mode 100644 index 4bc0d43d01..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/changebreakonexception.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _type_arg = 32; -var _enable = true; -%ChangeBreakOnException(_type_arg, _enable); diff --git a/deps/v8/test/mjsunit/runtime-gen/charfromcode.js b/deps/v8/test/mjsunit/runtime-gen/charfromcode.js deleted file mode 100644 index 20823391da..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/charfromcode.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _code = 32; -%CharFromCode(_code); diff --git a/deps/v8/test/mjsunit/runtime-gen/checkexecutionstate.js b/deps/v8/test/mjsunit/runtime-gen/checkexecutionstate.js deleted file mode 100644 index 7e740c39f6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/checkexecutionstate.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -try { -%CheckExecutionState(_break_id); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/checkisbootstrapping.js b/deps/v8/test/mjsunit/runtime-gen/checkisbootstrapping.js deleted file mode 100644 index 114b20c1c8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/checkisbootstrapping.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -try { -%CheckIsBootstrapping(); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/clearbreakpoint.js b/deps/v8/test/mjsunit/runtime-gen/clearbreakpoint.js deleted file mode 100644 index 1c11bc8f74..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/clearbreakpoint.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_point_object_arg = new Object(); -%ClearBreakPoint(_break_point_object_arg); diff --git a/deps/v8/test/mjsunit/runtime-gen/clearfunctiontypefeedback.js b/deps/v8/test/mjsunit/runtime-gen/clearfunctiontypefeedback.js deleted file mode 100644 index f42b8da200..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/clearfunctiontypefeedback.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function = function() {}; -%ClearFunctionTypeFeedback(_function); diff --git a/deps/v8/test/mjsunit/runtime-gen/clearstepping.js b/deps/v8/test/mjsunit/runtime-gen/clearstepping.js deleted file mode 100644 index bfab2cde0b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/clearstepping.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%ClearStepping(); diff --git a/deps/v8/test/mjsunit/runtime-gen/collectstacktrace.js b/deps/v8/test/mjsunit/runtime-gen/collectstacktrace.js deleted file mode 100644 index bac9b6a66c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/collectstacktrace.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _error_object = new Object(); -var _caller = new Object(); -%CollectStackTrace(_error_object, _caller); diff --git a/deps/v8/test/mjsunit/runtime-gen/compilestring.js b/deps/v8/test/mjsunit/runtime-gen/compilestring.js deleted file mode 100644 index 659afcaaef..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/compilestring.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _source = "foo"; -var arg1 = false; -%CompileString(_source, arg1); diff --git a/deps/v8/test/mjsunit/runtime-gen/constructdouble.js b/deps/v8/test/mjsunit/runtime-gen/constructdouble.js deleted file mode 100644 index 9ac3dee9c0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/constructdouble.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _hi = 32; -var _lo = 32; -%ConstructDouble(_hi, _lo); diff --git a/deps/v8/test/mjsunit/runtime-gen/createbreakiterator.js b/deps/v8/test/mjsunit/runtime-gen/createbreakiterator.js deleted file mode 100644 index a8750b3399..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createbreakiterator.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = 'en-US'; -var arg1 = {type: 'string'}; -var _resolved = new Object(); -%CreateBreakIterator(arg0, arg1, _resolved); diff --git a/deps/v8/test/mjsunit/runtime-gen/createcollator.js b/deps/v8/test/mjsunit/runtime-gen/createcollator.js deleted file mode 100644 index 0d5b18d55d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createcollator.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _locale = "foo"; -var _options = new Object(); -var _resolved = new Object(); -%CreateCollator(_locale, _options, _resolved); diff --git a/deps/v8/test/mjsunit/runtime-gen/createglobalprivatesymbol.js b/deps/v8/test/mjsunit/runtime-gen/createglobalprivatesymbol.js deleted file mode 100644 index e4968c14f3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createglobalprivatesymbol.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _name = "foo"; -%CreateGlobalPrivateSymbol(_name); diff --git a/deps/v8/test/mjsunit/runtime-gen/createjsfunctionproxy.js b/deps/v8/test/mjsunit/runtime-gen/createjsfunctionproxy.js deleted file mode 100644 index b4e1c31ae8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createjsfunctionproxy.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _handler = new Object(); -var arg1 = function() {}; -var _construct_trap = function() {}; -var _prototype = new Object(); -%CreateJSFunctionProxy(_handler, arg1, _construct_trap, _prototype); diff --git a/deps/v8/test/mjsunit/runtime-gen/createjsproxy.js b/deps/v8/test/mjsunit/runtime-gen/createjsproxy.js deleted file mode 100644 index ecdef60223..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createjsproxy.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _handler = new Object(); -var _prototype = new Object(); -%CreateJSProxy(_handler, _prototype); diff --git a/deps/v8/test/mjsunit/runtime-gen/createprivateownsymbol.js b/deps/v8/test/mjsunit/runtime-gen/createprivateownsymbol.js deleted file mode 100644 index 74548287c1..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createprivateownsymbol.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = "foo"; -%CreatePrivateOwnSymbol(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/createprivatesymbol.js b/deps/v8/test/mjsunit/runtime-gen/createprivatesymbol.js deleted file mode 100644 index bbd99c12b8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createprivatesymbol.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = "foo"; -%CreatePrivateSymbol(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/createsymbol.js b/deps/v8/test/mjsunit/runtime-gen/createsymbol.js deleted file mode 100644 index 8452b9c90b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/createsymbol.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = "foo"; -%CreateSymbol(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetbuffer.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetbuffer.js deleted file mode 100644 index 84bab807f3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetbuffer.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -%DataViewGetBuffer(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetfloat32.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetfloat32.js deleted file mode 100644 index 57f3c2a596..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetfloat32.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetFloat32(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetfloat64.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetfloat64.js deleted file mode 100644 index 7f80c5b0a0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetfloat64.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetFloat64(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetint16.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetint16.js deleted file mode 100644 index e618c1c00a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetint16.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetInt16(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetint32.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetint32.js deleted file mode 100644 index 2395a6dd9c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetint32.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetInt32(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetint8.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetint8.js deleted file mode 100644 index fe92ed7c35..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetint8.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetInt8(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint16.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint16.js deleted file mode 100644 index 50be62b009..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint16.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetUint16(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint32.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint32.js deleted file mode 100644 index 2f85aeef8a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint32.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetUint32(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint8.js b/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint8.js deleted file mode 100644 index 6a682e1731..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewgetuint8.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _is_little_endian = true; -%DataViewGetUint8(_holder, _offset, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewinitialize.js b/deps/v8/test/mjsunit/runtime-gen/dataviewinitialize.js deleted file mode 100644 index 167d531562..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewinitialize.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _buffer = new ArrayBuffer(8); -var _byte_offset = 1.5; -var _byte_length = 1.5; -%DataViewInitialize(_holder, _buffer, _byte_offset, _byte_length); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetfloat32.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetfloat32.js deleted file mode 100644 index 46d00afff0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetfloat32.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetFloat32(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetfloat64.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetfloat64.js deleted file mode 100644 index c57b514dd0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetfloat64.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetFloat64(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetint16.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetint16.js deleted file mode 100644 index 1f45448f69..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetint16.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetInt16(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetint32.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetint32.js deleted file mode 100644 index 837d4f26d5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetint32.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetInt32(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetint8.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetint8.js deleted file mode 100644 index 725e658ec4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetint8.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetInt8(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint16.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint16.js deleted file mode 100644 index d1b1a24bcd..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint16.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetUint16(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint32.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint32.js deleted file mode 100644 index e46c8f302a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint32.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetUint32(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint8.js b/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint8.js deleted file mode 100644 index 6c36723082..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dataviewsetuint8.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new DataView(new ArrayBuffer(24)); -var _offset = 1.5; -var _value = 1.5; -var _is_little_endian = true; -%DataViewSetUint8(_holder, _offset, _value, _is_little_endian); diff --git a/deps/v8/test/mjsunit/runtime-gen/datecacheversion.js b/deps/v8/test/mjsunit/runtime-gen/datecacheversion.js deleted file mode 100644 index ea56c73c74..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/datecacheversion.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%DateCacheVersion(); diff --git a/deps/v8/test/mjsunit/runtime-gen/datecurrenttime.js b/deps/v8/test/mjsunit/runtime-gen/datecurrenttime.js deleted file mode 100644 index 759ebd0038..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/datecurrenttime.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%DateCurrentTime(); diff --git a/deps/v8/test/mjsunit/runtime-gen/datelocaltimezone.js b/deps/v8/test/mjsunit/runtime-gen/datelocaltimezone.js deleted file mode 100644 index bfc1a81c7f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/datelocaltimezone.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%DateLocalTimezone(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/datemakeday.js b/deps/v8/test/mjsunit/runtime-gen/datemakeday.js deleted file mode 100644 index 3d2334f51e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/datemakeday.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _year = 1; -var _month = 1; -%DateMakeDay(_year, _month); diff --git a/deps/v8/test/mjsunit/runtime-gen/dateparsestring.js b/deps/v8/test/mjsunit/runtime-gen/dateparsestring.js deleted file mode 100644 index fdf5faa7e9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/dateparsestring.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _str = "foo"; -var arg1 = new Array(8); -%DateParseString(_str, arg1); diff --git a/deps/v8/test/mjsunit/runtime-gen/datesetvalue.js b/deps/v8/test/mjsunit/runtime-gen/datesetvalue.js deleted file mode 100644 index dac1a36447..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/datesetvalue.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _date = new Date(); -var _time = 1.5; -var _is_utc = 1; -%DateSetValue(_date, _time, _is_utc); diff --git a/deps/v8/test/mjsunit/runtime-gen/datetoutc.js b/deps/v8/test/mjsunit/runtime-gen/datetoutc.js deleted file mode 100644 index f46644e951..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/datetoutc.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%DateToUTC(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugasynctaskevent.js b/deps/v8/test/mjsunit/runtime-gen/debugasynctaskevent.js deleted file mode 100644 index ceeaf13774..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugasynctaskevent.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _data = new Object(); -%DebugAsyncTaskEvent(_data); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugbreak.js b/deps/v8/test/mjsunit/runtime-gen/debugbreak.js deleted file mode 100644 index 68220dfa9b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugbreak.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%DebugBreak(); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugcallbacksupportsstepping.js b/deps/v8/test/mjsunit/runtime-gen/debugcallbacksupportsstepping.js deleted file mode 100644 index b683be0aa4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugcallbacksupportsstepping.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _callback = new Object(); -%DebugCallbackSupportsStepping(_callback); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugconstructedby.js b/deps/v8/test/mjsunit/runtime-gen/debugconstructedby.js deleted file mode 100644 index 885034429b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugconstructedby.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _constructor = function() {}; -var _max_references = 32; -%DebugConstructedBy(_constructor, _max_references); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugdisassembleconstructor.js b/deps/v8/test/mjsunit/runtime-gen/debugdisassembleconstructor.js deleted file mode 100644 index c2faca4f0c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugdisassembleconstructor.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _func = function() {}; -%DebugDisassembleConstructor(_func); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugdisassemblefunction.js b/deps/v8/test/mjsunit/runtime-gen/debugdisassemblefunction.js deleted file mode 100644 index f65886779d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugdisassemblefunction.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _func = function() {}; -%DebugDisassembleFunction(_func); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugevaluate.js b/deps/v8/test/mjsunit/runtime-gen/debugevaluate.js deleted file mode 100644 index 60e1e63fd0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugevaluate.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _wrapped_id = 1; -var _inlined_jsframe_index = 32; -var _source = "foo"; -var _disable_break = true; -var _context_extension = new Object(); -try { -%DebugEvaluate(_break_id, _wrapped_id, _inlined_jsframe_index, _source, _disable_break, _context_extension); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/debugevaluateglobal.js b/deps/v8/test/mjsunit/runtime-gen/debugevaluateglobal.js deleted file mode 100644 index 11411d1992..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugevaluateglobal.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _source = "foo"; -var _disable_break = true; -var _context_extension = new Object(); -try { -%DebugEvaluateGlobal(_break_id, _source, _disable_break, _context_extension); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/debuggetproperty.js b/deps/v8/test/mjsunit/runtime-gen/debuggetproperty.js deleted file mode 100644 index 90109d1dc8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debuggetproperty.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _name = "name"; -%DebugGetProperty(_obj, _name); diff --git a/deps/v8/test/mjsunit/runtime-gen/debuggetpropertydetails.js b/deps/v8/test/mjsunit/runtime-gen/debuggetpropertydetails.js deleted file mode 100644 index 0fe2f3104f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debuggetpropertydetails.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _name = "name"; -%DebugGetPropertyDetails(_obj, _name); diff --git a/deps/v8/test/mjsunit/runtime-gen/debuggetprototype.js b/deps/v8/test/mjsunit/runtime-gen/debuggetprototype.js deleted file mode 100644 index 27de855b7b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debuggetprototype.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%DebugGetPrototype(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugindexedinterceptorelementvalue.js b/deps/v8/test/mjsunit/runtime-gen/debugindexedinterceptorelementvalue.js deleted file mode 100644 index 22d24eead9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugindexedinterceptorelementvalue.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _index = 32; -try { -%DebugIndexedInterceptorElementValue(_obj, _index); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/debugnamedinterceptorpropertyvalue.js b/deps/v8/test/mjsunit/runtime-gen/debugnamedinterceptorpropertyvalue.js deleted file mode 100644 index 13641d2c2b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugnamedinterceptorpropertyvalue.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _name = "name"; -try { -%DebugNamedInterceptorPropertyValue(_obj, _name); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpoppromise.js b/deps/v8/test/mjsunit/runtime-gen/debugpoppromise.js deleted file mode 100644 index 9b81b13705..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpoppromise.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%DebugPopPromise(); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpreparestepinifstepping.js b/deps/v8/test/mjsunit/runtime-gen/debugpreparestepinifstepping.js deleted file mode 100644 index a6061e6f98..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpreparestepinifstepping.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _callback = function() {}; -%DebugPrepareStepInIfStepping(_callback); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugprintscopes.js b/deps/v8/test/mjsunit/runtime-gen/debugprintscopes.js deleted file mode 100644 index 2f106ddb6a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugprintscopes.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%DebugPrintScopes(); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpromiseevent.js b/deps/v8/test/mjsunit/runtime-gen/debugpromiseevent.js deleted file mode 100644 index 20ae13c67a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpromiseevent.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _data = new Object(); -%DebugPromiseEvent(_data); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpromiserejectevent.js b/deps/v8/test/mjsunit/runtime-gen/debugpromiserejectevent.js deleted file mode 100644 index 4e6e633426..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpromiserejectevent.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _promise = new Object(); -var _value = new Object(); -%DebugPromiseRejectEvent(_promise, _value); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpropertyattributesfromdetails.js b/deps/v8/test/mjsunit/runtime-gen/debugpropertyattributesfromdetails.js deleted file mode 100644 index 7802a35242..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpropertyattributesfromdetails.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _details = 513; -%DebugPropertyAttributesFromDetails(_details); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpropertyindexfromdetails.js b/deps/v8/test/mjsunit/runtime-gen/debugpropertyindexfromdetails.js deleted file mode 100644 index 02edeeee24..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpropertyindexfromdetails.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _details = 513; -%DebugPropertyIndexFromDetails(_details); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpropertytypefromdetails.js b/deps/v8/test/mjsunit/runtime-gen/debugpropertytypefromdetails.js deleted file mode 100644 index 551ff2c621..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpropertytypefromdetails.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _details = 513; -%DebugPropertyTypeFromDetails(_details); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugpushpromise.js b/deps/v8/test/mjsunit/runtime-gen/debugpushpromise.js deleted file mode 100644 index 350a61354a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugpushpromise.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _promise = new Object(); -%DebugPushPromise(_promise); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugreferencedby.js b/deps/v8/test/mjsunit/runtime-gen/debugreferencedby.js deleted file mode 100644 index 94e1242793..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugreferencedby.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _target = new Object(); -var _instance_filter = new Object(); -var _max_references = 32; -%DebugReferencedBy(_target, _instance_filter, _max_references); diff --git a/deps/v8/test/mjsunit/runtime-gen/debugtrace.js b/deps/v8/test/mjsunit/runtime-gen/debugtrace.js deleted file mode 100644 index 2933ad114d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/debugtrace.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%DebugTrace(); diff --git a/deps/v8/test/mjsunit/runtime-gen/defineaccessorpropertyunchecked.js b/deps/v8/test/mjsunit/runtime-gen/defineaccessorpropertyunchecked.js deleted file mode 100644 index c6cbb91cc7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/defineaccessorpropertyunchecked.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _name = "name"; -var arg2 = function() {}; -var arg3 = function() {}; -var arg4 = 2; -%DefineAccessorPropertyUnchecked(_obj, _name, arg2, arg3, arg4); diff --git a/deps/v8/test/mjsunit/runtime-gen/defineapiaccessorproperty.js b/deps/v8/test/mjsunit/runtime-gen/defineapiaccessorproperty.js deleted file mode 100644 index 856a53129e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/defineapiaccessorproperty.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _name = "name"; -var arg2 = undefined; -var arg3 = undefined; -var _attribute = 1; -%DefineApiAccessorProperty(_object, _name, arg2, arg3, _attribute); diff --git a/deps/v8/test/mjsunit/runtime-gen/definedatapropertyunchecked.js b/deps/v8/test/mjsunit/runtime-gen/definedatapropertyunchecked.js deleted file mode 100644 index cb0f07f600..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/definedatapropertyunchecked.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _js_object = new Object(); -var _name = "name"; -var _obj_value = new Object(); -var _unchecked = 1; -%DefineDataPropertyUnchecked(_js_object, _name, _obj_value, _unchecked); diff --git a/deps/v8/test/mjsunit/runtime-gen/deleteproperty.js b/deps/v8/test/mjsunit/runtime-gen/deleteproperty.js deleted file mode 100644 index 66a882b1ab..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/deleteproperty.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _key = "name"; -var _strict_mode = 1; -%DeleteProperty(_object, _key, _strict_mode); diff --git a/deps/v8/test/mjsunit/runtime-gen/deoptimizefunction.js b/deps/v8/test/mjsunit/runtime-gen/deoptimizefunction.js deleted file mode 100644 index ec5db2ddae..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/deoptimizefunction.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function = function() {}; -%DeoptimizeFunction(_function); diff --git a/deps/v8/test/mjsunit/runtime-gen/doublehi.js b/deps/v8/test/mjsunit/runtime-gen/doublehi.js deleted file mode 100644 index ac945dcd28..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/doublehi.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%DoubleHi(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/doublelo.js b/deps/v8/test/mjsunit/runtime-gen/doublelo.js deleted file mode 100644 index 42c4c25495..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/doublelo.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%DoubleLo(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/enqueuemicrotask.js b/deps/v8/test/mjsunit/runtime-gen/enqueuemicrotask.js deleted file mode 100644 index 2f21667613..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/enqueuemicrotask.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _microtask = function() {}; -%EnqueueMicrotask(_microtask); diff --git a/deps/v8/test/mjsunit/runtime-gen/estimatenumberofelements.js b/deps/v8/test/mjsunit/runtime-gen/estimatenumberofelements.js deleted file mode 100644 index cf3b9b606f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/estimatenumberofelements.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _array = new Array(); -%EstimateNumberOfElements(_array); diff --git a/deps/v8/test/mjsunit/runtime-gen/executeindebugcontext.js b/deps/v8/test/mjsunit/runtime-gen/executeindebugcontext.js deleted file mode 100644 index 18bfac9b53..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/executeindebugcontext.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function = function() {}; -var _without_debugger = true; -%ExecuteInDebugContext(_function, _without_debugger); diff --git a/deps/v8/test/mjsunit/runtime-gen/finisharrayprototypesetup.js b/deps/v8/test/mjsunit/runtime-gen/finisharrayprototypesetup.js deleted file mode 100644 index e4e8eabab4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/finisharrayprototypesetup.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _prototype = new Array(); -%FinishArrayPrototypeSetup(_prototype); diff --git a/deps/v8/test/mjsunit/runtime-gen/fix.js b/deps/v8/test/mjsunit/runtime-gen/fix.js deleted file mode 100644 index 010d2bcb70..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/fix.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _proxy = Proxy.create({}); -%Fix(_proxy); diff --git a/deps/v8/test/mjsunit/runtime-gen/flattenstring.js b/deps/v8/test/mjsunit/runtime-gen/flattenstring.js deleted file mode 100644 index 3f0b38d6c8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/flattenstring.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _str = "foo"; -%FlattenString(_str); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionbindarguments.js b/deps/v8/test/mjsunit/runtime-gen/functionbindarguments.js deleted file mode 100644 index 4d36716253..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionbindarguments.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _bound_function = function() {}; -var _bindee = new Object(); -var arg2 = undefined; -var _new_length = 1.5; -%FunctionBindArguments(_bound_function, _bindee, arg2, _new_length); diff --git a/deps/v8/test/mjsunit/runtime-gen/functiongetinferredname.js b/deps/v8/test/mjsunit/runtime-gen/functiongetinferredname.js deleted file mode 100644 index 8d765007cb..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functiongetinferredname.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionGetInferredName(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functiongetname.js b/deps/v8/test/mjsunit/runtime-gen/functiongetname.js deleted file mode 100644 index ad23b11a69..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functiongetname.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionGetName(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functiongetscript.js b/deps/v8/test/mjsunit/runtime-gen/functiongetscript.js deleted file mode 100644 index bd4364447e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functiongetscript.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -%FunctionGetScript(_fun); diff --git a/deps/v8/test/mjsunit/runtime-gen/functiongetscriptsourceposition.js b/deps/v8/test/mjsunit/runtime-gen/functiongetscriptsourceposition.js deleted file mode 100644 index eb462f96f7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functiongetscriptsourceposition.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -%FunctionGetScriptSourcePosition(_fun); diff --git a/deps/v8/test/mjsunit/runtime-gen/functiongetsourcecode.js b/deps/v8/test/mjsunit/runtime-gen/functiongetsourcecode.js deleted file mode 100644 index b9de88a15d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functiongetsourcecode.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionGetSourceCode(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionisapifunction.js b/deps/v8/test/mjsunit/runtime-gen/functionisapifunction.js deleted file mode 100644 index 7fb8a21e0a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionisapifunction.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionIsAPIFunction(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionisarrow.js b/deps/v8/test/mjsunit/runtime-gen/functionisarrow.js deleted file mode 100644 index 08410b49dd..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionisarrow.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = () => null; -%FunctionIsArrow(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionisbuiltin.js b/deps/v8/test/mjsunit/runtime-gen/functionisbuiltin.js deleted file mode 100644 index a8dd6c6a88..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionisbuiltin.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionIsBuiltin(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionisgenerator.js b/deps/v8/test/mjsunit/runtime-gen/functionisgenerator.js deleted file mode 100644 index 8be6aab2a7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionisgenerator.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionIsGenerator(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionmarknameshouldprintasanonymous.js b/deps/v8/test/mjsunit/runtime-gen/functionmarknameshouldprintasanonymous.js deleted file mode 100644 index 74f18e258c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionmarknameshouldprintasanonymous.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionMarkNameShouldPrintAsAnonymous(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionnameshouldprintasanonymous.js b/deps/v8/test/mjsunit/runtime-gen/functionnameshouldprintasanonymous.js deleted file mode 100644 index aa5bcddc18..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionnameshouldprintasanonymous.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionNameShouldPrintAsAnonymous(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionremoveprototype.js b/deps/v8/test/mjsunit/runtime-gen/functionremoveprototype.js deleted file mode 100644 index a7ec5f52a9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionremoveprototype.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -%FunctionRemovePrototype(_f); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionsetinstanceclassname.js b/deps/v8/test/mjsunit/runtime-gen/functionsetinstanceclassname.js deleted file mode 100644 index 6986a15b1c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionsetinstanceclassname.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -var _name = "foo"; -%FunctionSetInstanceClassName(_fun, _name); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionsetlength.js b/deps/v8/test/mjsunit/runtime-gen/functionsetlength.js deleted file mode 100644 index 5582e82cf2..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionsetlength.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -var _length = 1; -%FunctionSetLength(_fun, _length); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionsetname.js b/deps/v8/test/mjsunit/runtime-gen/functionsetname.js deleted file mode 100644 index 0d44b20317..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionsetname.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _f = function() {}; -var _name = "foo"; -%FunctionSetName(_f, _name); diff --git a/deps/v8/test/mjsunit/runtime-gen/functionsetprototype.js b/deps/v8/test/mjsunit/runtime-gen/functionsetprototype.js deleted file mode 100644 index eb69ea8f5b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/functionsetprototype.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -var _value = new Object(); -%FunctionSetPrototype(_fun, _value); diff --git a/deps/v8/test/mjsunit/runtime-gen/getallscopesdetails.js b/deps/v8/test/mjsunit/runtime-gen/getallscopesdetails.js deleted file mode 100644 index 97ad7cb538..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getallscopesdetails.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _wrapped_id = 1; -var _inlined_jsframe_index = 32; -var _flag = true; -try { -%GetAllScopesDetails(_break_id, _wrapped_id, _inlined_jsframe_index, _flag); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getargumentsproperty.js b/deps/v8/test/mjsunit/runtime-gen/getargumentsproperty.js deleted file mode 100644 index 646e56be9f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getargumentsproperty.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _raw_key = new Object(); -%GetArgumentsProperty(_raw_key); diff --git a/deps/v8/test/mjsunit/runtime-gen/getarraykeys.js b/deps/v8/test/mjsunit/runtime-gen/getarraykeys.js deleted file mode 100644 index 341faa69ec..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getarraykeys.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _array = new Object(); -var _length = 32; -%GetArrayKeys(_array, _length); diff --git a/deps/v8/test/mjsunit/runtime-gen/getbreaklocations.js b/deps/v8/test/mjsunit/runtime-gen/getbreaklocations.js deleted file mode 100644 index d31fa15c51..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getbreaklocations.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -var arg1 = 0; -%GetBreakLocations(_fun, arg1); diff --git a/deps/v8/test/mjsunit/runtime-gen/getcalltrap.js b/deps/v8/test/mjsunit/runtime-gen/getcalltrap.js deleted file mode 100644 index 406af9ffd9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getcalltrap.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _proxy = Proxy.createFunction({}, function() {}); -%GetCallTrap(_proxy); diff --git a/deps/v8/test/mjsunit/runtime-gen/getconstructordelegate.js b/deps/v8/test/mjsunit/runtime-gen/getconstructordelegate.js deleted file mode 100644 index 6d01415667..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getconstructordelegate.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%GetConstructorDelegate(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/getconstructtrap.js b/deps/v8/test/mjsunit/runtime-gen/getconstructtrap.js deleted file mode 100644 index 116d301eb3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getconstructtrap.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _proxy = Proxy.createFunction({}, function() {}); -%GetConstructTrap(_proxy); diff --git a/deps/v8/test/mjsunit/runtime-gen/getdataproperty.js b/deps/v8/test/mjsunit/runtime-gen/getdataproperty.js deleted file mode 100644 index 59cfba56d9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getdataproperty.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _key = "name"; -%GetDataProperty(_object, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/getdefaulticulocale.js b/deps/v8/test/mjsunit/runtime-gen/getdefaulticulocale.js deleted file mode 100644 index 920f256683..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getdefaulticulocale.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%GetDefaultICULocale(); diff --git a/deps/v8/test/mjsunit/runtime-gen/getdefaultreceiver.js b/deps/v8/test/mjsunit/runtime-gen/getdefaultreceiver.js deleted file mode 100644 index 1d5b1cb44c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getdefaultreceiver.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = function() {}; -%GetDefaultReceiver(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/getframecount.js b/deps/v8/test/mjsunit/runtime-gen/getframecount.js deleted file mode 100644 index a958efcd7f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getframecount.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -try { -%GetFrameCount(_break_id); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getframedetails.js b/deps/v8/test/mjsunit/runtime-gen/getframedetails.js deleted file mode 100644 index 1138424845..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getframedetails.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _index = 32; -try { -%GetFrameDetails(_break_id, _index); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getfunctioncodepositionfromsource.js b/deps/v8/test/mjsunit/runtime-gen/getfunctioncodepositionfromsource.js deleted file mode 100644 index 473b263241..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getfunctioncodepositionfromsource.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function = function() {}; -var _source_position = 32; -%GetFunctionCodePositionFromSource(_function, _source_position); diff --git a/deps/v8/test/mjsunit/runtime-gen/getfunctiondelegate.js b/deps/v8/test/mjsunit/runtime-gen/getfunctiondelegate.js deleted file mode 100644 index 4d02ec2194..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getfunctiondelegate.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%GetFunctionDelegate(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/getfunctionscopecount.js b/deps/v8/test/mjsunit/runtime-gen/getfunctionscopecount.js deleted file mode 100644 index fb854cff42..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getfunctionscopecount.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -%GetFunctionScopeCount(_fun); diff --git a/deps/v8/test/mjsunit/runtime-gen/getfunctionscopedetails.js b/deps/v8/test/mjsunit/runtime-gen/getfunctionscopedetails.js deleted file mode 100644 index c24314003a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getfunctionscopedetails.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -var _index = 32; -%GetFunctionScopeDetails(_fun, _index); diff --git a/deps/v8/test/mjsunit/runtime-gen/gethandler.js b/deps/v8/test/mjsunit/runtime-gen/gethandler.js deleted file mode 100644 index ea982cbb51..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/gethandler.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _proxy = Proxy.create({}); -%GetHandler(_proxy); diff --git a/deps/v8/test/mjsunit/runtime-gen/getheapusage.js b/deps/v8/test/mjsunit/runtime-gen/getheapusage.js deleted file mode 100644 index cb174b72f2..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getheapusage.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%GetHeapUsage(); diff --git a/deps/v8/test/mjsunit/runtime-gen/getimplfrominitializedintlobject.js b/deps/v8/test/mjsunit/runtime-gen/getimplfrominitializedintlobject.js deleted file mode 100644 index 899ba8859e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getimplfrominitializedintlobject.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = new Intl.NumberFormat('en-US'); -%GetImplFromInitializedIntlObject(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/getindexedinterceptorelementnames.js b/deps/v8/test/mjsunit/runtime-gen/getindexedinterceptorelementnames.js deleted file mode 100644 index 8a83f0acd6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getindexedinterceptorelementnames.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%GetIndexedInterceptorElementNames(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/getinterceptorinfo.js b/deps/v8/test/mjsunit/runtime-gen/getinterceptorinfo.js deleted file mode 100644 index b33ba64916..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getinterceptorinfo.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%GetInterceptorInfo(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/getlanguagetagvariants.js b/deps/v8/test/mjsunit/runtime-gen/getlanguagetagvariants.js deleted file mode 100644 index 0ecfee522c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getlanguagetagvariants.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _input = new Array(); -%GetLanguageTagVariants(_input); diff --git a/deps/v8/test/mjsunit/runtime-gen/getnamedinterceptorpropertynames.js b/deps/v8/test/mjsunit/runtime-gen/getnamedinterceptorpropertynames.js deleted file mode 100644 index 0dee531be6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getnamedinterceptorpropertynames.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%GetNamedInterceptorPropertyNames(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/getobjectcontextnotifierperformchange.js b/deps/v8/test/mjsunit/runtime-gen/getobjectcontextnotifierperformchange.js deleted file mode 100644 index 2960acee45..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getobjectcontextnotifierperformchange.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object_info = new Object(); -%GetObjectContextNotifierPerformChange(_object_info); diff --git a/deps/v8/test/mjsunit/runtime-gen/getobjectcontextobjectgetnotifier.js b/deps/v8/test/mjsunit/runtime-gen/getobjectcontextobjectgetnotifier.js deleted file mode 100644 index d6a043061e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getobjectcontextobjectgetnotifier.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%GetObjectContextObjectGetNotifier(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/getobjectcontextobjectobserve.js b/deps/v8/test/mjsunit/runtime-gen/getobjectcontextobjectobserve.js deleted file mode 100644 index f1669e7385..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getobjectcontextobjectobserve.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%GetObjectContextObjectObserve(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/getobservationstate.js b/deps/v8/test/mjsunit/runtime-gen/getobservationstate.js deleted file mode 100644 index 429cdcd91f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getobservationstate.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%GetObservationState(); diff --git a/deps/v8/test/mjsunit/runtime-gen/getoptimizationcount.js b/deps/v8/test/mjsunit/runtime-gen/getoptimizationcount.js deleted file mode 100644 index da1ab9efcc..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getoptimizationcount.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function = function() {}; -%GetOptimizationCount(_function); diff --git a/deps/v8/test/mjsunit/runtime-gen/getownelementnames.js b/deps/v8/test/mjsunit/runtime-gen/getownelementnames.js deleted file mode 100644 index 54d9a69855..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getownelementnames.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%GetOwnElementNames(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/getownproperty.js b/deps/v8/test/mjsunit/runtime-gen/getownproperty.js deleted file mode 100644 index 1e5a808f71..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getownproperty.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _name = "name"; -%GetOwnProperty(_obj, _name); diff --git a/deps/v8/test/mjsunit/runtime-gen/getownpropertynames.js b/deps/v8/test/mjsunit/runtime-gen/getownpropertynames.js deleted file mode 100644 index 10f7f2c776..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getownpropertynames.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _filter_value = 1; -%GetOwnPropertyNames(_obj, _filter_value); diff --git a/deps/v8/test/mjsunit/runtime-gen/getproperty.js b/deps/v8/test/mjsunit/runtime-gen/getproperty.js deleted file mode 100644 index 569189a3aa..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getproperty.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _key = new Object(); -%GetProperty(_object, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/getpropertynames.js b/deps/v8/test/mjsunit/runtime-gen/getpropertynames.js deleted file mode 100644 index ad94eedc9c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getpropertynames.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%GetPropertyNames(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/getpropertynamesfast.js b/deps/v8/test/mjsunit/runtime-gen/getpropertynamesfast.js deleted file mode 100644 index c2d14cb653..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getpropertynamesfast.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _raw_object = new Object(); -%GetPropertyNamesFast(_raw_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/getprototype.js b/deps/v8/test/mjsunit/runtime-gen/getprototype.js deleted file mode 100644 index b9ef1f9912..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getprototype.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%GetPrototype(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/getrootnan.js b/deps/v8/test/mjsunit/runtime-gen/getrootnan.js deleted file mode 100644 index b6df0fd5fb..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getrootnan.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -try { -%GetRootNaN(); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getscopecount.js b/deps/v8/test/mjsunit/runtime-gen/getscopecount.js deleted file mode 100644 index d53bece37c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getscopecount.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _wrapped_id = 1; -try { -%GetScopeCount(_break_id, _wrapped_id); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getscopedetails.js b/deps/v8/test/mjsunit/runtime-gen/getscopedetails.js deleted file mode 100644 index 4ea28ac73e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getscopedetails.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _wrapped_id = 1; -var _inlined_jsframe_index = 32; -var _index = 32; -try { -%GetScopeDetails(_break_id, _wrapped_id, _inlined_jsframe_index, _index); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getscript.js b/deps/v8/test/mjsunit/runtime-gen/getscript.js deleted file mode 100644 index cae0087ccf..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getscript.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _script_name = "foo"; -%GetScript(_script_name); diff --git a/deps/v8/test/mjsunit/runtime-gen/getstepinpositions.js b/deps/v8/test/mjsunit/runtime-gen/getstepinpositions.js deleted file mode 100644 index 221c586ed4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getstepinpositions.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _wrapped_id = 1; -try { -%GetStepInPositions(_break_id, _wrapped_id); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/gettemplatefield.js b/deps/v8/test/mjsunit/runtime-gen/gettemplatefield.js deleted file mode 100644 index 16d3824b2d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/gettemplatefield.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _templ = new Object(); -var _index = 1; -try { -%GetTemplateField(_templ, _index); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getthreadcount.js b/deps/v8/test/mjsunit/runtime-gen/getthreadcount.js deleted file mode 100644 index 5037066a7d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getthreadcount.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -try { -%GetThreadCount(_break_id); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getthreaddetails.js b/deps/v8/test/mjsunit/runtime-gen/getthreaddetails.js deleted file mode 100644 index 6fc0d14ce4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getthreaddetails.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _break_id = 32; -var _index = 32; -try { -%GetThreadDetails(_break_id, _index); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/getv8version.js b/deps/v8/test/mjsunit/runtime-gen/getv8version.js deleted file mode 100644 index e311eef139..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getv8version.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%GetV8Version(); diff --git a/deps/v8/test/mjsunit/runtime-gen/getweakmapentries.js b/deps/v8/test/mjsunit/runtime-gen/getweakmapentries.js deleted file mode 100644 index ced728d3b5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getweakmapentries.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new WeakMap(); -%GetWeakMapEntries(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/getweaksetvalues.js b/deps/v8/test/mjsunit/runtime-gen/getweaksetvalues.js deleted file mode 100644 index 650c947d07..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/getweaksetvalues.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new WeakMap(); -%GetWeakSetValues(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/globalprint.js b/deps/v8/test/mjsunit/runtime-gen/globalprint.js deleted file mode 100644 index 059f08efe2..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/globalprint.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _string = "foo"; -%GlobalPrint(_string); diff --git a/deps/v8/test/mjsunit/runtime-gen/globalproxy.js b/deps/v8/test/mjsunit/runtime-gen/globalproxy.js deleted file mode 100644 index 80e500c887..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/globalproxy.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _global = new Object(); -%GlobalProxy(_global); diff --git a/deps/v8/test/mjsunit/runtime-gen/haselement.js b/deps/v8/test/mjsunit/runtime-gen/haselement.js deleted file mode 100644 index 3d32ac5f00..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/haselement.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _receiver = new Object(); -var _index = 1; -%HasElement(_receiver, _index); diff --git a/deps/v8/test/mjsunit/runtime-gen/hasownproperty.js b/deps/v8/test/mjsunit/runtime-gen/hasownproperty.js deleted file mode 100644 index 7443bff104..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/hasownproperty.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _key = "name"; -%HasOwnProperty(_object, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/hasproperty.js b/deps/v8/test/mjsunit/runtime-gen/hasproperty.js deleted file mode 100644 index df4de8eb34..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/hasproperty.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _receiver = new Object(); -var _key = "name"; -%HasProperty(_receiver, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/havesamemap.js b/deps/v8/test/mjsunit/runtime-gen/havesamemap.js deleted file mode 100644 index b399d17cb7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/havesamemap.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj1 = new Object(); -var _obj2 = new Object(); -%HaveSameMap(_obj1, _obj2); diff --git a/deps/v8/test/mjsunit/runtime-gen/internalcompare.js b/deps/v8/test/mjsunit/runtime-gen/internalcompare.js deleted file mode 100644 index 95cc006f31..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/internalcompare.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.Collator('en-US')); -var _string1 = "foo"; -var _string2 = "foo"; -%InternalCompare(arg0, _string1, _string2); diff --git a/deps/v8/test/mjsunit/runtime-gen/internaldateformat.js b/deps/v8/test/mjsunit/runtime-gen/internaldateformat.js deleted file mode 100644 index 933714e934..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/internaldateformat.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.DateTimeFormat('en-US')); -var _date = new Date(); -%InternalDateFormat(arg0, _date); diff --git a/deps/v8/test/mjsunit/runtime-gen/internaldateparse.js b/deps/v8/test/mjsunit/runtime-gen/internaldateparse.js deleted file mode 100644 index be8c49a942..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/internaldateparse.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.DateTimeFormat('en-US')); -var _date_string = "foo"; -%InternalDateParse(arg0, _date_string); diff --git a/deps/v8/test/mjsunit/runtime-gen/internalnumberformat.js b/deps/v8/test/mjsunit/runtime-gen/internalnumberformat.js deleted file mode 100644 index cd21edc247..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/internalnumberformat.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.NumberFormat('en-US')); -var _number = new Object(); -%InternalNumberFormat(arg0, _number); diff --git a/deps/v8/test/mjsunit/runtime-gen/internalnumberparse.js b/deps/v8/test/mjsunit/runtime-gen/internalnumberparse.js deleted file mode 100644 index cdbd322c4c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/internalnumberparse.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = %GetImplFromInitializedIntlObject(new Intl.NumberFormat('en-US')); -var _number_string = "foo"; -%InternalNumberParse(arg0, _number_string); diff --git a/deps/v8/test/mjsunit/runtime-gen/internalsetprototype.js b/deps/v8/test/mjsunit/runtime-gen/internalsetprototype.js deleted file mode 100644 index 1bc67d3826..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/internalsetprototype.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _prototype = new Object(); -%InternalSetPrototype(_obj, _prototype); diff --git a/deps/v8/test/mjsunit/runtime-gen/isattachedglobal.js b/deps/v8/test/mjsunit/runtime-gen/isattachedglobal.js deleted file mode 100644 index 9ead91a408..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isattachedglobal.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _global = new Object(); -%IsAttachedGlobal(_global); diff --git a/deps/v8/test/mjsunit/runtime-gen/isbreakonexception.js b/deps/v8/test/mjsunit/runtime-gen/isbreakonexception.js deleted file mode 100644 index e55c7d030a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isbreakonexception.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _type_arg = 32; -%IsBreakOnException(_type_arg); diff --git a/deps/v8/test/mjsunit/runtime-gen/isconcurrentrecompilationsupported.js b/deps/v8/test/mjsunit/runtime-gen/isconcurrentrecompilationsupported.js deleted file mode 100644 index 44e2917d72..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isconcurrentrecompilationsupported.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%IsConcurrentRecompilationSupported(); diff --git a/deps/v8/test/mjsunit/runtime-gen/isextensible.js b/deps/v8/test/mjsunit/runtime-gen/isextensible.js deleted file mode 100644 index 20a7c8d8a4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isextensible.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%IsExtensible(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/isinitializedintlobject.js b/deps/v8/test/mjsunit/runtime-gen/isinitializedintlobject.js deleted file mode 100644 index 2816e5e27a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isinitializedintlobject.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _input = new Object(); -%IsInitializedIntlObject(_input); diff --git a/deps/v8/test/mjsunit/runtime-gen/isinitializedintlobjectoftype.js b/deps/v8/test/mjsunit/runtime-gen/isinitializedintlobjectoftype.js deleted file mode 100644 index 60e3850082..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isinitializedintlobjectoftype.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _input = new Object(); -var _expected_type = "foo"; -%IsInitializedIntlObjectOfType(_input, _expected_type); diff --git a/deps/v8/test/mjsunit/runtime-gen/isinprototypechain.js b/deps/v8/test/mjsunit/runtime-gen/isinprototypechain.js deleted file mode 100644 index 37048348d1..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isinprototypechain.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _O = new Object(); -var _V = new Object(); -%IsInPrototypeChain(_O, _V); diff --git a/deps/v8/test/mjsunit/runtime-gen/isjsfunctionproxy.js b/deps/v8/test/mjsunit/runtime-gen/isjsfunctionproxy.js deleted file mode 100644 index ca6ea5a916..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isjsfunctionproxy.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%IsJSFunctionProxy(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/isjsglobalproxy.js b/deps/v8/test/mjsunit/runtime-gen/isjsglobalproxy.js deleted file mode 100644 index f0de610155..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isjsglobalproxy.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%IsJSGlobalProxy(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/isjsmodule.js b/deps/v8/test/mjsunit/runtime-gen/isjsmodule.js deleted file mode 100644 index 8b43a729fb..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isjsmodule.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%IsJSModule(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/isjsproxy.js b/deps/v8/test/mjsunit/runtime-gen/isjsproxy.js deleted file mode 100644 index a4d32beb16..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isjsproxy.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%IsJSProxy(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/isobserved.js b/deps/v8/test/mjsunit/runtime-gen/isobserved.js deleted file mode 100644 index f649a1b33e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isobserved.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%IsObserved(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/isoptimized.js b/deps/v8/test/mjsunit/runtime-gen/isoptimized.js deleted file mode 100644 index e1daf0da88..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isoptimized.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%IsOptimized(); diff --git a/deps/v8/test/mjsunit/runtime-gen/ispropertyenumerable.js b/deps/v8/test/mjsunit/runtime-gen/ispropertyenumerable.js deleted file mode 100644 index 575ee3468c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/ispropertyenumerable.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _key = "name"; -%IsPropertyEnumerable(_object, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/issloppymodefunction.js b/deps/v8/test/mjsunit/runtime-gen/issloppymodefunction.js deleted file mode 100644 index a0c75b32df..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/issloppymodefunction.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = function() {}; -%IsSloppyModeFunction(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/istemplate.js b/deps/v8/test/mjsunit/runtime-gen/istemplate.js deleted file mode 100644 index 421229fe6e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/istemplate.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _arg = new Object(); -%IsTemplate(_arg); diff --git a/deps/v8/test/mjsunit/runtime-gen/isvalidsmi.js b/deps/v8/test/mjsunit/runtime-gen/isvalidsmi.js deleted file mode 100644 index 98cf53bb2d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/isvalidsmi.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _number = 32; -%IsValidSmi(_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/keyedgetproperty.js b/deps/v8/test/mjsunit/runtime-gen/keyedgetproperty.js deleted file mode 100644 index cd8473c99a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/keyedgetproperty.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _receiver_obj = new Object(); -var _key_obj = new Object(); -%KeyedGetProperty(_receiver_obj, _key_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/liveeditcheckanddropactivations.js b/deps/v8/test/mjsunit/runtime-gen/liveeditcheckanddropactivations.js deleted file mode 100644 index 7247acc3a7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/liveeditcheckanddropactivations.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _shared_array = new Array(); -var _do_drop = true; -%LiveEditCheckAndDropActivations(_shared_array, _do_drop); diff --git a/deps/v8/test/mjsunit/runtime-gen/liveeditcomparestrings.js b/deps/v8/test/mjsunit/runtime-gen/liveeditcomparestrings.js deleted file mode 100644 index 611d78b03c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/liveeditcomparestrings.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _s1 = "foo"; -var _s2 = "foo"; -%LiveEditCompareStrings(_s1, _s2); diff --git a/deps/v8/test/mjsunit/runtime-gen/liveeditfunctionsetscript.js b/deps/v8/test/mjsunit/runtime-gen/liveeditfunctionsetscript.js deleted file mode 100644 index 51d61d3bc7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/liveeditfunctionsetscript.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function_object = new Object(); -var _script_object = new Object(); -%LiveEditFunctionSetScript(_function_object, _script_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/lookupaccessor.js b/deps/v8/test/mjsunit/runtime-gen/loadfromsuper.js index 89f40d76c9..25f4ff9ac8 100644 --- a/deps/v8/test/mjsunit/runtime-gen/lookupaccessor.js +++ b/deps/v8/test/mjsunit/runtime-gen/loadfromsuper.js @@ -1,7 +1,7 @@ // Copyright 2014 the V8 project authors. All rights reserved. // AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY // Flags: --allow-natives-syntax --harmony --harmony-proxies +var _home_object = new Object(); var _receiver = new Object(); var _name = "name"; -var _flag = 1; -%LookupAccessor(_receiver, _name, _flag); +%LoadFromSuper(_home_object, _receiver, _name); diff --git a/deps/v8/test/mjsunit/runtime-gen/loadmutabledouble.js b/deps/v8/test/mjsunit/runtime-gen/loadmutabledouble.js deleted file mode 100644 index 1a2e7e9f90..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/loadmutabledouble.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = {foo: 1.2}; -var _index = 1; -%LoadMutableDouble(arg0, _index); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapclear.js b/deps/v8/test/mjsunit/runtime-gen/mapclear.js deleted file mode 100644 index b34e694514..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapclear.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map(); -%MapClear(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapdelete.js b/deps/v8/test/mjsunit/runtime-gen/mapdelete.js deleted file mode 100644 index ab78954427..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapdelete.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map(); -var _key = new Object(); -%MapDelete(_holder, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapget.js b/deps/v8/test/mjsunit/runtime-gen/mapget.js deleted file mode 100644 index 0e996f5232..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapget.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map(); -var _key = new Object(); -%MapGet(_holder, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapgetsize.js b/deps/v8/test/mjsunit/runtime-gen/mapgetsize.js deleted file mode 100644 index 50a06044b4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapgetsize.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map(); -%MapGetSize(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/maphas.js b/deps/v8/test/mjsunit/runtime-gen/maphas.js deleted file mode 100644 index 2dc70c93e3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/maphas.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map(); -var _key = new Object(); -%MapHas(_holder, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapinitialize.js b/deps/v8/test/mjsunit/runtime-gen/mapinitialize.js deleted file mode 100644 index 6240a02594..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapinitialize.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map(); -%MapInitialize(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapiteratorinitialize.js b/deps/v8/test/mjsunit/runtime-gen/mapiteratorinitialize.js deleted file mode 100644 index 584fe18a4d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapiteratorinitialize.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map().entries(); -var _map = new Map(); -var _kind = 1; -%MapIteratorInitialize(_holder, _map, _kind); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapiteratornext.js b/deps/v8/test/mjsunit/runtime-gen/mapiteratornext.js deleted file mode 100644 index e155227023..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapiteratornext.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map().entries(); -var _value_array = new Array(); -%MapIteratorNext(_holder, _value_array); diff --git a/deps/v8/test/mjsunit/runtime-gen/mapset.js b/deps/v8/test/mjsunit/runtime-gen/mapset.js deleted file mode 100644 index 32c2080a8d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mapset.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Map(); -var _key = new Object(); -var _value = new Object(); -%MapSet(_holder, _key, _value); diff --git a/deps/v8/test/mjsunit/runtime-gen/markasinitializedintlobjectoftype.js b/deps/v8/test/mjsunit/runtime-gen/markasinitializedintlobjectoftype.js deleted file mode 100644 index bd0c581c89..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/markasinitializedintlobjectoftype.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _input = new Object(); -var _type = "foo"; -var _impl = new Object(); -%MarkAsInitializedIntlObjectOfType(_input, _type, _impl); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathacos.js b/deps/v8/test/mjsunit/runtime-gen/mathacos.js deleted file mode 100644 index fa44268389..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathacos.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathAcos(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathasin.js b/deps/v8/test/mjsunit/runtime-gen/mathasin.js deleted file mode 100644 index 0d20b3108d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathasin.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathAsin(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathatan.js b/deps/v8/test/mjsunit/runtime-gen/mathatan.js deleted file mode 100644 index 0e2708f1f2..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathatan.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathAtan(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathatan2.js b/deps/v8/test/mjsunit/runtime-gen/mathatan2.js deleted file mode 100644 index 4294797115..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathatan2.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -%MathAtan2(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathexprt.js b/deps/v8/test/mjsunit/runtime-gen/mathexprt.js deleted file mode 100644 index e4584366de..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathexprt.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathExpRT(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathfloorrt.js b/deps/v8/test/mjsunit/runtime-gen/mathfloorrt.js deleted file mode 100644 index 2ae83aab52..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathfloorrt.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathFloorRT(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathfround.js b/deps/v8/test/mjsunit/runtime-gen/mathfround.js deleted file mode 100644 index 10a92986c1..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathfround.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathFround(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathlogrt.js b/deps/v8/test/mjsunit/runtime-gen/mathlogrt.js deleted file mode 100644 index 5c484cbbb1..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathlogrt.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathLogRT(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/mathsqrtrt.js b/deps/v8/test/mjsunit/runtime-gen/mathsqrtrt.js deleted file mode 100644 index e0df8d72d5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/mathsqrtrt.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%MathSqrtRT(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/maxsmi.js b/deps/v8/test/mjsunit/runtime-gen/maxsmi.js deleted file mode 100644 index 717a6544eb..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/maxsmi.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%MaxSmi(); diff --git a/deps/v8/test/mjsunit/runtime-gen/movearraycontents.js b/deps/v8/test/mjsunit/runtime-gen/movearraycontents.js deleted file mode 100644 index 41c4ee1cd3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/movearraycontents.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _from = new Array(); -var _to = new Array(); -%MoveArrayContents(_from, _to); diff --git a/deps/v8/test/mjsunit/runtime-gen/neveroptimizefunction.js b/deps/v8/test/mjsunit/runtime-gen/neveroptimizefunction.js deleted file mode 100644 index b03e42f1f8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/neveroptimizefunction.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function = function() {}; -%NeverOptimizeFunction(_function); diff --git a/deps/v8/test/mjsunit/runtime-gen/newarguments.js b/deps/v8/test/mjsunit/runtime-gen/newarguments.js deleted file mode 100644 index 908fc3af7c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/newarguments.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _callee = function() {}; -%NewArguments(_callee); diff --git a/deps/v8/test/mjsunit/runtime-gen/newobjectfrombound.js b/deps/v8/test/mjsunit/runtime-gen/newobjectfrombound.js deleted file mode 100644 index 36f75077b6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/newobjectfrombound.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = (function() {}).bind({}); -%NewObjectFromBound(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/newstring.js b/deps/v8/test/mjsunit/runtime-gen/newstring.js deleted file mode 100644 index 24b01489e5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/newstring.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _length = 1; -var _is_one_byte = true; -%NewString(_length, _is_one_byte); diff --git a/deps/v8/test/mjsunit/runtime-gen/newstringwrapper.js b/deps/v8/test/mjsunit/runtime-gen/newstringwrapper.js deleted file mode 100644 index cf53a3af20..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/newstringwrapper.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _value = "foo"; -%NewStringWrapper(_value); diff --git a/deps/v8/test/mjsunit/runtime-gen/newsymbolwrapper.js b/deps/v8/test/mjsunit/runtime-gen/newsymbolwrapper.js deleted file mode 100644 index 08c0ea7e60..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/newsymbolwrapper.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _symbol = Symbol("symbol"); -%NewSymbolWrapper(_symbol); diff --git a/deps/v8/test/mjsunit/runtime-gen/notifycontextdisposed.js b/deps/v8/test/mjsunit/runtime-gen/notifycontextdisposed.js deleted file mode 100644 index d353fc5cea..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/notifycontextdisposed.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%NotifyContextDisposed(); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberadd.js b/deps/v8/test/mjsunit/runtime-gen/numberadd.js deleted file mode 100644 index f85017d49d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberadd.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -%NumberAdd(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberand.js b/deps/v8/test/mjsunit/runtime-gen/numberand.js deleted file mode 100644 index 9635e11bb6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberand.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 32; -var _y = 32; -%NumberAnd(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbercompare.js b/deps/v8/test/mjsunit/runtime-gen/numbercompare.js deleted file mode 100644 index 5f7ac9363c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbercompare.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -var _uncomparable_result = new Object(); -%NumberCompare(_x, _y, _uncomparable_result); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberdiv.js b/deps/v8/test/mjsunit/runtime-gen/numberdiv.js deleted file mode 100644 index c62d5921c7..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberdiv.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -%NumberDiv(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberequals.js b/deps/v8/test/mjsunit/runtime-gen/numberequals.js deleted file mode 100644 index 3b919fc02f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberequals.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -%NumberEquals(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberimul.js b/deps/v8/test/mjsunit/runtime-gen/numberimul.js deleted file mode 100644 index f3c98bdc28..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberimul.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 32; -var _y = 32; -%NumberImul(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbermod.js b/deps/v8/test/mjsunit/runtime-gen/numbermod.js deleted file mode 100644 index 6d5faeb2c5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbermod.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -%NumberMod(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbermul.js b/deps/v8/test/mjsunit/runtime-gen/numbermul.js deleted file mode 100644 index 0bdc7c2378..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbermul.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -%NumberMul(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberor.js b/deps/v8/test/mjsunit/runtime-gen/numberor.js deleted file mode 100644 index c5ac65fc8d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberor.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 32; -var _y = 32; -%NumberOr(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbersar.js b/deps/v8/test/mjsunit/runtime-gen/numbersar.js deleted file mode 100644 index 639270a08a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbersar.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 32; -var _y = 32; -%NumberSar(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbershl.js b/deps/v8/test/mjsunit/runtime-gen/numbershl.js deleted file mode 100644 index b505ff6ed8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbershl.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 32; -var _y = 32; -%NumberShl(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbershr.js b/deps/v8/test/mjsunit/runtime-gen/numbershr.js deleted file mode 100644 index bd1a3c4541..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbershr.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 32; -var _y = 32; -%NumberShr(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbersub.js b/deps/v8/test/mjsunit/runtime-gen/numbersub.js deleted file mode 100644 index 5c99f872fa..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbersub.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -var _y = 1.5; -%NumberSub(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertoexponential.js b/deps/v8/test/mjsunit/runtime-gen/numbertoexponential.js deleted file mode 100644 index 30159bb3ad..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertoexponential.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _value = 1.5; -var _f_number = 1.5; -%NumberToExponential(_value, _f_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertofixed.js b/deps/v8/test/mjsunit/runtime-gen/numbertofixed.js deleted file mode 100644 index 0df152541a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertofixed.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _value = 1.5; -var _f_number = 1.5; -%NumberToFixed(_value, _f_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertointeger.js b/deps/v8/test/mjsunit/runtime-gen/numbertointeger.js deleted file mode 100644 index eada58f45a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertointeger.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _number = 1.5; -%NumberToInteger(_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertointegermapminuszero.js b/deps/v8/test/mjsunit/runtime-gen/numbertointegermapminuszero.js deleted file mode 100644 index ce32480610..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertointegermapminuszero.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _number = 1.5; -%NumberToIntegerMapMinusZero(_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertojsint32.js b/deps/v8/test/mjsunit/runtime-gen/numbertojsint32.js deleted file mode 100644 index 77321f9c62..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertojsint32.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _number = 1.5; -%NumberToJSInt32(_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertojsuint32.js b/deps/v8/test/mjsunit/runtime-gen/numbertojsuint32.js deleted file mode 100644 index d4f7302fe9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertojsuint32.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _number = 32; -%NumberToJSUint32(_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertoprecision.js b/deps/v8/test/mjsunit/runtime-gen/numbertoprecision.js deleted file mode 100644 index 6591117ec8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertoprecision.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _value = 1.5; -var _f_number = 1.5; -%NumberToPrecision(_value, _f_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertoradixstring.js b/deps/v8/test/mjsunit/runtime-gen/numbertoradixstring.js deleted file mode 100644 index 020aac2853..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertoradixstring.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _value = 1.5; -var arg1 = 2; -%NumberToRadixString(_value, arg1); diff --git a/deps/v8/test/mjsunit/runtime-gen/numbertostringrt.js b/deps/v8/test/mjsunit/runtime-gen/numbertostringrt.js deleted file mode 100644 index 4b2b6d93b0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numbertostringrt.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _number = 1.5; -%NumberToStringRT(_number); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberunaryminus.js b/deps/v8/test/mjsunit/runtime-gen/numberunaryminus.js deleted file mode 100644 index 54dc49eda9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberunaryminus.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%NumberUnaryMinus(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/numberxor.js b/deps/v8/test/mjsunit/runtime-gen/numberxor.js deleted file mode 100644 index 237269803b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/numberxor.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 32; -var _y = 32; -%NumberXor(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/objectfreeze.js b/deps/v8/test/mjsunit/runtime-gen/objectfreeze.js deleted file mode 100644 index cfc066c6f1..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/objectfreeze.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%ObjectFreeze(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/objectwascreatedincurrentorigin.js b/deps/v8/test/mjsunit/runtime-gen/objectwascreatedincurrentorigin.js deleted file mode 100644 index 776997009c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/objectwascreatedincurrentorigin.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%ObjectWasCreatedInCurrentOrigin(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/observationweakmapcreate.js b/deps/v8/test/mjsunit/runtime-gen/observationweakmapcreate.js deleted file mode 100644 index 6c71eace41..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/observationweakmapcreate.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%ObservationWeakMapCreate(); diff --git a/deps/v8/test/mjsunit/runtime-gen/observerobjectandrecordhavesameorigin.js b/deps/v8/test/mjsunit/runtime-gen/observerobjectandrecordhavesameorigin.js deleted file mode 100644 index 6c251ecd95..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/observerobjectandrecordhavesameorigin.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _observer = function() {}; -var _object = new Object(); -var _record = new Object(); -%ObserverObjectAndRecordHaveSameOrigin(_observer, _object, _record); diff --git a/deps/v8/test/mjsunit/runtime-gen/optimizeobjectforaddingmultipleproperties.js b/deps/v8/test/mjsunit/runtime-gen/optimizeobjectforaddingmultipleproperties.js deleted file mode 100644 index 7016e1c062..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/optimizeobjectforaddingmultipleproperties.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _properties = 1; -%OptimizeObjectForAddingMultipleProperties(_object, _properties); diff --git a/deps/v8/test/mjsunit/runtime-gen/ownkeys.js b/deps/v8/test/mjsunit/runtime-gen/ownkeys.js deleted file mode 100644 index 0a392422cc..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/ownkeys.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _raw_object = new Object(); -%OwnKeys(_raw_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/parsejson.js b/deps/v8/test/mjsunit/runtime-gen/parsejson.js deleted file mode 100644 index 0a038790ea..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/parsejson.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = "{}"; -%ParseJson(arg0); diff --git a/deps/v8/test/mjsunit/runtime-gen/preventextensions.js b/deps/v8/test/mjsunit/runtime-gen/preventextensions.js deleted file mode 100644 index 8e24b75e0c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/preventextensions.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%PreventExtensions(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/pushifabsent.js b/deps/v8/test/mjsunit/runtime-gen/pushifabsent.js deleted file mode 100644 index c998121f53..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/pushifabsent.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _array = new Array(); -var _element = new Object(); -%PushIfAbsent(_array, _element); diff --git a/deps/v8/test/mjsunit/runtime-gen/quotejsonstring.js b/deps/v8/test/mjsunit/runtime-gen/quotejsonstring.js deleted file mode 100644 index 61ade34263..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/quotejsonstring.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _string = "foo"; -%QuoteJSONString(_string); diff --git a/deps/v8/test/mjsunit/runtime-gen/regexpcompile.js b/deps/v8/test/mjsunit/runtime-gen/regexpcompile.js deleted file mode 100644 index c0edfa6fcf..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/regexpcompile.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _re = /ab/g; -var _pattern = "foo"; -var _flags = "foo"; -%RegExpCompile(_re, _pattern, _flags); diff --git a/deps/v8/test/mjsunit/runtime-gen/regexpconstructresult.js b/deps/v8/test/mjsunit/runtime-gen/regexpconstructresult.js deleted file mode 100644 index 50d2e0d8fe..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/regexpconstructresult.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _size = 1; -var _index = new Object(); -var _input = new Object(); -%_RegExpConstructResult(_size, _index, _input); diff --git a/deps/v8/test/mjsunit/runtime-gen/regexpexecmultiple.js b/deps/v8/test/mjsunit/runtime-gen/regexpexecmultiple.js deleted file mode 100644 index 9db6e6d2b3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/regexpexecmultiple.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _regexp = /ab/g; -var _subject = "foo"; -var arg2 = ['a']; -var arg3 = ['a']; -%RegExpExecMultiple(_regexp, _subject, arg2, arg3); diff --git a/deps/v8/test/mjsunit/runtime-gen/regexpexecrt.js b/deps/v8/test/mjsunit/runtime-gen/regexpexecrt.js deleted file mode 100644 index 3b20191f2b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/regexpexecrt.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _regexp = /ab/g; -var _subject = "foo"; -var _index = 1; -var _last_match_info = new Array(); -%RegExpExecRT(_regexp, _subject, _index, _last_match_info); diff --git a/deps/v8/test/mjsunit/runtime-gen/regexpinitializeobject.js b/deps/v8/test/mjsunit/runtime-gen/regexpinitializeobject.js deleted file mode 100644 index fccdeeed78..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/regexpinitializeobject.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _regexp = /ab/g; -var _source = "foo"; -var _global = new Object(); -var _ignoreCase = new Object(); -var _multiline = new Object(); -%RegExpInitializeObject(_regexp, _source, _global, _ignoreCase, _multiline); diff --git a/deps/v8/test/mjsunit/runtime-gen/removearrayholes.js b/deps/v8/test/mjsunit/runtime-gen/removearrayholes.js deleted file mode 100644 index 971e63cab5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/removearrayholes.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -var _limit = 32; -%RemoveArrayHoles(_object, _limit); diff --git a/deps/v8/test/mjsunit/runtime-gen/rempio2.js b/deps/v8/test/mjsunit/runtime-gen/rempio2.js deleted file mode 100644 index 6d47bac4ac..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/rempio2.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = 1.5; -%RemPiO2(_x); diff --git a/deps/v8/test/mjsunit/runtime-gen/roundnumber.js b/deps/v8/test/mjsunit/runtime-gen/roundnumber.js deleted file mode 100644 index 2ec1159b2b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/roundnumber.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _input = 1.5; -%RoundNumber(_input); diff --git a/deps/v8/test/mjsunit/runtime-gen/runmicrotasks.js b/deps/v8/test/mjsunit/runtime-gen/runmicrotasks.js deleted file mode 100644 index 945260a8df..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/runmicrotasks.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%RunMicrotasks(); diff --git a/deps/v8/test/mjsunit/runtime-gen/runninginsimulator.js b/deps/v8/test/mjsunit/runtime-gen/runninginsimulator.js deleted file mode 100644 index fe5678259d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/runninginsimulator.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%RunningInSimulator(); diff --git a/deps/v8/test/mjsunit/runtime-gen/setadd.js b/deps/v8/test/mjsunit/runtime-gen/setadd.js deleted file mode 100644 index 75b923fbf3..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setadd.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set(); -var _key = new Object(); -%SetAdd(_holder, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/setclear.js b/deps/v8/test/mjsunit/runtime-gen/setclear.js deleted file mode 100644 index 82ef6d955b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setclear.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set(); -%SetClear(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/setcode.js b/deps/v8/test/mjsunit/runtime-gen/setcode.js deleted file mode 100644 index 4e2206fbc8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setcode.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _target = function() {}; -var _source = function() {}; -%SetCode(_target, _source); diff --git a/deps/v8/test/mjsunit/runtime-gen/setdebugeventlistener.js b/deps/v8/test/mjsunit/runtime-gen/setdebugeventlistener.js deleted file mode 100644 index d51b277b80..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setdebugeventlistener.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = undefined; -var _data = new Object(); -%SetDebugEventListener(arg0, _data); diff --git a/deps/v8/test/mjsunit/runtime-gen/setdelete.js b/deps/v8/test/mjsunit/runtime-gen/setdelete.js deleted file mode 100644 index 80bd343d0e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setdelete.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set(); -var _key = new Object(); -%SetDelete(_holder, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/setdisablebreak.js b/deps/v8/test/mjsunit/runtime-gen/setdisablebreak.js deleted file mode 100644 index 461942b60f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setdisablebreak.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _disable_break = true; -%SetDisableBreak(_disable_break); diff --git a/deps/v8/test/mjsunit/runtime-gen/setflags.js b/deps/v8/test/mjsunit/runtime-gen/setflags.js deleted file mode 100644 index 70db03ee98..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setflags.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _arg = "foo"; -%SetFlags(_arg); diff --git a/deps/v8/test/mjsunit/runtime-gen/setfunctionbreakpoint.js b/deps/v8/test/mjsunit/runtime-gen/setfunctionbreakpoint.js deleted file mode 100644 index 010330e5a4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setfunctionbreakpoint.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _function = function() {}; -var arg1 = 218; -var _break_point_object_arg = new Object(); -%SetFunctionBreakPoint(_function, arg1, _break_point_object_arg); diff --git a/deps/v8/test/mjsunit/runtime-gen/setgetsize.js b/deps/v8/test/mjsunit/runtime-gen/setgetsize.js deleted file mode 100644 index 842016bb2d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setgetsize.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set(); -%SetGetSize(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/sethas.js b/deps/v8/test/mjsunit/runtime-gen/sethas.js deleted file mode 100644 index 8cec0d8c35..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/sethas.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set(); -var _key = new Object(); -%SetHas(_holder, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/setinitialize.js b/deps/v8/test/mjsunit/runtime-gen/setinitialize.js deleted file mode 100644 index b21a089692..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setinitialize.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set(); -%SetInitialize(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/setisobserved.js b/deps/v8/test/mjsunit/runtime-gen/setisobserved.js deleted file mode 100644 index d885113ffa..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setisobserved.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%SetIsObserved(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/setiteratorinitialize.js b/deps/v8/test/mjsunit/runtime-gen/setiteratorinitialize.js deleted file mode 100644 index 34769e51dc..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setiteratorinitialize.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set().values(); -var _set = new Set(); -var arg2 = 2; -%SetIteratorInitialize(_holder, _set, arg2); diff --git a/deps/v8/test/mjsunit/runtime-gen/setiteratornext.js b/deps/v8/test/mjsunit/runtime-gen/setiteratornext.js deleted file mode 100644 index 02b74d44da..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setiteratornext.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Set().values(); -var _value_array = new Array(); -%SetIteratorNext(_holder, _value_array); diff --git a/deps/v8/test/mjsunit/runtime-gen/setprototype.js b/deps/v8/test/mjsunit/runtime-gen/setprototype.js deleted file mode 100644 index 6353151f4e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setprototype.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -var _prototype = new Object(); -%SetPrototype(_obj, _prototype); diff --git a/deps/v8/test/mjsunit/runtime-gen/setscopevariablevalue.js b/deps/v8/test/mjsunit/runtime-gen/setscopevariablevalue.js deleted file mode 100644 index 680bab52cc..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/setscopevariablevalue.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _fun = function() {}; -var _wrapped_id = 1; -var _inlined_jsframe_index = 32; -var _index = 32; -var _variable_name = "foo"; -var _new_value = new Object(); -%SetScopeVariableValue(_fun, _wrapped_id, _inlined_jsframe_index, _index, _variable_name, _new_value); diff --git a/deps/v8/test/mjsunit/runtime-gen/smilexicographiccompare.js b/deps/v8/test/mjsunit/runtime-gen/smilexicographiccompare.js deleted file mode 100644 index d227a9ffc1..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/smilexicographiccompare.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x_value = 1; -var _y_value = 1; -%SmiLexicographicCompare(_x_value, _y_value); diff --git a/deps/v8/test/mjsunit/runtime-gen/sparsejoinwithseparator.js b/deps/v8/test/mjsunit/runtime-gen/sparsejoinwithseparator.js deleted file mode 100644 index 3a8e7754d4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/sparsejoinwithseparator.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _elements_array = new Array(); -var _array_length = 32; -var _separator = "foo"; -%SparseJoinWithSeparator(_elements_array, _array_length, _separator); diff --git a/deps/v8/test/mjsunit/runtime-gen/specialarrayfunctions.js b/deps/v8/test/mjsunit/runtime-gen/specialarrayfunctions.js deleted file mode 100644 index 5956e8422c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/specialarrayfunctions.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%SpecialArrayFunctions(); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringbuilderconcat.js b/deps/v8/test/mjsunit/runtime-gen/stringbuilderconcat.js deleted file mode 100644 index 9d7c78a3e6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringbuilderconcat.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = [1, 2, 3]; -var arg1 = 3; -var _special = "foo"; -%StringBuilderConcat(arg0, arg1, _special); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringbuilderjoin.js b/deps/v8/test/mjsunit/runtime-gen/stringbuilderjoin.js deleted file mode 100644 index bf990c62d6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringbuilderjoin.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var arg0 = ['a', 'b']; -var arg1 = 4; -var _separator = "foo"; -%StringBuilderJoin(arg0, arg1, _separator); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringcharcodeatrt.js b/deps/v8/test/mjsunit/runtime-gen/stringcharcodeatrt.js deleted file mode 100644 index fa016ac00e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringcharcodeatrt.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -var _i = 32; -%StringCharCodeAtRT(_subject, _i); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringequals.js b/deps/v8/test/mjsunit/runtime-gen/stringequals.js deleted file mode 100644 index 14e40eb028..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringequals.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _x = "foo"; -var _y = "foo"; -%StringEquals(_x, _y); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringindexof.js b/deps/v8/test/mjsunit/runtime-gen/stringindexof.js deleted file mode 100644 index 3c5cab31c5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringindexof.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _sub = "foo"; -var _pat = "foo"; -var _index = new Object(); -%StringIndexOf(_sub, _pat, _index); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringlastindexof.js b/deps/v8/test/mjsunit/runtime-gen/stringlastindexof.js deleted file mode 100644 index afbc51f5a4..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringlastindexof.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _sub = "foo"; -var _pat = "foo"; -var _index = new Object(); -%StringLastIndexOf(_sub, _pat, _index); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringlocalecompare.js b/deps/v8/test/mjsunit/runtime-gen/stringlocalecompare.js deleted file mode 100644 index b37e231183..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringlocalecompare.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _str1 = "foo"; -var _str2 = "foo"; -%StringLocaleCompare(_str1, _str2); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringmatch.js b/deps/v8/test/mjsunit/runtime-gen/stringmatch.js deleted file mode 100644 index 330aeae9c0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringmatch.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -var _regexp = /ab/g; -var arg2 = ['a', 'b']; -%StringMatch(_subject, _regexp, arg2); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringnormalize.js b/deps/v8/test/mjsunit/runtime-gen/stringnormalize.js deleted file mode 100644 index fb408a41a5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringnormalize.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _stringValue = "foo"; -var arg1 = 2; -%StringNormalize(_stringValue, arg1); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringparsefloat.js b/deps/v8/test/mjsunit/runtime-gen/stringparsefloat.js deleted file mode 100644 index 520a24e756..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringparsefloat.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -%StringParseFloat(_subject); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringparseint.js b/deps/v8/test/mjsunit/runtime-gen/stringparseint.js deleted file mode 100644 index 43116554eb..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringparseint.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -var _radix = 32; -%StringParseInt(_subject, _radix); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringreplaceglobalregexpwithstring.js b/deps/v8/test/mjsunit/runtime-gen/stringreplaceglobalregexpwithstring.js deleted file mode 100644 index ad2b6e67d9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringreplaceglobalregexpwithstring.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -var _regexp = /ab/g; -var _replacement = "foo"; -var arg3 = ['a']; -%StringReplaceGlobalRegExpWithString(_subject, _regexp, _replacement, arg3); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringreplaceonecharwithstring.js b/deps/v8/test/mjsunit/runtime-gen/stringreplaceonecharwithstring.js deleted file mode 100644 index 5e38a79f44..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringreplaceonecharwithstring.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -var _search = "foo"; -var _replace = "foo"; -%StringReplaceOneCharWithString(_subject, _search, _replace); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringsplit.js b/deps/v8/test/mjsunit/runtime-gen/stringsplit.js deleted file mode 100644 index dfe683194a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringsplit.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -var _pattern = "foo"; -var _limit = 32; -%StringSplit(_subject, _pattern, _limit); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringtoarray.js b/deps/v8/test/mjsunit/runtime-gen/stringtoarray.js deleted file mode 100644 index 6ed48a771a..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringtoarray.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _s = "foo"; -var _limit = 32; -%StringToArray(_s, _limit); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringtolowercase.js b/deps/v8/test/mjsunit/runtime-gen/stringtolowercase.js deleted file mode 100644 index 3a7261a0e0..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringtolowercase.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _s = "foo"; -%StringToLowerCase(_s); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringtonumber.js b/deps/v8/test/mjsunit/runtime-gen/stringtonumber.js deleted file mode 100644 index 88e2e84a2e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringtonumber.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _subject = "foo"; -%StringToNumber(_subject); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringtouppercase.js b/deps/v8/test/mjsunit/runtime-gen/stringtouppercase.js deleted file mode 100644 index b7d9731015..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringtouppercase.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _s = "foo"; -%StringToUpperCase(_s); diff --git a/deps/v8/test/mjsunit/runtime-gen/stringtrim.js b/deps/v8/test/mjsunit/runtime-gen/stringtrim.js deleted file mode 100644 index 75d197efa9..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/stringtrim.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _string = "foo"; -var _trimLeft = true; -var _trimRight = true; -%StringTrim(_string, _trimLeft, _trimRight); diff --git a/deps/v8/test/mjsunit/runtime-gen/symboldescription.js b/deps/v8/test/mjsunit/runtime-gen/symboldescription.js deleted file mode 100644 index 13360828b8..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/symboldescription.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _symbol = Symbol("symbol"); -%SymbolDescription(_symbol); diff --git a/deps/v8/test/mjsunit/runtime-gen/symbolisprivate.js b/deps/v8/test/mjsunit/runtime-gen/symbolisprivate.js deleted file mode 100644 index 8e5343e1d5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/symbolisprivate.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _symbol = Symbol("symbol"); -%SymbolIsPrivate(_symbol); diff --git a/deps/v8/test/mjsunit/runtime-gen/symbolregistry.js b/deps/v8/test/mjsunit/runtime-gen/symbolregistry.js deleted file mode 100644 index 71964e6eae..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/symbolregistry.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%SymbolRegistry(); diff --git a/deps/v8/test/mjsunit/runtime-gen/tobool.js b/deps/v8/test/mjsunit/runtime-gen/tobool.js deleted file mode 100644 index ca522c8a9f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/tobool.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%ToBool(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/tofastproperties.js b/deps/v8/test/mjsunit/runtime-gen/tofastproperties.js deleted file mode 100644 index f9c1890b1c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/tofastproperties.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%ToFastProperties(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/traceenter.js b/deps/v8/test/mjsunit/runtime-gen/traceenter.js deleted file mode 100644 index 768a0c2437..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/traceenter.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%TraceEnter(); diff --git a/deps/v8/test/mjsunit/runtime-gen/traceexit.js b/deps/v8/test/mjsunit/runtime-gen/traceexit.js deleted file mode 100644 index 378d008c90..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/traceexit.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%TraceExit(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/truncatestring.js b/deps/v8/test/mjsunit/runtime-gen/truncatestring.js deleted file mode 100644 index 64ef628e5b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/truncatestring.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _string = "seqstring"; -var _new_length = 1; -%TruncateString(_string, _new_length); diff --git a/deps/v8/test/mjsunit/runtime-gen/trymigrateinstance.js b/deps/v8/test/mjsunit/runtime-gen/trymigrateinstance.js deleted file mode 100644 index b82eb741bb..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/trymigrateinstance.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _object = new Object(); -%TryMigrateInstance(_object); diff --git a/deps/v8/test/mjsunit/runtime-gen/typedarraygetbuffer.js b/deps/v8/test/mjsunit/runtime-gen/typedarraygetbuffer.js deleted file mode 100644 index 56a805b3b2..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/typedarraygetbuffer.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Int32Array(2); -%TypedArrayGetBuffer(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/typedarraygetlength.js b/deps/v8/test/mjsunit/runtime-gen/typedarraygetlength.js deleted file mode 100644 index 8d1865f40f..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/typedarraygetlength.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Int32Array(2); -%TypedArrayGetLength(_holder); diff --git a/deps/v8/test/mjsunit/runtime-gen/typedarrayinitialize.js b/deps/v8/test/mjsunit/runtime-gen/typedarrayinitialize.js deleted file mode 100644 index be1e29607e..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/typedarrayinitialize.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Int32Array(2); -var arg1 = 6; -var arg2 = new ArrayBuffer(8); -var _byte_offset_object = 1.5; -var arg4 = 4; -%TypedArrayInitialize(_holder, arg1, arg2, _byte_offset_object, arg4); diff --git a/deps/v8/test/mjsunit/runtime-gen/typedarrayinitializefromarraylike.js b/deps/v8/test/mjsunit/runtime-gen/typedarrayinitializefromarraylike.js deleted file mode 100644 index 0ca7a0f7ce..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/typedarrayinitializefromarraylike.js +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _holder = new Int32Array(2); -var arg1 = 6; -var _source = new Object(); -var _length_obj = 1.5; -%TypedArrayInitializeFromArrayLike(_holder, arg1, _source, _length_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/typedarraymaxsizeinheap.js b/deps/v8/test/mjsunit/runtime-gen/typedarraymaxsizeinheap.js deleted file mode 100644 index 61467bd9fa..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/typedarraymaxsizeinheap.js +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -%TypedArrayMaxSizeInHeap(); diff --git a/deps/v8/test/mjsunit/runtime-gen/typedarraysetfastcases.js b/deps/v8/test/mjsunit/runtime-gen/typedarraysetfastcases.js deleted file mode 100644 index 495212952b..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/typedarraysetfastcases.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _target_obj = new Int32Array(2); -var _source_obj = new Int32Array(2); -var arg2 = 0; -%TypedArraySetFastCases(_target_obj, _source_obj, arg2); diff --git a/deps/v8/test/mjsunit/runtime-gen/typeof.js b/deps/v8/test/mjsunit/runtime-gen/typeof.js deleted file mode 100644 index 78bfa6ea2c..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/typeof.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _obj = new Object(); -%Typeof(_obj); diff --git a/deps/v8/test/mjsunit/runtime-gen/unblockconcurrentrecompilation.js b/deps/v8/test/mjsunit/runtime-gen/unblockconcurrentrecompilation.js deleted file mode 100644 index a08add7b28..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/unblockconcurrentrecompilation.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -try { -%UnblockConcurrentRecompilation(); -} catch(e) {} diff --git a/deps/v8/test/mjsunit/runtime-gen/uriescape.js b/deps/v8/test/mjsunit/runtime-gen/uriescape.js deleted file mode 100644 index f32edc98e6..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/uriescape.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _source = "foo"; -%URIEscape(_source); diff --git a/deps/v8/test/mjsunit/runtime-gen/uriunescape.js b/deps/v8/test/mjsunit/runtime-gen/uriunescape.js deleted file mode 100644 index 2ba812c588..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/uriunescape.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _source = "foo"; -%URIUnescape(_source); diff --git a/deps/v8/test/mjsunit/runtime-gen/weakcollectiondelete.js b/deps/v8/test/mjsunit/runtime-gen/weakcollectiondelete.js deleted file mode 100644 index a6fff79e19..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/weakcollectiondelete.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _weak_collection = new WeakMap(); -var _key = new Object(); -%WeakCollectionDelete(_weak_collection, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/weakcollectionget.js b/deps/v8/test/mjsunit/runtime-gen/weakcollectionget.js deleted file mode 100644 index f248ac05a5..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/weakcollectionget.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _weak_collection = new WeakMap(); -var _key = new Object(); -%WeakCollectionGet(_weak_collection, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/weakcollectionhas.js b/deps/v8/test/mjsunit/runtime-gen/weakcollectionhas.js deleted file mode 100644 index af600c3e8d..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/weakcollectionhas.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _weak_collection = new WeakMap(); -var _key = new Object(); -%WeakCollectionHas(_weak_collection, _key); diff --git a/deps/v8/test/mjsunit/runtime-gen/weakcollectioninitialize.js b/deps/v8/test/mjsunit/runtime-gen/weakcollectioninitialize.js deleted file mode 100644 index 97f5ce56a1..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/weakcollectioninitialize.js +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _weak_collection = new WeakMap(); -%WeakCollectionInitialize(_weak_collection); diff --git a/deps/v8/test/mjsunit/runtime-gen/weakcollectionset.js b/deps/v8/test/mjsunit/runtime-gen/weakcollectionset.js deleted file mode 100644 index 3479ba6031..0000000000 --- a/deps/v8/test/mjsunit/runtime-gen/weakcollectionset.js +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY -// Flags: --allow-natives-syntax --harmony --harmony-proxies -var _weak_collection = new WeakMap(); -var _key = new Object(); -var _value = new Object(); -%WeakCollectionSet(_weak_collection, _key, _value); diff --git a/deps/v8/test/mjsunit/serialize-ic.js b/deps/v8/test/mjsunit/serialize-ic.js new file mode 100644 index 0000000000..8f20b2758f --- /dev/null +++ b/deps/v8/test/mjsunit/serialize-ic.js @@ -0,0 +1,9 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --cache=code --serialize-toplevel + +var foo = []; +foo[0] = "bar"; +assertEquals(["bar"], foo); diff --git a/deps/v8/test/mjsunit/string-external-cached.js b/deps/v8/test/mjsunit/string-external-cached.js index 6e24285331..cd368f660a 100644 --- a/deps/v8/test/mjsunit/string-external-cached.js +++ b/deps/v8/test/mjsunit/string-external-cached.js @@ -68,8 +68,8 @@ function test() { externalizeString(ascii, false); externalizeString(twobyte, true); } catch (ex) { } - assertTrue(isAsciiString(ascii)); - assertFalse(isAsciiString(twobyte)); + assertTrue(isOneByteString(ascii)); + assertFalse(isOneByteString(twobyte)); var ascii_slice = ascii.slice(1,-1); var twobyte_slice = twobyte.slice(2,-1); var ascii_cons = ascii + ascii; @@ -97,18 +97,18 @@ function test() { externalizeString(long_ascii, false); externalizeString(short_twobyte, true); externalizeString(long_twobyte, true); - assertTrue(isAsciiString(short_asii) && isAsciiString(long_ascii)); - assertFalse(isAsciiString(short_twobyte) || isAsciiString(long_twobyte)); + assertTrue(isOneByteString(short_asii) && isOneByteString(long_ascii)); + assertFalse(isOneByteString(short_twobyte) || isOneByteString(long_twobyte)); } catch (ex) { } assertEquals("E=MCsquared", short_ascii + long_ascii); - assertTrue(isAsciiString(short_ascii + long_ascii)); + assertTrue(isOneByteString(short_ascii + long_ascii)); assertEquals("MCsquaredE=", long_ascii + short_ascii); assertEquals("E\u1234MCsquare\u1234", short_twobyte + long_twobyte); - assertFalse(isAsciiString(short_twobyte + long_twobyte)); + assertFalse(isOneByteString(short_twobyte + long_twobyte)); assertEquals("E=MCsquared", "E=" + long_ascii); assertEquals("E\u1234MCsquared", short_twobyte + "MCsquared"); assertEquals("E\u1234MCsquared", short_twobyte + long_ascii); - assertFalse(isAsciiString(short_twobyte + long_ascii)); + assertFalse(isOneByteString(short_twobyte + long_ascii)); } // Run the test many times to ensure IC-s don't break things. diff --git a/deps/v8/test/mjsunit/string-externalize.js b/deps/v8/test/mjsunit/string-externalize.js index d52a7e2baf..39cc124914 100644 --- a/deps/v8/test/mjsunit/string-externalize.js +++ b/deps/v8/test/mjsunit/string-externalize.js @@ -36,27 +36,27 @@ function test() { for (var i = 0; i < size; i++) { str += String.fromCharCode(i & 0x7f); } - assertTrue(isAsciiString(str)); + assertTrue(isOneByteString(str)); - var twoByteExternalWithAsciiData = + var twoByteExternalWithOneByteData = "AA" + (function() { return "A"; })(); - externalizeString(twoByteExternalWithAsciiData, true /* force two-byte */); - assertFalse(isAsciiString(twoByteExternalWithAsciiData)); + externalizeString(twoByteExternalWithOneByteData, true /* force two-byte */); + assertFalse(isOneByteString(twoByteExternalWithOneByteData)); var realTwoByteExternalString = "\u1234\u1234\u1234\u1234" + (function() { return "\u1234"; })(); externalizeString(realTwoByteExternalString); - assertFalse(isAsciiString(realTwoByteExternalString)); + assertFalse(isOneByteString(realTwoByteExternalString)); - assertTrue(isAsciiString(["a", twoByteExternalWithAsciiData].join(""))); + assertTrue(isOneByteString(["a", twoByteExternalWithOneByteData].join(""))); // Appending a two-byte string that contains only ascii chars should // still produce an ascii cons. - var str1 = str + twoByteExternalWithAsciiData; - assertTrue(isAsciiString(str1)); + var str1 = str + twoByteExternalWithOneByteData; + assertTrue(isOneByteString(str1)); // Force flattening of the string. - var old_length = str1.length - twoByteExternalWithAsciiData.length; + var old_length = str1.length - twoByteExternalWithOneByteData.length; for (var i = 0; i < old_length; i++) { assertEquals(String.fromCharCode(i & 0x7f), str1[i]); } @@ -65,16 +65,16 @@ function test() { } // Flattened string should still be ascii. - assertTrue(isAsciiString(str1)); + assertTrue(isOneByteString(str1)); // Lower-casing an ascii string should produce ascii. - assertTrue(isAsciiString(str1.toLowerCase())); + assertTrue(isOneByteString(str1.toLowerCase())); - assertFalse(isAsciiString(["a", realTwoByteExternalString].join(""))); + assertFalse(isOneByteString(["a", realTwoByteExternalString].join(""))); // Appending a real two-byte string should produce a two-byte cons. var str2 = str + realTwoByteExternalString; - assertFalse(isAsciiString(str2)); + assertFalse(isOneByteString(str2)); // Force flattening of the string. old_length = str2.length - realTwoByteExternalString.length; @@ -86,7 +86,7 @@ function test() { } // Flattened string should still be two-byte. - assertFalse(isAsciiString(str2)); + assertFalse(isOneByteString(str2)); } // Run the test many times to ensure IC-s don't break things. diff --git a/deps/v8/test/mjsunit/string-match.js b/deps/v8/test/mjsunit/string-match.js index 202396d308..7689652cee 100644 --- a/deps/v8/test/mjsunit/string-match.js +++ b/deps/v8/test/mjsunit/string-match.js @@ -66,7 +66,6 @@ function testMatch(name, input, regexp, result, captures, from, to) { assertEquals(undefined, RegExp.$10, name + "-nocapture-10"); assertEquals(input, RegExp.input, name + "-input"); - assertEquals(input, RegExp.$input, name + "-$input"); assertEquals(input, RegExp.$_, name + "-$_"); assertEquals(preMatch, RegExp["$`"], name + "-$`"); diff --git a/deps/v8/test/mjsunit/string-natives.js b/deps/v8/test/mjsunit/string-natives.js index 7a9009bfd1..40fe9c697e 100644 --- a/deps/v8/test/mjsunit/string-natives.js +++ b/deps/v8/test/mjsunit/string-natives.js @@ -29,27 +29,27 @@ function test() { var s1 = %NewString(26, true); - for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, 65); + for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, 65, s1); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s1); - %_OneByteSeqStringSetChar(s1, 25, 66); + %_OneByteSeqStringSetChar(25, 66, s1); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s1); - for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(s1, i, i+65); + for (i = 0; i < 26; i++) %_OneByteSeqStringSetChar(i, i+65, s1); assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s1); s1 = %TruncateString(s1, 13); assertEquals("ABCDEFGHIJKLM", s1); var s2 = %NewString(26, false); - for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, 65); + for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, 65, s2); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAA", s2); - %_TwoByteSeqStringSetChar(s2, 25, 66); + %_TwoByteSeqStringSetChar(25, 66, s2); assertEquals("AAAAAAAAAAAAAAAAAAAAAAAAAB", s2); - for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s2, i, i+65); + for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+65, s2); assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ", s2); s2 = %TruncateString(s2, 13); assertEquals("ABCDEFGHIJKLM", s2); var s3 = %NewString(26, false); - for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(s3, i, i+1000); + for (i = 0; i < 26; i++) %_TwoByteSeqStringSetChar(i, i+1000, s3); for (i = 0; i < 26; i++) assertEquals(s3[i], String.fromCharCode(i+1000)); var a = []; diff --git a/deps/v8/test/mjsunit/string-oom-concat.js b/deps/v8/test/mjsunit/string-oom-concat.js index 9529c89381..0b35021c33 100644 --- a/deps/v8/test/mjsunit/string-oom-concat.js +++ b/deps/v8/test/mjsunit/string-oom-concat.js @@ -7,6 +7,7 @@ function concat() { for (var i = 0; i < 100; i++) { a += a; } + return a; } assertThrows(concat, RangeError); diff --git a/deps/v8/test/mjsunit/string-slices.js b/deps/v8/test/mjsunit/string-slices.js index 2fec04b0b0..c3f889bd99 100644 --- a/deps/v8/test/mjsunit/string-slices.js +++ b/deps/v8/test/mjsunit/string-slices.js @@ -197,9 +197,9 @@ var a = "123456789" + "qwertyuiopasdfghjklzxcvbnm"; var b = "23456789qwertyuiopasdfghjklzxcvbn" assertEquals(a.slice(1,-1), b); -assertTrue(isAsciiString(a)); +assertTrue(isOneByteString(a)); externalizeString(a, true); -assertFalse(isAsciiString(a)); +assertFalse(isOneByteString(a)); assertEquals(a.slice(1,-1), b); assertTrue(/3456789qwe/.test(a)); diff --git a/deps/v8/test/mozilla/mozilla.status b/deps/v8/test/mozilla/mozilla.status index 5662ee4144..e9f58c6133 100644 --- a/deps/v8/test/mozilla/mozilla.status +++ b/deps/v8/test/mozilla/mozilla.status @@ -56,12 +56,10 @@ # TODO(turbofan): These are all covered by mjsunit as well. Enable them once # we pass 'mjsunit' and 'webkit' with TurboFan. 'js1_4/Functions/function-001': [PASS, NO_VARIANTS], - 'js1_5/Regress/regress-104077': [PASS, NO_VARIANTS], 'js1_5/Regress/regress-396684': [PASS, NO_VARIANTS], 'js1_5/Regress/regress-80981': [PASS, NO_VARIANTS], # TODO(turbofan): Large switch statements crash. - 'js1_5/Regress/regress-366601': [PASS, NO_VARIANTS], 'js1_5/Regress/regress-398085-01': [PASS, NO_VARIANTS], ##################### SKIPPED TESTS ##################### diff --git a/deps/v8/test/perf-test/Collections/Collections.json b/deps/v8/test/perf-test/Collections/Collections.json new file mode 100644 index 0000000000..bf735c0dcb --- /dev/null +++ b/deps/v8/test/perf-test/Collections/Collections.json @@ -0,0 +1,15 @@ +{ + "path": ["."], + "main": "run.js", + "flags": ["--harmony-collections"], + "run_count": 5, + "units": "score", + "results_regexp": "^%s\\-Collections\\(Score\\): (.+)$", + "total": true, + "tests": [ + {"name": "Map"}, + {"name": "Set"}, + {"name": "WeakMap"}, + {"name": "WeakSet"} + ] +} diff --git a/deps/v8/test/perf-test/Collections/base.js b/deps/v8/test/perf-test/Collections/base.js new file mode 100644 index 0000000000..b0ce40b888 --- /dev/null +++ b/deps/v8/test/perf-test/Collections/base.js @@ -0,0 +1,367 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +// Performance.now is used in latency benchmarks, the fallback is Date.now. +var performance = performance || {}; +performance.now = (function() { + return performance.now || + performance.mozNow || + performance.msNow || + performance.oNow || + performance.webkitNow || + Date.now; +})(); + +// Simple framework for running the benchmark suites and +// computing a score based on the timing measurements. + + +// A benchmark has a name (string) and a function that will be run to +// do the performance measurement. The optional setup and tearDown +// arguments are functions that will be invoked before and after +// running the benchmark, but the running time of these functions will +// not be accounted for in the benchmark score. +function Benchmark(name, doWarmup, doDeterministic, deterministicIterations, + run, setup, tearDown, rmsResult, minIterations) { + this.name = name; + this.doWarmup = doWarmup; + this.doDeterministic = doDeterministic; + this.deterministicIterations = deterministicIterations; + this.run = run; + this.Setup = setup ? setup : function() { }; + this.TearDown = tearDown ? tearDown : function() { }; + this.rmsResult = rmsResult ? rmsResult : null; + this.minIterations = minIterations ? minIterations : 32; +} + + +// Benchmark results hold the benchmark and the measured time used to +// run the benchmark. The benchmark score is computed later once a +// full benchmark suite has run to completion. If latency is set to 0 +// then there is no latency score for this benchmark. +function BenchmarkResult(benchmark, time, latency) { + this.benchmark = benchmark; + this.time = time; + this.latency = latency; +} + + +// Automatically convert results to numbers. Used by the geometric +// mean computation. +BenchmarkResult.prototype.valueOf = function() { + return this.time; +} + + +// Suites of benchmarks consist of a name and the set of benchmarks in +// addition to the reference timing that the final score will be based +// on. This way, all scores are relative to a reference run and higher +// scores implies better performance. +function BenchmarkSuite(name, reference, benchmarks) { + this.name = name; + this.reference = reference; + this.benchmarks = benchmarks; + BenchmarkSuite.suites.push(this); +} + + +// Keep track of all declared benchmark suites. +BenchmarkSuite.suites = []; + +// Scores are not comparable across versions. Bump the version if +// you're making changes that will affect that scores, e.g. if you add +// a new benchmark or change an existing one. +BenchmarkSuite.version = '1'; + + +// Defines global benchsuite running mode that overrides benchmark suite +// behavior. Intended to be set by the benchmark driver. Undefined +// values here allow a benchmark to define behaviour itself. +BenchmarkSuite.config = { + doWarmup: undefined, + doDeterministic: undefined +}; + + +// Override the alert function to throw an exception instead. +alert = function(s) { + throw "Alert called with argument: " + s; +}; + + +// To make the benchmark results predictable, we replace Math.random +// with a 100% deterministic alternative. +BenchmarkSuite.ResetRNG = function() { + Math.random = (function() { + var seed = 49734321; + return function() { + // Robert Jenkins' 32 bit integer hash function. + seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; + seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; + seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; + seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff; + seed = ((seed + 0xfd7046c5) + (seed << 3)) & 0xffffffff; + seed = ((seed ^ 0xb55a4f09) ^ (seed >>> 16)) & 0xffffffff; + return (seed & 0xfffffff) / 0x10000000; + }; + })(); +} + + +// Runs all registered benchmark suites and optionally yields between +// each individual benchmark to avoid running for too long in the +// context of browsers. Once done, the final score is reported to the +// runner. +BenchmarkSuite.RunSuites = function(runner, skipBenchmarks) { + skipBenchmarks = typeof skipBenchmarks === 'undefined' ? [] : skipBenchmarks; + var continuation = null; + var suites = BenchmarkSuite.suites; + var length = suites.length; + BenchmarkSuite.scores = []; + var index = 0; + function RunStep() { + while (continuation || index < length) { + if (continuation) { + continuation = continuation(); + } else { + var suite = suites[index++]; + if (runner.NotifyStart) runner.NotifyStart(suite.name); + if (skipBenchmarks.indexOf(suite.name) > -1) { + suite.NotifySkipped(runner); + } else { + continuation = suite.RunStep(runner); + } + } + if (continuation && typeof window != 'undefined' && window.setTimeout) { + window.setTimeout(RunStep, 25); + return; + } + } + + // show final result + if (runner.NotifyScore) { + var score = BenchmarkSuite.GeometricMean(BenchmarkSuite.scores); + var formatted = BenchmarkSuite.FormatScore(100 * score); + runner.NotifyScore(formatted); + } + } + RunStep(); +} + + +// Counts the total number of registered benchmarks. Useful for +// showing progress as a percentage. +BenchmarkSuite.CountBenchmarks = function() { + var result = 0; + var suites = BenchmarkSuite.suites; + for (var i = 0; i < suites.length; i++) { + result += suites[i].benchmarks.length; + } + return result; +} + + +// Computes the geometric mean of a set of numbers. +BenchmarkSuite.GeometricMean = function(numbers) { + var log = 0; + for (var i = 0; i < numbers.length; i++) { + log += Math.log(numbers[i]); + } + return Math.pow(Math.E, log / numbers.length); +} + + +// Computes the geometric mean of a set of throughput time measurements. +BenchmarkSuite.GeometricMeanTime = function(measurements) { + var log = 0; + for (var i = 0; i < measurements.length; i++) { + log += Math.log(measurements[i].time); + } + return Math.pow(Math.E, log / measurements.length); +} + + +// Computes the geometric mean of a set of rms measurements. +BenchmarkSuite.GeometricMeanLatency = function(measurements) { + var log = 0; + var hasLatencyResult = false; + for (var i = 0; i < measurements.length; i++) { + if (measurements[i].latency != 0) { + log += Math.log(measurements[i].latency); + hasLatencyResult = true; + } + } + if (hasLatencyResult) { + return Math.pow(Math.E, log / measurements.length); + } else { + return 0; + } +} + + +// Converts a score value to a string with at least three significant +// digits. +BenchmarkSuite.FormatScore = function(value) { + if (value > 100) { + return value.toFixed(0); + } else { + return value.toPrecision(3); + } +} + +// Notifies the runner that we're done running a single benchmark in +// the benchmark suite. This can be useful to report progress. +BenchmarkSuite.prototype.NotifyStep = function(result) { + this.results.push(result); + if (this.runner.NotifyStep) this.runner.NotifyStep(result.benchmark.name); +} + + +// Notifies the runner that we're done with running a suite and that +// we have a result which can be reported to the user if needed. +BenchmarkSuite.prototype.NotifyResult = function() { + var mean = BenchmarkSuite.GeometricMeanTime(this.results); + var score = this.reference[0] / mean; + BenchmarkSuite.scores.push(score); + if (this.runner.NotifyResult) { + var formatted = BenchmarkSuite.FormatScore(100 * score); + this.runner.NotifyResult(this.name, formatted); + } + if (this.reference.length == 2) { + var meanLatency = BenchmarkSuite.GeometricMeanLatency(this.results); + if (meanLatency != 0) { + var scoreLatency = this.reference[1] / meanLatency; + BenchmarkSuite.scores.push(scoreLatency); + if (this.runner.NotifyResult) { + var formattedLatency = BenchmarkSuite.FormatScore(100 * scoreLatency) + this.runner.NotifyResult(this.name + "Latency", formattedLatency); + } + } + } +} + + +BenchmarkSuite.prototype.NotifySkipped = function(runner) { + BenchmarkSuite.scores.push(1); // push default reference score. + if (runner.NotifyResult) { + runner.NotifyResult(this.name, "Skipped"); + } +} + + +// Notifies the runner that running a benchmark resulted in an error. +BenchmarkSuite.prototype.NotifyError = function(error) { + if (this.runner.NotifyError) { + this.runner.NotifyError(this.name, error); + } + if (this.runner.NotifyStep) { + this.runner.NotifyStep(this.name); + } +} + + +// Runs a single benchmark for at least a second and computes the +// average time it takes to run a single iteration. +BenchmarkSuite.prototype.RunSingleBenchmark = function(benchmark, data) { + var config = BenchmarkSuite.config; + var doWarmup = config.doWarmup !== undefined + ? config.doWarmup + : benchmark.doWarmup; + var doDeterministic = config.doDeterministic !== undefined + ? config.doDeterministic + : benchmark.doDeterministic; + + function Measure(data) { + var elapsed = 0; + var start = new Date(); + + // Run either for 1 second or for the number of iterations specified + // by minIterations, depending on the config flag doDeterministic. + for (var i = 0; (doDeterministic ? + i<benchmark.deterministicIterations : elapsed < 1000); i++) { + benchmark.run(); + elapsed = new Date() - start; + } + if (data != null) { + data.runs += i; + data.elapsed += elapsed; + } + } + + // Sets up data in order to skip or not the warmup phase. + if (!doWarmup && data == null) { + data = { runs: 0, elapsed: 0 }; + } + + if (data == null) { + Measure(null); + return { runs: 0, elapsed: 0 }; + } else { + Measure(data); + // If we've run too few iterations, we continue for another second. + if (data.runs < benchmark.minIterations) return data; + var usec = (data.elapsed * 1000) / data.runs; + var rms = (benchmark.rmsResult != null) ? benchmark.rmsResult() : 0; + this.NotifyStep(new BenchmarkResult(benchmark, usec, rms)); + return null; + } +} + + +// This function starts running a suite, but stops between each +// individual benchmark in the suite and returns a continuation +// function which can be invoked to run the next benchmark. Once the +// last benchmark has been executed, null is returned. +BenchmarkSuite.prototype.RunStep = function(runner) { + BenchmarkSuite.ResetRNG(); + this.results = []; + this.runner = runner; + var length = this.benchmarks.length; + var index = 0; + var suite = this; + var data; + + // Run the setup, the actual benchmark, and the tear down in three + // separate steps to allow the framework to yield between any of the + // steps. + + function RunNextSetup() { + if (index < length) { + try { + suite.benchmarks[index].Setup(); + } catch (e) { + suite.NotifyError(e); + return null; + } + return RunNextBenchmark; + } + suite.NotifyResult(); + return null; + } + + function RunNextBenchmark() { + try { + data = suite.RunSingleBenchmark(suite.benchmarks[index], data); + } catch (e) { + suite.NotifyError(e); + return null; + } + // If data is null, we're done with this benchmark. + return (data == null) ? RunNextTearDown : RunNextBenchmark(); + } + + function RunNextTearDown() { + try { + suite.benchmarks[index++].TearDown(); + } catch (e) { + suite.NotifyError(e); + return null; + } + return RunNextSetup; + } + + // Start out running the setup. + return RunNextSetup(); +} diff --git a/deps/v8/test/perf-test/Collections/map.js b/deps/v8/test/perf-test/Collections/map.js new file mode 100644 index 0000000000..b310a71902 --- /dev/null +++ b/deps/v8/test/perf-test/Collections/map.js @@ -0,0 +1,81 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +var MapBenchmark = new BenchmarkSuite('Map', [1000], [ + new Benchmark('Set', false, false, 0, MapSet), + new Benchmark('Has', false, false, 0, MapHas, MapSetup, MapTearDown), + new Benchmark('Get', false, false, 0, MapGet, MapSetup, MapTearDown), + new Benchmark('Delete', false, false, 0, MapDelete, MapSetup, MapTearDown), + new Benchmark('ForEach', false, false, 0, MapForEach, MapSetup, MapTearDown), +]); + + +var map; +var N = 10; + + +function MapSetup() { + map = new Map; + for (var i = 0; i < N; i++) { + map.set(i, i); + } +} + + +function MapTearDown() { + map = null; +} + + +function MapSet() { + MapSetup(); + MapTearDown(); +} + + +function MapHas() { + for (var i = 0; i < N; i++) { + if (!map.has(i)) { + throw new Error(); + } + } + for (var i = N; i < 2 * N; i++) { + if (map.has(i)) { + throw new Error(); + } + } +} + + +function MapGet() { + for (var i = 0; i < N; i++) { + if (map.get(i) !== i) { + throw new Error(); + } + } + for (var i = N; i < 2 * N; i++) { + if (map.get(i) !== undefined) { + throw new Error(); + } + } +} + + +function MapDelete() { + // This is run more than once per setup so we will end up deleting items + // more than once. Therefore, we do not the return value of delete. + for (var i = 0; i < N; i++) { + map.delete(i); + } +} + + +function MapForEach() { + map.forEach(function(v, k) { + if (v !== k) { + throw new Error(); + } + }); +} diff --git a/deps/v8/test/perf-test/Collections/run.js b/deps/v8/test/perf-test/Collections/run.js new file mode 100644 index 0000000000..cfd1aef525 --- /dev/null +++ b/deps/v8/test/perf-test/Collections/run.js @@ -0,0 +1,30 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +load('base.js'); +load('map.js'); +load('set.js'); +load('weakmap.js'); +load('weakset.js'); + + +var success = true; + +function PrintResult(name, result) { + print(name + '-Collections(Score): ' + result); +} + + +function PrintError(name, error) { + PrintResult(name, error); + success = false; +} + + +BenchmarkSuite.config.doWarmup = undefined; +BenchmarkSuite.config.doDeterministic = undefined; + +BenchmarkSuite.RunSuites({ NotifyResult: PrintResult, + NotifyError: PrintError }); diff --git a/deps/v8/test/perf-test/Collections/set.js b/deps/v8/test/perf-test/Collections/set.js new file mode 100644 index 0000000000..e6455e1c0a --- /dev/null +++ b/deps/v8/test/perf-test/Collections/set.js @@ -0,0 +1,66 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +var SetBenchmark = new BenchmarkSuite('Set', [1000], [ + new Benchmark('Add', false, false, 0, SetAdd), + new Benchmark('Has', false, false, 0, SetHas, SetSetup, SetTearDown), + new Benchmark('Delete', false, false, 0, SetDelete, SetSetup, SetTearDown), + new Benchmark('ForEach', false, false, 0, SetForEach, SetSetup, SetTearDown), +]); + + +var set; +var N = 10; + + +function SetSetup() { + set = new Set; + for (var i = 0; i < N; i++) { + set.add(i); + } +} + + +function SetTearDown() { + map = null; +} + + +function SetAdd() { + SetSetup(); + SetTearDown(); +} + + +function SetHas() { + for (var i = 0; i < N; i++) { + if (!set.has(i)) { + throw new Error(); + } + } + for (var i = N; i < 2 * N; i++) { + if (set.has(i)) { + throw new Error(); + } + } +} + + +function SetDelete() { + // This is run more than once per setup so we will end up deleting items + // more than once. Therefore, we do not the return value of delete. + for (var i = 0; i < N; i++) { + set.delete(i); + } +} + + +function SetForEach() { + set.forEach(function(v, k) { + if (v !== k) { + throw new Error(); + } + }); +} diff --git a/deps/v8/test/perf-test/Collections/weakmap.js b/deps/v8/test/perf-test/Collections/weakmap.js new file mode 100644 index 0000000000..8736dfd58b --- /dev/null +++ b/deps/v8/test/perf-test/Collections/weakmap.js @@ -0,0 +1,80 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +var MapBenchmark = new BenchmarkSuite('WeakMap', [1000], [ + new Benchmark('Set', false, false, 0, WeakMapSet), + new Benchmark('Has', false, false, 0, WeakMapHas, WeakMapSetup, + WeakMapTearDown), + new Benchmark('Get', false, false, 0, WeakMapGet, WeakMapSetup, + WeakMapTearDown), + new Benchmark('Delete', false, false, 0, WeakMapDelete, WeakMapSetup, + WeakMapTearDown), +]); + + +var wm; +var N = 10; +var keys = []; + + +for (var i = 0; i < N * 2; i++) { + keys[i] = {}; +} + + +function WeakMapSetup() { + wm = new WeakMap; + for (var i = 0; i < N; i++) { + wm.set(keys[i], i); + } +} + + +function WeakMapTearDown() { + wm = null; +} + + +function WeakMapSet() { + WeakMapSetup(); + WeakMapTearDown(); +} + + +function WeakMapHas() { + for (var i = 0; i < N; i++) { + if (!wm.has(keys[i])) { + throw new Error(); + } + } + for (var i = N; i < 2 * N; i++) { + if (wm.has(keys[i])) { + throw new Error(); + } + } +} + + +function WeakMapGet() { + for (var i = 0; i < N; i++) { + if (wm.get(keys[i]) !== i) { + throw new Error(); + } + } + for (var i = N; i < 2 * N; i++) { + if (wm.get(keys[i]) !== undefined) { + throw new Error(); + } + } +} + + +function WeakMapDelete() { + // This is run more than once per setup so we will end up deleting items + // more than once. Therefore, we do not the return value of delete. + for (var i = 0; i < N; i++) { + wm.delete(keys[i]); + } +} diff --git a/deps/v8/test/perf-test/Collections/weakset.js b/deps/v8/test/perf-test/Collections/weakset.js new file mode 100644 index 0000000000..a7d0f3d076 --- /dev/null +++ b/deps/v8/test/perf-test/Collections/weakset.js @@ -0,0 +1,64 @@ +// Copyright 2014 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + + +var SetBenchmark = new BenchmarkSuite('WeakSet', [1000], [ + new Benchmark('Add', false, false, 0, WeakSetAdd), + new Benchmark('Has', false, false, 0, WeakSetHas, WeakSetSetup, + WeakSetTearDown), + new Benchmark('Delete', false, false, 0, WeakSetDelete, WeakSetSetup, + WeakSetTearDown), +]); + + +var ws; +var N = 10; +var keys = []; + + +for (var i = 0; i < N * 2; i++) { + keys[i] = {}; +} + + +function WeakSetSetup() { + ws = new WeakSet; + for (var i = 0; i < N; i++) { + ws.add(keys[i]); + } +} + + +function WeakSetTearDown() { + ws = null; +} + + +function WeakSetAdd() { + WeakSetSetup(); + WeakSetTearDown(); +} + + +function WeakSetHas() { + for (var i = 0; i < N; i++) { + if (!ws.has(keys[i])) { + throw new Error(); + } + } + for (var i = N; i < 2 * N; i++) { + if (ws.has(keys[i])) { + throw new Error(); + } + } +} + + +function WeakSetDelete() { + // This is run more than once per setup so we will end up deleting items + // more than once. Therefore, we do not the return value of delete. + for (var i = 0; i < N; i++) { + ws.delete(keys[i]); + } +} diff --git a/deps/v8/test/preparser/duplicate-property.pyt b/deps/v8/test/preparser/duplicate-property.pyt deleted file mode 100644 index 594b4786cb..0000000000 --- a/deps/v8/test/preparser/duplicate-property.pyt +++ /dev/null @@ -1,162 +0,0 @@ -# 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. - -# Tests of duplicate properties in object literals. - -# ---------------------------------------------------------------------- -# Utility functions to generate a number of tests for each property -# name pair. - -def PropertyTest(name, propa, propb, allow_strict = True): - replacement = {"id1": propa, "id2": propb, "name": name} - - # Tests same test in both strict and non-strict context. - def StrictTest(name, source, replacement, expectation): - if (allow_strict): - Template("strict-" + name, - "\"use strict\";\n" + source)(replacement, expectation) - Template(name, source)(replacement, expectation) - - # This one only fails in non-strict context. - if (allow_strict): - Template("strict-$name-data-data", """ - "use strict"; - var o = {$id1: 42, $id2: 42}; - """)(replacement, "strict_duplicate_property") - - Template("$name-data-data", """ - var o = {$id1: 42, $id2: 42}; - """)(replacement, None) - - StrictTest("$name-data-get", """ - var o = {$id1: 42, get $id2(){}}; - """, replacement, "accessor_data_property") - - StrictTest("$name-data-set", """ - var o = {$id1: 42, set $id2(v){}}; - """, replacement, "accessor_data_property") - - StrictTest("$name-get-data", """ - var o = {get $id1(){}, $id2: 42}; - """, replacement, "accessor_data_property") - - StrictTest("$name-set-data", """ - var o = {set $id1(v){}, $id2: 42}; - """, replacement, "accessor_data_property") - - StrictTest("$name-get-get", """ - var o = {get $id1(){}, get $id2(){}}; - """, replacement, "accessor_get_set") - - StrictTest("$name-set-set", """ - var o = {set $id1(v){}, set $id2(v){}}; - """, replacement, "accessor_get_set") - - StrictTest("$name-nested-get", """ - var o = {get $id1(){}, o: {get $id2(){} } }; - """, replacement, None) - - StrictTest("$name-nested-set", """ - var o = {set $id1(v){}, o: {set $id2(v){} } }; - """, replacement, None) - - -def TestBothWays(name, propa, propb, allow_strict = True): - PropertyTest(name + "-1", propa, propb, allow_strict) - PropertyTest(name + "-2", propb, propa, allow_strict) - -def TestSame(name, prop, allow_strict = True): - PropertyTest(name, prop, prop, allow_strict) - -#----------------------------------------------------------------------- - -# Simple identifier property -TestSame("a", "a") - -# Get/set identifiers -TestSame("get-id", "get") -TestSame("set-id", "set") - -# Number properties -TestSame("0", "0") -TestSame("0.1", "0.1") -TestSame("1.0", "1.0") -TestSame("42.33", "42.33") -TestSame("2^32-2", "4294967294") -TestSame("2^32", "4294967296") -TestSame("2^53", "9007199254740992") -TestSame("Hex20", "0x20") -TestSame("exp10", "1e10") -TestSame("exp20", "1e20") -TestSame("Oct40", "040", False); - - -# String properties -TestSame("str-a", '"a"') -TestSame("str-0", '"0"') -TestSame("str-42", '"42"') -TestSame("str-empty", '""') - -# Keywords -TestSame("if", "if") -TestSame("case", "case") - -# Future reserved keywords -TestSame("public", "public") -TestSame("class", "class") - - -# Test that numbers are converted to string correctly. - -TestBothWays("hex-int", "0x20", "32") -TestBothWays("oct-int", "040", "32", False) # Octals disallowed in strict mode. -TestBothWays("dec-int", "32.00", "32") -TestBothWays("dec-underflow-int", - "32.00000000000000000000000000000000000000001", "32") -TestBothWays("exp-int", "3.2e1", "32") -TestBothWays("exp-int", "3200e-2", "32") -TestBothWays("overflow-inf", "1e2000", "Infinity") -TestBothWays("overflow-inf-exact", "1.797693134862315808e+308", "Infinity") -TestBothWays("non-overflow-inf-exact", "1.797693134862315807e+308", - "1.7976931348623157e+308") -TestBothWays("underflow-0", "1e-2000", "0") -TestBothWays("underflow-0-exact", "2.4703282292062E-324", "0") -TestBothWays("non-underflow-0-exact", "2.4703282292063E-324", "5e-324") -TestBothWays("precission-loss-high", "9007199254740992", "9007199254740993") -TestBothWays("precission-loss-low", "1.9999999999999998", "1.9999999999999997") -TestBothWays("non-canonical-literal-int", "1.0", "1") -TestBothWays("non-canonical-literal-frac", "1.50", "1.5") -TestBothWays("rounding-down", "1.12512512512512452", "1.1251251251251244") -TestBothWays("rounding-up", "1.12512512512512453", "1.1251251251251246") - -TestBothWays("hex-int-str", "0x20", '"32"') -TestBothWays("dec-int-str", "32.00", '"32"') -TestBothWays("exp-int-str", "3.2e1", '"32"') -TestBothWays("overflow-inf-str", "1e2000", '"Infinity"') -TestBothWays("underflow-0-str", "1e-2000", '"0"') -TestBothWays("non-canonical-literal-int-str", "1.0", '"1"') -TestBothWays("non-canonical-literal-frac-str", "1.50", '"1.5"') diff --git a/deps/v8/test/preparser/preparser.status b/deps/v8/test/preparser/preparser.status index babf35d5d8..9d69988f71 100644 --- a/deps/v8/test/preparser/preparser.status +++ b/deps/v8/test/preparser/preparser.status @@ -25,10 +25,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# We don't parse RegExps at scanning time, so we can't fail on octal -# escapes (we need to parse to distinguish octal escapes from valid -# back-references). [ [ALWAYS, { # TODO(mstarzinger): This script parses but throws a TypeError when run. diff --git a/deps/v8/test/promises-aplus/promises-aplus.status b/deps/v8/test/promises-aplus/promises-aplus.status index fdcf40b13f..5da9efae90 100644 --- a/deps/v8/test/promises-aplus/promises-aplus.status +++ b/deps/v8/test/promises-aplus/promises-aplus.status @@ -25,7 +25,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - [ [ALWAYS, { }], # ALWAYS diff --git a/deps/v8/test/test262-es6/README b/deps/v8/test/test262-es6/README new file mode 100644 index 0000000000..d0b3b42ef9 --- /dev/null +++ b/deps/v8/test/test262-es6/README @@ -0,0 +1,18 @@ +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 + + https://github.com/tc39/test262 + +at hash 9bd6686 (2014/08/25 revision) 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. + + git clone https://github.com/tc39/test262 data + cd data + git checkout 9bd6686 + +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/deps/v8/test/test262-es6/harness-adapt.js b/deps/v8/test/test262-es6/harness-adapt.js new file mode 100644 index 0000000000..60c0858f02 --- /dev/null +++ b/deps/v8/test/test262-es6/harness-adapt.js @@ -0,0 +1,91 @@ +// 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 + " " + this.error; + } + + function registerTest(test) { + if (!(test.precondition && !test.precondition())) { + var error; + try { + var res = test.test.call($this); + } catch(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') { + var precondition = (test.precondition !== undefined) + ? test.precondition.toString() + : ''; + + throw new Test262Error( + test.id, + test.path, + test.description, + test.test.toString(), + precondition, + retVal, + error); + } + } + } + + return { + registerTest: registerTest + } +})(); + +function $DONE(arg){ + if (arg) { + print('FAILED! Error: ' + arg); + quit(1); + } + + quit(0); +}; diff --git a/deps/v8/test/test262-es6/test262-es6.status b/deps/v8/test/test262-es6/test262-es6.status new file mode 100644 index 0000000000..c4c94f3bf0 --- /dev/null +++ b/deps/v8/test/test262-es6/test262-es6.status @@ -0,0 +1,166 @@ +# 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. + +[ +[ALWAYS, { + ############################### BUGS ################################### + + '15.5.4.9_CE': [['no_i18n', SKIP]], + + # BUG(v8:3455) + '11.2.3_b': [FAIL], + '12.2.3_b': [FAIL], + + ###################### NEEDS INVESTIGATION ####################### + + # Possibly same cause as S8.5_A2.1, below: floating-point tests. + 'S15.8.2.16_A7': [PASS, FAIL_OK], + 'S15.8.2.18_A7': [PASS, FAIL_OK], + 'S15.8.2.7_A7': [PASS, FAIL_OK], + + # This is an incompatibility between ES5 and V8 on enumerating + # shadowed elements in a for..in loop. + # https://code.google.com/p/v8/issues/detail?id=705 + '12.6.4-2': [PASS, FAIL_OK], + + ###################### MISSING ES6 FEATURES ####################### + + # Array.from + 'S22.1.2.1_T1': [FAIL], + 'S22.1.2.1_T2': [FAIL], + + # Direct proxies + 'Array.prototype.find_callable-predicate': [FAIL], + + ######################## OBSOLETED BY ES6 ########################### + + # ES6 allows duplicate properties + # TODO(arv): Reactivate when check removal has relanded. + # '11.1.5-4-4-a-1-s': [FAIL], + # '11.1.5_4-4-b-1': [FAIL], + # '11.1.5_4-4-b-2': [FAIL], + # '11.1.5_4-4-c-1': [FAIL], + # '11.1.5_4-4-c-2': [FAIL], + # '11.1.5_4-4-d-1': [FAIL], + # '11.1.5_4-4-d-2': [FAIL], + # '11.1.5_4-4-d-3': [FAIL], + # '11.1.5_4-4-d-4': [FAIL], + + # ES6 allows block-local functions. + 'Sbp_A1_T1': [FAIL], + 'Sbp_A2_T1': [FAIL], + 'Sbp_A2_T2': [FAIL], + 'Sbp_A3_T1': [FAIL], + 'Sbp_A3_T2': [FAIL], + 'Sbp_A4_T1': [FAIL], + 'Sbp_A4_T2': [FAIL], + 'Sbp_A5_T1': [PASS], # Test is broken (strict reference to unbound variable) + 'Sbp_A5_T2': [FAIL], + + ######################## NEEDS INVESTIGATION ########################### + + # These test failures are specific to the intl402 suite and need investigation + # to be either marked as bugs with issues filed for them or as deliberate + # incompatibilities if the test cases turn out to be broken or ambiguous. + '6.2.3': [FAIL], + '9.2.1_2': [FAIL], + '9.2.6_2': [FAIL], + '10.1.1_a': [FAIL], + '10.1.1_19_c': [PASS, FAIL, NO_VARIANTS], + '10.1.2.1_4': [FAIL], + '10.2.3_b': [PASS, FAIL], + '10.3_a': [FAIL], + '11.1.1_17': [PASS, FAIL], + '11.1.1_19': [PASS, FAIL], + '11.1.1_20_c': [FAIL], + '11.1.1_a': [FAIL], + '11.1.2.1_4': [FAIL], + '11.3.2_FN_2': [PASS, FAIL], + '11.3.2_TRF': [PASS, FAIL], + '11.3_a': [FAIL], + '12.1.1_a': [FAIL], + '12.1.2.1_4': [FAIL], + '12.3.2_FDT_7_a_iv': [FAIL], + '12.3.3': [FAIL], + '12.3_a': [FAIL], + '15.5.4.9_3': [PASS, FAIL], + + ##################### DELIBERATE INCOMPATIBILITIES ##################### + + 'S15.8.2.8_A6': [PASS, FAIL_OK], # Math.exp (less precise with --fast-math) + + # Linux for ia32 (and therefore simulators) default to extended 80 bit + # floating point formats, so these tests checking 64-bit FP precision fail. + # The other platforms/arch's pass these tests. + # We follow the other major JS engines by keeping this default. + 'S8.5_A2.1': [PASS, FAIL_OK], + 'S8.5_A2.2': [PASS, FAIL_OK], + + ############################ INVALID TESTS ############################# + + # The reference value calculated by Test262 is incorrect if you run these + # tests in PST/PDT between first Sunday in March and first Sunday in April. + # The DST switch was moved in 2007 whereas Test262 bases the reference value + # on 2000. Test262 Bug: https://bugs.ecmascript.org/show_bug.cgi?id=293 + 'S15.9.3.1_A5_T1': [PASS, FAIL_OK], + 'S15.9.3.1_A5_T2': [PASS, FAIL_OK], + 'S15.9.3.1_A5_T3': [PASS, FAIL_OK], + 'S15.9.3.1_A5_T4': [PASS, FAIL_OK], + 'S15.9.3.1_A5_T5': [PASS, FAIL_OK], + 'S15.9.3.1_A5_T6': [PASS, FAIL_OK], + + # Test makes unjustified assumptions about the number of calls to SortCompare. + # Test262 Bug: https://bugs.ecmascript.org/show_bug.cgi?id=596 + 'bug_596_1': [PASS, FAIL_OK], + + ############################ SKIPPED TESTS ############################# + + # These tests take a looong time to run in debug mode. + 'S15.1.3.1_A2.5_T1': [PASS, ['mode == debug', SKIP]], + 'S15.1.3.2_A2.5_T1': [PASS, ['mode == debug', SKIP]], +}], # ALWAYS + +['system == macos', { + '11.3.2_TRP': [FAIL], + '9.2.5_11_g_ii_2': [FAIL], +}], # system == macos + +['arch == arm or arch == mipsel or arch == mips or arch == arm64 or arch == mips64el', { + + # TODO(mstarzinger): Causes stack overflow on simulators due to eager + # compilation of parenthesized function literals. Needs investigation. + 'S13.2.1_A1_T1': [SKIP], + + # BUG(3251225): Tests that timeout with --nocrankshaft. + 'S15.1.3.1_A2.4_T1': [SKIP], + 'S15.1.3.1_A2.5_T1': [SKIP], + 'S15.1.3.2_A2.4_T1': [SKIP], + 'S15.1.3.2_A2.5_T1': [SKIP], + 'S15.1.3.3_A2.3_T1': [SKIP], + 'S15.1.3.4_A2.3_T1': [SKIP], +}], # 'arch == arm or arch == mipsel or arch == mips or arch == arm64' +] diff --git a/deps/v8/test/test262-es6/testcfg.py b/deps/v8/test/test262-es6/testcfg.py new file mode 100644 index 0000000000..59eda32b7b --- /dev/null +++ b/deps/v8/test/test262-es6/testcfg.py @@ -0,0 +1,164 @@ +# Copyright 2012 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 hashlib +import os +import shutil +import sys +import tarfile +import imp + +from testrunner.local import testsuite +from testrunner.local import utils +from testrunner.objects import testcase + +TEST_262_ARCHIVE_REVISION = "9bd6686" # This is the 2014-08-25 revision. +TEST_262_ARCHIVE_MD5 = "0f5928b391864890d5a397f8cdc82705" +TEST_262_URL = "https://github.com/tc39/test262/tarball/%s" +TEST_262_HARNESS_FILES = ["sta.js"] + +TEST_262_SUITE_PATH = ["data", "test", "suite"] +TEST_262_HARNESS_PATH = ["data", "test", "harness"] +TEST_262_TOOLS_PATH = ["data", "tools", "packaging"] + +class Test262TestSuite(testsuite.TestSuite): + + def __init__(self, name, root): + super(Test262TestSuite, self).__init__(name, root) + self.testroot = os.path.join(self.root, *TEST_262_SUITE_PATH) + self.harnesspath = os.path.join(self.root, *TEST_262_HARNESS_PATH) + self.harness = [os.path.join(self.harnesspath, f) + for f in TEST_262_HARNESS_FILES] + self.harness += [os.path.join(self.root, "harness-adapt.js")] + self.ParseTestRecord = None + + def CommonTestName(self, testcase): + return testcase.path.split(os.path.sep)[-1] + + def ListTests(self, context): + tests = [] + for dirname, dirs, files in os.walk(self.testroot): + for dotted in [x for x in dirs if x.startswith(".")]: + dirs.remove(dotted) + if context.noi18n and "intl402" in dirs: + dirs.remove("intl402") + dirs.sort() + files.sort() + for filename in files: + if filename.endswith(".js"): + testname = os.path.join(dirname[len(self.testroot) + 1:], + filename[:-3]) + case = testcase.TestCase(self, testname) + tests.append(case) + return tests + + def GetFlagsForTestCase(self, testcase, context): + return (testcase.flags + context.mode_flags + self.harness + + self.GetIncludesForTest(testcase) + ["--harmony"] + + [os.path.join(self.testroot, testcase.path + ".js")]) + + def LoadParseTestRecord(self): + if not self.ParseTestRecord: + root = os.path.join(self.root, *TEST_262_TOOLS_PATH) + f = None + try: + (f, pathname, description) = imp.find_module("parseTestRecord", [root]) + module = imp.load_module("parseTestRecord", f, pathname, description) + self.ParseTestRecord = module.parseTestRecord + except: + raise ImportError("Cannot load parseTestRecord; you may need to " + "--download-data for test262") + finally: + if f: + f.close() + return self.ParseTestRecord + + def GetTestRecord(self, testcase): + if not hasattr(testcase, "test_record"): + ParseTestRecord = self.LoadParseTestRecord() + testcase.test_record = ParseTestRecord(self.GetSourceForTest(testcase), + testcase.path) + return testcase.test_record + + def GetIncludesForTest(self, testcase): + test_record = self.GetTestRecord(testcase) + if "includes" in test_record: + includes = [os.path.join(self.harnesspath, f) + for f in test_record["includes"]] + else: + includes = [] + return includes + + def GetSourceForTest(self, testcase): + filename = os.path.join(self.testroot, testcase.path + ".js") + with open(filename) as f: + return f.read() + + def IsNegativeTest(self, testcase): + test_record = self.GetTestRecord(testcase) + return "negative" in test_record + + def IsFailureOutput(self, output, testpath): + if output.exit_code != 0: + return True + return "FAILED!" in output.stdout + + def DownloadData(self): + revision = TEST_262_ARCHIVE_REVISION + archive_url = TEST_262_URL % revision + archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) + directory_name = os.path.join(self.root, "data") + directory_old_name = os.path.join(self.root, "data.old") + if not os.path.exists(archive_name): + print "Downloading test data from %s ..." % archive_url + utils.URLRetrieve(archive_url, archive_name) + if os.path.exists(directory_name): + if os.path.exists(directory_old_name): + shutil.rmtree(directory_old_name) + os.rename(directory_name, directory_old_name) + if not os.path.exists(directory_name): + print "Extracting test262-%s.tar.gz ..." % revision + md5 = hashlib.md5() + with open(archive_name, "rb") as f: + for chunk in iter(lambda: f.read(8192), ""): + md5.update(chunk) + if md5.hexdigest() != TEST_262_ARCHIVE_MD5: + os.remove(archive_name) + raise Exception("Hash mismatch of test data file") + archive = tarfile.open(archive_name, "r:gz") + if sys.platform in ("win32", "cygwin"): + # Magic incantation to allow longer path names on Windows. + archive.extractall(u"\\\\?\\%s" % self.root) + else: + archive.extractall(self.root) + os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), + directory_name) + + +def GetSuite(name, root): + return Test262TestSuite(name, root) diff --git a/deps/v8/test/test262/test262.status b/deps/v8/test/test262/test262.status index dd075d9688..86663130ac 100644 --- a/deps/v8/test/test262/test262.status +++ b/deps/v8/test/test262/test262.status @@ -31,9 +31,6 @@ '15.5.4.9_CE': [['no_i18n', SKIP]], - # TODO(turbofan): Timeouts on TurboFan need investigation. - '10.1.1_13': [PASS, NO_VARIANTS], - # BUG(v8:3455) '11.2.3_b': [FAIL], '12.2.3_b': [FAIL], diff --git a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt index 4b8eb14775..4fe6742d00 100644 --- a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt +++ b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt @@ -77,7 +77,7 @@ PASS getSortedOwnPropertyNames(Number) is ['EPSILON', 'MAX_SAFE_INTEGER', 'MAX_V PASS getSortedOwnPropertyNames(Number.prototype) is ['constructor', 'toExponential', 'toFixed', 'toLocaleString', 'toPrecision', 'toString', 'valueOf'] PASS getSortedOwnPropertyNames(Date) is ['UTC', 'arguments', 'caller', 'length', 'name', 'now', 'parse', 'prototype'] PASS getSortedOwnPropertyNames(Date.prototype) is ['constructor', 'getDate', 'getDay', 'getFullYear', 'getHours', 'getMilliseconds', 'getMinutes', 'getMonth', 'getSeconds', 'getTime', 'getTimezoneOffset', 'getUTCDate', 'getUTCDay', 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toISOString', 'toJSON', 'toLocaleDateString', 'toLocaleString', 'toLocaleTimeString', 'toString', 'toTimeString', 'toUTCString', 'valueOf'] -FAIL getSortedOwnPropertyNames(RegExp) should be $&,$',$*,$+,$1,$2,$3,$4,$5,$6,$7,$8,$9,$_,$`,arguments,caller,input,lastMatch,lastParen,leftContext,length,multiline,name,prototype,rightContext. Was $&,$',$*,$+,$1,$2,$3,$4,$5,$6,$7,$8,$9,$_,$`,$input,arguments,caller,input,lastMatch,lastParen,leftContext,length,multiline,name,prototype,rightContext. +PASS getSortedOwnPropertyNames(RegExp) is ['$&', "$'", '$*', '$+', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$_', '$`', 'arguments', 'caller', 'input', 'lastMatch', 'lastParen', 'leftContext', 'length', 'multiline', 'name', 'prototype', 'rightContext'] PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString'] PASS getSortedOwnPropertyNames(Error) is ['arguments', 'caller', 'captureStackTrace', 'length', 'name', 'prototype', 'stackTraceLimit'] PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString'] diff --git a/deps/v8/test/webkit/webkit.status b/deps/v8/test/webkit/webkit.status index c14d5c13c4..3bb6574dde 100644 --- a/deps/v8/test/webkit/webkit.status +++ b/deps/v8/test/webkit/webkit.status @@ -33,8 +33,6 @@ 'dfg-inline-arguments-become-int32': [PASS, FAIL], 'dfg-inline-arguments-reset': [PASS, FAIL], 'dfg-inline-arguments-reset-changetype': [PASS, FAIL], - # TODO(turbofan): Sometimes the try-catch blacklist fails. - 'exception-with-handler-inside-eval-with-dynamic-scope': [PASS, NO_VARIANTS], # TODO(turbofan): We run out of stack earlier on 64-bit for now. 'fast/js/deep-recursion-test': [PASS, NO_VARIANTS], # TODO(bmeurer,svenpanne): Investigate test failure. |