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

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: Even better codegen for 1 arg case, and refactoring. 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
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 11566 matching lines...) Expand 10 before | Expand all | Expand 10 after
11577 start_indexes_[g] = start_indexes_[g - 1] + count; 11577 start_indexes_[g] = start_indexes_[g - 1] + count;
11578 } 11578 }
11579 } 11579 }
11580 11580
11581 11581
11582 DependentCode* DependentCode::ForObject(Handle<HeapObject> object, 11582 DependentCode* DependentCode::ForObject(Handle<HeapObject> object,
11583 DependencyGroup group) { 11583 DependencyGroup group) {
11584 AllowDeferredHandleDereference dependencies_are_safe; 11584 AllowDeferredHandleDereference dependencies_are_safe;
11585 if (group == DependentCode::kPropertyCellChangedGroup) { 11585 if (group == DependentCode::kPropertyCellChangedGroup) {
11586 return Handle<PropertyCell>::cast(object)->dependent_code(); 11586 return Handle<PropertyCell>::cast(object)->dependent_code();
11587 } else if (group == DependentCode::kAllocationSiteTenuringChangedGroup ||
11588 group == DependentCode::kAllocationSiteTransitionChangedGroup) {
11589 return Handle<AllocationSite>::cast(object)->dependent_code();
11587 } 11590 }
11588 return Handle<Map>::cast(object)->dependent_code(); 11591 return Handle<Map>::cast(object)->dependent_code();
11589 } 11592 }
11590 11593
11591 11594
11592 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries, 11595 Handle<DependentCode> DependentCode::Insert(Handle<DependentCode> entries,
11593 DependencyGroup group, 11596 DependencyGroup group,
11594 Handle<Object> object) { 11597 Handle<Object> object) {
11595 GroupStartIndexes starts(*entries); 11598 GroupStartIndexes starts(*entries);
11596 int start = starts.at(group); 11599 int start = starts.at(group);
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
12736 AllocationSite* current_site = AllocationSite::cast(current); 12739 AllocationSite* current_site = AllocationSite::cast(current);
12737 if (current_site->nested_site() == this) { 12740 if (current_site->nested_site() == this) {
12738 return true; 12741 return true;
12739 } 12742 }
12740 current = current_site->weak_next(); 12743 current = current_site->weak_next();
12741 } 12744 }
12742 return false; 12745 return false;
12743 } 12746 }
12744 12747
12745 12748
12746 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { 12749 MaybeObject* AllocationSite::DigestTransitionFeedback(ElementsKind to_kind) {
12747 if (!FLAG_track_allocation_sites || !IsJSArray()) { 12750 Isolate* isolate = GetIsolate();
12748 return this;
12749 }
12750 12751
12751 AllocationMemento* memento = AllocationMemento::FindForJSObject(this); 12752 if (SitePointsToLiteral() &&
Toon Verwaest 2013/11/06 16:42:44 nit: merge lines
mvstanton 2013/11/07 16:34:05 Done.
12752 if (memento == NULL || !memento->IsValid()) { 12753 transition_info()->IsJSArray()) {
12753 return this; 12754 JSArray* transition_info = JSArray::cast(this->transition_info());
12754 }
12755
12756 // Walk through to the Allocation Site
12757 AllocationSite* site = memento->GetAllocationSite();
12758 if (site->SitePointsToLiteral() &&
12759 site->transition_info()->IsJSArray()) {
12760 JSArray* transition_info = JSArray::cast(site->transition_info());
12761 ElementsKind kind = transition_info->GetElementsKind(); 12755 ElementsKind kind = transition_info->GetElementsKind();
12762 // if kind is holey ensure that to_kind is as well. 12756 // if kind is holey ensure that to_kind is as well.
12763 if (IsHoleyElementsKind(kind)) { 12757 if (IsHoleyElementsKind(kind)) {
12764 to_kind = GetHoleyElementsKind(to_kind); 12758 to_kind = GetHoleyElementsKind(to_kind);
12765 } 12759 }
12766 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { 12760 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
12767 // If the array is huge, it's not likely to be defined in a local 12761 // If the array is huge, it's not likely to be defined in a local
12768 // function, so we shouldn't make new instances of it very often. 12762 // function, so we shouldn't make new instances of it very often.
12769 uint32_t length = 0; 12763 uint32_t length = 0;
12770 CHECK(transition_info->length()->ToArrayIndex(&length)); 12764 CHECK(transition_info->length()->ToArrayIndex(&length));
12771 if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { 12765 if (length <= kMaximumArrayBytesToPretransition) {
12772 if (FLAG_trace_track_allocation_sites) { 12766 if (FLAG_trace_track_allocation_sites) {
12773 bool is_nested = site->IsNestedSite(); 12767 bool is_nested = IsNestedSite();
12774 PrintF( 12768 PrintF(
12775 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n", 12769 "AllocationSite: JSArray %p boilerplate %s updated %s->%s\n",
12776 reinterpret_cast<void*>(this), 12770 reinterpret_cast<void*>(this),
12777 is_nested ? "(nested)" : "", 12771 is_nested ? "(nested)" : "",
12778 ElementsKindToString(kind), 12772 ElementsKindToString(kind),
12779 ElementsKindToString(to_kind)); 12773 ElementsKindToString(to_kind));
12780 } 12774 }
12781 return transition_info->TransitionElementsKind(to_kind); 12775 MaybeObject* result = transition_info->TransitionElementsKind(to_kind);
12776 if (result->IsFailure()) return result;
12777 dependent_code()->DeoptimizeDependentCodeGroup(
12778 isolate, DependentCode::kAllocationSiteTransitionChangedGroup);
12782 } 12779 }
12783 } 12780 }
12784 } else { 12781 } else {
12785 ElementsKind kind = site->GetElementsKind(); 12782 ElementsKind kind = GetElementsKind();
12786 // if kind is holey ensure that to_kind is as well. 12783 // if kind is holey ensure that to_kind is as well.
12787 if (IsHoleyElementsKind(kind)) { 12784 if (IsHoleyElementsKind(kind)) {
12788 to_kind = GetHoleyElementsKind(to_kind); 12785 to_kind = GetHoleyElementsKind(to_kind);
12789 } 12786 }
12790 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { 12787 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
12791 if (FLAG_trace_track_allocation_sites) { 12788 if (FLAG_trace_track_allocation_sites) {
12792 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", 12789 PrintF("AllocationSite: JSArray %p site updated %s->%s\n",
12793 reinterpret_cast<void*>(this), 12790 reinterpret_cast<void*>(this),
12794 ElementsKindToString(kind), 12791 ElementsKindToString(kind),
12795 ElementsKindToString(to_kind)); 12792 ElementsKindToString(to_kind));
12796 } 12793 }
12797 site->set_transition_info(Smi::FromInt(to_kind)); 12794 SetElementsKind(to_kind);
12795 dependent_code()->DeoptimizeDependentCodeGroup(
12796 isolate, DependentCode::kAllocationSiteTransitionChangedGroup);
12798 } 12797 }
12799 } 12798 }
12800 return this; 12799 return this;
12801 } 12800 }
12802 12801
12803 12802
12803 void AllocationSite::AddDependentCompilationInfo(Reason reason,
12804 CompilationInfo* info) {
12805 DependentCode::DependencyGroup group = ToDependencyGroup(reason);
12806 Handle<DependentCode> dep(dependent_code());
12807 Handle<DependentCode> codes =
12808 DependentCode::Insert(dep, group, info->object_wrapper());
12809 if (*codes != dependent_code()) set_dependent_code(*codes);
12810 info->dependencies(group)->Add(Handle<HeapObject>(this), info->zone());
12811 }
12812
12813
12814 void AllocationSite::AddDependentCode(Reason reason, Handle<Code> code) {
12815 DependentCode::DependencyGroup group = ToDependencyGroup(reason);
12816 Handle<DependentCode> codes = DependentCode::Insert(
12817 Handle<DependentCode>(dependent_code()), group, code);
12818 if (*codes != dependent_code()) set_dependent_code(*codes);
12819 }
12820
12821
12822 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
12823 if (!FLAG_track_allocation_sites || !IsJSArray()) {
12824 return this;
12825 }
12826
12827 AllocationMemento* memento = AllocationMemento::FindForJSObject(this);
12828 if (memento == NULL || !memento->IsValid()) {
12829 return this;
12830 }
12831
12832 // Walk through to the Allocation Site
12833 AllocationSite* site = memento->GetAllocationSite();
12834 return site->DigestTransitionFeedback(to_kind);
12835 }
12836
12837
12804 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { 12838 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) {
12805 ASSERT(!map()->is_observed()); 12839 ASSERT(!map()->is_observed());
12806 ElementsKind from_kind = map()->elements_kind(); 12840 ElementsKind from_kind = map()->elements_kind();
12807 12841
12808 if (IsFastHoleyElementsKind(from_kind)) { 12842 if (IsFastHoleyElementsKind(from_kind)) {
12809 to_kind = GetHoleyElementsKind(to_kind); 12843 to_kind = GetHoleyElementsKind(to_kind);
12810 } 12844 }
12811 12845
12812 if (from_kind == to_kind) return this; 12846 if (from_kind == to_kind) return this;
12813 12847
(...skipping 3649 matching lines...) Expand 10 before | Expand all | Expand 10 after
16463 #define ERROR_MESSAGES_TEXTS(C, T) T, 16497 #define ERROR_MESSAGES_TEXTS(C, T) T,
16464 static const char* error_messages_[] = { 16498 static const char* error_messages_[] = {
16465 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16499 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16466 }; 16500 };
16467 #undef ERROR_MESSAGES_TEXTS 16501 #undef ERROR_MESSAGES_TEXTS
16468 return error_messages_[reason]; 16502 return error_messages_[reason];
16469 } 16503 }
16470 16504
16471 16505
16472 } } // namespace v8::internal 16506 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698