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

Unified Diff: src/transitions.h

Issue 676393002: Reland "Limit the number of transitions allowed per hidden class." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Make sure TransitionArray::Insert() is called only when it is allowed Created 6 years, 1 month 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/objects-inl.h ('k') | src/transitions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/transitions.h
diff --git a/src/transitions.h b/src/transitions.h
index aa9b7b86d6a02b1180bc26f5766b3c7fd2ac0d89..b7e4ebe2856e022dc963fcbf3e74e3b7e1881c69 100644
--- a/src/transitions.h
+++ b/src/transitions.h
@@ -30,8 +30,9 @@ namespace internal {
// The full format is:
// [0] Undefined or back pointer map
// [1] Smi(0) or fixed array of prototype transitions
-// [2] First transition
-// [length() - kTransitionSize] Last transition
+// [2] Number of transitions
+// [3] First transition
+// [3 + number of transitions * kTransitionSize]: start of slack
class TransitionArray: public FixedArray {
public:
// Accessors for fetching instance transition at transition number.
@@ -67,10 +68,21 @@ class TransitionArray: public FixedArray {
// Returns the number of transitions in the array.
int number_of_transitions() {
if (IsSimpleTransition()) return 1;
- int len = length();
- return len <= kFirstIndex ? 0 : (len - kFirstIndex) / kTransitionSize;
+ if (length() <= kFirstIndex) return 0;
+ return Smi::cast(get(kTransitionLengthIndex))->value();
}
+ int number_of_transitions_storage() {
+ if (IsSimpleTransition()) return 1;
+ if (length() <= kFirstIndex) return 0;
+ return (length() - kFirstIndex) / kTransitionSize;
+ }
+
+ int NumberOfSlackTransitions() {
+ return number_of_transitions_storage() - number_of_transitions();
+ }
+
+ inline void SetNumberOfTransitions(int number_of_transitions);
inline int number_of_entries() { return number_of_transitions(); }
// Creates a FullTransitionArray from a SimpleTransitionArray in
@@ -78,21 +90,22 @@ class TransitionArray: public FixedArray {
static Handle<TransitionArray> ExtendToFullTransitionArray(
Handle<Map> containing_map);
- // Create a transition array, copying from the owning map if it already has
- // one, otherwise creating a new one according to flag.
+ // Return a transition array, using the array from the owning map if it
+ // already has one (copying into a larger array if necessary), otherwise
+ // creating a new one according to flag.
// TODO(verwaest): This should not cause an existing transition to be
// overwritten.
- static Handle<TransitionArray> CopyInsert(Handle<Map> map,
- Handle<Name> name,
- Handle<Map> target,
- SimpleTransitionFlag flag);
+ static Handle<TransitionArray> Insert(Handle<Map> map, Handle<Name> name,
+ Handle<Map> target,
+ SimpleTransitionFlag flag);
// Search a transition for a given property name.
inline int Search(Name* name);
// Allocates a TransitionArray.
- static Handle<TransitionArray> Allocate(
- Isolate* isolate, int number_of_transitions);
+ static Handle<TransitionArray> Allocate(Isolate* isolate,
+ int number_of_transitions,
+ int slack = 0);
bool IsSimpleTransition() {
return length() == kSimpleTransitionSize &&
@@ -120,7 +133,8 @@ class TransitionArray: public FixedArray {
// Layout for full transition arrays.
static const int kPrototypeTransitionsIndex = 1;
- static const int kFirstIndex = 2;
+ static const int kTransitionLengthIndex = 2;
+ static const int kFirstIndex = 3;
// Layout for simple transition arrays.
static const int kSimpleTransitionTarget = 1;
@@ -133,6 +147,8 @@ class TransitionArray: public FixedArray {
// Layout for the full transition array header.
static const int kPrototypeTransitionsOffset = kBackPointerStorageOffset +
kPointerSize;
+ static const int kTransitionLengthOffset =
+ kPrototypeTransitionsOffset + kPointerSize;
// Layout of map transition entries in full transition arrays.
static const int kTransitionKey = 0;
@@ -157,6 +173,12 @@ class TransitionArray: public FixedArray {
// fit in a page).
static const int kMaxNumberOfTransitions = 1024 + 512;
+ // Returns the fixed array length required to hold number_of_transitions
+ // transitions.
+ static int LengthFor(int number_of_transitions) {
+ return ToKeyIndex(number_of_transitions);
+ }
+
private:
// Conversion from transition number to array indices.
static int ToKeyIndex(int transition_number) {
« no previous file with comments | « src/objects-inl.h ('k') | src/transitions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698