From d2f229bf9fe217e2b44948e01dc961730679e78a Mon Sep 17 00:00:00 2001 From: "ishell@chromium.org" Date: Mon, 23 Jun 2014 13:46:49 +0000 Subject: [PATCH] Several methods moved from JSObject to Map. R=verwaest@chromium.org Review URL: https://codereview.chromium.org/349203002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21940 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/json-parser.h | 6 +++--- src/objects-inl.h | 6 +++--- src/objects.h | 33 ++++++++++++++++++--------------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/json-parser.h b/src/json-parser.h index 60855a0..09320ab 100644 --- a/src/json-parser.h +++ b/src/json-parser.h @@ -358,19 +358,19 @@ Handle JsonParser::ParseJsonObject() { bool follow_expected = false; Handle target; if (seq_ascii) { - key = JSObject::ExpectedTransitionKey(map); + key = Map::ExpectedTransitionKey(map); follow_expected = !key.is_null() && ParseJsonString(key); } // If the expected transition hits, follow it. if (follow_expected) { - target = JSObject::ExpectedTransitionTarget(map); + target = Map::ExpectedTransitionTarget(map); } else { // If the expected transition failed, parse an internalized string and // try to find a matching transition. key = ParseJsonInternalizedString(); if (key.is_null()) return ReportUnexpectedCharacter(); - target = JSObject::FindTransitionToField(map, key); + target = Map::FindTransitionToField(map, key); // If a transition was found, follow it and continue. transitioning = !target.is_null(); } diff --git a/src/objects-inl.h b/src/objects-inl.h index b0da6f8..7640a76 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1810,7 +1810,7 @@ void JSObject::initialize_elements() { } -Handle JSObject::ExpectedTransitionKey(Handle map) { +Handle Map::ExpectedTransitionKey(Handle map) { DisallowHeapAllocation no_gc; if (!map->HasTransitionArray()) return Handle::null(); TransitionArray* transitions = map->transitions(); @@ -1825,14 +1825,14 @@ Handle JSObject::ExpectedTransitionKey(Handle map) { } -Handle JSObject::ExpectedTransitionTarget(Handle map) { +Handle Map::ExpectedTransitionTarget(Handle map) { ASSERT(!ExpectedTransitionKey(map).is_null()); return Handle(map->transitions()->GetTarget( TransitionArray::kSimpleTransitionIndex)); } -Handle JSObject::FindTransitionToField(Handle map, Handle key) { +Handle Map::FindTransitionToField(Handle map, Handle key) { DisallowHeapAllocation no_allocation; if (!map->HasTransitionArray()) return Handle::null(); TransitionArray* transitions = map->transitions(); diff --git a/src/objects.h b/src/objects.h index 5240a70..8e7d326 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2152,14 +2152,6 @@ class JSObject: public JSReceiver { StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); - static inline Handle ExpectedTransitionKey(Handle map); - static inline Handle ExpectedTransitionTarget(Handle map); - - // Try to follow an existing transition to a field with attributes NONE. The - // return value indicates whether the transition was successful. - static inline Handle FindTransitionToField(Handle map, - Handle key); - // Extend the receiver with a single fast property appeared first in the // passed map. This also extends the property backing store if necessary. static void AllocateStorageForMap(Handle object, Handle map); @@ -6234,14 +6226,21 @@ class Map: public HeapObject { inline bool HasTransitionArray() const; inline bool HasElementsTransition(); inline Map* elements_transition_map(); - static Handle SetElementsTransitionMap( - Handle map, Handle transitioned_map); + inline Map* GetTransition(int transition_index); inline int SearchTransition(Name* name); inline FixedArrayBase* GetInitialElements(); DECL_ACCESSORS(transitions, TransitionArray) + static inline Handle ExpectedTransitionKey(Handle map); + static inline Handle ExpectedTransitionTarget(Handle map); + + // Try to follow an existing transition to a field with attributes NONE. The + // return value indicates whether the transition was successful. + static inline Handle FindTransitionToField(Handle map, + Handle key); + Map* FindRootMap(); Map* FindFieldOwner(int descriptor); @@ -6249,15 +6248,17 @@ class Map: public HeapObject { int NumberOfFields(); + // TODO(ishell): candidate with JSObject::MigrateToMap(). bool InstancesNeedRewriting(Map* target, int target_number_of_fields, int target_inobject, int target_unused); + // TODO(ishell): moveit! static Handle GeneralizeAllFieldRepresentations(Handle map); - static Handle GeneralizeFieldType(Handle type1, - Handle type2, - Isolate* isolate) - V8_WARN_UNUSED_RESULT; + MUST_USE_RESULT static Handle GeneralizeFieldType( + Handle type1, + Handle type2, + Isolate* isolate); static void GeneralizeFieldType(Handle map, int modify_index, Handle new_field_type); @@ -6542,7 +6543,6 @@ class Map: public HeapObject { // elements_kind that's found in |candidates|, or null handle if no match is // found at all. Handle FindTransitionedMap(MapHandleList* candidates); - Map* FindTransitionedMap(MapList* candidates); bool CanTransition() { // Only JSObject and subtypes have map transitions and back pointers. @@ -6704,6 +6704,9 @@ class Map: public HeapObject { bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); private: + static Handle SetElementsTransitionMap( + Handle map, Handle transitioned_map); + bool EquivalentToForTransition(Map* other); static Handle RawCopy(Handle map, int instance_size); static Handle ShareDescriptor(Handle map, -- 2.7.4