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

Unified Diff: src/interpreter/bytecode-array-builder.cc

Issue 2793923002: [Interpreter] Optimize code of the form 'if (x === undefined)'. (Closed)
Patch Set: Rebase Created 3 years, 9 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/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-array-writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-array-builder.cc
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
index 114850ad5e10fbd375174b9994a8c2ad825f9dec..615580baadb7ad481604417087c7dbfd11ee953b 100644
--- a/src/interpreter/bytecode-array-builder.cc
+++ b/src/interpreter/bytecode-array-builder.cc
@@ -389,6 +389,36 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CompareOperation(Token::Value op,
return *this;
}
+BytecodeArrayBuilder& BytecodeArrayBuilder::CompareUndetectable() {
+ OutputTestUndetectable();
+ return *this;
+}
+
+BytecodeArrayBuilder& BytecodeArrayBuilder::CompareUndefined() {
+ OutputTestUndefined();
+ return *this;
+}
+
+BytecodeArrayBuilder& BytecodeArrayBuilder::CompareNull() {
+ OutputTestNull();
+ return *this;
+}
+
+BytecodeArrayBuilder& BytecodeArrayBuilder::CompareNil(Token::Value op,
+ NilValue nil) {
+ if (op == Token::EQ) {
+ return CompareUndetectable();
+ } else {
+ DCHECK_EQ(Token::EQ_STRICT, op);
+ if (nil == kUndefinedValue) {
+ return CompareUndefined();
+ } else {
+ DCHECK_EQ(kNullValue, nil);
+ return CompareNull();
+ }
+ }
+}
+
BytecodeArrayBuilder& BytecodeArrayBuilder::CompareTypeOf(
TestTypeOfFlags::LiteralFlag literal_flag) {
DCHECK(literal_flag != TestTypeOfFlags::LiteralFlag::kOther);
@@ -885,6 +915,13 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNull(BytecodeLabel* label) {
return *this;
}
+BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotNull(
+ BytecodeLabel* label) {
+ DCHECK(!label->is_bound());
+ OutputJumpIfNotNull(label, 0);
+ return *this;
+}
+
BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfUndefined(
BytecodeLabel* label) {
DCHECK(!label->is_bound());
@@ -892,6 +929,47 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfUndefined(
return *this;
}
+BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotUndefined(
+ BytecodeLabel* label) {
+ DCHECK(!label->is_bound());
+ OutputJumpIfNotUndefined(label, 0);
+ return *this;
+}
+
+BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNil(BytecodeLabel* label,
+ Token::Value op,
+ NilValue nil) {
+ if (op == Token::EQ) {
+ // TODO(rmcilroy): Implement JumpIfUndetectable.
+ return CompareUndetectable().JumpIfTrue(label);
+ } else {
+ DCHECK_EQ(Token::EQ_STRICT, op);
+ if (nil == kUndefinedValue) {
+ return JumpIfUndefined(label);
+ } else {
+ DCHECK_EQ(kNullValue, nil);
+ return JumpIfNull(label);
+ }
+ }
+}
+
+BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotNil(BytecodeLabel* label,
+ Token::Value op,
+ NilValue nil) {
+ if (op == Token::EQ) {
+ // TODO(rmcilroy): Implement JumpIfUndetectable.
+ return CompareUndetectable().JumpIfFalse(label);
+ } else {
+ DCHECK_EQ(Token::EQ_STRICT, op);
+ if (nil == kUndefinedValue) {
+ return JumpIfNotUndefined(label);
+ } else {
+ DCHECK_EQ(kNullValue, nil);
+ return JumpIfNotNull(label);
+ }
+ }
+}
+
BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole(
BytecodeLabel* label) {
DCHECK(!label->is_bound());
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-array-writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698