OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/elements.h" | 5 #include "src/elements.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/factory.h" | 9 #include "src/factory.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 } | 443 } |
444 } | 444 } |
445 JavaScriptFrame::PrintTop(isolate, stdout, false, true); | 445 JavaScriptFrame::PrintTop(isolate, stdout, false, true); |
446 } | 446 } |
447 | 447 |
448 static void SortIndices( | 448 static void SortIndices( |
449 Handle<FixedArray> indices, uint32_t sort_size, | 449 Handle<FixedArray> indices, uint32_t sort_size, |
450 WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER) { | 450 WriteBarrierMode write_barrier_mode = UPDATE_WRITE_BARRIER) { |
451 struct { | 451 struct { |
452 bool operator()(Object* a, Object* b) { | 452 bool operator()(Object* a, Object* b) { |
453 if (a->IsSmi() || !a->IsUndefined(HeapObject::cast(a)->GetIsolate())) { | 453 if (!a->IsUndefined()) { |
454 if (!b->IsSmi() && b->IsUndefined(HeapObject::cast(b)->GetIsolate())) { | 454 if (b->IsUndefined()) return true; |
455 return true; | |
456 } | |
457 return a->Number() < b->Number(); | 455 return a->Number() < b->Number(); |
458 } | 456 } |
459 return !b->IsSmi() && b->IsUndefined(HeapObject::cast(b)->GetIsolate()); | 457 return b->IsUndefined(); |
460 } | 458 } |
461 } cmp; | 459 } cmp; |
462 Object** start = | 460 Object** start = |
463 reinterpret_cast<Object**>(indices->GetFirstElementAddress()); | 461 reinterpret_cast<Object**>(indices->GetFirstElementAddress()); |
464 std::sort(start, start + sort_size, cmp); | 462 std::sort(start, start + sort_size, cmp); |
465 if (write_barrier_mode != SKIP_WRITE_BARRIER) { | 463 if (write_barrier_mode != SKIP_WRITE_BARRIER) { |
466 FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(indices->GetIsolate()->heap(), *indices, | 464 FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(indices->GetIsolate()->heap(), *indices, |
467 0, sort_size); | 465 0, sort_size); |
468 } | 466 } |
469 } | 467 } |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 } | 1167 } |
1170 | 1168 |
1171 | 1169 |
1172 static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { | 1170 static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { |
1173 // TODO(verwaest): Remove reliance on index in Shrink. | 1171 // TODO(verwaest): Remove reliance on index in Shrink. |
1174 Handle<SeededNumberDictionary> dict( | 1172 Handle<SeededNumberDictionary> dict( |
1175 SeededNumberDictionary::cast(obj->elements())); | 1173 SeededNumberDictionary::cast(obj->elements())); |
1176 uint32_t index = GetIndexForEntryImpl(*dict, entry); | 1174 uint32_t index = GetIndexForEntryImpl(*dict, entry); |
1177 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); | 1175 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
1178 USE(result); | 1176 USE(result); |
1179 DCHECK(result->IsTrue(dict->GetIsolate())); | 1177 DCHECK(result->IsTrue()); |
1180 Handle<FixedArray> new_elements = | 1178 Handle<FixedArray> new_elements = |
1181 SeededNumberDictionary::Shrink(dict, index); | 1179 SeededNumberDictionary::Shrink(dict, index); |
1182 obj->set_elements(*new_elements); | 1180 obj->set_elements(*new_elements); |
1183 } | 1181 } |
1184 | 1182 |
1185 static bool HasAccessorsImpl(JSObject* holder, | 1183 static bool HasAccessorsImpl(JSObject* holder, |
1186 FixedArrayBase* backing_store) { | 1184 FixedArrayBase* backing_store) { |
1187 DisallowHeapAllocation no_gc; | 1185 DisallowHeapAllocation no_gc; |
1188 SeededNumberDictionary* dict = SeededNumberDictionary::cast(backing_store); | 1186 SeededNumberDictionary* dict = SeededNumberDictionary::cast(backing_store); |
1189 if (!dict->requires_slow_elements()) return false; | 1187 if (!dict->requires_slow_elements()) return false; |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2440 ElementsKindTraits<SLOW_SLOPPY_ARGUMENTS_ELEMENTS> >(name) {} | 2438 ElementsKindTraits<SLOW_SLOPPY_ARGUMENTS_ELEMENTS> >(name) {} |
2441 | 2439 |
2442 static void DeleteFromArguments(Handle<JSObject> obj, uint32_t entry) { | 2440 static void DeleteFromArguments(Handle<JSObject> obj, uint32_t entry) { |
2443 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); | 2441 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); |
2444 Handle<SeededNumberDictionary> dict( | 2442 Handle<SeededNumberDictionary> dict( |
2445 SeededNumberDictionary::cast(parameter_map->get(1))); | 2443 SeededNumberDictionary::cast(parameter_map->get(1))); |
2446 // TODO(verwaest): Remove reliance on index in Shrink. | 2444 // TODO(verwaest): Remove reliance on index in Shrink. |
2447 uint32_t index = GetIndexForEntryImpl(*dict, entry); | 2445 uint32_t index = GetIndexForEntryImpl(*dict, entry); |
2448 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); | 2446 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
2449 USE(result); | 2447 USE(result); |
2450 DCHECK(result->IsTrue(dict->GetIsolate())); | 2448 DCHECK(result->IsTrue()); |
2451 Handle<FixedArray> new_elements = | 2449 Handle<FixedArray> new_elements = |
2452 SeededNumberDictionary::Shrink(dict, index); | 2450 SeededNumberDictionary::Shrink(dict, index); |
2453 parameter_map->set(1, *new_elements); | 2451 parameter_map->set(1, *new_elements); |
2454 } | 2452 } |
2455 | 2453 |
2456 static void AddImpl(Handle<JSObject> object, uint32_t index, | 2454 static void AddImpl(Handle<JSObject> object, uint32_t index, |
2457 Handle<Object> value, PropertyAttributes attributes, | 2455 Handle<Object> value, PropertyAttributes attributes, |
2458 uint32_t new_capacity) { | 2456 uint32_t new_capacity) { |
2459 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); | 2457 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); |
2460 Handle<FixedArrayBase> old_elements( | 2458 Handle<FixedArrayBase> old_elements( |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3026 insertion_index += len; | 3024 insertion_index += len; |
3027 } | 3025 } |
3028 | 3026 |
3029 DCHECK_EQ(insertion_index, result_len); | 3027 DCHECK_EQ(insertion_index, result_len); |
3030 return result_array; | 3028 return result_array; |
3031 } | 3029 } |
3032 | 3030 |
3033 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3031 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3034 } // namespace internal | 3032 } // namespace internal |
3035 } // namespace v8 | 3033 } // namespace v8 |
OLD | NEW |