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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 3b232e6e93ee2d307e5ea9504266825fb9f11b36..dc97a817a5570e84b5563b9a8d9385a486f73572 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1634,16 +1634,34 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
}
int elements_location = JSArray::kSize;
+
+ if (isolate()->heap_profiler()->is_tracking_allocations()) {
+ RecordObjectAllocation(array, Add<HConstant>(JSArray::kSize));
+ }
+
if (mode == TRACK_ALLOCATION_SITE) {
elements_location += AllocationMemento::kSize;
+ if (isolate()->heap_profiler()->is_tracking_allocations()) {
+ RecordObjectAllocation(Add<HInnerAllocatedObject>(array, JSArray::kSize),
+ Add<HConstant>(AllocationMemento::kSize));
+ }
}
HValue* elements = Add<HInnerAllocatedObject>(array, elements_location);
Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements);
+
return static_cast<HInnerAllocatedObject*>(elements);
}
+void HGraphBuilder::RecordObjectAllocation(HValue* object, HValue* size) {
+ Add<HPushArgument>(object);
+ Add<HPushArgument>(size);
+ Add<HCallExternal>(
+ ExternalReference::record_object_allocation_function(isolate()), 2);
+}
+
+
HInstruction* HGraphBuilder::AddElementAccess(
HValue* elements,
HValue* checked_key,
@@ -2055,6 +2073,19 @@ HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() {
}
+HInstruction* HGraphBuilder::JSArrayBuilder::EstablishTotalSize(
+ int base_size, HValue* length_node) {
+ HInstruction* elements_size_value =
+ builder()->Add<HConstant>(elements_size());
+ HInstruction* mul = builder()->Add<HMul>(length_node, elements_size_value);
+ mul->ClearFlag(HValue::kCanOverflow);
+ HInstruction* base = builder()->Add<HConstant>(base_size);
+ HInstruction* total_size = builder()->Add<HAdd>(base, mul);
+ total_size->ClearFlag(HValue::kCanOverflow);
+ return total_size;
+}
+
+
HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize(
HValue* length_node) {
ASSERT(length_node != NULL);
@@ -2067,15 +2098,7 @@ HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize(
STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize);
base_size += FixedArray::kHeaderSize;
- HInstruction* elements_size_value =
- builder()->Add<HConstant>(elements_size());
- HInstruction* mul = builder()->Add<HMul>(length_node, elements_size_value);
- mul->ClearFlag(HValue::kCanOverflow);
-
- HInstruction* base = builder()->Add<HConstant>(base_size);
- HInstruction* total_size = builder()->Add<HAdd>(base, mul);
- total_size->ClearFlag(HValue::kCanOverflow);
- return total_size;
+ return EstablishTotalSize(base_size, length_node);
}
@@ -2144,6 +2167,11 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes,
kind_,
allocation_site_payload_,
length_field);
+ if (builder()->isolate()->heap_profiler()->is_tracking_allocations()) {
+ HValue* elements_size = EstablishTotalSize(
+ FixedArray::kHeaderSize, length_field);
+ builder()->RecordObjectAllocation(elements_location_, elements_size);
+ }
// Initialize the elements
builder()->BuildInitializeElementsHeader(elements_location_, kind_, capacity);
« 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