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->IsUndefined()) { | 453 if (a->IsSmi() || !a->IsUndefined(HeapObject::cast(a)->GetIsolate())) { |
454 if (b->IsUndefined()) return true; | 454 if (!b->IsSmi() && b->IsUndefined(HeapObject::cast(b)->GetIsolate())) { |
| 455 return true; |
| 456 } |
455 return a->Number() < b->Number(); | 457 return a->Number() < b->Number(); |
456 } | 458 } |
457 return b->IsUndefined(); | 459 return !b->IsSmi() && b->IsUndefined(HeapObject::cast(b)->GetIsolate()); |
458 } | 460 } |
459 } cmp; | 461 } cmp; |
460 Object** start = | 462 Object** start = |
461 reinterpret_cast<Object**>(indices->GetFirstElementAddress()); | 463 reinterpret_cast<Object**>(indices->GetFirstElementAddress()); |
462 std::sort(start, start + sort_size, cmp); | 464 std::sort(start, start + sort_size, cmp); |
463 if (write_barrier_mode != SKIP_WRITE_BARRIER) { | 465 if (write_barrier_mode != SKIP_WRITE_BARRIER) { |
464 FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(indices->GetIsolate()->heap(), *indices, | 466 FIXED_ARRAY_ELEMENTS_WRITE_BARRIER(indices->GetIsolate()->heap(), *indices, |
465 0, sort_size); | 467 0, sort_size); |
466 } | 468 } |
467 } | 469 } |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 } | 1169 } |
1168 | 1170 |
1169 | 1171 |
1170 static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { | 1172 static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { |
1171 // TODO(verwaest): Remove reliance on index in Shrink. | 1173 // TODO(verwaest): Remove reliance on index in Shrink. |
1172 Handle<SeededNumberDictionary> dict( | 1174 Handle<SeededNumberDictionary> dict( |
1173 SeededNumberDictionary::cast(obj->elements())); | 1175 SeededNumberDictionary::cast(obj->elements())); |
1174 uint32_t index = GetIndexForEntryImpl(*dict, entry); | 1176 uint32_t index = GetIndexForEntryImpl(*dict, entry); |
1175 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); | 1177 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
1176 USE(result); | 1178 USE(result); |
1177 DCHECK(result->IsTrue()); | 1179 DCHECK(result->IsTrue(dict->GetIsolate())); |
1178 Handle<FixedArray> new_elements = | 1180 Handle<FixedArray> new_elements = |
1179 SeededNumberDictionary::Shrink(dict, index); | 1181 SeededNumberDictionary::Shrink(dict, index); |
1180 obj->set_elements(*new_elements); | 1182 obj->set_elements(*new_elements); |
1181 } | 1183 } |
1182 | 1184 |
1183 static bool HasAccessorsImpl(JSObject* holder, | 1185 static bool HasAccessorsImpl(JSObject* holder, |
1184 FixedArrayBase* backing_store) { | 1186 FixedArrayBase* backing_store) { |
1185 DisallowHeapAllocation no_gc; | 1187 DisallowHeapAllocation no_gc; |
1186 SeededNumberDictionary* dict = SeededNumberDictionary::cast(backing_store); | 1188 SeededNumberDictionary* dict = SeededNumberDictionary::cast(backing_store); |
1187 if (!dict->requires_slow_elements()) return false; | 1189 if (!dict->requires_slow_elements()) return false; |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2438 ElementsKindTraits<SLOW_SLOPPY_ARGUMENTS_ELEMENTS> >(name) {} | 2440 ElementsKindTraits<SLOW_SLOPPY_ARGUMENTS_ELEMENTS> >(name) {} |
2439 | 2441 |
2440 static void DeleteFromArguments(Handle<JSObject> obj, uint32_t entry) { | 2442 static void DeleteFromArguments(Handle<JSObject> obj, uint32_t entry) { |
2441 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); | 2443 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); |
2442 Handle<SeededNumberDictionary> dict( | 2444 Handle<SeededNumberDictionary> dict( |
2443 SeededNumberDictionary::cast(parameter_map->get(1))); | 2445 SeededNumberDictionary::cast(parameter_map->get(1))); |
2444 // TODO(verwaest): Remove reliance on index in Shrink. | 2446 // TODO(verwaest): Remove reliance on index in Shrink. |
2445 uint32_t index = GetIndexForEntryImpl(*dict, entry); | 2447 uint32_t index = GetIndexForEntryImpl(*dict, entry); |
2446 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); | 2448 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
2447 USE(result); | 2449 USE(result); |
2448 DCHECK(result->IsTrue()); | 2450 DCHECK(result->IsTrue(dict->GetIsolate())); |
2449 Handle<FixedArray> new_elements = | 2451 Handle<FixedArray> new_elements = |
2450 SeededNumberDictionary::Shrink(dict, index); | 2452 SeededNumberDictionary::Shrink(dict, index); |
2451 parameter_map->set(1, *new_elements); | 2453 parameter_map->set(1, *new_elements); |
2452 } | 2454 } |
2453 | 2455 |
2454 static void AddImpl(Handle<JSObject> object, uint32_t index, | 2456 static void AddImpl(Handle<JSObject> object, uint32_t index, |
2455 Handle<Object> value, PropertyAttributes attributes, | 2457 Handle<Object> value, PropertyAttributes attributes, |
2456 uint32_t new_capacity) { | 2458 uint32_t new_capacity) { |
2457 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); | 2459 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); |
2458 Handle<FixedArrayBase> old_elements( | 2460 Handle<FixedArrayBase> old_elements( |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 insertion_index += len; | 3026 insertion_index += len; |
3025 } | 3027 } |
3026 | 3028 |
3027 DCHECK_EQ(insertion_index, result_len); | 3029 DCHECK_EQ(insertion_index, result_len); |
3028 return result_array; | 3030 return result_array; |
3029 } | 3031 } |
3030 | 3032 |
3031 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 3033 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
3032 } // namespace internal | 3034 } // namespace internal |
3033 } // namespace v8 | 3035 } // namespace v8 |
OLD | NEW |