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

Side by Side Diff: src/elements.cc

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: rebased Created 3 years, 11 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 | « src/deoptimizer.cc ('k') | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 FixedArray* to = FixedArray::cast(to_base); 180 FixedArray* to = FixedArray::cast(to_base);
181 uint32_t to_length = to->length(); 181 uint32_t to_length = to->length();
182 if (to_start + copy_size > to_length) { 182 if (to_start + copy_size > to_length) {
183 copy_size = to_length - to_start; 183 copy_size = to_length - to_start;
184 } 184 }
185 WriteBarrierMode write_barrier_mode = IsFastObjectElementsKind(to_kind) 185 WriteBarrierMode write_barrier_mode = IsFastObjectElementsKind(to_kind)
186 ? UPDATE_WRITE_BARRIER 186 ? UPDATE_WRITE_BARRIER
187 : SKIP_WRITE_BARRIER; 187 : SKIP_WRITE_BARRIER;
188 Isolate* isolate = from->GetIsolate(); 188 Isolate* isolate = from->GetIsolate();
189 for (int i = 0; i < copy_size; i++) { 189 for (int i = 0; i < copy_size; i++) {
190 int entry = from->FindEntry(i + from_start); 190 int entry = from->FindEntry(isolate, i + from_start);
191 if (entry != SeededNumberDictionary::kNotFound) { 191 if (entry != SeededNumberDictionary::kNotFound) {
192 Object* value = from->ValueAt(entry); 192 Object* value = from->ValueAt(entry);
193 DCHECK(!value->IsTheHole(isolate)); 193 DCHECK(!value->IsTheHole(isolate));
194 to->set(i + to_start, value, write_barrier_mode); 194 to->set(i + to_start, value, write_barrier_mode);
195 } else { 195 } else {
196 to->set_the_hole(isolate, i + to_start); 196 to->set_the_hole(isolate, i + to_start);
197 } 197 }
198 } 198 }
199 } 199 }
200 200
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 FixedDoubleArray::cast(to_base)->set_the_hole(i); 410 FixedDoubleArray::cast(to_base)->set_the_hole(i);
411 } 411 }
412 } 412 }
413 } 413 }
414 if (copy_size == 0) return; 414 if (copy_size == 0) return;
415 FixedDoubleArray* to = FixedDoubleArray::cast(to_base); 415 FixedDoubleArray* to = FixedDoubleArray::cast(to_base);
416 uint32_t to_length = to->length(); 416 uint32_t to_length = to->length();
417 if (to_start + copy_size > to_length) { 417 if (to_start + copy_size > to_length) {
418 copy_size = to_length - to_start; 418 copy_size = to_length - to_start;
419 } 419 }
420 Isolate* isolate = from->GetIsolate();
420 for (int i = 0; i < copy_size; i++) { 421 for (int i = 0; i < copy_size; i++) {
421 int entry = from->FindEntry(i + from_start); 422 int entry = from->FindEntry(isolate, i + from_start);
422 if (entry != SeededNumberDictionary::kNotFound) { 423 if (entry != SeededNumberDictionary::kNotFound) {
423 to->set(i + to_start, from->ValueAt(entry)->Number()); 424 to->set(i + to_start, from->ValueAt(entry)->Number());
424 } else { 425 } else {
425 to->set_the_hole(i + to_start); 426 to->set_the_hole(i + to_start);
426 } 427 }
427 } 428 }
428 } 429 }
429 430
430 static void TraceTopFrame(Isolate* isolate) { 431 static void TraceTopFrame(Isolate* isolate) {
431 StackFrameIterator it(isolate); 432 StackFrameIterator it(isolate);
(...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 isolate, receiver, value, start_from, length, &result)) { 1622 isolate, receiver, value, start_from, length, &result)) {
1622 return result; 1623 return result;
1623 } 1624 }
1624 } 1625 }
1625 1626
1626 Handle<SeededNumberDictionary> dictionary( 1627 Handle<SeededNumberDictionary> dictionary(
1627 SeededNumberDictionary::cast(receiver->elements()), isolate); 1628 SeededNumberDictionary::cast(receiver->elements()), isolate);
1628 // Iterate through entire range, as accessing elements out of order is 1629 // Iterate through entire range, as accessing elements out of order is
1629 // observable 1630 // observable
1630 for (uint32_t k = start_from; k < length; ++k) { 1631 for (uint32_t k = start_from; k < length; ++k) {
1631 int entry = dictionary->FindEntry(k); 1632 int entry = dictionary->FindEntry(isolate, k);
1632 if (entry == SeededNumberDictionary::kNotFound) { 1633 if (entry == SeededNumberDictionary::kNotFound) {
1633 if (search_for_hole) return Just(true); 1634 if (search_for_hole) return Just(true);
1634 continue; 1635 continue;
1635 } 1636 }
1636 1637
1637 PropertyDetails details = GetDetailsImpl(*dictionary, entry); 1638 PropertyDetails details = GetDetailsImpl(*dictionary, entry);
1638 switch (details.kind()) { 1639 switch (details.kind()) {
1639 case kData: { 1640 case kData: {
1640 Object* element_k = dictionary->ValueAt(entry); 1641 Object* element_k = dictionary->ValueAt(entry);
1641 if (value->SameValueZero(element_k)) return Just(true); 1642 if (value->SameValueZero(element_k)) return Just(true);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 Handle<JSObject> receiver, 1688 Handle<JSObject> receiver,
1688 Handle<Object> value, 1689 Handle<Object> value,
1689 uint32_t start_from, uint32_t length) { 1690 uint32_t start_from, uint32_t length) {
1690 DCHECK(JSObject::PrototypeHasNoElements(isolate, *receiver)); 1691 DCHECK(JSObject::PrototypeHasNoElements(isolate, *receiver));
1691 1692
1692 Handle<SeededNumberDictionary> dictionary( 1693 Handle<SeededNumberDictionary> dictionary(
1693 SeededNumberDictionary::cast(receiver->elements()), isolate); 1694 SeededNumberDictionary::cast(receiver->elements()), isolate);
1694 // Iterate through entire range, as accessing elements out of order is 1695 // Iterate through entire range, as accessing elements out of order is
1695 // observable. 1696 // observable.
1696 for (uint32_t k = start_from; k < length; ++k) { 1697 for (uint32_t k = start_from; k < length; ++k) {
1697 int entry = dictionary->FindEntry(k); 1698 int entry = dictionary->FindEntry(isolate, k);
1698 if (entry == SeededNumberDictionary::kNotFound) { 1699 if (entry == SeededNumberDictionary::kNotFound) {
1699 continue; 1700 continue;
1700 } 1701 }
1701 1702
1702 PropertyDetails details = GetDetailsImpl(*dictionary, entry); 1703 PropertyDetails details = GetDetailsImpl(*dictionary, entry);
1703 switch (details.kind()) { 1704 switch (details.kind()) {
1704 case kData: { 1705 case kData: {
1705 Object* element_k = dictionary->ValueAt(entry); 1706 Object* element_k = dictionary->ValueAt(entry);
1706 if (value->StrictEquals(element_k)) { 1707 if (value->StrictEquals(element_k)) {
1707 return Just<int64_t>(k); 1708 return Just<int64_t>(k);
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after
3852 insertion_index += len; 3853 insertion_index += len;
3853 } 3854 }
3854 3855
3855 DCHECK_EQ(insertion_index, result_len); 3856 DCHECK_EQ(insertion_index, result_len);
3856 return result_array; 3857 return result_array;
3857 } 3858 }
3858 3859
3859 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 3860 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
3860 } // namespace internal 3861 } // namespace internal
3861 } // namespace v8 3862 } // namespace v8
OLDNEW
« no previous file with comments | « src/deoptimizer.cc ('k') | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698