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

Side by Side Diff: src/code-stubs.cc

Issue 2370693002: [compiler] Properly guard the speculative optimizations for instanceof. (Closed)
Patch Set: Fix registers on arm/arm64. Created 4 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 unified diff | Download patch
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/ast-graph-builder.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2920 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 { 2931 {
2932 result.Bind(assembler->CallRuntime(Runtime::kInstanceOf, context, object, 2932 result.Bind(assembler->CallRuntime(Runtime::kInstanceOf, context, object,
2933 callable)); 2933 callable));
2934 assembler->Goto(&end); 2934 assembler->Goto(&end);
2935 } 2935 }
2936 2936
2937 assembler->Bind(&end); 2937 assembler->Bind(&end);
2938 return result.value(); 2938 return result.value();
2939 } 2939 }
2940 2940
2941 // static
2942 compiler::Node* InstanceOfWithFeedbackStub::Generate(
2943 CodeStubAssembler* assembler, compiler::Node* object,
2944 compiler::Node* callable, compiler::Node* slot_id,
2945 compiler::Node* type_feedback_vector, compiler::Node* context) {
2946 // TODO(bmeurer): Unify this with the InstanceOfStub above. This
2947 // stub itself can be removed once we get rid of fullcodegen.
2948 typedef CodeStubAssembler::Label Label;
2949 typedef compiler::Node Node;
2950 typedef CodeStubAssembler::Variable Variable;
2951
2952 Label return_runtime(assembler, Label::kDeferred), end(assembler);
2953 Variable result(assembler, MachineRepresentation::kTagged);
2954
2955 // Check if no one installed @@hasInstance somewhere.
2956 assembler->GotoUnless(
2957 assembler->WordEqual(
2958 assembler->LoadObjectField(
2959 assembler->LoadRoot(Heap::kHasInstanceProtectorRootIndex),
2960 PropertyCell::kValueOffset),
2961 assembler->SmiConstant(Smi::FromInt(Isolate::kArrayProtectorValid))),
2962 &return_runtime);
2963
2964 // Check if {callable} is a valid receiver.
2965 assembler->GotoIf(assembler->WordIsSmi(callable), &return_runtime);
2966 assembler->GotoIf(
2967 assembler->Word32Equal(
2968 assembler->Word32And(
2969 assembler->LoadMapBitField(assembler->LoadMap(callable)),
2970 assembler->Int32Constant(1 << Map::kIsCallable)),
2971 assembler->Int32Constant(0)),
2972 &return_runtime);
2973
2974 // Use the inline OrdinaryHasInstance directly.
2975 CodeStubAssembler::VectorSlotPair feedback(type_feedback_vector, slot_id);
2976 result.Bind(
2977 assembler->OrdinaryHasInstance(context, callable, object, feedback));
2978 assembler->Goto(&end);
2979
2980 assembler->Bind(&return_runtime);
2981 {
2982 // Record megamorphic here; we use this feedback to guard a bunch of
2983 // speculative optimizations in TurboFand (and Crankshaft) that just
2984 // deoptimize in case of funny inputs to instanceof.
2985 Node* megamorphic_sentinel = assembler->HeapConstant(
2986 TypeFeedbackVector::MegamorphicSentinel(assembler->isolate()));
2987 assembler->StoreFixedArrayElement(type_feedback_vector, slot_id,
2988 megamorphic_sentinel, SKIP_WRITE_BARRIER);
2989
2990 // Fallback to the %InstanceOf runtime implementation for now, which
2991 // can deal with @@hasInstance and friends.
2992 // TODO(bmeurer): Use GetPropertyStub here once available.
2993 result.Bind(assembler->CallRuntime(Runtime::kInstanceOf, context, object,
2994 callable));
2995 assembler->Goto(&end);
2996 }
2997
2998 assembler->Bind(&end);
2999 return result.value();
3000 }
3001
2941 namespace { 3002 namespace {
2942 3003
2943 enum RelationalComparisonMode { 3004 enum RelationalComparisonMode {
2944 kLessThan, 3005 kLessThan,
2945 kLessThanOrEqual, 3006 kLessThanOrEqual,
2946 kGreaterThan, 3007 kGreaterThan,
2947 kGreaterThanOrEqual 3008 kGreaterThanOrEqual
2948 }; 3009 };
2949 3010
2950 compiler::Node* GenerateAbstractRelationalComparison( 3011 compiler::Node* GenerateAbstractRelationalComparison(
(...skipping 3310 matching lines...) Expand 10 before | Expand all | Expand 10 after
6261 6322
6262 if (type == MachineType::Pointer()) { 6323 if (type == MachineType::Pointer()) {
6263 return Representation::External(); 6324 return Representation::External();
6264 } 6325 }
6265 6326
6266 return Representation::Tagged(); 6327 return Representation::Tagged();
6267 } 6328 }
6268 6329
6269 } // namespace internal 6330 } // namespace internal
6270 } // namespace v8 6331 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698