[test] Move away from deprecated API for heap-related tests.

Removed deprecated API usage in
 - test-heap.cc
 - test-incremental-marking.cc
 - test-alloc.cc

BUG=v8:4134
LOG=n

Review URL: https://codereview.chromium.org/1406393005

Cr-Commit-Position: refs/heads/master@{#31898}
This commit is contained in:
mlippautz 2015-11-09 11:48:08 -08:00 committed by Commit bot
parent 744424208b
commit aecd084dd9
4 changed files with 359 additions and 229 deletions

View File

@ -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(jochen): Remove this after the setting is turned on globally.
#define V8_IMMINENT_DEPRECATION_WARNINGS
#include "src/v8.h"
#include "test/cctest/cctest.h"
@ -99,7 +102,7 @@ Handle<Object> v8::internal::HeapTester::TestAllocateAfterFailures() {
HEAP_TEST(StressHandles) {
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
v8::Local<v8::Context> env = v8::Context::New(CcTest::isolate());
env->Enter();
Handle<Object> o = TestAllocateAfterFailures();
CHECK(o->IsTrue());
@ -137,7 +140,7 @@ TEST(StressJS) {
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate());
v8::Local<v8::Context> env = v8::Context::New(CcTest::isolate());
env->Enter();
Handle<JSFunction> function = factory->NewFunction(
factory->function_string());
@ -160,12 +163,22 @@ TEST(StressJS) {
map->AppendDescriptor(&d);
// Add the Foo constructor the global object.
env->Global()->Set(v8::String::NewFromUtf8(CcTest::isolate(), "Foo"),
v8::Utils::CallableToLocal(function));
CHECK(env->Global()
->Set(env, v8::String::NewFromUtf8(CcTest::isolate(), "Foo",
v8::NewStringType::kNormal)
.ToLocalChecked(),
v8::Utils::CallableToLocal(function))
.FromJust());
// Call the accessor through JavaScript.
v8::Handle<v8::Value> result = v8::Script::Compile(
v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get"))->Run();
CHECK_EQ(true, result->BooleanValue());
v8::Local<v8::Value> result =
v8::Script::Compile(
env, v8::String::NewFromUtf8(CcTest::isolate(), "(new Foo).get",
v8::NewStringType::kNormal)
.ToLocalChecked())
.ToLocalChecked()
->Run(env)
.ToLocalChecked();
CHECK_EQ(true, result->BooleanValue(env).FromJust());
env->Exit();
}

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(jochen): Remove this after the setting is turned on globally.
#define V8_IMMINENT_DEPRECATION_WARNINGS
#include <stdlib.h>
#ifdef __linux__
@ -24,6 +27,8 @@ using v8::IdleTask;
using v8::Task;
using v8::Isolate;
namespace v8 {
namespace internal {
class MockPlatform : public v8::Platform {
public:
@ -39,11 +44,11 @@ class MockPlatform : public v8::Platform {
platform_->CallOnBackgroundThread(task, expected_runtime);
}
void CallOnForegroundThread(Isolate* isolate, Task* task) override {
void CallOnForegroundThread(v8::Isolate* isolate, Task* task) override {
platform_->CallOnForegroundThread(isolate, task);
}
void CallDelayedOnForegroundThread(Isolate* isolate, Task* task,
void CallDelayedOnForegroundThread(v8::Isolate* isolate, Task* task,
double delay_in_seconds) override {
if (delayed_task_ != nullptr) {
delete delayed_task_;
@ -55,12 +60,13 @@ class MockPlatform : public v8::Platform {
return platform_->MonotonicallyIncreasingTime();
}
void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) override {
void CallIdleOnForegroundThread(v8::Isolate* isolate,
IdleTask* task) override {
CHECK(nullptr == idle_task_);
idle_task_ = task;
}
bool IdleTasksEnabled(Isolate* isolate) override { return true; }
bool IdleTasksEnabled(v8::Isolate* isolate) override { return true; }
bool PendingIdleTask() { return idle_task_ != nullptr; }
@ -166,3 +172,6 @@ TEST(IncrementalMarkingUsingDelayedTasks) {
CHECK(marking->IsStopped());
i::V8::SetPlatformForTesting(old_platform);
}
} // namespace internal
} // namespace v8

View File

@ -36,7 +36,8 @@
#include "test/cctest/cctest.h"
#include "test/cctest/heap-tester.h"
using namespace v8::internal;
namespace v8 {
namespace internal {
#if 0
static void VerifyRegionMarking(Address page_start) {
@ -104,9 +105,6 @@ TEST(Page) {
#endif
namespace v8 {
namespace internal {
// Temporarily sets a given allocator in an isolate.
class TestMemoryAllocatorScope {
public:
@ -148,9 +146,6 @@ class TestCodeRangeScope {
DISALLOW_COPY_AND_ASSIGN(TestCodeRangeScope);
};
} // namespace internal
} // namespace v8
static void VerifyMemoryChunk(Isolate* isolate,
Heap* heap,
@ -176,14 +171,15 @@ static void VerifyMemoryChunk(Isolate* isolate,
commit_area_size,
executable,
NULL);
size_t alignment = code_range != NULL && code_range->valid() ?
MemoryChunk::kAlignment : v8::base::OS::CommitPageSize();
size_t alignment = code_range != NULL && code_range->valid()
? MemoryChunk::kAlignment
: base::OS::CommitPageSize();
size_t reserved_size =
((executable == EXECUTABLE))
? RoundUp(header_size + guard_size + reserve_area_size + guard_size,
alignment)
: RoundUp(header_size + reserve_area_size,
v8::base::OS::CommitPageSize());
base::OS::CommitPageSize());
CHECK(memory_chunk->size() == reserved_size);
CHECK(memory_chunk->area_start() < memory_chunk->address() +
memory_chunk->size());
@ -888,3 +884,6 @@ UNINITIALIZED_TEST(InlineAllocationObserver) {
}
isolate->Dispose();
}
} // namespace internal
} // namespace v8