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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2893263002: [turbofan] Add Symbol feedback to Equal/StrictEqual. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/compiler/effect-control-linearizer.h » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 3265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3276 Node* CodeStubAssembler::IsName(Node* object) { 3276 Node* CodeStubAssembler::IsName(Node* object) {
3277 return Int32LessThanOrEqual(LoadInstanceType(object), 3277 return Int32LessThanOrEqual(LoadInstanceType(object),
3278 Int32Constant(LAST_NAME_TYPE)); 3278 Int32Constant(LAST_NAME_TYPE));
3279 } 3279 }
3280 3280
3281 Node* CodeStubAssembler::IsString(Node* object) { 3281 Node* CodeStubAssembler::IsString(Node* object) {
3282 return Int32LessThan(LoadInstanceType(object), 3282 return Int32LessThan(LoadInstanceType(object),
3283 Int32Constant(FIRST_NONSTRING_TYPE)); 3283 Int32Constant(FIRST_NONSTRING_TYPE));
3284 } 3284 }
3285 3285
3286 Node* CodeStubAssembler::IsSymbolInstanceType(Node* instance_type) {
3287 return Word32Equal(instance_type, Int32Constant(SYMBOL_TYPE));
3288 }
3289
3286 Node* CodeStubAssembler::IsSymbol(Node* object) { 3290 Node* CodeStubAssembler::IsSymbol(Node* object) {
3287 return IsSymbolMap(LoadMap(object)); 3291 return IsSymbolMap(LoadMap(object));
3288 } 3292 }
3289 3293
3290 Node* CodeStubAssembler::IsPrivateSymbol(Node* object) { 3294 Node* CodeStubAssembler::IsPrivateSymbol(Node* object) {
3291 return Select( 3295 return Select(
3292 IsSymbol(object), 3296 IsSymbol(object),
3293 [=] { 3297 [=] {
3294 Node* const flags = 3298 Node* const flags =
3295 SmiToWord32(LoadObjectField(object, Symbol::kFlagsOffset)); 3299 SmiToWord32(LoadObjectField(object, Symbol::kFlagsOffset));
(...skipping 4131 matching lines...) Expand 10 before | Expand all | Expand 10 after
7427 7431
7428 // Check if the HeapNumber value is a NaN. 7432 // Check if the HeapNumber value is a NaN.
7429 BranchIfFloat64IsNaN(value_value, if_notequal, if_equal); 7433 BranchIfFloat64IsNaN(value_value, if_notequal, if_equal);
7430 } 7434 }
7431 7435
7432 BIND(&if_valueisnotnumber); 7436 BIND(&if_valueisnotnumber);
7433 if (var_type_feedback != nullptr) { 7437 if (var_type_feedback != nullptr) {
7434 // Collect type feedback. 7438 // Collect type feedback.
7435 Node* instance_type = LoadMapInstanceType(value_map); 7439 Node* instance_type = LoadMapInstanceType(value_map);
7436 7440
7437 Label if_valueisstring(this), if_valueisnotstring(this); 7441 Label if_valueisstring(this), if_valueisreceiver(this),
7438 Branch(IsStringInstanceType(instance_type), &if_valueisstring, 7442 if_valueissymbol(this), if_valueisother(this, Label::kDeferred);
7439 &if_valueisnotstring); 7443 GotoIf(IsStringInstanceType(instance_type), &if_valueisstring);
7444 GotoIf(IsJSReceiverInstanceType(instance_type), &if_valueisreceiver);
7445 Branch(IsSymbolInstanceType(instance_type), &if_valueissymbol,
7446 &if_valueisother);
7440 7447
7441 BIND(&if_valueisstring); 7448 BIND(&if_valueisstring);
7442 { 7449 {
7443 CombineFeedback(var_type_feedback, 7450 CombineFeedback(var_type_feedback,
7444 CollectFeedbackForString(instance_type)); 7451 CollectFeedbackForString(instance_type));
7445 Goto(if_equal); 7452 Goto(if_equal);
7446 } 7453 }
7447 7454
7448 BIND(&if_valueisnotstring); 7455 BIND(&if_valueissymbol);
7449 { 7456 {
7450 var_type_feedback->Bind(SmiConstant(CompareOperationFeedback::kAny)); 7457 CombineFeedback(var_type_feedback,
7451 GotoIfNot(IsJSReceiverInstanceType(instance_type), if_equal); 7458 SmiConstant(CompareOperationFeedback::kSymbol));
7459 Goto(if_equal);
7460 }
7452 7461
7462 BIND(&if_valueisreceiver);
7463 {
7453 CombineFeedback(var_type_feedback, 7464 CombineFeedback(var_type_feedback,
7454 SmiConstant(CompareOperationFeedback::kReceiver)); 7465 SmiConstant(CompareOperationFeedback::kReceiver));
7455 Goto(if_equal); 7466 Goto(if_equal);
7456 } 7467 }
7468
7469 BIND(&if_valueisother);
7470 {
7471 CombineFeedback(var_type_feedback,
7472 SmiConstant(CompareOperationFeedback::kAny));
7473 Goto(if_equal);
7474 }
7457 } else { 7475 } else {
7458 Goto(if_equal); 7476 Goto(if_equal);
7459 } 7477 }
7460 } 7478 }
7461 7479
7462 BIND(&if_valueissmi); 7480 BIND(&if_valueissmi);
7463 if (var_type_feedback != nullptr) { 7481 if (var_type_feedback != nullptr) {
7464 CombineFeedback(var_type_feedback, 7482 CombineFeedback(var_type_feedback,
7465 SmiConstant(CompareOperationFeedback::kSignedSmall)); 7483 SmiConstant(CompareOperationFeedback::kSignedSmall));
7466 } 7484 }
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
7844 Branch(Word32Equal( 7862 Branch(Word32Equal(
7845 Word32And(rhs_bitfield, 7863 Word32And(rhs_bitfield,
7846 Int32Constant(1 << Map::kIsUndetectable)), 7864 Int32Constant(1 << Map::kIsUndetectable)),
7847 Int32Constant(0)), 7865 Int32Constant(0)),
7848 &if_notequal, &if_equal); 7866 &if_notequal, &if_equal);
7849 } 7867 }
7850 } 7868 }
7851 7869
7852 BIND(&if_lhsissymbol); 7870 BIND(&if_lhsissymbol);
7853 { 7871 {
7854 if (var_type_feedback != nullptr) {
7855 var_type_feedback->Bind(
7856 SmiConstant(CompareOperationFeedback::kAny));
7857 }
7858
7859 // Check if the {rhs} is a JSReceiver. 7872 // Check if the {rhs} is a JSReceiver.
7860 Label if_rhsisreceiver(this), if_rhsisnotreceiver(this); 7873 Label if_rhsisreceiver(this), if_rhsisnotreceiver(this);
7861 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
7862 Branch(IsJSReceiverInstanceType(rhs_instance_type), 7874 Branch(IsJSReceiverInstanceType(rhs_instance_type),
7863 &if_rhsisreceiver, &if_rhsisnotreceiver); 7875 &if_rhsisreceiver, &if_rhsisnotreceiver);
7864 7876
7865 BIND(&if_rhsisreceiver); 7877 BIND(&if_rhsisreceiver);
7866 { 7878 {
7867 // The {lhs} is a Primitive and the {rhs} is a JSReceiver. 7879 // The {lhs} is a Primitive and the {rhs} is a JSReceiver.
7868 // Swapping {lhs} and {rhs} is not observable and doesn't 7880 // Swapping {lhs} and {rhs} is not observable and doesn't
7869 // matter for the result, so we can just swap them and use 7881 // matter for the result, so we can just swap them and use
7870 // the JSReceiver handling below (for {lhs} being a JSReceiver). 7882 // the JSReceiver handling below (for {lhs} being a JSReceiver).
7883 if (var_type_feedback != nullptr) {
7884 var_type_feedback->Bind(
7885 SmiConstant(CompareOperationFeedback::kAny));
7886 }
7871 var_lhs.Bind(rhs); 7887 var_lhs.Bind(rhs);
7872 var_rhs.Bind(lhs); 7888 var_rhs.Bind(lhs);
7873 Goto(&loop); 7889 Goto(&loop);
7874 } 7890 }
7875 7891
7876 BIND(&if_rhsisnotreceiver); 7892 BIND(&if_rhsisnotreceiver);
7877 { 7893 {
7878 // The {rhs} is not a JSReceiver and also not the same Symbol 7894 // The {rhs} is not a JSReceiver and also not the same Symbol
7879 // as the {lhs}, so this is equality check is considered false. 7895 // as the {lhs}, so this is equality check is considered false.
7880 Goto(&if_notequal); 7896 if (var_type_feedback != nullptr) {
7897 Label if_rhsissymbol(this), if_rhsisnotsymbol(this);
7898 Branch(IsSymbolInstanceType(rhs_instance_type), &if_rhsissymbol,
7899 &if_rhsisnotsymbol);
7900
7901 BIND(&if_rhsissymbol);
7902 {
7903 var_type_feedback->Bind(
7904 SmiConstant(CompareOperationFeedback::kSymbol));
7905 Goto(&if_notequal);
7906 }
7907
7908 BIND(&if_rhsisnotsymbol);
7909 {
7910 var_type_feedback->Bind(
7911 SmiConstant(CompareOperationFeedback::kAny));
7912 Goto(&if_notequal);
7913 }
7914 } else {
7915 Goto(&if_notequal);
7916 }
7881 } 7917 }
7882 } 7918 }
7883 7919
7884 BIND(&if_lhsisreceiver); 7920 BIND(&if_lhsisreceiver);
7885 { 7921 {
7886 // Check if the {rhs} is also a JSReceiver. 7922 // Check if the {rhs} is also a JSReceiver.
7887 Label if_rhsisreceiver(this), if_rhsisnotreceiver(this); 7923 Label if_rhsisreceiver(this), if_rhsisnotreceiver(this);
7888 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE); 7924 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
7889 Branch(IsJSReceiverInstanceType(rhs_instance_type), 7925 Branch(IsJSReceiverInstanceType(rhs_instance_type),
7890 &if_rhsisreceiver, &if_rhsisnotreceiver); 7926 &if_rhsisreceiver, &if_rhsisnotreceiver);
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
8160 result.Bind(CallStub(callable, NoContextConstant(), lhs, rhs)); 8196 result.Bind(CallStub(callable, NoContextConstant(), lhs, rhs));
8161 Goto(&end); 8197 Goto(&end);
8162 } 8198 }
8163 8199
8164 BIND(&if_rhsisnotstring); 8200 BIND(&if_rhsisnotstring);
8165 Goto(&if_notequal); 8201 Goto(&if_notequal);
8166 } 8202 }
8167 8203
8168 BIND(&if_lhsisnotstring); 8204 BIND(&if_lhsisnotstring);
8169 if (var_type_feedback != nullptr) { 8205 if (var_type_feedback != nullptr) {
8170 GotoIfNot(IsJSReceiverInstanceType(lhs_instance_type), 8206 Label if_lhsissymbol(this), if_lhsisreceiver(this);
8171 &if_notequal); 8207 GotoIf(IsJSReceiverInstanceType(lhs_instance_type),
8172 GotoIfNot(IsJSReceiverInstanceType(rhs_instance_type), 8208 &if_lhsisreceiver);
8173 &if_notequal); 8209 Branch(IsSymbolInstanceType(lhs_instance_type), &if_lhsissymbol,
8174 var_type_feedback->Bind( 8210 &if_notequal);
8175 SmiConstant(CompareOperationFeedback::kReceiver)); 8211
8212 BIND(&if_lhsisreceiver);
8213 {
8214 GotoIfNot(IsJSReceiverInstanceType(rhs_instance_type),
8215 &if_notequal);
8216 var_type_feedback->Bind(
8217 SmiConstant(CompareOperationFeedback::kReceiver));
8218 Goto(&if_notequal);
8219 }
8220
8221 BIND(&if_lhsissymbol);
8222 {
8223 GotoIfNot(IsSymbolInstanceType(rhs_instance_type), &if_notequal);
8224 var_type_feedback->Bind(
8225 SmiConstant(CompareOperationFeedback::kSymbol));
8226 Goto(&if_notequal);
8227 }
8228 } else {
8229 Goto(&if_notequal);
8176 } 8230 }
8177 Goto(&if_notequal);
8178 } 8231 }
8179 } 8232 }
8180 } 8233 }
8181 8234
8182 BIND(&if_lhsissmi); 8235 BIND(&if_lhsissmi);
8183 { 8236 {
8184 // We already know that {lhs} and {rhs} are not reference equal, and {lhs} 8237 // We already know that {lhs} and {rhs} are not reference equal, and {lhs}
8185 // is a Smi; so {lhs} and {rhs} can only be strictly equal if {rhs} is a 8238 // is a Smi; so {lhs} and {rhs} can only be strictly equal if {rhs} is a
8186 // HeapNumber with an equal floating point value. 8239 // HeapNumber with an equal floating point value.
8187 8240
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
9191 formatted.c_str(), TENURED); 9244 formatted.c_str(), TENURED);
9192 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), 9245 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(),
9193 HeapConstant(string)); 9246 HeapConstant(string));
9194 } 9247 }
9195 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); 9248 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value);
9196 #endif 9249 #endif
9197 } 9250 }
9198 9251
9199 } // namespace internal 9252 } // namespace internal
9200 } // namespace v8 9253 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/compiler/effect-control-linearizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698