Commit b19d123f authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[heap] Move even more objects into RO_SPACE

Moves all Oddballs, empty_feedback_metadata, lots of symbols and
immortal heap numbers and several other empty collection objects.

      RO_SPACE  NEW_SPACE  OLD_SPACE  CODE_SPACE  MAP_SPACE  LO_SPACE
old      31592          0     221160       33280        176         0
new      35016          0     217736       33280        176         0
diff     +3424                 -3424

Bug: v8:7464
Change-Id: Ic99411bcbcb9c9a48b33c59dddb68359278fb0b3
Reviewed-on: https://chromium-review.googlesource.com/1025996
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53053}
parent cc399a0d
...@@ -177,16 +177,17 @@ Handle<TemplateObjectDescription> Factory::NewTemplateObjectDescription( ...@@ -177,16 +177,17 @@ Handle<TemplateObjectDescription> Factory::NewTemplateObjectDescription(
Handle<Oddball> Factory::NewOddball(Handle<Map> map, const char* to_string, Handle<Oddball> Factory::NewOddball(Handle<Map> map, const char* to_string,
Handle<Object> to_number, Handle<Object> to_number,
const char* type_of, byte kind) { const char* type_of, byte kind,
Handle<Oddball> oddball(Oddball::cast(New(map, TENURED)), isolate()); PretenureFlag pretenure) {
Handle<Oddball> oddball(Oddball::cast(New(map, pretenure)), isolate());
Oddball::Initialize(isolate(), oddball, to_string, to_number, type_of, kind); Oddball::Initialize(isolate(), oddball, to_string, to_number, type_of, kind);
return oddball; return oddball;
} }
Handle<Oddball> Factory::NewSelfReferenceMarker() { Handle<Oddball> Factory::NewSelfReferenceMarker(PretenureFlag pretenure) {
return NewOddball(self_reference_marker_map(), "self_reference_marker", return NewOddball(self_reference_marker_map(), "self_reference_marker",
handle(Smi::FromInt(-1), isolate()), "undefined", handle(Smi::FromInt(-1), isolate()), "undefined",
Oddball::kSelfReferenceMarker); Oddball::kSelfReferenceMarker, pretenure);
} }
Handle<PropertyArray> Factory::NewPropertyArray(int length, Handle<PropertyArray> Factory::NewPropertyArray(int length,
...@@ -401,11 +402,12 @@ Handle<FixedArrayBase> Factory::NewFixedDoubleArrayWithHoles( ...@@ -401,11 +402,12 @@ Handle<FixedArrayBase> Factory::NewFixedDoubleArrayWithHoles(
return array; return array;
} }
Handle<FeedbackMetadata> Factory::NewFeedbackMetadata(int slot_count) { Handle<FeedbackMetadata> Factory::NewFeedbackMetadata(int slot_count,
PretenureFlag tenure) {
DCHECK_LE(0, slot_count); DCHECK_LE(0, slot_count);
int size = FeedbackMetadata::SizeFor(slot_count); int size = FeedbackMetadata::SizeFor(slot_count);
HeapObject* result = HeapObject* result =
AllocateRawWithImmortalMap(size, TENURED, *feedback_metadata_map()); AllocateRawWithImmortalMap(size, tenure, *feedback_metadata_map());
Handle<FeedbackMetadata> data(FeedbackMetadata::cast(result), isolate()); Handle<FeedbackMetadata> data(FeedbackMetadata::cast(result), isolate());
data->set_slot_count(slot_count); data->set_slot_count(slot_count);
...@@ -1226,12 +1228,13 @@ Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) { ...@@ -1226,12 +1228,13 @@ Handle<JSStringIterator> Factory::NewJSStringIterator(Handle<String> string) {
return iterator; return iterator;
} }
Handle<Symbol> Factory::NewSymbol() { Handle<Symbol> Factory::NewSymbol(PretenureFlag flag) {
DCHECK(flag != NOT_TENURED);
// Statically ensure that it is safe to allocate symbols in paged spaces. // Statically ensure that it is safe to allocate symbols in paged spaces.
STATIC_ASSERT(Symbol::kSize <= kMaxRegularHeapObjectSize); STATIC_ASSERT(Symbol::kSize <= kMaxRegularHeapObjectSize);
HeapObject* result = HeapObject* result =
AllocateRawWithImmortalMap(Symbol::kSize, TENURED, *symbol_map()); AllocateRawWithImmortalMap(Symbol::kSize, flag, *symbol_map());
// Generate a random hash value. // Generate a random hash value.
int hash = isolate()->GenerateIdentityHash(Name::kHashBitMask); int hash = isolate()->GenerateIdentityHash(Name::kHashBitMask);
...@@ -1245,8 +1248,9 @@ Handle<Symbol> Factory::NewSymbol() { ...@@ -1245,8 +1248,9 @@ Handle<Symbol> Factory::NewSymbol() {
return symbol; return symbol;
} }
Handle<Symbol> Factory::NewPrivateSymbol() { Handle<Symbol> Factory::NewPrivateSymbol(PretenureFlag flag) {
Handle<Symbol> symbol = NewSymbol(); DCHECK(flag != NOT_TENURED);
Handle<Symbol> symbol = NewSymbol(flag);
symbol->set_is_private(true); symbol->set_is_private(true);
return symbol; return symbol;
} }
...@@ -1426,10 +1430,11 @@ Handle<AccessorInfo> Factory::NewAccessorInfo() { ...@@ -1426,10 +1430,11 @@ Handle<AccessorInfo> Factory::NewAccessorInfo() {
return info; return info;
} }
Handle<Script> Factory::NewScript(Handle<String> source) { Handle<Script> Factory::NewScript(Handle<String> source, PretenureFlag tenure) {
DCHECK(tenure == TENURED || tenure == TENURED_READ_ONLY);
// Create and initialize script object. // Create and initialize script object.
Heap* heap = isolate()->heap(); Heap* heap = isolate()->heap();
Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE, TENURED)); Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE, tenure));
script->set_source(*source); script->set_source(*source);
script->set_name(heap->undefined_value()); script->set_name(heap->undefined_value());
script->set_id(isolate()->heap()->NextScriptId()); script->set_id(isolate()->heap()->NextScriptId());
...@@ -1616,11 +1621,12 @@ Handle<FeedbackCell> Factory::NewManyClosuresCell(Handle<HeapObject> value) { ...@@ -1616,11 +1621,12 @@ Handle<FeedbackCell> Factory::NewManyClosuresCell(Handle<HeapObject> value) {
return cell; return cell;
} }
Handle<PropertyCell> Factory::NewPropertyCell(Handle<Name> name) { Handle<PropertyCell> Factory::NewPropertyCell(Handle<Name> name,
PretenureFlag pretenure) {
DCHECK(name->IsUniqueName()); DCHECK(name->IsUniqueName());
STATIC_ASSERT(PropertyCell::kSize <= kMaxRegularHeapObjectSize); STATIC_ASSERT(PropertyCell::kSize <= kMaxRegularHeapObjectSize);
HeapObject* result = AllocateRawWithImmortalMap(PropertyCell::kSize, TENURED, HeapObject* result = AllocateRawWithImmortalMap(
*global_property_cell_map()); PropertyCell::kSize, pretenure, *global_property_cell_map());
Handle<PropertyCell> cell(PropertyCell::cast(result), isolate()); Handle<PropertyCell> cell(PropertyCell::cast(result), isolate());
cell->set_dependent_code(DependentCode::cast(*empty_fixed_array()), cell->set_dependent_code(DependentCode::cast(*empty_fixed_array()),
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
......
...@@ -88,10 +88,11 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -88,10 +88,11 @@ class V8_EXPORT_PRIVATE Factory {
public: public:
Handle<Oddball> NewOddball(Handle<Map> map, const char* to_string, Handle<Oddball> NewOddball(Handle<Map> map, const char* to_string,
Handle<Object> to_number, const char* type_of, Handle<Object> to_number, const char* type_of,
byte kind); byte kind,
PretenureFlag pretenure = TENURED_READ_ONLY);
// Marks self references within code generation. // Marks self references within code generation.
Handle<Oddball> NewSelfReferenceMarker(); Handle<Oddball> NewSelfReferenceMarker(PretenureFlag pretenure = TENURED);
// Allocates a fixed array-like object with given map and initialized with // Allocates a fixed array-like object with given map and initialized with
// undefined values. // undefined values.
...@@ -158,7 +159,8 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -158,7 +159,8 @@ class V8_EXPORT_PRIVATE Factory {
int size, PretenureFlag pretenure = NOT_TENURED); int size, PretenureFlag pretenure = NOT_TENURED);
// Allocates a FeedbackMedata object and zeroes the data section. // Allocates a FeedbackMedata object and zeroes the data section.
Handle<FeedbackMetadata> NewFeedbackMetadata(int slot_count); Handle<FeedbackMetadata> NewFeedbackMetadata(int slot_count,
PretenureFlag tenure = TENURED);
Handle<FrameArray> NewFrameArray(int number_of_frames, Handle<FrameArray> NewFrameArray(int number_of_frames,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
...@@ -346,9 +348,9 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -346,9 +348,9 @@ class V8_EXPORT_PRIVATE Factory {
Handle<ExternalOneByteString> NewNativeSourceString( Handle<ExternalOneByteString> NewNativeSourceString(
const ExternalOneByteString::Resource* resource); const ExternalOneByteString::Resource* resource);
// Create a symbol in old space. // Create a symbol in old or read-only space.
Handle<Symbol> NewSymbol(); Handle<Symbol> NewSymbol(PretenureFlag pretenure = TENURED);
Handle<Symbol> NewPrivateSymbol(); Handle<Symbol> NewPrivateSymbol(PretenureFlag pretenure = TENURED);
Handle<Symbol> NewPrivateFieldSymbol(); Handle<Symbol> NewPrivateFieldSymbol();
// Create a global (but otherwise uninitialized) context. // Create a global (but otherwise uninitialized) context.
...@@ -397,7 +399,8 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -397,7 +399,8 @@ class V8_EXPORT_PRIVATE Factory {
Handle<AccessorInfo> NewAccessorInfo(); Handle<AccessorInfo> NewAccessorInfo();
Handle<Script> NewScript(Handle<String> source); Handle<Script> NewScript(Handle<String> source,
PretenureFlag tenure = TENURED);
Handle<BreakPointInfo> NewBreakPointInfo(int source_position); Handle<BreakPointInfo> NewBreakPointInfo(int source_position);
Handle<BreakPoint> NewBreakPoint(int id, Handle<String> condition); Handle<BreakPoint> NewBreakPoint(int id, Handle<String> condition);
...@@ -437,7 +440,8 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -437,7 +440,8 @@ class V8_EXPORT_PRIVATE Factory {
Handle<Cell> NewCell(Handle<Object> value); Handle<Cell> NewCell(Handle<Object> value);
Handle<PropertyCell> NewPropertyCell(Handle<Name> name); Handle<PropertyCell> NewPropertyCell(Handle<Name> name,
PretenureFlag pretenure = TENURED);
Handle<WeakCell> NewWeakCell(Handle<HeapObject> value, Handle<WeakCell> NewWeakCell(Handle<HeapObject> value,
PretenureFlag pretenure = TENURED); PretenureFlag pretenure = TENURED);
......
...@@ -2173,8 +2173,8 @@ class Heap { ...@@ -2173,8 +2173,8 @@ class Heap {
void FinalizePartialMap(Map* map); void FinalizePartialMap(Map* map);
// Allocate empty fixed typed array of given type. // Allocate empty fixed typed array of given type.
V8_WARN_UNUSED_RESULT AllocationResult AllocateEmptyFixedTypedArray( V8_WARN_UNUSED_RESULT AllocationResult
ExternalArrayType array_type, AllocationSpace space = OLD_SPACE); AllocateEmptyFixedTypedArray(ExternalArrayType array_type);
void set_force_oom(bool value) { force_oom_ = value; } void set_force_oom(bool value) { force_oom_ = value; }
......
This diff is collapsed.
...@@ -2416,7 +2416,7 @@ TEST(OptimizedPretenuringDoubleArrayProperties) { ...@@ -2416,7 +2416,7 @@ TEST(OptimizedPretenuringDoubleArrayProperties) {
return; return;
v8::HandleScope scope(CcTest::isolate()); v8::HandleScope scope(CcTest::isolate());
// Grow new space unitl maximum capacity reached. // Grow new space until maximum capacity reached.
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) { while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
CcTest::heap()->new_space()->Grow(); CcTest::heap()->new_space()->Grow();
} }
...@@ -2443,7 +2443,7 @@ TEST(OptimizedPretenuringDoubleArrayProperties) { ...@@ -2443,7 +2443,7 @@ TEST(OptimizedPretenuringDoubleArrayProperties) {
v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res))); v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(res)));
CHECK(CcTest::heap()->InOldSpace(*o)); CHECK(CcTest::heap()->InOldSpace(*o));
CHECK(CcTest::heap()->InOldSpace(o->property_array())); CHECK_EQ(o->property_array(), CcTest::heap()->empty_property_array());
} }
......
This diff is collapsed.
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