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

Unified Diff: src/a64/code-stubs-a64.cc

Issue 169683003: Second attempt at introducing a premonomorphic state in the call (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 6 years, 10 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 | « no previous file | src/arm/code-stubs-arm.cc » ('j') | src/runtime.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/a64/code-stubs-a64.cc
===================================================================
--- src/a64/code-stubs-a64.cc (revision 19412)
+++ src/a64/code-stubs-a64.cc (working copy)
@@ -3189,12 +3189,17 @@
// x1 : the function to call
// x2 : feedback vector
// x3 : slot in feedback vector (smi)
- Label initialize, done, miss, megamorphic, not_array_function;
+ Label check_array, initialize_array, initialize_non_array, megamorphic, done;
ASSERT_EQ(*TypeFeedbackInfo::MegamorphicSentinel(masm->isolate()),
masm->isolate()->heap()->undefined_value());
+ Heap::RootListIndex kMegamorphicRootIndex = Heap::kUndefinedValueRootIndex;
ASSERT_EQ(*TypeFeedbackInfo::UninitializedSentinel(masm->isolate()),
masm->isolate()->heap()->the_hole_value());
+ Heap::RootListIndex kUninitializedRootIndex = Heap::kTheHoleValueRootIndex;
+ ASSERT_EQ(*TypeFeedbackInfo::PremonomorphicSentinel(masm->isolate()),
+ masm->isolate()->heap()->null_value());
+ Heap::RootListIndex kPremonomorphicRootIndex = Heap::kNullValueRootIndex;
// Load the cache state.
__ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2));
@@ -3204,43 +3209,44 @@
// function without changing the state.
__ Cmp(x4, x1);
__ B(eq, &done);
+ __ JumpIfRoot(x4, kMegamorphicRootIndex, &done);
- // If we came here, we need to see if we are the array function.
- // If we didn't have a matching function, and we didn't find the megamorph
- // sentinel, then we have in the slot either some other function or an
- // AllocationSite. Do a map check on the object in ecx.
- __ Ldr(x5, FieldMemOperand(x4, AllocationSite::kMapOffset));
- __ JumpIfNotRoot(x5, Heap::kAllocationSiteMapRootIndex, &miss);
+ // Check if we're dealing with the Array function or not.
+ __ LoadArrayFunction(x5);
+ __ Cmp(x1, x5);
+ __ B(eq, &check_array);
- // Make sure the function is the Array() function
- __ LoadArrayFunction(x4);
- __ Cmp(x1, x4);
- __ B(ne, &megamorphic);
+ // Non-array cache: Check the cache state.
+ __ JumpIfRoot(x4, kPremonomorphicRootIndex, &initialize_non_array);
+ __ JumpIfNotRoot(x4, kUninitializedRootIndex, &megamorphic);
+
+ // Non-array cache: Uninitialized -> premonomorphic. The sentinel is an
+ // immortal immovable object (null) so no write-barrier is needed.
+ __ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2));
+ __ LoadRoot(x10, kPremonomorphicRootIndex);
+ __ Str(x10, FieldMemOperand(x4, FixedArray::kHeaderSize));
__ B(&done);
- __ Bind(&miss);
+ // Array cache: Check the cache state to see if we're in a monomorphic
+ // state where the state object is an AllocationSite object.
+ __ Bind(&check_array);
+ __ Ldr(x5, FieldMemOperand(x4, AllocationSite::kMapOffset));
+ __ JumpIfRoot(x5, Heap::kAllocationSiteMapRootIndex, &done);
- // A monomorphic miss (i.e, here the cache is not uninitialized) goes
- // megamorphic.
- __ JumpIfRoot(x4, Heap::kTheHoleValueRootIndex, &initialize);
- // MegamorphicSentinel is an immortal immovable object (undefined) so no
- // write-barrier is needed.
+ // Array cache: Uninitialized or premonomorphic -> monomorphic.
+ __ JumpIfRoot(x4, kUninitializedRootIndex, &initialize_array);
+ __ JumpIfRoot(x4, kPremonomorphicRootIndex, &initialize_array);
+
+ // Both caches: Monomorphic -> megamorphic. The sentinel is an
+ // immortal immovable object (undefined) so no write-barrier is needed.
__ Bind(&megamorphic);
__ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2));
- __ LoadRoot(x10, Heap::kUndefinedValueRootIndex);
+ __ LoadRoot(x10, kMegamorphicRootIndex);
__ Str(x10, FieldMemOperand(x4, FixedArray::kHeaderSize));
__ B(&done);
- // An uninitialized cache is patched with the function or sentinel to
- // indicate the ElementsKind if function is the Array constructor.
- __ Bind(&initialize);
- // Make sure the function is the Array() function
- __ LoadArrayFunction(x4);
- __ Cmp(x1, x4);
- __ B(ne, &not_array_function);
-
- // The target function is the Array constructor,
- // Create an AllocationSite if we don't already have it, store it in the slot.
+ // Array cache: Uninitialized or premonomorphic -> monomorphic.
+ __ Bind(&initialize_array);
{
FrameScope scope(masm, StackFrame::INTERNAL);
CreateAllocationSiteStub create_stub;
@@ -3256,9 +3262,8 @@
}
__ B(&done);
- __ Bind(&not_array_function);
- // An uninitialized cache is patched with the function.
-
+ // Non-array cache: Premonomorphic -> monomorphic.
+ __ Bind(&initialize_non_array);
__ Add(x4, x2, Operand::UntagSmiAndScale(x3, kPointerSizeLog2));
// TODO(all): Does the value need to be left in x4? If not, FieldMemOperand
// could be used to avoid this add.
@@ -3271,7 +3276,6 @@
__ Pop(x1, x2, x4);
// TODO(all): Are x4, x2 and x1 outputs? This isn't clear.
-
__ Bind(&done);
}
« no previous file with comments | « no previous file | src/arm/code-stubs-arm.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698