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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 1130283002: [strong] Disallow implicit conversions for comparison (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback Created 5 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/ic/ic.cc ('k') | src/mips/full-codegen-mips.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( 87 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor(
88 CodeStubDescriptor* descriptor) { 88 CodeStubDescriptor* descriptor) {
89 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); 89 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1);
90 } 90 }
91 91
92 92
93 #define __ ACCESS_MASM(masm) 93 #define __ ACCESS_MASM(masm)
94 94
95 95
96 static void EmitIdenticalObjectComparison(MacroAssembler* masm, 96 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
97 Label* slow, 97 Condition cc, bool strong);
98 Condition cc);
99 static void EmitSmiNonsmiComparison(MacroAssembler* masm, 98 static void EmitSmiNonsmiComparison(MacroAssembler* masm,
100 Register lhs, 99 Register lhs,
101 Register rhs, 100 Register rhs,
102 Label* rhs_not_nan, 101 Label* rhs_not_nan,
103 Label* slow, 102 Label* slow,
104 bool strict); 103 bool strict);
105 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, 104 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm,
106 Register lhs, 105 Register lhs,
107 Register rhs); 106 Register rhs);
108 107
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 __ bind(&done); 268 __ bind(&done);
270 269
271 __ Pop(scratch, scratch2, scratch3); 270 __ Pop(scratch, scratch2, scratch3);
272 __ Ret(); 271 __ Ret();
273 } 272 }
274 273
275 274
276 // Handle the case where the lhs and rhs are the same object. 275 // Handle the case where the lhs and rhs are the same object.
277 // Equality is almost reflexive (everything but NaN), so this is a test 276 // Equality is almost reflexive (everything but NaN), so this is a test
278 // for "identity and not NaN". 277 // for "identity and not NaN".
279 static void EmitIdenticalObjectComparison(MacroAssembler* masm, 278 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
280 Label* slow, 279 Condition cc, bool strong) {
281 Condition cc) {
282 Label not_identical; 280 Label not_identical;
283 Label heap_number, return_equal; 281 Label heap_number, return_equal;
284 Register exp_mask_reg = t5; 282 Register exp_mask_reg = t5;
285 283
286 __ Branch(&not_identical, ne, a0, Operand(a1)); 284 __ Branch(&not_identical, ne, a0, Operand(a1));
287 285
288 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); 286 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask));
289 287
290 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), 288 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(),
291 // so we do the second best thing - test it ourselves. 289 // so we do the second best thing - test it ourselves.
292 // They are both equal and they are not both Smis so both of them are not 290 // They are both equal and they are not both Smis so both of them are not
293 // Smis. If it's not a heap number, then return equal. 291 // Smis. If it's not a heap number, then return equal.
294 __ GetObjectType(a0, t4, t4); 292 __ GetObjectType(a0, t4, t4);
295 if (cc == less || cc == greater) { 293 if (cc == less || cc == greater) {
294 // Call runtime on identical JSObjects.
296 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE)); 295 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE));
296 // Call runtime on identical symbols since we need to throw a TypeError.
297 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE)); 297 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE));
298 if (strong) {
299 // Call the runtime on anything that is converted in the semantics, since
300 // we need to throw a TypeError. Smis have already been ruled out.
301 __ Branch(&return_equal, eq, t4, Operand(HEAP_NUMBER_TYPE));
302 __ And(t4, t4, Operand(kIsNotStringMask));
303 __ Branch(slow, ne, t4, Operand(zero_reg));
304 }
298 } else { 305 } else {
299 __ Branch(&heap_number, eq, t4, Operand(HEAP_NUMBER_TYPE)); 306 __ Branch(&heap_number, eq, t4, Operand(HEAP_NUMBER_TYPE));
300 // Comparing JS objects with <=, >= is complicated. 307 // Comparing JS objects with <=, >= is complicated.
301 if (cc != eq) { 308 if (cc != eq) {
302 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE)); 309 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE));
310 // Call runtime on identical symbols since we need to throw a TypeError.
303 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE)); 311 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE));
312 if (strong) {
313 // Call the runtime on anything that is converted in the semantics,
314 // since we need to throw a TypeError. Smis and heap numbers have
315 // already been ruled out.
316 __ And(t4, t4, Operand(kIsNotStringMask));
317 __ Branch(slow, ne, t4, Operand(zero_reg));
318 }
304 // Normally here we fall through to return_equal, but undefined is 319 // Normally here we fall through to return_equal, but undefined is
305 // special: (undefined == undefined) == true, but 320 // special: (undefined == undefined) == true, but
306 // (undefined <= undefined) == false! See ECMAScript 11.8.5. 321 // (undefined <= undefined) == false! See ECMAScript 11.8.5.
307 if (cc == less_equal || cc == greater_equal) { 322 if (cc == less_equal || cc == greater_equal) {
308 __ Branch(&return_equal, ne, t4, Operand(ODDBALL_TYPE)); 323 __ Branch(&return_equal, ne, t4, Operand(ODDBALL_TYPE));
309 __ LoadRoot(t2, Heap::kUndefinedValueRootIndex); 324 __ LoadRoot(t2, Heap::kUndefinedValueRootIndex);
310 __ Branch(&return_equal, ne, a0, Operand(t2)); 325 __ Branch(&return_equal, ne, a0, Operand(t2));
311 DCHECK(is_int16(GREATER) && is_int16(LESS)); 326 DCHECK(is_int16(GREATER) && is_int16(LESS));
312 __ Ret(USE_DELAY_SLOT); 327 __ Ret(USE_DELAY_SLOT);
313 if (cc == le) { 328 if (cc == le) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 __ sra(a0, a0, 1); 593 __ sra(a0, a0, 1);
579 __ Ret(USE_DELAY_SLOT); 594 __ Ret(USE_DELAY_SLOT);
580 __ subu(v0, a1, a0); 595 __ subu(v0, a1, a0);
581 __ bind(&not_two_smis); 596 __ bind(&not_two_smis);
582 597
583 // NOTICE! This code is only reached after a smi-fast-case check, so 598 // NOTICE! This code is only reached after a smi-fast-case check, so
584 // it is certain that at least one operand isn't a smi. 599 // it is certain that at least one operand isn't a smi.
585 600
586 // Handle the case where the objects are identical. Either returns the answer 601 // Handle the case where the objects are identical. Either returns the answer
587 // or goes to slow. Only falls through if the objects were not identical. 602 // or goes to slow. Only falls through if the objects were not identical.
588 EmitIdenticalObjectComparison(masm, &slow, cc); 603 EmitIdenticalObjectComparison(masm, &slow, cc, strong());
589 604
590 // If either is a Smi (we know that not both are), then they can only 605 // If either is a Smi (we know that not both are), then they can only
591 // be strictly equal if the other is a HeapNumber. 606 // be strictly equal if the other is a HeapNumber.
592 STATIC_ASSERT(kSmiTag == 0); 607 STATIC_ASSERT(kSmiTag == 0);
593 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); 608 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0));
594 __ And(t2, lhs, Operand(rhs)); 609 __ And(t2, lhs, Operand(rhs));
595 __ JumpIfNotSmi(t2, &not_smis, t0); 610 __ JumpIfNotSmi(t2, &not_smis, t0);
596 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: 611 // One operand is a smi. EmitSmiNonsmiComparison generates code that can:
597 // 1) Return the answer. 612 // 1) Return the answer.
598 // 2) Go to slow. 613 // 2) Go to slow.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 721
707 __ bind(&slow); 722 __ bind(&slow);
708 // Prepare for call to builtin. Push object pointers, a0 (lhs) first, 723 // Prepare for call to builtin. Push object pointers, a0 (lhs) first,
709 // a1 (rhs) second. 724 // a1 (rhs) second.
710 __ Push(lhs, rhs); 725 __ Push(lhs, rhs);
711 // Figure out which native to call and setup the arguments. 726 // Figure out which native to call and setup the arguments.
712 Builtins::JavaScript native; 727 Builtins::JavaScript native;
713 if (cc == eq) { 728 if (cc == eq) {
714 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; 729 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS;
715 } else { 730 } else {
716 native = Builtins::COMPARE; 731 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE;
717 int ncr; // NaN compare result. 732 int ncr; // NaN compare result.
718 if (cc == lt || cc == le) { 733 if (cc == lt || cc == le) {
719 ncr = GREATER; 734 ncr = GREATER;
720 } else { 735 } else {
721 DCHECK(cc == gt || cc == ge); // Remaining cases. 736 DCHECK(cc == gt || cc == ge); // Remaining cases.
722 ncr = LESS; 737 ncr = LESS;
723 } 738 }
724 __ li(a0, Operand(Smi::FromInt(ncr))); 739 __ li(a0, Operand(Smi::FromInt(ncr)));
725 __ push(a0); 740 __ push(a0);
726 } 741 }
(...skipping 3009 matching lines...) Expand 10 before | Expand all | Expand 10 after
3736 __ bind(&fpu_eq); 3751 __ bind(&fpu_eq);
3737 __ Ret(USE_DELAY_SLOT); 3752 __ Ret(USE_DELAY_SLOT);
3738 __ li(v0, Operand(EQUAL)); 3753 __ li(v0, Operand(EQUAL));
3739 3754
3740 __ bind(&fpu_lt); 3755 __ bind(&fpu_lt);
3741 __ Ret(USE_DELAY_SLOT); 3756 __ Ret(USE_DELAY_SLOT);
3742 __ li(v0, Operand(LESS)); 3757 __ li(v0, Operand(LESS));
3743 3758
3744 __ bind(&unordered); 3759 __ bind(&unordered);
3745 __ bind(&generic_stub); 3760 __ bind(&generic_stub);
3746 CompareICStub stub(isolate(), op(), CompareICState::GENERIC, 3761 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC,
3747 CompareICState::GENERIC, CompareICState::GENERIC); 3762 CompareICState::GENERIC, CompareICState::GENERIC);
3748 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 3763 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
3749 3764
3750 __ bind(&maybe_undefined1); 3765 __ bind(&maybe_undefined1);
3751 if (Token::IsOrderedRelationalCompareOp(op())) { 3766 if (Token::IsOrderedRelationalCompareOp(op())) {
3752 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 3767 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
3753 __ Branch(&miss, ne, a0, Operand(at)); 3768 __ Branch(&miss, ne, a0, Operand(at));
3754 __ JumpIfSmi(a1, &unordered); 3769 __ JumpIfSmi(a1, &unordered);
3755 __ GetObjectType(a1, a2, a2); 3770 __ GetObjectType(a1, a2, a2);
3756 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); 3771 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE));
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after
5500 kStackUnwindSpace, kInvalidStackOffset, 5515 kStackUnwindSpace, kInvalidStackOffset,
5501 MemOperand(fp, 6 * kPointerSize), NULL); 5516 MemOperand(fp, 6 * kPointerSize), NULL);
5502 } 5517 }
5503 5518
5504 5519
5505 #undef __ 5520 #undef __
5506 5521
5507 } } // namespace v8::internal 5522 } } // namespace v8::internal
5508 5523
5509 #endif // V8_TARGET_ARCH_MIPS 5524 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698