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

Side by Side Diff: src/hydrogen.cc

Issue 40153003: AllocationProfiler: Inital version of RecordObjectAllocation for hydrogen. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: mips, ia32 and arm platforms were added 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/hydrogen.h ('k') | src/hydrogen-instructions.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 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), 1627 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind),
1628 length_field); 1628 length_field);
1629 1629
1630 if (mode == TRACK_ALLOCATION_SITE) { 1630 if (mode == TRACK_ALLOCATION_SITE) {
1631 BuildCreateAllocationMemento(array, 1631 BuildCreateAllocationMemento(array,
1632 JSArray::kSize, 1632 JSArray::kSize,
1633 allocation_site_payload); 1633 allocation_site_payload);
1634 } 1634 }
1635 1635
1636 int elements_location = JSArray::kSize; 1636 int elements_location = JSArray::kSize;
1637
1638 if (isolate()->heap_profiler()->is_tracking_allocations()) {
1639 RecordObjectAllocation(array, Add<HConstant>(JSArray::kSize));
1640 }
1641
1637 if (mode == TRACK_ALLOCATION_SITE) { 1642 if (mode == TRACK_ALLOCATION_SITE) {
1638 elements_location += AllocationMemento::kSize; 1643 elements_location += AllocationMemento::kSize;
1644 if (isolate()->heap_profiler()->is_tracking_allocations()) {
1645 RecordObjectAllocation(Add<HInnerAllocatedObject>(array, JSArray::kSize),
1646 Add<HConstant>(AllocationMemento::kSize));
1647 }
1639 } 1648 }
1640 1649
1641 HValue* elements = Add<HInnerAllocatedObject>(array, elements_location); 1650 HValue* elements = Add<HInnerAllocatedObject>(array, elements_location);
1642 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements); 1651 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements);
1652
1643 return static_cast<HInnerAllocatedObject*>(elements); 1653 return static_cast<HInnerAllocatedObject*>(elements);
1644 } 1654 }
1645 1655
1646 1656
1657 void HGraphBuilder::RecordObjectAllocation(HValue* object, HValue* size) {
1658 Add<HPushArgument>(object);
1659 Add<HPushArgument>(size);
1660 Add<HCallExternal>(
1661 ExternalReference::record_object_allocation_function(isolate()), 2);
1662 }
1663
1664
1647 HInstruction* HGraphBuilder::AddElementAccess( 1665 HInstruction* HGraphBuilder::AddElementAccess(
1648 HValue* elements, 1666 HValue* elements,
1649 HValue* checked_key, 1667 HValue* checked_key,
1650 HValue* val, 1668 HValue* val,
1651 HValue* dependency, 1669 HValue* dependency,
1652 ElementsKind elements_kind, 1670 ElementsKind elements_kind,
1653 bool is_store, 1671 bool is_store,
1654 LoadKeyedHoleMode load_mode) { 1672 LoadKeyedHoleMode load_mode) {
1655 if (is_store) { 1673 if (is_store) {
1656 ASSERT(val != NULL); 1674 ASSERT(val != NULL);
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 } 2066 }
2049 2067
2050 2068
2051 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { 2069 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() {
2052 // Find the map near the constructor function 2070 // Find the map near the constructor function
2053 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); 2071 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap();
2054 return builder()->AddLoadNamedField(constructor_function_, access); 2072 return builder()->AddLoadNamedField(constructor_function_, access);
2055 } 2073 }
2056 2074
2057 2075
2076 HInstruction* HGraphBuilder::JSArrayBuilder::EstablishTotalSize(
2077 int base_size, HValue* length_node) {
2078 HInstruction* elements_size_value =
2079 builder()->Add<HConstant>(elements_size());
2080 HInstruction* mul = builder()->Add<HMul>(length_node, elements_size_value);
2081 mul->ClearFlag(HValue::kCanOverflow);
2082 HInstruction* base = builder()->Add<HConstant>(base_size);
2083 HInstruction* total_size = builder()->Add<HAdd>(base, mul);
2084 total_size->ClearFlag(HValue::kCanOverflow);
2085 return total_size;
2086 }
2087
2088
2058 HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize( 2089 HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize(
2059 HValue* length_node) { 2090 HValue* length_node) {
2060 ASSERT(length_node != NULL); 2091 ASSERT(length_node != NULL);
2061 2092
2062 int base_size = JSArray::kSize; 2093 int base_size = JSArray::kSize;
2063 if (mode_ == TRACK_ALLOCATION_SITE) { 2094 if (mode_ == TRACK_ALLOCATION_SITE) {
2064 base_size += AllocationMemento::kSize; 2095 base_size += AllocationMemento::kSize;
2065 } 2096 }
2066 2097
2067 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize); 2098 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize);
2068 base_size += FixedArray::kHeaderSize; 2099 base_size += FixedArray::kHeaderSize;
2069 2100
2070 HInstruction* elements_size_value = 2101 return EstablishTotalSize(base_size, length_node);
2071 builder()->Add<HConstant>(elements_size());
2072 HInstruction* mul = builder()->Add<HMul>(length_node, elements_size_value);
2073 mul->ClearFlag(HValue::kCanOverflow);
2074
2075 HInstruction* base = builder()->Add<HConstant>(base_size);
2076 HInstruction* total_size = builder()->Add<HAdd>(base, mul);
2077 total_size->ClearFlag(HValue::kCanOverflow);
2078 return total_size;
2079 } 2102 }
2080 2103
2081 2104
2082 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() { 2105 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() {
2083 int base_size = JSArray::kSize; 2106 int base_size = JSArray::kSize;
2084 if (mode_ == TRACK_ALLOCATION_SITE) { 2107 if (mode_ == TRACK_ALLOCATION_SITE) {
2085 base_size += AllocationMemento::kSize; 2108 base_size += AllocationMemento::kSize;
2086 } 2109 }
2087 2110
2088 base_size += IsFastDoubleElementsKind(kind_) 2111 base_size += IsFastDoubleElementsKind(kind_)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 map = EmitInternalMapCode(); 2160 map = EmitInternalMapCode();
2138 } else { 2161 } else {
2139 map = EmitMapCode(); 2162 map = EmitMapCode();
2140 } 2163 }
2141 elements_location_ = builder()->BuildJSArrayHeader(new_object, 2164 elements_location_ = builder()->BuildJSArrayHeader(new_object,
2142 map, 2165 map,
2143 mode_, 2166 mode_,
2144 kind_, 2167 kind_,
2145 allocation_site_payload_, 2168 allocation_site_payload_,
2146 length_field); 2169 length_field);
2170 if (builder()->isolate()->heap_profiler()->is_tracking_allocations()) {
2171 HValue* elements_size = EstablishTotalSize(
2172 FixedArray::kHeaderSize, length_field);
2173 builder()->RecordObjectAllocation(elements_location_, elements_size);
2174 }
2147 2175
2148 // Initialize the elements 2176 // Initialize the elements
2149 builder()->BuildInitializeElementsHeader(elements_location_, kind_, capacity); 2177 builder()->BuildInitializeElementsHeader(elements_location_, kind_, capacity);
2150 2178
2151 if (fill_with_hole) { 2179 if (fill_with_hole) {
2152 builder()->BuildFillElementsWithHole(elements_location_, kind_, 2180 builder()->BuildFillElementsWithHole(elements_location_, kind_,
2153 graph()->GetConstant0(), capacity); 2181 graph()->GetConstant0(), capacity);
2154 } 2182 }
2155 2183
2156 return new_object; 2184 return new_object;
(...skipping 7667 matching lines...) Expand 10 before | Expand all | Expand 10 after
9824 if (ShouldProduceTraceOutput()) { 9852 if (ShouldProduceTraceOutput()) {
9825 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9853 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9826 } 9854 }
9827 9855
9828 #ifdef DEBUG 9856 #ifdef DEBUG
9829 graph_->Verify(false); // No full verify. 9857 graph_->Verify(false); // No full verify.
9830 #endif 9858 #endif
9831 } 9859 }
9832 9860
9833 } } // namespace v8::internal 9861 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698