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

Side by Side Diff: src/objects.cc

Issue 1823613002: Simplify JSArray::HasReadOnlyLength (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 16098 matching lines...) Expand 10 before | Expand all | Expand 10 after
16109 return false; 16109 return false;
16110 } 16110 }
16111 16111
16112 // Transitions from HOLEY -> PACKED are not allowed. 16112 // Transitions from HOLEY -> PACKED are not allowed.
16113 return !IsFastHoleyElementsKind(from_kind) || 16113 return !IsFastHoleyElementsKind(from_kind) ||
16114 IsFastHoleyElementsKind(to_kind); 16114 IsFastHoleyElementsKind(to_kind);
16115 } 16115 }
16116 16116
16117 16117
16118 bool JSArray::HasReadOnlyLength(Handle<JSArray> array) { 16118 bool JSArray::HasReadOnlyLength(Handle<JSArray> array) {
16119 Isolate* isolate = array->GetIsolate(); 16119 Map* map = array->map();
16120 // Optimistic fast path: "length" is usually the first fast property. 16120 // Fast path: "length" is the first fast property of arrays. Since it's not
16121 DescriptorArray* descriptors = array->map()->instance_descriptors(); 16121 // configurable, it's guaranteed to be the first in the descriptor array.
16122 if (descriptors->length() >= 1 && 16122 if (!map->is_dictionary_map()) {
16123 descriptors->GetKey(0) == isolate->heap()->length_string()) { 16123 DCHECK(map->instance_descriptors()->GetKey(0) ==
16124 return descriptors->GetDetails(0).IsReadOnly(); 16124 array->GetHeap()->length_string());
16125 return map->instance_descriptors()->GetDetails(0).IsReadOnly();
16125 } 16126 }
16126 16127
16128 Isolate* isolate = array->GetIsolate();
16127 LookupIterator it(array, isolate->factory()->length_string(), array, 16129 LookupIterator it(array, isolate->factory()->length_string(), array,
16128 LookupIterator::OWN_SKIP_INTERCEPTOR); 16130 LookupIterator::OWN_SKIP_INTERCEPTOR);
16129 CHECK_EQ(LookupIterator::ACCESSOR, it.state()); 16131 CHECK_EQ(LookupIterator::ACCESSOR, it.state());
16130 return it.IsReadOnly(); 16132 return it.IsReadOnly();
16131 } 16133 }
16132 16134
16133 16135
16134 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array, 16136 bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array,
16135 uint32_t index) { 16137 uint32_t index) {
16136 uint32_t length = 0; 16138 uint32_t length = 0;
(...skipping 3608 matching lines...) Expand 10 before | Expand all | Expand 10 after
19745 if (cell->value() != *new_value) { 19747 if (cell->value() != *new_value) {
19746 cell->set_value(*new_value); 19748 cell->set_value(*new_value);
19747 Isolate* isolate = cell->GetIsolate(); 19749 Isolate* isolate = cell->GetIsolate();
19748 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19750 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19749 isolate, DependentCode::kPropertyCellChangedGroup); 19751 isolate, DependentCode::kPropertyCellChangedGroup);
19750 } 19752 }
19751 } 19753 }
19752 19754
19753 } // namespace internal 19755 } // namespace internal
19754 } // namespace v8 19756 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698