Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: src/hydrogen.cc

Issue 21074004: Cleaning up HAllocate space and double alignment selection. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/heap.h ('K') | « src/heap.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 0e103caf5b8fdcc03aafa2320cba5d980e9b9ce0..5e69b0b6cda5122519e670b7370a9fa5d7d89481 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1312,9 +1312,17 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
ElementsKind kind,
HValue* capacity) {
Zone* zone = this->zone();
+ int elements_size;
+ InstanceType instance_type;
+
+ if (IsFastDoubleElementsKind(kind)) {
+ elements_size = kDoubleSize;
+ instance_type = FIXED_DOUBLE_ARRAY_TYPE;
+ } else {
+ elements_size = kPointerSize;
+ instance_type = FIXED_ARRAY_TYPE;
+ }
- int elements_size = IsFastDoubleElementsKind(kind)
- ? kDoubleSize : kPointerSize;
HConstant* elements_size_value = Add<HConstant>(elements_size);
HValue* mul = AddInstruction(
HMul::New(zone, context, capacity, elements_size_value));
@@ -1326,7 +1334,7 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
total_size->ClearFlag(HValue::kCanOverflow);
return Add<HAllocate>(context, total_size, HType::JSArray(),
- isolate()->heap()->ShouldGloballyPretenure(), kind);
+ isolate()->heap()->GetAllocationMode(), instance_type);
}
@@ -1651,10 +1659,14 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context,
size += AllocationMemento::kSize;
}
int elems_offset = size;
+ InstanceType instance_type = FIXED_ARRAY_TYPE;
if (length > 0) {
- size += IsFastDoubleElementsKind(kind)
- ? FixedDoubleArray::SizeFor(length)
- : FixedArray::SizeFor(length);
+ if (IsFastDoubleElementsKind(kind)) {
+ size += FixedDoubleArray::SizeFor(length);
+ instance_type = FIXED_DOUBLE_ARRAY_TYPE;
+ } else {
+ size += FixedArray::SizeFor(length);
+ }
}
// Allocate both the JS array and the elements array in one big
@@ -1663,8 +1675,8 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context,
HInstruction* object = Add<HAllocate>(context,
size_in_bytes,
HType::JSObject(),
- false,
- kind);
+ NEW_SPACE_ALLOCATION,
+ instance_type);
// Copy the JS array part.
for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
@@ -1947,7 +1959,7 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes,
// Allocate (dealing with failure appropriately)
HAllocate* new_object = builder()->Add<HAllocate>(context, size_in_bytes,
- HType::JSArray(), false, kind_);
+ HType::JSArray(), NEW_SPACE_ALLOCATION, JS_ARRAY_TYPE);
// Fill in the fields: map, properties, length
HValue* map;
@@ -4551,8 +4563,8 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
NoObservableSideEffectsScope no_side_effects(this);
HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize);
HInstruction* heap_number = Add<HAllocate>(
- environment()->LookupContext(), heap_number_size,
- HType::HeapNumber(), false);
+ environment()->LookupContext(), heap_number_size, HType::HeapNumber(),
+ NEW_SPACE_ALLOCATION, HEAP_NUMBER_TYPE);
AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map());
AddStore(heap_number, HObjectAccess::ForHeapNumberValue(), value);
instr = new(zone()) HStoreNamedField(
@@ -7133,10 +7145,12 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
// Allocate an instance of the implicit receiver object.
HValue* size_in_bytes = Add<HConstant>(instance_size);
- bool pretenure = FLAG_pretenuring_call_new &&
- isolate()->heap()->ShouldGloballyPretenure();
+ AllocationMode allocation_mode = FLAG_pretenuring_call_new &&
+ isolate()->heap()->GetAllocationMode() == OLD_SPACE_ALLOCATION ?
+ OLD_SPACE_ALLOCATION : NEW_SPACE_ALLOCATION;
HAllocate* receiver =
- Add<HAllocate>(context, size_in_bytes, HType::JSObject(), pretenure);
+ Add<HAllocate>(context, size_in_bytes, HType::JSObject(),
+ allocation_mode, JS_OBJECT_TYPE);
receiver->set_known_initial_map(initial_map);
// Load the initial map from the constructor.
@@ -8214,13 +8228,11 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
HInstruction* target = NULL;
HInstruction* data_target = NULL;
- ElementsKind kind = boilerplate_object->map()->elements_kind();
-
- if (isolate()->heap()->ShouldGloballyPretenure()) {
+ if (isolate()->heap()->GetAllocationMode() == OLD_SPACE_ALLOCATION) {
if (data_size != 0) {
HValue* size_in_bytes = Add<HConstant>(data_size);
data_target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(),
- true, FAST_DOUBLE_ELEMENTS);
+ OLD_SPACE_ALLOCATION, FIXED_DOUBLE_ARRAY_TYPE);
Handle<Map> free_space_map = isolate()->factory()->free_space_map();
AddStoreMapConstant(data_target, free_space_map);
HObjectAccess access =
@@ -8230,12 +8242,13 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
if (pointer_size != 0) {
HValue* size_in_bytes = Add<HConstant>(pointer_size);
target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(),
- true);
+ OLD_SPACE_ALLOCATION, JS_OBJECT_TYPE);
}
} else {
+ InstanceType instance_type = boilerplate_object->map()->instance_type();
HValue* size_in_bytes = Add<HConstant>(data_size + pointer_size);
- target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(), false,
- kind);
+ target = Add<HAllocate>(context, size_in_bytes, HType::JSObject(),
+ NEW_SPACE_ALLOCATION, instance_type);
}
int offset = 0;
« src/heap.h ('K') | « src/heap.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698