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

Side by Side Diff: src/objects.cc

Issue 55933002: Inline array constructor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added comment to CreateArrayDispatchOneArgument Created 7 years, 1 month 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-inl.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 11615 matching lines...) Expand 10 before | Expand all | Expand 10 after
11626 start_indexes_[g] = start_indexes_[g - 1] + count; 11626 start_indexes_[g] = start_indexes_[g - 1] + count;
11627 } 11627 }
11628 } 11628 }
11629 11629
11630 11630
11631 DependentCode* DependentCode::ForObject(Handle<HeapObject> object, 11631 DependentCode* DependentCode::ForObject(Handle<HeapObject> object,
11632 DependencyGroup group) { 11632 DependencyGroup group) {
11633 AllowDeferredHandleDereference dependencies_are_safe; 11633 AllowDeferredHandleDereference dependencies_are_safe;
11634 if (group == DependentCode::kPropertyCellChangedGroup) { 11634 if (group == DependentCode::kPropertyCellChangedGroup) {
11635 return Handle<PropertyCell>::cast(object)->dependent_code(); 11635 return Handle<PropertyCell>::cast(object)->dependent_code();
11636 } else if (group == DependentCode::kAllocationSiteTenuringChangedGroup ||
11637 group == DependentCode::kAllocationSiteTransitionChangedGroup) {
11638 return Handle<AllocationSite>::cast(object)->dependent_code();
11636 } 11639 }
11637 return Handle<Map>::cast(object)->dependent_code(); 11640 return Handle<Map>::cast(object)->dependent_code();
11638 } 11641 }
11639 11642
11640 11643
11641 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, 11644 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries,
11642 DependencyGroup group, 11645 DependencyGroup group,
11643 Handle<Object> object) { 11646 Handle<Object> object) {
11644 GroupStartIndexes starts(*entries); 11647 GroupStartIndexes starts(*entries);
11645 int start = starts.at(group); 11648 int start = starts.at(group);
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
12797 AllocationSite* current_site = AllocationSite::cast(current); 12800 AllocationSite* current_site = AllocationSite::cast(current);
12798 if (current_site->nested_site() == this) { 12801 if (current_site->nested_site() == this) {
12799 return true; 12802 return true;
12800 } 12803 }
12801 current = current_site->weak_next(); 12804 current = current_site->weak_next();
12802 } 12805 }
12803 return false; 12806 return false;
12804 } 12807 }
12805 12808
12806 12809
12807 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { 12810 MaybeObject* AllocationSite::DigestTransitionFeedback(ElementsKind to_kind) {
12808 if (!FLAG_track_allocation_sites || !IsJSArray()) { 12811 Isolate* isolate = GetIsolate();
12809 return this;
12810 }
12811 12812
12812 AllocationMemento* memento = AllocationMemento::FindForJSObject(this); 12813 if (SitePointsToLiteral() && transition_info()->IsJSArray()) {
12813 if (memento == NULL || !memento->IsValid()) { 12814 JSArray* transition_info = JSArray::cast(this->transition_info());
12814 return this;
12815 }
12816
12817 // Walk through to the Allocation Site
12818 AllocationSite* site = memento->GetAllocationSite();
12819 if (site->SitePointsToLiteral() &&
12820 site->transition_info()->IsJSArray()) {
12821 JSArray* transition_info = JSArray::cast(site->transition_info());
12822 ElementsKind kind = transition_info->GetElementsKind(); 12815 ElementsKind kind = transition_info->GetElementsKind();
12823 // if kind is holey ensure that to_kind is as well. 12816 // if kind is holey ensure that to_kind is as well.
12824 if (IsHoleyElementsKind(kind)) { 12817 if (IsHoleyElementsKind(kind)) {
12825 to_kind = GetHoleyElementsKind(to_kind); 12818 to_kind = GetHoleyElementsKind(to_kind);
12826 } 12819 }
12827 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { 12820 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
12828 // If the array is huge, it's not likely to be defined in a local 12821 // If the array is huge, it's not likely to be defined in a local
12829 // function, so we shouldn't make new instances of it very often. 12822 // function, so we shouldn't make new instances of it very often.
12830 uint32_t length = 0; 12823 uint32_t length = 0;
12831 CHECK(transition_info->length()->ToArrayIndex(&length)); 12824 CHECK(transition_info->length()->ToArrayIndex(&length));
12832 if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { 12825 if (length <= kMaximumArrayBytesToPretransition) {
12833 if (FLAG_trace_track_allocation_sites) { 12826 if (FLAG_trace_track_allocation_sites) {
12834 bool is_nested = site->IsNestedSite(); 12827 bool is_nested = IsNestedSite();
12835 PrintF( 12828 PrintF(
12836 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n", 12829 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n",
12837 reinterpret_cast<void*>(this), 12830 reinterpret_cast<void*>(this),
12838 is_nested ? "(nested)" : "", 12831 is_nested ? "(nested)" : "",
12839 ElementsKindToString(kind), 12832 ElementsKindToString(kind),
12840 ElementsKindToString(to_kind)); 12833 ElementsKindToString(to_kind));
12841 } 12834 }
12842 return transition_info->TransitionElementsKind(to_kind); 12835 MaybeObject* result = transition_info->TransitionElementsKind(to_kind);
12836 if (result->IsFailure()) return result;
12837 dependent_code()->DeoptimizeDependentCodeGroup(
12838 isolate, DependentCode::kAllocationSiteTransitionChangedGroup);
12843 } 12839 }
12844 } 12840 }
12845 } else { 12841 } else {
12846 ElementsKind kind = site->GetElementsKind(); 12842 ElementsKind kind = GetElementsKind();
12847 // if kind is holey ensure that to_kind is as well. 12843 // if kind is holey ensure that to_kind is as well.
12848 if (IsHoleyElementsKind(kind)) { 12844 if (IsHoleyElementsKind(kind)) {
12849 to_kind = GetHoleyElementsKind(to_kind); 12845 to_kind = GetHoleyElementsKind(to_kind);
12850 } 12846 }
12851 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { 12847 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
12852 if (FLAG_trace_track_allocation_sites) { 12848 if (FLAG_trace_track_allocation_sites) {
12853 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", 12849 PrintF("AllocationSite: JSArray %p site updated %s->%s\n",
12854 reinterpret_cast<void*>(this), 12850 reinterpret_cast<void*>(this),
12855 ElementsKindToString(kind), 12851 ElementsKindToString(kind),
12856 ElementsKindToString(to_kind)); 12852 ElementsKindToString(to_kind));
12857 } 12853 }
12858 site->set_transition_info(Smi::FromInt(to_kind)); 12854 SetElementsKind(to_kind);
12855 dependent_code()->DeoptimizeDependentCodeGroup(
12856 isolate, DependentCode::kAllocationSiteTransitionChangedGroup);
12859 } 12857 }
12860 } 12858 }
12861 return this; 12859 return this;
12862 } 12860 }
12863 12861
12864 12862
12863 void AllocationSite::AddDependentCompilationInfo(Reason reason,
12864 CompilationInfo* info) {
12865 DependentCode::DependencyGroup group = ToDependencyGroup(reason);
12866 Handle<DependentCode> dep(dependent_code());
12867 Handle<DependentCode> codes =
12868 DependentCode::Insert(dep, group, info->object_wrapper());
12869 if (*codes != dependent_code()) set_dependent_code(*codes);
12870 info->dependencies(group)->Add(Handle<HeapObject>(this), info->zone());
12871 }
12872
12873
12874 void AllocationSite::AddDependentCode(Reason reason, Handle<Code> code) {
12875 DependentCode::DependencyGroup group = ToDependencyGroup(reason);
12876 Handle<DependentCode> codes = DependentCode::Insert(
12877 Handle<DependentCode>(dependent_code()), group, code);
12878 if (*codes != dependent_code()) set_dependent_code(*codes);
12879 }
12880
12881
12882 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
12883 if (!FLAG_track_allocation_sites || !IsJSArray()) {
12884 return this;
12885 }
12886
12887 AllocationMemento* memento = AllocationMemento::FindForJSObject(this);
12888 if (memento == NULL || !memento->IsValid()) {
12889 return this;
12890 }
12891
12892 // Walk through to the Allocation Site
12893 AllocationSite* site = memento->GetAllocationSite();
12894 return site->DigestTransitionFeedback(to_kind);
12895 }
12896
12897
12865 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { 12898 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) {
12866 ASSERT(!map()->is_observed()); 12899 ASSERT(!map()->is_observed());
12867 ElementsKind from_kind = map()->elements_kind(); 12900 ElementsKind from_kind = map()->elements_kind();
12868 12901
12869 if (IsFastHoleyElementsKind(from_kind)) { 12902 if (IsFastHoleyElementsKind(from_kind)) {
12870 to_kind = GetHoleyElementsKind(to_kind); 12903 to_kind = GetHoleyElementsKind(to_kind);
12871 } 12904 }
12872 12905
12873 if (from_kind == to_kind) return this; 12906 if (from_kind == to_kind) return this;
12874 // Don't update the site if to_kind isn't fast 12907 // Don't update the site if to_kind isn't fast
(...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after
16526 #define ERROR_MESSAGES_TEXTS(C, T) T, 16559 #define ERROR_MESSAGES_TEXTS(C, T) T,
16527 static const char* error_messages_[] = { 16560 static const char* error_messages_[] = {
16528 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16561 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16529 }; 16562 };
16530 #undef ERROR_MESSAGES_TEXTS 16563 #undef ERROR_MESSAGES_TEXTS
16531 return error_messages_[reason]; 16564 return error_messages_[reason];
16532 } 16565 }
16533 16566
16534 16567
16535 } } // namespace v8::internal 16568 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698