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

Unified Diff: src/code-stub-assembler.cc

Issue 2370693002: [compiler] Properly guard the speculative optimizations for instanceof. (Closed)
Patch Set: Fix registers on arm/arm64. Created 4 years, 3 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/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 4e1c4a44f701bc3e879f1788334428e5a578402d..18b4e5ff83968d9f80ff6808e0ea4f09943fa501 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -3886,7 +3886,8 @@ void CodeStubAssembler::TryPrototypeChainLookup(
}
Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable,
- Node* object) {
+ Node* object,
+ VectorSlotPair feedback) {
Variable var_result(this, MachineRepresentation::kTagged);
Label return_false(this), return_true(this),
return_runtime(this, Label::kDeferred), return_result(this);
@@ -4011,6 +4012,17 @@ Node* CodeStubAssembler::OrdinaryHasInstance(Node* context, Node* callable,
{
// Invalidate the global instanceof cache.
StoreRoot(Heap::kInstanceofCacheFunctionRootIndex, SmiConstant(0));
+
+ // Record megamorphic {feedback} if requested; we use this feedback to
+ // guard a bunch of speculative optimizations in TurboFand (and Crankshaft)
+ // that just deoptimize in case of funny inputs to instanceof.
+ if (feedback.IsValid()) {
+ Node* megamorphic_sentinel =
+ HeapConstant(TypeFeedbackVector::MegamorphicSentinel(isolate()));
+ StoreFixedArrayElement(feedback.vector(), feedback.index(),
+ megamorphic_sentinel, SKIP_WRITE_BARRIER);
+ }
+
// Fallback to the runtime implementation.
var_result.Bind(
CallRuntime(Runtime::kOrdinaryHasInstance, context, callable, object));
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698