Revision: 16000
Author: [email protected]
Date: Thu Aug 1 01:34:36 2013
Log: Cleaning up HAllocate space and double alignment selection.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/21074004
http://code.google.com/p/v8/source/detail?r=16000
Modified:
/branches/bleeding_edge/src/code-stubs-hydrogen.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Wed Jul 31 07:58:39
2013
+++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Thu Aug 1 01:34:36
2013
@@ -425,7 +425,7 @@
HValue* size_in_bytes = Add<HConstant>(size);
HInstruction* object = Add<HAllocate>(size_in_bytes, HType::JSObject(),
- isolate()->heap()->ShouldGloballyPretenure());
+ isolate()->heap()->GetPretenureMode(), JS_OBJECT_TYPE);
for (int i = 0; i < size; i += kPointerSize) {
HObjectAccess access = HObjectAccess::ForJSObjectOffset(i);
@@ -449,7 +449,8 @@
template <>
HValue* CodeStubGraphBuilder<CreateAllocationSiteStub>::BuildCodeStub() {
HValue* size = Add<HConstant>(AllocationSite::kSize);
- HInstruction* object = Add<HAllocate>(size, HType::JSObject(), true);
+ HInstruction* object = Add<HAllocate>(size, HType::JSObject(), TENURED,
+ JS_OBJECT_TYPE);
// Store the map
Handle<Map> allocation_site_map(isolate()->heap()->allocation_site_map(),
=======================================
--- /branches/bleeding_edge/src/heap.h Wed Jul 31 10:08:50 2013
+++ /branches/bleeding_edge/src/heap.h Thu Aug 1 01:34:36 2013
@@ -483,6 +483,7 @@
INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
};
+
class Heap {
public:
// Configure heap size before setup. Return false if the heap has been
@@ -1399,7 +1400,7 @@
// Finds out which space an object should get promoted to based on its
type.
inline OldSpace* TargetSpace(HeapObject* object);
- inline AllocationSpace TargetSpaceId(InstanceType type);
+ static inline AllocationSpace TargetSpaceId(InstanceType type);
// Sets the stub_cache_ (only used when expanding the dictionary).
void public_set_code_stubs(UnseededNumberDictionary* value) {
@@ -1545,20 +1546,17 @@
MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length);
MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length,
PretenureFlag
pretenure);
-
- // Predicate that governs global pre-tenuring decisions based on observed
- // promotion rates of previous collections.
- inline bool ShouldGloballyPretenure() {
- return FLAG_pretenuring && new_space_high_promotion_mode_active_;
- }
// This is only needed for testing high promotion mode.
void SetNewSpaceHighPromotionModeActive(bool mode) {
new_space_high_promotion_mode_active_ = mode;
}
+ // Returns the allocation mode (pre-tenuring) based on observed promotion
+ // rates of previous collections.
inline PretenureFlag GetPretenureMode() {
- return new_space_high_promotion_mode_active_ ? TENURED : NOT_TENURED;
+ return FLAG_pretenuring && new_space_high_promotion_mode_active_
+ ? TENURED : NOT_TENURED;
}
inline Address* NewSpaceHighPromotionModeActiveAddress() {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Wed Jul 31 09:41:51
2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Aug 1 01:34:36
2013
@@ -5457,9 +5457,10 @@
HValue* context,
HValue* size,
HType type,
- bool pretenure,
- ElementsKind kind = FAST_ELEMENTS) {
- return new(zone) HAllocate(context, size, type, pretenure, kind);
+ PretenureFlag pretenure_flag,
+ InstanceType instance_type) {
+ return new(zone) HAllocate(context, size, type, pretenure_flag,
+ instance_type);
}
// Maximum instance size for which allocations will be inlined.
@@ -5535,8 +5536,8 @@
HAllocate(HValue* context,
HValue* size,
HType type,
- bool pretenure,
- ElementsKind kind)
+ PretenureFlag pretenure_flag,
+ InstanceType instance_type)
: HTemplateInstruction<2>(type) {
SetOperandAt(0, context);
SetOperandAt(1, size);
@@ -5544,19 +5545,13 @@
SetFlag(kTrackSideEffectDominators);
SetGVNFlag(kChangesNewSpacePromotion);
SetGVNFlag(kDependsOnNewSpacePromotion);
- if (pretenure) {
- if (IsFastDoubleElementsKind(kind)) {
- flags_ = static_cast<HAllocate::Flags>(ALLOCATE_IN_OLD_DATA_SPACE |
- ALLOCATE_DOUBLE_ALIGNED);
- } else {
- flags_ = ALLOCATE_IN_OLD_POINTER_SPACE;
- }
- } else {
- flags_ = ALLOCATE_IN_NEW_SPACE;
- if (IsFastDoubleElementsKind(kind)) {
- flags_ = static_cast<HAllocate::Flags>(flags_ |
- ALLOCATE_DOUBLE_ALIGNED);
- }
+ flags_ = pretenure_flag == TENURED
+ ? (Heap::TargetSpaceId(instance_type) == OLD_POINTER_SPACE
+ ? ALLOCATE_IN_OLD_POINTER_SPACE : ALLOCATE_IN_OLD_DATA_SPACE)
+ : ALLOCATE_IN_NEW_SPACE;
+ if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
+ flags_ = static_cast<HAllocate::Flags>(flags_ |
+ ALLOCATE_DOUBLE_ALIGNED);
}
}
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Wed Jul 31 08:40:24 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Thu Aug 1 01:34:36 2013
@@ -1315,8 +1315,17 @@
HValue* HGraphBuilder::BuildAllocateElements(ElementsKind kind,
HValue* capacity) {
- int elements_size = IsFastDoubleElementsKind(kind)
- ? kDoubleSize : kPointerSize;
+ 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;
+ }
+
HConstant* elements_size_value = Add<HConstant>(elements_size);
HValue* mul = Add<HMul>(capacity, elements_size_value);
mul->ClearFlag(HValue::kCanOverflow);
@@ -1326,7 +1335,7 @@
total_size->ClearFlag(HValue::kCanOverflow);
return Add<HAllocate>(total_size, HType::JSArray(),
- isolate()->heap()->ShouldGloballyPretenure(), kind);
+ isolate()->heap()->GetPretenureMode(), instance_type);
}
@@ -1646,6 +1655,8 @@
size += AllocationMemento::kSize;
}
int elems_offset = size;
+ InstanceType instance_type = IsFastDoubleElementsKind(kind) ?
+ FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE;
if (length > 0) {
size += IsFastDoubleElementsKind(kind)
? FixedDoubleArray::SizeFor(length)
@@ -1657,8 +1668,8 @@
HValue* size_in_bytes = Add<HConstant>(size);
HInstruction* object = Add<HAllocate>(size_in_bytes,
HType::JSObject(),
- false,
- kind);
+ NOT_TENURED,
+ instance_type);
// Copy the JS array part.
for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
@@ -1936,7 +1947,7 @@
Representation::Smi());
// Allocate (dealing with failure appropriately)
HAllocate* new_object = builder()->Add<HAllocate>(size_in_bytes,
- HType::JSArray(), false, kind_);
+ HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE);
// Fill in the fields: map, properties, length
HValue* map;
@@ -4520,7 +4531,7 @@
NoObservableSideEffectsScope no_side_effects(this);
HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize);
HInstruction* heap_number = Add<HAllocate>(heap_number_size,
- HType::HeapNumber(), false);
+ HType::HeapNumber(), NOT_TENURED, HEAP_NUMBER_TYPE);
AddStoreMapConstant(heap_number,
isolate()->factory()->heap_number_map());
Add<HStoreNamedField>(heap_number,
HObjectAccess::ForHeapNumberValue(),
value);
@@ -7090,10 +7101,13 @@
// 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();
+ PretenureFlag pretenure_flag =
+ (FLAG_pretenuring_call_new &&
+ isolate()->heap()->GetPretenureMode() == TENURED)
+ ? TENURED : NOT_TENURED;
HAllocate* receiver =
- Add<HAllocate>(size_in_bytes, HType::JSObject(), pretenure);
+ Add<HAllocate>(size_in_bytes, HType::JSObject(), pretenure_flag,
+ JS_OBJECT_TYPE);
receiver->set_known_initial_map(initial_map);
// Load the initial map from the constructor.
@@ -8165,13 +8179,11 @@
HInstruction* target = NULL;
HInstruction* data_target = NULL;
- ElementsKind kind = boilerplate_object->map()->elements_kind();
-
- if (isolate()->heap()->ShouldGloballyPretenure()) {
+ if (isolate()->heap()->GetPretenureMode() == TENURED) {
if (data_size != 0) {
HValue* size_in_bytes = Add<HConstant>(data_size);
- data_target = Add<HAllocate>(size_in_bytes, HType::JSObject(),
- true, FAST_DOUBLE_ELEMENTS);
+ data_target = Add<HAllocate>(size_in_bytes, HType::JSObject(),
TENURED,
+ FIXED_DOUBLE_ARRAY_TYPE);
Handle<Map> free_space_map = isolate()->factory()->free_space_map();
AddStoreMapConstant(data_target, free_space_map);
HObjectAccess access =
@@ -8180,11 +8192,14 @@
}
if (pointer_size != 0) {
HValue* size_in_bytes = Add<HConstant>(pointer_size);
- target = Add<HAllocate>(size_in_bytes, HType::JSObject(), true);
+ target = Add<HAllocate>(size_in_bytes, HType::JSObject(), TENURED,
+ 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>(size_in_bytes, HType::JSObject(), false, kind);
+ target = Add<HAllocate>(size_in_bytes, HType::JSObject(), NOT_TENURED,
+ instance_type);
}
int offset = 0;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.