OLD | NEW |
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 7232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7243 Bind(&if_notequal); | 7243 Bind(&if_notequal); |
7244 { | 7244 { |
7245 result.Bind(FalseConstant()); | 7245 result.Bind(FalseConstant()); |
7246 Goto(&end); | 7246 Goto(&end); |
7247 } | 7247 } |
7248 | 7248 |
7249 Bind(&end); | 7249 Bind(&end); |
7250 return result.value(); | 7250 return result.value(); |
7251 } | 7251 } |
7252 | 7252 |
7253 Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs, Node* context) { | 7253 Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs) { |
7254 // Here's pseudo-code for the algorithm below in case of kDontNegateResult | 7254 // Here's pseudo-code for the algorithm below in case of kDontNegateResult |
7255 // mode; for kNegateResult mode we properly negate the result. | 7255 // mode; for kNegateResult mode we properly negate the result. |
7256 // | 7256 // |
7257 // if (lhs == rhs) { | 7257 // if (lhs == rhs) { |
7258 // if (lhs->IsHeapNumber()) return HeapNumber::cast(lhs)->value() != NaN; | 7258 // if (lhs->IsHeapNumber()) return HeapNumber::cast(lhs)->value() != NaN; |
7259 // return true; | 7259 // return true; |
7260 // } | 7260 // } |
7261 // if (!lhs->IsSmi()) { | 7261 // if (!lhs->IsSmi()) { |
7262 // if (lhs->IsHeapNumber()) { | 7262 // if (lhs->IsHeapNumber()) { |
7263 // if (rhs->IsSmi()) { | 7263 // if (rhs->IsSmi()) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7393 | 7393 |
7394 // Check if {rhs} is also a String. | 7394 // Check if {rhs} is also a String. |
7395 Label if_rhsisstring(this, Label::kDeferred), | 7395 Label if_rhsisstring(this, Label::kDeferred), |
7396 if_rhsisnotstring(this); | 7396 if_rhsisnotstring(this); |
7397 Branch(IsStringInstanceType(rhs_instance_type), &if_rhsisstring, | 7397 Branch(IsStringInstanceType(rhs_instance_type), &if_rhsisstring, |
7398 &if_rhsisnotstring); | 7398 &if_rhsisnotstring); |
7399 | 7399 |
7400 Bind(&if_rhsisstring); | 7400 Bind(&if_rhsisstring); |
7401 { | 7401 { |
7402 Callable callable = CodeFactory::StringEqual(isolate()); | 7402 Callable callable = CodeFactory::StringEqual(isolate()); |
7403 result.Bind(CallStub(callable, context, lhs, rhs)); | 7403 result.Bind(CallStub(callable, NoContextConstant(), lhs, rhs)); |
7404 Goto(&end); | 7404 Goto(&end); |
7405 } | 7405 } |
7406 | 7406 |
7407 Bind(&if_rhsisnotstring); | 7407 Bind(&if_rhsisnotstring); |
7408 Goto(&if_notequal); | 7408 Goto(&if_notequal); |
7409 } | 7409 } |
7410 | 7410 |
7411 Bind(&if_lhsisnotstring); | 7411 Bind(&if_lhsisnotstring); |
7412 Goto(&if_notequal); | 7412 Goto(&if_notequal); |
7413 } | 7413 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7464 Goto(&end); | 7464 Goto(&end); |
7465 } | 7465 } |
7466 | 7466 |
7467 Bind(&end); | 7467 Bind(&end); |
7468 return result.value(); | 7468 return result.value(); |
7469 } | 7469 } |
7470 | 7470 |
7471 // ECMA#sec-samevalue | 7471 // ECMA#sec-samevalue |
7472 // This algorithm differs from the Strict Equality Comparison Algorithm in its | 7472 // This algorithm differs from the Strict Equality Comparison Algorithm in its |
7473 // treatment of signed zeroes and NaNs. | 7473 // treatment of signed zeroes and NaNs. |
7474 Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs, Node* context) { | 7474 Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs) { |
7475 Variable var_result(this, MachineRepresentation::kWord32); | 7475 Variable var_result(this, MachineRepresentation::kWord32); |
7476 Label strict_equal(this), out(this); | 7476 Label strict_equal(this), out(this); |
7477 | 7477 |
7478 Node* const int_false = Int32Constant(0); | 7478 Node* const int_false = Int32Constant(0); |
7479 Node* const int_true = Int32Constant(1); | 7479 Node* const int_true = Int32Constant(1); |
7480 | 7480 |
7481 Label if_equal(this), if_notequal(this); | 7481 Label if_equal(this), if_notequal(this); |
7482 Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal); | 7482 Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal); |
7483 | 7483 |
7484 Bind(&if_equal); | 7484 Bind(&if_equal); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7538 Bind(&if_floatnotequal); | 7538 Bind(&if_floatnotequal); |
7539 { | 7539 { |
7540 var_result.Bind(int_false); | 7540 var_result.Bind(int_false); |
7541 Goto(&out); | 7541 Goto(&out); |
7542 } | 7542 } |
7543 } | 7543 } |
7544 } | 7544 } |
7545 | 7545 |
7546 Bind(&strict_equal); | 7546 Bind(&strict_equal); |
7547 { | 7547 { |
7548 Node* const is_equal = StrictEqual(lhs, rhs, context); | 7548 Node* const is_equal = StrictEqual(lhs, rhs); |
7549 Node* const result = WordEqual(is_equal, TrueConstant()); | 7549 Node* const result = WordEqual(is_equal, TrueConstant()); |
7550 var_result.Bind(result); | 7550 var_result.Bind(result); |
7551 Goto(&out); | 7551 Goto(&out); |
7552 } | 7552 } |
7553 | 7553 |
7554 Bind(&out); | 7554 Bind(&out); |
7555 return var_result.value(); | 7555 return var_result.value(); |
7556 } | 7556 } |
7557 | 7557 |
7558 Node* CodeStubAssembler::HasProperty( | 7558 Node* CodeStubAssembler::HasProperty( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7649 Goto(&return_result); | 7649 Goto(&return_result); |
7650 | 7650 |
7651 Bind(&if_primitive); | 7651 Bind(&if_primitive); |
7652 var_result.Bind(NullConstant()); | 7652 var_result.Bind(NullConstant()); |
7653 Goto(&return_result); | 7653 Goto(&return_result); |
7654 | 7654 |
7655 Bind(&return_result); | 7655 Bind(&return_result); |
7656 return var_result.value(); | 7656 return var_result.value(); |
7657 } | 7657 } |
7658 | 7658 |
7659 Node* CodeStubAssembler::Typeof(Node* value, Node* context) { | 7659 Node* CodeStubAssembler::Typeof(Node* value) { |
7660 Variable result_var(this, MachineRepresentation::kTagged); | 7660 Variable result_var(this, MachineRepresentation::kTagged); |
7661 | 7661 |
7662 Label return_number(this, Label::kDeferred), if_oddball(this), | 7662 Label return_number(this, Label::kDeferred), if_oddball(this), |
7663 return_function(this), return_undefined(this), return_object(this), | 7663 return_function(this), return_undefined(this), return_object(this), |
7664 return_string(this), return_result(this); | 7664 return_string(this), return_result(this); |
7665 | 7665 |
7666 GotoIf(TaggedIsSmi(value), &return_number); | 7666 GotoIf(TaggedIsSmi(value), &return_number); |
7667 | 7667 |
7668 Node* map = LoadMap(value); | 7668 Node* map = LoadMap(value); |
7669 | 7669 |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8312 formatted.c_str(), TENURED); | 8312 formatted.c_str(), TENURED); |
8313 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), | 8313 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), |
8314 HeapConstant(string)); | 8314 HeapConstant(string)); |
8315 } | 8315 } |
8316 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); | 8316 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); |
8317 #endif | 8317 #endif |
8318 } | 8318 } |
8319 | 8319 |
8320 } // namespace internal | 8320 } // namespace internal |
8321 } // namespace v8 | 8321 } // namespace v8 |
OLD | NEW |