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

Unified Diff: src/code-stubs.cc

Issue 1980483003: [es6] Reintroduce the instanceof operator in the backends. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Igors comments. Created 4 years, 7 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-stubs.h ('k') | src/compiler/ast-graph-builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 4834e70ed9544a96cf855da4987f552938ced426..a82167924fddd1c42e7e8e1d597ac69326857d50 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -1759,6 +1759,43 @@ void DecStub::GenerateAssembly(CodeStubAssembler* assembler) const {
}
}
+void InstanceOfStub::GenerateAssembly(CodeStubAssembler* assembler) const {
+ typedef CodeStubAssembler::Label Label;
+ typedef compiler::Node Node;
+
+ Node* object = assembler->Parameter(0);
+ Node* callable = assembler->Parameter(1);
+ Node* context = assembler->Parameter(2);
+
+ Label return_runtime(assembler, Label::kDeferred);
+
+ // Check if no one installed @@hasInstance somewhere.
+ assembler->GotoUnless(
+ assembler->WordEqual(
+ assembler->LoadObjectField(
+ assembler->LoadRoot(Heap::kHasInstanceProtectorRootIndex),
+ PropertyCell::kValueOffset),
+ assembler->SmiConstant(Smi::FromInt(Isolate::kArrayProtectorValid))),
+ &return_runtime);
+
+ // Check if {callable} is a valid receiver.
+ assembler->GotoIf(assembler->WordIsSmi(callable), &return_runtime);
+ assembler->GotoIf(
+ assembler->Word32Equal(
+ assembler->Word32And(
+ assembler->LoadMapBitField(assembler->LoadMap(callable)),
+ assembler->Int32Constant(1 << Map::kIsCallable)),
+ assembler->Int32Constant(0)),
+ &return_runtime);
+
+ // Use the inline OrdinaryHasInstance directly.
+ assembler->Return(assembler->OrdinaryHasInstance(context, callable, object));
+
+ // TODO(bmeurer): Use GetPropertyStub here once available.
+ assembler->Bind(&return_runtime);
+ assembler->TailCallRuntime(Runtime::kInstanceOf, context, object, callable);
+}
+
namespace {
enum RelationalComparisonMode {
« 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