Index: test/cctest/test-alloc.cc |
=================================================================== |
--- test/cctest/test-alloc.cc (revision 7267) |
+++ test/cctest/test-alloc.cc (working copy) |
@@ -27,7 +27,6 @@ |
#include "v8.h" |
#include "accessors.h" |
-#include "top.h" |
#include "cctest.h" |
@@ -38,13 +37,14 @@ |
static MaybeObject* AllocateAfterFailures() { |
static int attempts = 0; |
if (++attempts < 3) return Failure::RetryAfterGC(); |
+ Heap* heap = Isolate::Current()->heap(); |
// New space. |
- NewSpace* new_space = Heap::new_space(); |
+ NewSpace* new_space = heap->new_space(); |
static const int kNewSpaceFillerSize = ByteArray::SizeFor(0); |
while (new_space->Available() > kNewSpaceFillerSize) { |
int available_before = static_cast<int>(new_space->Available()); |
- CHECK(!Heap::AllocateByteArray(0)->IsFailure()); |
+ CHECK(!heap->AllocateByteArray(0)->IsFailure()); |
if (available_before == new_space->Available()) { |
// It seems that we are avoiding new space allocations when |
// allocation is forced, so no need to fill up new space |
@@ -52,45 +52,46 @@ |
break; |
} |
} |
- CHECK(!Heap::AllocateByteArray(100)->IsFailure()); |
- CHECK(!Heap::AllocateFixedArray(100, NOT_TENURED)->IsFailure()); |
+ CHECK(!heap->AllocateByteArray(100)->IsFailure()); |
+ CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure()); |
// Make sure we can allocate through optimized allocation functions |
// for specific kinds. |
- CHECK(!Heap::AllocateFixedArray(100)->IsFailure()); |
- CHECK(!Heap::AllocateHeapNumber(0.42)->IsFailure()); |
- CHECK(!Heap::AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); |
- Object* object = |
- Heap::AllocateJSObject(*Top::object_function())->ToObjectChecked(); |
- CHECK(!Heap::CopyJSObject(JSObject::cast(object))->IsFailure()); |
+ CHECK(!heap->AllocateFixedArray(100)->IsFailure()); |
+ CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure()); |
+ CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure()); |
+ Object* object = heap->AllocateJSObject( |
+ *Isolate::Current()->object_function())->ToObjectChecked(); |
+ CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure()); |
// Old data space. |
- OldSpace* old_data_space = Heap::old_data_space(); |
+ OldSpace* old_data_space = heap->old_data_space(); |
static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0); |
while (old_data_space->Available() > kOldDataSpaceFillerSize) { |
- CHECK(!Heap::AllocateByteArray(0, TENURED)->IsFailure()); |
+ CHECK(!heap->AllocateByteArray(0, TENURED)->IsFailure()); |
} |
- CHECK(!Heap::AllocateRawAsciiString(100, TENURED)->IsFailure()); |
+ CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure()); |
// Large object space. |
- while (!Heap::OldGenerationAllocationLimitReached()) { |
- CHECK(!Heap::AllocateFixedArray(10000, TENURED)->IsFailure()); |
+ while (!heap->OldGenerationAllocationLimitReached()) { |
+ CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); |
} |
- CHECK(!Heap::AllocateFixedArray(10000, TENURED)->IsFailure()); |
+ CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure()); |
// Map space. |
- MapSpace* map_space = Heap::map_space(); |
+ MapSpace* map_space = heap->map_space(); |
static const int kMapSpaceFillerSize = Map::kSize; |
InstanceType instance_type = JS_OBJECT_TYPE; |
int instance_size = JSObject::kHeaderSize; |
while (map_space->Available() > kMapSpaceFillerSize) { |
- CHECK(!Heap::AllocateMap(instance_type, instance_size)->IsFailure()); |
+ CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure()); |
} |
- CHECK(!Heap::AllocateMap(instance_type, instance_size)->IsFailure()); |
+ CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure()); |
// Test that we can allocate in old pointer space and code space. |
- CHECK(!Heap::AllocateFixedArray(100, TENURED)->IsFailure()); |
- CHECK(!Heap::CopyCode(Builtins::builtin(Builtins::Illegal))->IsFailure()); |
+ CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure()); |
+ CHECK(!heap->CopyCode(Isolate::Current()->builtins()->builtin( |
+ Builtins::Illegal))->IsFailure()); |
// Return success. |
return Smi::FromInt(42); |
@@ -98,7 +99,7 @@ |
static Handle<Object> Test() { |
- CALL_HEAP_FUNCTION(AllocateAfterFailures(), Object); |
+ CALL_HEAP_FUNCTION(ISOLATE, AllocateAfterFailures(), Object); |
} |
@@ -129,18 +130,19 @@ |
v8::HandleScope scope; |
env->Enter(); |
Handle<JSFunction> function = |
- Factory::NewFunction(Factory::function_symbol(), Factory::null_value()); |
+ FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value()); |
// Force the creation of an initial map and set the code to |
// something empty. |
- Factory::NewJSObject(function); |
- function->ReplaceCode(Builtins::builtin(Builtins::EmptyFunction)); |
+ FACTORY->NewJSObject(function); |
+ function->ReplaceCode(Isolate::Current()->builtins()->builtin( |
+ Builtins::EmptyFunction)); |
// Patch the map to have an accessor for "get". |
Handle<Map> map(function->initial_map()); |
Handle<DescriptorArray> instance_descriptors(map->instance_descriptors()); |
- Handle<Proxy> proxy = Factory::NewProxy(&kDescriptor); |
- instance_descriptors = Factory::CopyAppendProxyDescriptor( |
+ Handle<Proxy> proxy = FACTORY->NewProxy(&kDescriptor); |
+ instance_descriptors = FACTORY->CopyAppendProxyDescriptor( |
instance_descriptors, |
- Factory::NewStringFromAscii(Vector<const char>("get", 3)), |
+ FACTORY->NewStringFromAscii(Vector<const char>("get", 3)), |
proxy, |
static_cast<PropertyAttributes>(0)); |
map->set_instance_descriptors(*instance_descriptors); |
@@ -183,7 +185,8 @@ |
TEST(CodeRange) { |
const int code_range_size = 16*MB; |
- CodeRange::Setup(code_range_size); |
+ OS::Setup(); |
+ Isolate::Current()->code_range()->Setup(code_range_size); |
int current_allocated = 0; |
int total_allocated = 0; |
List<Block> blocks(1000); |
@@ -195,14 +198,16 @@ |
size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) + |
Pseudorandom() % 5000 + 1; |
size_t allocated = 0; |
- void* base = CodeRange::AllocateRawMemory(requested, &allocated); |
+ void* base = Isolate::Current()->code_range()-> |
+ AllocateRawMemory(requested, &allocated); |
blocks.Add(Block(base, static_cast<int>(allocated))); |
current_allocated += static_cast<int>(allocated); |
total_allocated += static_cast<int>(allocated); |
} else { |
// Free a block. |
int index = Pseudorandom() % blocks.length(); |
- CodeRange::FreeRawMemory(blocks[index].base, blocks[index].size); |
+ Isolate::Current()->code_range()->FreeRawMemory( |
+ blocks[index].base, blocks[index].size); |
current_allocated -= blocks[index].size; |
if (index < blocks.length() - 1) { |
blocks[index] = blocks.RemoveLast(); |
@@ -212,5 +217,5 @@ |
} |
} |
- CodeRange::TearDown(); |
+ Isolate::Current()->code_range()->TearDown(); |
} |