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

Side by Side Diff: src/objects.cc

Issue 11663005: Adapt Danno's Track Allocation Info idea to fast literals. When allocating a literal array, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: A few more review comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7884 matching lines...) Expand 10 before | Expand all | Expand 10 after
7895 // that are a multiple of pointer size. 7895 // that are a multiple of pointer size.
7896 Address end_of_string = address() + string_size; 7896 Address end_of_string = address() + string_size;
7897 heap->CreateFillerObjectAt(end_of_string, delta); 7897 heap->CreateFillerObjectAt(end_of_string, delta);
7898 if (Marking::IsBlack(Marking::MarkBitFrom(this))) { 7898 if (Marking::IsBlack(Marking::MarkBitFrom(this))) {
7899 MemoryChunk::IncrementLiveBytesFromMutator(address(), -delta); 7899 MemoryChunk::IncrementLiveBytesFromMutator(address(), -delta);
7900 } 7900 }
7901 return this; 7901 return this;
7902 } 7902 }
7903 7903
7904 7904
7905 AllocationSiteInfo* AllocationSiteInfo::FindForJSObject(JSObject* object) {
7906 // Currently, AllocationSiteInfo objects are only allocated immediately
7907 // after JSArrays in NewSpace, and detecting whether a JSArray has one
7908 // involves carefully checking the object immediately after the JSArray
7909 // (if there is one) to see if it's an AllocationSiteInfo.
7910 if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) {
7911 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) +
7912 object->Size();
7913 if ((ptr_end + AllocationSiteInfo::kSize) <=
7914 object->GetHeap()->NewSpaceTop()) {
7915 // There is room in newspace for allocation info. Do we have some?
7916 Map** possible_allocation_site_info_map =
7917 reinterpret_cast<Map**>(ptr_end);
7918 if (*possible_allocation_site_info_map ==
7919 object->GetHeap()->allocation_site_info_map()) {
7920 AllocationSiteInfo* info = AllocationSiteInfo::cast(
7921 reinterpret_cast<Object*>(ptr_end + 1));
7922 return info;
7923 }
7924 }
7925 }
7926 return NULL;
7927 }
7928
7929
7905 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { 7930 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
7906 // For array indexes mix the length into the hash as an array index could 7931 // For array indexes mix the length into the hash as an array index could
7907 // be zero. 7932 // be zero.
7908 ASSERT(length > 0); 7933 ASSERT(length > 0);
7909 ASSERT(length <= String::kMaxArrayIndexSize); 7934 ASSERT(length <= String::kMaxArrayIndexSize);
7910 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 7935 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
7911 (1 << String::kArrayIndexValueBits)); 7936 (1 << String::kArrayIndexValueBits));
7912 7937
7913 value <<= String::kHashShift; 7938 value <<= String::kHashShift;
7914 value |= length << String::kArrayIndexHashLengthShift; 7939 value |= length << String::kArrayIndexHashLengthShift;
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
10241 } 10266 }
10242 if (convert_to_slow) { 10267 if (convert_to_slow) {
10243 MaybeObject* result = NormalizeElements(); 10268 MaybeObject* result = NormalizeElements();
10244 if (result->IsFailure()) return result; 10269 if (result->IsFailure()) return result;
10245 return SetDictionaryElement(index, value, NONE, strict_mode, 10270 return SetDictionaryElement(index, value, NONE, strict_mode,
10246 check_prototype); 10271 check_prototype);
10247 } 10272 }
10248 } 10273 }
10249 // Convert to fast double elements if appropriate. 10274 // Convert to fast double elements if appropriate.
10250 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) { 10275 if (HasFastSmiElements() && !value->IsSmi() && value->IsNumber()) {
10276 // Consider fixing the boilerplate as well if we have one.
10277 ElementsKind to_kind = IsHoleyElementsKind(elements_kind)
10278 ? FAST_HOLEY_DOUBLE_ELEMENTS
10279 : FAST_DOUBLE_ELEMENTS;
10280
10281 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind);
10282 if (trans != NULL && trans->IsFailure()) return trans;
10283
10251 MaybeObject* maybe = 10284 MaybeObject* maybe =
10252 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length); 10285 SetFastDoubleElementsCapacityAndLength(new_capacity, array_length);
10253 if (maybe->IsFailure()) return maybe; 10286 if (maybe->IsFailure()) return maybe;
10254 FixedDoubleArray::cast(elements())->set(index, value->Number()); 10287 FixedDoubleArray::cast(elements())->set(index, value->Number());
10255 ValidateElements(); 10288 ValidateElements();
10256 return value; 10289 return value;
10257 } 10290 }
10258 // Change elements kind from Smi-only to generic FAST if necessary. 10291 // Change elements kind from Smi-only to generic FAST if necessary.
10259 if (HasFastSmiElements() && !value->IsSmi()) { 10292 if (HasFastSmiElements() && !value->IsSmi()) {
10260 Map* new_map; 10293 Map* new_map;
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
10782 10815
10783 10816
10784 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object, 10817 Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object,
10785 ElementsKind to_kind) { 10818 ElementsKind to_kind) {
10786 CALL_HEAP_FUNCTION(object->GetIsolate(), 10819 CALL_HEAP_FUNCTION(object->GetIsolate(),
10787 object->TransitionElementsKind(to_kind), 10820 object->TransitionElementsKind(to_kind),
10788 Object); 10821 Object);
10789 } 10822 }
10790 10823
10791 10824
10825 MaybeObject* JSObject::PossiblyTransitionArrayBoilerplate(
10826 ElementsKind to_kind) {
10827 ASSERT(IsJSArray());
10828 MaybeObject* ret = NULL;
10829 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(this);
10830 if (info != NULL) {
10831 JSObject* payload = JSObject::cast(info->payload());
10832 if (payload->GetElementsKind() != to_kind) {
10833 if (IsMoreGeneralElementsKindTransition(payload->GetElementsKind(),
10834 to_kind)) {
10835 ret = payload->TransitionElementsKind(to_kind);
10836 }
10837 }
10838 }
10839 return ret;
10840 }
10841
10842
10792 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { 10843 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) {
10793 ASSERT(!map()->is_observed()); 10844 ASSERT(!map()->is_observed());
10794 ElementsKind from_kind = map()->elements_kind(); 10845 ElementsKind from_kind = map()->elements_kind();
10795 10846
10796 if (IsFastHoleyElementsKind(from_kind)) { 10847 if (IsFastHoleyElementsKind(from_kind)) {
10797 to_kind = GetHoleyElementsKind(to_kind); 10848 to_kind = GetHoleyElementsKind(to_kind);
10798 } 10849 }
10799 10850
10800 if (from_kind == to_kind) return this; 10851 if (from_kind == to_kind) return this;
10801 10852
10853 MaybeObject* trans = PossiblyTransitionArrayBoilerplate(to_kind);
10854 if (trans != NULL && trans->IsFailure()) return trans;
10855
10802 Isolate* isolate = GetIsolate(); 10856 Isolate* isolate = GetIsolate();
10803 if (elements() == isolate->heap()->empty_fixed_array() || 10857 if (elements() == isolate->heap()->empty_fixed_array() ||
10804 (IsFastSmiOrObjectElementsKind(from_kind) && 10858 (IsFastSmiOrObjectElementsKind(from_kind) &&
10805 IsFastSmiOrObjectElementsKind(to_kind)) || 10859 IsFastSmiOrObjectElementsKind(to_kind)) ||
10806 (from_kind == FAST_DOUBLE_ELEMENTS && 10860 (from_kind == FAST_DOUBLE_ELEMENTS &&
10807 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) { 10861 to_kind == FAST_HOLEY_DOUBLE_ELEMENTS)) {
10808 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND); 10862 ASSERT(from_kind != TERMINAL_FAST_ELEMENTS_KIND);
10809 // No change is needed to the elements() buffer, the transition 10863 // No change is needed to the elements() buffer, the transition
10810 // only requires a map change. 10864 // only requires a map change.
10811 MaybeObject* maybe_new_map = GetElementsTransitionMap(isolate, to_kind); 10865 MaybeObject* maybe_new_map = GetElementsTransitionMap(isolate, to_kind);
(...skipping 3330 matching lines...) Expand 10 before | Expand all | Expand 10 after
14142 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 14196 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
14143 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 14197 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
14144 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 14198 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
14145 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 14199 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
14146 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 14200 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
14147 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 14201 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
14148 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 14202 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
14149 } 14203 }
14150 14204
14151 } } // namespace v8::internal 14205 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698