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

Unified Diff: src/objects-inl.h

Issue 228333003: Handlefy Descriptor and other code in objects.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Formatting stuff. Created 6 years, 8 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/objects.cc ('k') | src/property.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index cedd6f4348d8b558ed5f6e0d800f2bfd718994f7..65022887cfe6b5120acbb3d4de47b54300d6243c 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1750,28 +1750,6 @@ void JSObject::EnsureCanContainElements(Handle<JSObject> object,
}
-MaybeObject* JSObject::GetElementsTransitionMap(Isolate* isolate,
- ElementsKind to_kind) {
- Map* current_map = map();
- ElementsKind from_kind = current_map->elements_kind();
- if (from_kind == to_kind) return current_map;
-
- Context* native_context = isolate->context()->native_context();
- Object* maybe_array_maps = native_context->js_array_maps();
- if (maybe_array_maps->IsFixedArray()) {
- FixedArray* array_maps = FixedArray::cast(maybe_array_maps);
- if (array_maps->get(from_kind) == current_map) {
- Object* maybe_transitioned_map = array_maps->get(to_kind);
- if (maybe_transitioned_map->IsMap()) {
- return Map::cast(maybe_transitioned_map);
- }
- }
- }
-
- return GetElementsTransitionMapSlow(to_kind);
-}
-
-
void JSObject::SetMapAndElements(Handle<JSObject> object,
Handle<Map> new_map,
Handle<FixedArrayBase> value) {
@@ -1800,50 +1778,8 @@ void JSObject::initialize_properties() {
void JSObject::initialize_elements() {
- if (map()->has_fast_smi_or_object_elements() ||
- map()->has_fast_double_elements()) {
- ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
- WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array());
- } else if (map()->has_external_array_elements()) {
- ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(map());
- ASSERT(!GetHeap()->InNewSpace(empty_array));
- WRITE_FIELD(this, kElementsOffset, empty_array);
- } else if (map()->has_fixed_typed_array_elements()) {
- FixedTypedArrayBase* empty_array =
- GetHeap()->EmptyFixedTypedArrayForMap(map());
- ASSERT(!GetHeap()->InNewSpace(empty_array));
- WRITE_FIELD(this, kElementsOffset, empty_array);
- } else {
- UNREACHABLE();
- }
-}
-
-
-MaybeObject* JSObject::ResetElements() {
- if (map()->is_observed()) {
- // Maintain invariant that observed elements are always in dictionary mode.
- SeededNumberDictionary* dictionary;
- MaybeObject* maybe = SeededNumberDictionary::Allocate(GetHeap(), 0);
- if (!maybe->To(&dictionary)) return maybe;
- if (map() == GetHeap()->sloppy_arguments_elements_map()) {
- FixedArray::cast(elements())->set(1, dictionary);
- } else {
- set_elements(dictionary);
- }
- return this;
- }
-
- ElementsKind elements_kind = GetInitialFastElementsKind();
- if (!FLAG_smi_only_arrays) {
- elements_kind = FastSmiToObjectElementsKind(elements_kind);
- }
- MaybeObject* maybe = GetElementsTransitionMap(GetIsolate(), elements_kind);
- Map* map;
- if (!maybe->To(&map)) return maybe;
- set_map(map);
- initialize_elements();
-
- return this;
+ FixedArrayBase* elements = map()->GetInitialElements();
+ WRITE_FIELD(this, kElementsOffset, elements);
}
@@ -2692,6 +2628,27 @@ void Map::LookupTransition(JSObject* holder,
}
+FixedArrayBase* Map::GetInitialElements() {
+ if (has_fast_smi_or_object_elements() ||
+ has_fast_double_elements()) {
+ ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
+ return GetHeap()->empty_fixed_array();
+ } else if (has_external_array_elements()) {
+ ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(this);
+ ASSERT(!GetHeap()->InNewSpace(empty_array));
+ return empty_array;
+ } else if (has_fixed_typed_array_elements()) {
+ FixedTypedArrayBase* empty_array =
+ GetHeap()->EmptyFixedTypedArrayForMap(this);
+ ASSERT(!GetHeap()->InNewSpace(empty_array));
+ return empty_array;
+ } else {
+ UNREACHABLE();
+ }
+ return NULL;
+}
+
+
Object** DescriptorArray::GetKeySlot(int descriptor_number) {
ASSERT(descriptor_number < number_of_descriptors());
return RawFieldOfElementAt(ToKeyIndex(descriptor_number));
@@ -2796,8 +2753,8 @@ AccessorDescriptor* DescriptorArray::GetCallbacks(int descriptor_number) {
void DescriptorArray::Get(int descriptor_number, Descriptor* desc) {
- desc->Init(GetKey(descriptor_number),
- GetValue(descriptor_number),
+ desc->Init(handle(GetKey(descriptor_number), GetIsolate()),
+ handle(GetValue(descriptor_number), GetIsolate()),
GetDetails(descriptor_number));
}
@@ -2810,10 +2767,10 @@ void DescriptorArray::Set(int descriptor_number,
NoIncrementalWriteBarrierSet(this,
ToKeyIndex(descriptor_number),
- desc->GetKey());
+ *desc->GetKey());
NoIncrementalWriteBarrierSet(this,
ToValueIndex(descriptor_number),
- desc->GetValue());
+ *desc->GetValue());
NoIncrementalWriteBarrierSet(this,
ToDetailsIndex(descriptor_number),
desc->GetDetails().AsSmi());
@@ -2824,14 +2781,15 @@ void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
// Range check.
ASSERT(descriptor_number < number_of_descriptors());
- set(ToKeyIndex(descriptor_number), desc->GetKey());
- set(ToValueIndex(descriptor_number), desc->GetValue());
+ set(ToKeyIndex(descriptor_number), *desc->GetKey());
+ set(ToValueIndex(descriptor_number), *desc->GetValue());
set(ToDetailsIndex(descriptor_number), desc->GetDetails().AsSmi());
}
void DescriptorArray::Append(Descriptor* desc,
const WhitenessWitness& witness) {
+ DisallowHeapAllocation no_gc;
int descriptor_number = number_of_descriptors();
SetNumberOfDescriptors(descriptor_number + 1);
Set(descriptor_number, desc, witness);
@@ -2851,6 +2809,7 @@ void DescriptorArray::Append(Descriptor* desc,
void DescriptorArray::Append(Descriptor* desc) {
+ DisallowHeapAllocation no_gc;
int descriptor_number = number_of_descriptors();
SetNumberOfDescriptors(descriptor_number + 1);
Set(descriptor_number, desc);
@@ -5066,14 +5025,6 @@ bool Map::CanHaveMoreTransitions() {
}
-MaybeObject* Map::AddTransition(Name* key,
- Map* target,
- SimpleTransitionFlag flag) {
- if (HasTransitionArray()) return transitions()->CopyInsert(key, target);
- return TransitionArray::NewWith(flag, key, target, GetBackPointer());
-}
-
-
void Map::SetTransition(int transition_index, Map* target) {
transitions()->SetTarget(transition_index, target);
}
@@ -5090,18 +5041,6 @@ int Map::SearchTransition(Name* name) {
}
-MaybeObject* Map::set_elements_transition_map(Map* transitioned_map) {
- TransitionArray* transitions;
- MaybeObject* maybe_transitions = AddTransition(
- GetHeap()->elements_transition_symbol(),
- transitioned_map,
- FULL_TRANSITION);
- if (!maybe_transitions->To(&transitions)) return maybe_transitions;
- set_transitions(transitions);
- return transitions;
-}
-
-
FixedArray* Map::GetPrototypeTransitions() {
if (!HasTransitionArray()) return GetHeap()->empty_fixed_array();
if (!transitions()->HasPrototypeTransitions()) {
« no previous file with comments | « src/objects.cc ('k') | src/property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698