Commit 7ba980f2 authored by hpayer@chromium.org's avatar hpayer@chromium.org

Added pretenuring support for fast literal allocation in old data space.

BUG=
R=mstarzinger@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15306 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ebdf62c2
...@@ -9940,28 +9940,46 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( ...@@ -9940,28 +9940,46 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
int pointer_size, int pointer_size,
AllocationSiteMode mode) { AllocationSiteMode mode) {
Zone* zone = this->zone(); Zone* zone = this->zone();
int total_size = data_size + pointer_size;
NoObservableSideEffectsScope no_effects(this); NoObservableSideEffectsScope no_effects(this);
HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; HInstruction* target = NULL;
// TODO(hpayer): add support for old data space HInstruction* data_target = NULL;
if (isolate()->heap()->ShouldGloballyPretenure() &&
data_size == 0) { HAllocate::Flags flags = HAllocate::DefaultFlags();
if (isolate()->heap()->ShouldGloballyPretenure()) {
if (data_size != 0) {
HAllocate::Flags data_flags =
static_cast<HAllocate::Flags>(HAllocate::DefaultFlags() |
HAllocate::CAN_ALLOCATE_IN_OLD_DATA_SPACE);
HValue* size_in_bytes = AddInstruction(new(zone) HConstant(data_size));
data_target = AddInstruction(new(zone) HAllocate(
context, size_in_bytes, HType::JSObject(), data_flags));
Handle<Map> free_space_map = isolate()->factory()->free_space_map();
AddStoreMapConstant(data_target, free_space_map);
HObjectAccess access =
HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset);
AddStore(data_target, access, size_in_bytes);
}
if (pointer_size != 0) {
flags = static_cast<HAllocate::Flags>( flags = static_cast<HAllocate::Flags>(
flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
HValue* size_in_bytes = AddInstruction(new(zone) HConstant(pointer_size));
target = AddInstruction(new(zone) HAllocate(context,
size_in_bytes, HType::JSObject(), flags));
}
} else {
HValue* size_in_bytes =
AddInstruction(new(zone) HConstant(data_size + pointer_size));
target = AddInstruction(new(zone) HAllocate(context, size_in_bytes,
HType::JSObject(), flags));
} }
HValue* size_in_bytes = AddInstruction(new(zone) HConstant(total_size));
HInstruction* result =
AddInstruction(new(zone) HAllocate(context,
size_in_bytes,
HType::JSObject(),
flags));
int offset = 0; int offset = 0;
BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, result, int data_offset = 0;
&offset, mode); BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, target,
return result; &offset, data_target, &data_offset, mode);
return target;
} }
...@@ -9970,6 +9988,8 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( ...@@ -9970,6 +9988,8 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy(
Handle<JSObject> original_boilerplate_object, Handle<JSObject> original_boilerplate_object,
HInstruction* target, HInstruction* target,
int* offset, int* offset,
HInstruction* data_target,
int* data_offset,
AllocationSiteMode mode) { AllocationSiteMode mode) {
Zone* zone = this->zone(); Zone* zone = this->zone();
...@@ -9978,30 +9998,38 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( ...@@ -9978,30 +9998,38 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy(
original_boilerplate_object->elements()); original_boilerplate_object->elements());
ElementsKind kind = boilerplate_object->map()->elements_kind(); ElementsKind kind = boilerplate_object->map()->elements_kind();
// Increase the offset so that subsequent objects end up right after
// this object and its backing store.
int object_offset = *offset; int object_offset = *offset;
int object_size = boilerplate_object->map()->instance_size(); int object_size = boilerplate_object->map()->instance_size();
int elements_size = (elements->length() > 0 && int elements_size = (elements->length() > 0 &&
elements->map() != isolate()->heap()->fixed_cow_array_map()) ? elements->map() != isolate()->heap()->fixed_cow_array_map()) ?
elements->Size() : 0; elements->Size() : 0;
int elements_offset = *offset + object_size; int elements_offset = 0;
*offset += object_size + elements_size; if (data_target != NULL && boilerplate_object->HasFastDoubleElements()) {
elements_offset = *data_offset;
*data_offset += elements_size;
} else {
// Place elements right after this object.
elements_offset = *offset + object_size;
*offset += elements_size;
}
// Increase the offset so that subsequent objects end up right after this
// object (and it's elements if they are allocated in the same space).
*offset += object_size;
// Copy object elements if non-COW. // Copy object elements if non-COW.
HValue* object_elements = BuildEmitObjectHeader(boilerplate_object, target, HValue* object_elements = BuildEmitObjectHeader(boilerplate_object, target,
object_offset, elements_offset, elements_size); data_target, object_offset, elements_offset, elements_size);
if (object_elements != NULL) { if (object_elements != NULL) {
BuildEmitElements(elements, original_elements, kind, object_elements, BuildEmitElements(elements, original_elements, kind, object_elements,
target, offset); target, offset, data_target, data_offset);
} }
// Copy in-object properties. // Copy in-object properties.
HValue* object_properties = HValue* object_properties =
AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset));
BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object,
object_properties, target, offset); object_properties, target, offset, data_target, data_offset);
// Create allocation site info. // Create allocation site info.
if (mode == TRACK_ALLOCATION_SITE && if (mode == TRACK_ALLOCATION_SITE &&
...@@ -10018,6 +10046,7 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( ...@@ -10018,6 +10046,7 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy(
HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader(
Handle<JSObject> boilerplate_object, Handle<JSObject> boilerplate_object,
HInstruction* target, HInstruction* target,
HInstruction* data_target,
int object_offset, int object_offset,
int elements_offset, int elements_offset,
int elements_size) { int elements_size) {
...@@ -10035,9 +10064,14 @@ HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( ...@@ -10035,9 +10064,14 @@ HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader(
Handle<Object> elements_field = Handle<Object> elements_field =
Handle<Object>(boilerplate_object->elements(), isolate()); Handle<Object>(boilerplate_object->elements(), isolate());
elements = AddInstruction(new(zone) HConstant(elements_field)); elements = AddInstruction(new(zone) HConstant(elements_field));
} else {
if (data_target != NULL && boilerplate_object->HasFastDoubleElements()) {
elements = AddInstruction(new(zone) HInnerAllocatedObject(
data_target, elements_offset));
} else { } else {
elements = AddInstruction(new(zone) HInnerAllocatedObject( elements = AddInstruction(new(zone) HInnerAllocatedObject(
target, elements_offset)); target, elements_offset));
}
result = elements; result = elements;
} }
AddStore(object_header, HObjectAccess::ForElementsPointer(), elements); AddStore(object_header, HObjectAccess::ForElementsPointer(), elements);
...@@ -10074,7 +10108,9 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties( ...@@ -10074,7 +10108,9 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
Handle<JSObject> original_boilerplate_object, Handle<JSObject> original_boilerplate_object,
HValue* object_properties, HValue* object_properties,
HInstruction* target, HInstruction* target,
int* offset) { int* offset,
HInstruction* data_target,
int* data_offset) {
Zone* zone = this->zone(); Zone* zone = this->zone();
Handle<DescriptorArray> descriptors( Handle<DescriptorArray> descriptors(
boilerplate_object->map()->instance_descriptors()); boilerplate_object->map()->instance_descriptors());
...@@ -10108,7 +10144,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties( ...@@ -10108,7 +10144,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
AddStore(object_properties, access, value_instruction); AddStore(object_properties, access, value_instruction);
BuildEmitDeepCopy(value_object, original_value_object, target, BuildEmitDeepCopy(value_object, original_value_object, target,
offset, DONT_TRACK_ALLOCATION_SITE); offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE);
} else { } else {
Representation representation = details.representation(); Representation representation = details.representation();
HInstruction* value_instruction = HInstruction* value_instruction =
...@@ -10116,14 +10152,21 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties( ...@@ -10116,14 +10152,21 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
if (representation.IsDouble()) { if (representation.IsDouble()) {
// Allocate a HeapNumber box and store the value into it. // Allocate a HeapNumber box and store the value into it.
HInstruction* double_box = HInstruction* double_box;
AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); if (data_target != NULL) {
double_box = AddInstruction(new(zone) HInnerAllocatedObject(
data_target, *data_offset));
*data_offset += HeapNumber::kSize;
} else {
double_box = AddInstruction(new(zone) HInnerAllocatedObject(
target, *offset));
*offset += HeapNumber::kSize;
}
AddStoreMapConstant(double_box, AddStoreMapConstant(double_box,
isolate()->factory()->heap_number_map()); isolate()->factory()->heap_number_map());
AddStore(double_box, HObjectAccess::ForHeapNumberValue(), AddStore(double_box, HObjectAccess::ForHeapNumberValue(),
value_instruction, Representation::Double()); value_instruction, Representation::Double());
value_instruction = double_box; value_instruction = double_box;
*offset += HeapNumber::kSize;
} }
AddStore(object_properties, access, value_instruction); AddStore(object_properties, access, value_instruction);
...@@ -10148,7 +10191,9 @@ void HOptimizedGraphBuilder::BuildEmitElements( ...@@ -10148,7 +10191,9 @@ void HOptimizedGraphBuilder::BuildEmitElements(
ElementsKind kind, ElementsKind kind,
HValue* object_elements, HValue* object_elements,
HInstruction* target, HInstruction* target,
int* offset) { int* offset,
HInstruction* data_target,
int* data_offset) {
Zone* zone = this->zone(); Zone* zone = this->zone();
int elements_length = elements->length(); int elements_length = elements->length();
...@@ -10162,7 +10207,7 @@ void HOptimizedGraphBuilder::BuildEmitElements( ...@@ -10162,7 +10207,7 @@ void HOptimizedGraphBuilder::BuildEmitElements(
BuildEmitFixedDoubleArray(elements, kind, object_elements); BuildEmitFixedDoubleArray(elements, kind, object_elements);
} else if (elements->IsFixedArray()) { } else if (elements->IsFixedArray()) {
BuildEmitFixedArray(elements, original_elements, kind, object_elements, BuildEmitFixedArray(elements, original_elements, kind, object_elements,
target, offset); target, offset, data_target, data_offset);
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
...@@ -10195,7 +10240,9 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray( ...@@ -10195,7 +10240,9 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray(
ElementsKind kind, ElementsKind kind,
HValue* object_elements, HValue* object_elements,
HInstruction* target, HInstruction* target,
int* offset) { int* offset,
HInstruction* data_target,
int* data_offset) {
Zone* zone = this->zone(); Zone* zone = this->zone();
HInstruction* boilerplate_elements = HInstruction* boilerplate_elements =
AddInstruction(new(zone) HConstant(elements)); AddInstruction(new(zone) HConstant(elements));
...@@ -10215,7 +10262,7 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray( ...@@ -10215,7 +10262,7 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray(
AddInstruction(new(zone) HStoreKeyed( AddInstruction(new(zone) HStoreKeyed(
object_elements, key_constant, value_instruction, kind)); object_elements, key_constant, value_instruction, kind));
BuildEmitDeepCopy(value_object, original_value_object, target, BuildEmitDeepCopy(value_object, original_value_object, target,
offset, DONT_TRACK_ALLOCATION_SITE); offset, data_target, data_offset, DONT_TRACK_ALLOCATION_SITE);
} else { } else {
HInstruction* value_instruction = HInstruction* value_instruction =
AddInstruction(new(zone) HLoadKeyed( AddInstruction(new(zone) HLoadKeyed(
......
...@@ -1828,13 +1828,16 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { ...@@ -1828,13 +1828,16 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
void BuildEmitDeepCopy(Handle<JSObject> boilerplat_object, void BuildEmitDeepCopy(Handle<JSObject> boilerplat_object,
Handle<JSObject> object, Handle<JSObject> object,
HInstruction* result, HInstruction* target,
int* offset, int* offset,
HInstruction* data_target,
int* data_offset,
AllocationSiteMode mode); AllocationSiteMode mode);
MUST_USE_RESULT HValue* BuildEmitObjectHeader( MUST_USE_RESULT HValue* BuildEmitObjectHeader(
Handle<JSObject> boilerplat_object, Handle<JSObject> boilerplat_object,
HInstruction* target, HInstruction* target,
HInstruction* data_target,
int object_offset, int object_offset,
int elements_offset, int elements_offset,
int elements_size); int elements_size);
...@@ -1843,14 +1846,18 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { ...@@ -1843,14 +1846,18 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
Handle<JSObject> original_boilerplate_object, Handle<JSObject> original_boilerplate_object,
HValue* object_properties, HValue* object_properties,
HInstruction* target, HInstruction* target,
int* offset); int* offset,
HInstruction* data_target,
int* data_offset);
void BuildEmitElements(Handle<FixedArrayBase> elements, void BuildEmitElements(Handle<FixedArrayBase> elements,
Handle<FixedArrayBase> original_elements, Handle<FixedArrayBase> original_elements,
ElementsKind kind, ElementsKind kind,
HValue* object_elements, HValue* object_elements,
HInstruction* target, HInstruction* target,
int* offset); int* offset,
HInstruction* data_target,
int* data_offset);
void BuildEmitFixedDoubleArray(Handle<FixedArrayBase> elements, void BuildEmitFixedDoubleArray(Handle<FixedArrayBase> elements,
ElementsKind kind, ElementsKind kind,
...@@ -1861,7 +1868,9 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor { ...@@ -1861,7 +1868,9 @@ class HOptimizedGraphBuilder: public HGraphBuilder, public AstVisitor {
ElementsKind kind, ElementsKind kind,
HValue* object_elements, HValue* object_elements,
HInstruction* target, HInstruction* target,
int* offset); int* offset,
HInstruction* data_target,
int* data_offset);
void AddCheckPrototypeMaps(Handle<JSObject> holder, void AddCheckPrototypeMaps(Handle<JSObject> holder,
Handle<Map> receiver_map); Handle<Map> receiver_map);
......
...@@ -2109,8 +2109,7 @@ TEST(OptimizedAllocationAlwaysInNewSpace) { ...@@ -2109,8 +2109,7 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
} }
// Test pretenuring of array literals allocated with HAllocate. TEST(OptimizedPretenuringObjectArrayLiterals) {
TEST(OptimizedPretenuringArrayLiterals) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM(); CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
...@@ -2118,11 +2117,9 @@ TEST(OptimizedPretenuringArrayLiterals) { ...@@ -2118,11 +2117,9 @@ TEST(OptimizedPretenuringArrayLiterals) {
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true); HEAP->SetNewSpaceHighPromotionModeActive(true);
AlwaysAllocateScope always_allocate;
v8::Local<v8::Value> res = CompileRun( v8::Local<v8::Value> res = CompileRun(
"function f() {" "function f() {"
" var numbers = [1, 2, 3];" " var numbers = [{}, {}, {}];"
" numbers[0] = {};"
" return numbers;" " return numbers;"
"};" "};"
"f(); f(); f();" "f(); f(); f();"
...@@ -2133,21 +2130,22 @@ TEST(OptimizedPretenuringArrayLiterals) { ...@@ -2133,21 +2130,22 @@ TEST(OptimizedPretenuringArrayLiterals) {
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldPointerSpace(o->elements())); CHECK(HEAP->InOldPointerSpace(o->elements()));
CHECK(HEAP->InOldPointerSpace(*o));
} }
TEST(OptimizedPretenuringSimpleArrayLiterals) { TEST(OptimizedPretenuringMixedInObjectProperties) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
i::FLAG_pretenuring = false;
CcTest::InitializeVM(); CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return; if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true);
AlwaysAllocateScope always_allocate;
v8::Local<v8::Value> res = CompileRun( v8::Local<v8::Value> res = CompileRun(
"function f() {" "function f() {"
" return [1, 2, 3];" " var numbers = {a: {c: 2.2, d: {}}, b: 1.1};"
" return numbers;"
"};" "};"
"f(); f(); f();" "f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);" "%OptimizeFunctionOnNextCall(f);"
...@@ -2156,7 +2154,168 @@ TEST(OptimizedPretenuringSimpleArrayLiterals) { ...@@ -2156,7 +2154,168 @@ TEST(OptimizedPretenuringSimpleArrayLiterals) {
Handle<JSObject> o = Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InNewSpace(*o)); CHECK(HEAP->InOldPointerSpace(*o));
CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(0)));
CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(1)));
JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0));
CHECK(HEAP->InOldPointerSpace(inner_object));
CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0)));
CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1)));
}
TEST(OptimizedPretenuringDoubleArrayProperties) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true);
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var numbers = {a: 1.1, b: 2.2};"
" return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldPointerSpace(*o));
CHECK(HEAP->InOldDataSpace(o->properties()));
}
TEST(OptimizedPretenuringdoubleArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true);
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var numbers = [1.1, 2.2, 3.3];"
" return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldDataSpace(o->elements()));
CHECK(HEAP->InOldPointerSpace(*o));
}
TEST(OptimizedPretenuringNestedMixedArrayLiterals) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true);
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var numbers = [[{}, {}, {}],[1.1, 2.2, 3.3]];"
" return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
v8::Local<v8::Value> int_array = v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> int_array_handle =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array));
v8::Local<v8::Value> double_array = v8::Object::Cast(*res)->Get(v8_str("1"));
Handle<JSObject> double_array_handle =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array));
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldPointerSpace(*o));
CHECK(HEAP->InOldPointerSpace(*int_array_handle));
CHECK(HEAP->InOldPointerSpace(int_array_handle->elements()));
CHECK(HEAP->InOldPointerSpace(*double_array_handle));
CHECK(HEAP->InOldDataSpace(double_array_handle->elements()));
}
TEST(OptimizedPretenuringNestedObjectLiterals) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true);
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var numbers = [[{}, {}, {}],[{}, {}, {}]];"
" return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
v8::Local<v8::Value> int_array_1 = v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> int_array_handle_1 =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_1));
v8::Local<v8::Value> int_array_2 = v8::Object::Cast(*res)->Get(v8_str("1"));
Handle<JSObject> int_array_handle_2 =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(int_array_2));
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldPointerSpace(*o));
CHECK(HEAP->InOldPointerSpace(*int_array_handle_1));
CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements()));
CHECK(HEAP->InOldPointerSpace(*int_array_handle_2));
CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements()));
}
TEST(OptimizedPretenuringNestedDoubleLiterals) {
i::FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate());
HEAP->SetNewSpaceHighPromotionModeActive(true);
v8::Local<v8::Value> res = CompileRun(
"function f() {"
" var numbers = [[1.1, 1.2, 1.3],[2.1, 2.2, 2.3]];"
" return numbers;"
"};"
"f(); f(); f();"
"%OptimizeFunctionOnNextCall(f);"
"f();");
v8::Local<v8::Value> double_array_1 =
v8::Object::Cast(*res)->Get(v8_str("0"));
Handle<JSObject> double_array_handle_1 =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_1));
v8::Local<v8::Value> double_array_2 =
v8::Object::Cast(*res)->Get(v8_str("1"));
Handle<JSObject> double_array_handle_2 =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(double_array_2));
Handle<JSObject> o =
v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
CHECK(HEAP->InOldPointerSpace(*o));
CHECK(HEAP->InOldPointerSpace(*double_array_handle_1));
CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements()));
CHECK(HEAP->InOldPointerSpace(*double_array_handle_2));
CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements()));
} }
...@@ -2168,7 +2327,6 @@ TEST(OptimizedAllocationArrayLiterals) { ...@@ -2168,7 +2327,6 @@ TEST(OptimizedAllocationArrayLiterals) {
if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
AlwaysAllocateScope always_allocate;
v8::Local<v8::Value> res = CompileRun( v8::Local<v8::Value> res = CompileRun(
"function f() {" "function f() {"
" var numbers = new Array(1, 2, 3);" " var numbers = new Array(1, 2, 3);"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment