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

Unified Diff: runtime/vm/assembler_ia32.cc

Issue 1213013002: Update Assembler::TryAllocate to support inline allocation tracing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_mips.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler_ia32.cc
diff --git a/runtime/vm/assembler_ia32.cc b/runtime/vm/assembler_ia32.cc
index 249fba089e486e0fd03a0974c1726f857a3922f1..8f15c6e2105dc260f0cf24ec323e916ce6bbc787 100644
--- a/runtime/vm/assembler_ia32.cc
+++ b/runtime/vm/assembler_ia32.cc
@@ -2683,6 +2683,45 @@ static void ComputeCounterAddressesForCid(intptr_t cid,
}
+static void ComputeHeapStatsStateAddressForCid(intptr_t cid,
+ Address* state_address) {
+ ASSERT(cid < kNumPredefinedCids);
+ Isolate* isolate = Isolate::Current();
+ ClassTable* class_table = isolate->class_table();
+ const uword class_heap_stats_table_address =
+ class_table->PredefinedClassHeapStatsTableAddress();
+ const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
+ const uword state_offset = ClassHeapStats::state_offset();
+ *state_address = Address::Absolute(class_heap_stats_table_address +
+ class_offset +
+ state_offset);
+}
+
+
+void Assembler::MaybeTraceAllocation(intptr_t cid,
+ Register temp_reg,
+ Label* trace,
+ bool near_jump) {
+ ASSERT(cid > 0);
+ Address state_address(kNoRegister, 0);
+ if (cid < kNumPredefinedCids) {
+ ComputeHeapStatsStateAddressForCid(cid, &state_address);
+ } else {
+ ASSERT(temp_reg != kNoRegister);
+ const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
+ const uword state_offset = ClassHeapStats::state_offset();
+ // temp_reg gets address of class table pointer.
+ ClassTable* class_table = Isolate::Current()->class_table();
+ movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress()));
+ state_address = Address(temp_reg, class_offset + state_offset);
+ }
+ testb(state_address, Immediate(ClassHeapStats::TraceAllocationMask()));
+ // We are tracing for this class, jump to the trace label which will use
+ // the allocation stub.
+ j(NOT_ZERO, trace, near_jump);
+}
+
+
void Assembler::UpdateAllocationStats(intptr_t cid,
Register temp_reg,
Heap::Space space) {
@@ -2739,6 +2778,10 @@ void Assembler::TryAllocate(const Class& cls,
Register temp_reg) {
ASSERT(failure != NULL);
if (FLAG_inline_alloc) {
+ // If this allocation is traced, program will jump to failure path
+ // (i.e. the allocation stub) which will allocate the object and trace the
+ // allocation call site.
+ MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump);
Heap* heap = Isolate::Current()->heap();
const intptr_t instance_size = cls.instance_size();
Heap::Space space = heap->SpaceForAllocation(cls.id());
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698