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

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

Issue 2658253002: [csa] Add IsIntPtrOrSmiConstantZero to detect and optimize constant zero values (Closed)
Patch Set: Created 3 years, 11 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') | no next file » | 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 5537d0a9b0f3412325cf5f315344b6cd74269bda..952525e00c0059860732b5d7cb7a405071bef3b2 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -171,6 +171,16 @@ Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) {
}
}
+bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(Node* test) {
+ int32_t constant_test;
+ Smi* smi_test;
+ if ((ToInt32Constant(test, constant_test) && constant_test == 0) ||
+ (ToSmiConstant(test, smi_test) && smi_test->value() == 0)) {
+ return true;
+ }
+ return false;
+}
+
Node* CodeStubAssembler::IntPtrRoundUpToPowerOfTwo32(Node* value) {
Comment("IntPtrRoundUpToPowerOfTwo32");
CSA_ASSERT(this, UintPtrLessThanOrEqual(value, IntPtrConstant(0x80000000u)));
@@ -2062,8 +2072,7 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
Node* allocation_site,
ParameterMode capacity_mode) {
Node *array = nullptr, *elements = nullptr;
- int32_t constant_capacity;
- if (ToInt32Constant(capacity, constant_capacity) && constant_capacity == 0) {
+ if (IsIntPtrOrSmiConstantZero(capacity)) {
// Array is empty. Use the shared empty fixed array instead of allocating a
// new one.
array = AllocateUninitializedJSArrayWithoutElements(kind, array_map, length,
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698