Cleaning up HAllocate space and double alignment selection.
BUG= R=mstarzinger@chromium.org Review URL: https://codereview.chromium.org/21074004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16000 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
9f8d162471
commit
9e8058146e
@ -425,7 +425,7 @@ HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
|
||||
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 @@ Handle<Code> FastCloneShallowObjectStub::GenerateCode() {
|
||||
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(),
|
||||
|
14
src/heap.h
14
src/heap.h
@ -483,6 +483,7 @@ enum ArrayStorageAllocationMode {
|
||||
INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE
|
||||
};
|
||||
|
||||
|
||||
class Heap {
|
||||
public:
|
||||
// Configure heap size before setup. Return false if the heap has been
|
||||
@ -1399,7 +1400,7 @@ class Heap {
|
||||
|
||||
// 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) {
|
||||
@ -1546,19 +1547,16 @@ class Heap {
|
||||
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() {
|
||||
|
@ -5457,9 +5457,10 @@ class HAllocate: public HTemplateInstruction<2> {
|
||||
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 @@ class HAllocate: public HTemplateInstruction<2> {
|
||||
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 @@ class HAllocate: public HTemplateInstruction<2> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1315,8 +1315,17 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess(
|
||||
|
||||
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 @@ HValue* HGraphBuilder::BuildAllocateElements(ElementsKind kind,
|
||||
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 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate,
|
||||
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* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate,
|
||||
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 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes,
|
||||
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 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
|
||||
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 @@ 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();
|
||||
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* HOptimizedGraphBuilder::BuildFastLiteral(
|
||||
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 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral(
|
||||
}
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user