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

Unified Diff: src/transitions.cc

Issue 10915260: Reduce space usage of simple transitions and descriptors holders. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 8 years, 3 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
« no previous file with comments | « src/transitions.h ('k') | src/transitions-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/transitions.cc
diff --git a/src/transitions.cc b/src/transitions.cc
index 199fcc2c9838fb0691bbedd4c00e1dd7bd27bb3e..7233f7346e1a7239b3aee241c9b47d596d34a7a5 100644
--- a/src/transitions.cc
+++ b/src/transitions.cc
@@ -35,8 +35,8 @@ namespace v8 {
namespace internal {
-MaybeObject* TransitionArray::Allocate(int number_of_transitions,
- JSGlobalPropertyCell* descriptors_cell) {
+static MaybeObject* AllocateRaw(int length,
+ JSGlobalPropertyCell* descriptors_cell) {
Heap* heap = Isolate::Current()->heap();
if (descriptors_cell == NULL) {
@@ -45,13 +45,22 @@ MaybeObject* TransitionArray::Allocate(int number_of_transitions,
if (!maybe_cell->To(&descriptors_cell)) return maybe_cell;
}
- // Use FixedArray to not use DescriptorArray::cast on incomplete object.
+ // Use FixedArray to not use TransitionArray::cast on incomplete object.
FixedArray* array;
- MaybeObject* maybe_array =
- heap->AllocateFixedArray(ToKeyIndex(number_of_transitions));
+ MaybeObject* maybe_array = heap->AllocateFixedArray(length);
if (!maybe_array->To(&array)) return maybe_array;
- array->set(kDescriptorsPointerIndex, descriptors_cell);
+ array->set(TransitionArray::kDescriptorsPointerIndex, descriptors_cell);
+ return array;
+}
+
+
+MaybeObject* TransitionArray::Allocate(int number_of_transitions,
+ JSGlobalPropertyCell* descriptors_cell) {
+ FixedArray* array;
+ MaybeObject* maybe_array =
+ AllocateRaw(ToKeyIndex(number_of_transitions), descriptors_cell);
+ if (!maybe_array->To(&array)) return maybe_array;
array->set(kElementsTransitionIndex, Smi::FromInt(0));
array->set(kPrototypeTransitionsIndex, Smi::FromInt(0));
return array;
@@ -72,18 +81,46 @@ static bool InsertionPointFound(String* key1, String* key2) {
}
-MaybeObject* TransitionArray::NewWith(
- String* name,
- Map* target,
- JSGlobalPropertyCell* descriptors_pointer,
- Object* back_pointer) {
+MaybeObject* TransitionArray::NewWith(SimpleTransitionFlag flag,
+ String* key,
+ Map* target,
+ JSGlobalPropertyCell* descriptors_pointer,
+ Object* back_pointer) {
+ TransitionArray* result;
+ MaybeObject* maybe_result;
+
+ if (flag == SIMPLE_TRANSITION) {
+ maybe_result = AllocateRaw(kSimpleTransitionSize, descriptors_pointer);
+ if (!maybe_result->To(&result)) return maybe_result;
+ result->set(kSimpleTransitionTarget, target);
+ } else {
+ maybe_result = Allocate(1, descriptors_pointer);
+ if (!maybe_result->To(&result)) return maybe_result;
+ result->NoIncrementalWriteBarrierSet(0, key, target);
+ }
+ result->set_back_pointer_storage(back_pointer);
+ return result;
+}
+
+
+MaybeObject* TransitionArray::AllocateDescriptorsHolder(
+ JSGlobalPropertyCell* descriptors_pointer) {
+ return AllocateRaw(kDescriptorsHolderSize, descriptors_pointer);
+}
+
+
+MaybeObject* TransitionArray::ExtendToFullTransitionArray() {
+ ASSERT(!IsFullTransitionArray());
+ int nof = number_of_transitions();
TransitionArray* result;
+ MaybeObject* maybe_result = Allocate(nof, descriptors_pointer());
+ if (!maybe_result->To(&result)) return maybe_result;
- MaybeObject* maybe_array = TransitionArray::Allocate(1, descriptors_pointer);
- if (!maybe_array->To(&result)) return maybe_array;
+ if (nof == 1) {
+ result->NoIncrementalWriteBarrierCopyFrom(this, kSimpleTransitionIndex, 0);
+ }
- result->NoIncrementalWriteBarrierSet(0, name, target);
- result->set_back_pointer_storage(back_pointer);
+ result->set_back_pointer_storage(back_pointer_storage());
return result;
}
« no previous file with comments | « src/transitions.h ('k') | src/transitions-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698