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

Side by Side Diff: src/ppc/code-stubs-ppc.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/mips64/lithium-mips64.h ('k') | src/ppc/full-codegen-ppc.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_PPC 7 #if V8_TARGET_ARCH_PPC
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, Label* slow, 96 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
97 Condition cond); 97 Condition cond, bool strong);
98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, 98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs,
99 Register rhs, Label* lhs_not_nan, 99 Register rhs, Label* lhs_not_nan,
100 Label* slow, bool strict); 100 Label* slow, bool strict);
101 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, 101 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs,
102 Register rhs); 102 Register rhs);
103 103
104 104
105 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, 105 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm,
106 ExternalReference miss) { 106 ExternalReference miss) {
107 // Update the static counter each time a new code stub is generated. 107 // Update the static counter each time a new code stub is generated.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 __ pop(scratch); 242 __ pop(scratch);
243 243
244 __ Ret(); 244 __ Ret();
245 } 245 }
246 246
247 247
248 // Handle the case where the lhs and rhs are the same object. 248 // Handle the case where the lhs and rhs are the same object.
249 // Equality is almost reflexive (everything but NaN), so this is a test 249 // Equality is almost reflexive (everything but NaN), so this is a test
250 // for "identity and not NaN". 250 // for "identity and not NaN".
251 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, 251 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
252 Condition cond) { 252 Condition cond, bool strong) {
253 Label not_identical; 253 Label not_identical;
254 Label heap_number, return_equal; 254 Label heap_number, return_equal;
255 __ cmp(r3, r4); 255 __ cmp(r3, r4);
256 __ bne(&not_identical); 256 __ bne(&not_identical);
257 257
258 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), 258 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(),
259 // so we do the second best thing - test it ourselves. 259 // so we do the second best thing - test it ourselves.
260 // They are both equal and they are not both Smis so both of them are not 260 // They are both equal and they are not both Smis so both of them are not
261 // Smis. If it's not a heap number, then return equal. 261 // Smis. If it's not a heap number, then return equal.
262 if (cond == lt || cond == gt) { 262 if (cond == lt || cond == gt) {
263 // Call runtime on identical JSObjects.
263 __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE); 264 __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE);
264 __ bge(slow); 265 __ bge(slow);
266 // Call runtime on identical symbols since we need to throw a TypeError.
265 __ cmpi(r7, Operand(SYMBOL_TYPE)); 267 __ cmpi(r7, Operand(SYMBOL_TYPE));
266 __ beq(slow); 268 __ beq(slow);
269 if (strong) {
270 // Call the runtime on anything that is converted in the semantics, since
271 // we need to throw a TypeError. Smis have already been ruled out.
272 __ cmpi(r7, Operand(HEAP_NUMBER_TYPE));
273 __ beq(&return_equal);
274 __ andi(r7, r7, Operand(kIsNotStringMask));
275 __ bne(slow, cr0);
276 }
267 } else { 277 } else {
268 __ CompareObjectType(r3, r7, r7, HEAP_NUMBER_TYPE); 278 __ CompareObjectType(r3, r7, r7, HEAP_NUMBER_TYPE);
269 __ beq(&heap_number); 279 __ beq(&heap_number);
270 // Comparing JS objects with <=, >= is complicated. 280 // Comparing JS objects with <=, >= is complicated.
271 if (cond != eq) { 281 if (cond != eq) {
272 __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE)); 282 __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE));
273 __ bge(slow); 283 __ bge(slow);
284 // Call runtime on identical symbols since we need to throw a TypeError.
274 __ cmpi(r7, Operand(SYMBOL_TYPE)); 285 __ cmpi(r7, Operand(SYMBOL_TYPE));
275 __ beq(slow); 286 __ beq(slow);
287 if (strong) {
288 // Call the runtime on anything that is converted in the semantics,
289 // since we need to throw a TypeError. Smis and heap numbers have
290 // already been ruled out.
291 __ andi(r7, r7, Operand(kIsNotStringMask));
292 __ bne(slow, cr0);
293 }
276 // Normally here we fall through to return_equal, but undefined is 294 // Normally here we fall through to return_equal, but undefined is
277 // special: (undefined == undefined) == true, but 295 // special: (undefined == undefined) == true, but
278 // (undefined <= undefined) == false! See ECMAScript 11.8.5. 296 // (undefined <= undefined) == false! See ECMAScript 11.8.5.
279 if (cond == le || cond == ge) { 297 if (cond == le || cond == ge) {
280 __ cmpi(r7, Operand(ODDBALL_TYPE)); 298 __ cmpi(r7, Operand(ODDBALL_TYPE));
281 __ bne(&return_equal); 299 __ bne(&return_equal);
282 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); 300 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
283 __ cmp(r3, r5); 301 __ cmp(r3, r5);
284 __ bne(&return_equal); 302 __ bne(&return_equal);
285 if (cond == le) { 303 if (cond == le) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // Never falls through to here. 698 // Never falls through to here.
681 699
682 __ bind(&slow); 700 __ bind(&slow);
683 701
684 __ Push(lhs, rhs); 702 __ Push(lhs, rhs);
685 // Figure out which native to call and setup the arguments. 703 // Figure out which native to call and setup the arguments.
686 Builtins::JavaScript native; 704 Builtins::JavaScript native;
687 if (cc == eq) { 705 if (cc == eq) {
688 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; 706 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS;
689 } else { 707 } else {
690 native = Builtins::COMPARE; 708 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE;
691 int ncr; // NaN compare result 709 int ncr; // NaN compare result
692 if (cc == lt || cc == le) { 710 if (cc == lt || cc == le) {
693 ncr = GREATER; 711 ncr = GREATER;
694 } else { 712 } else {
695 DCHECK(cc == gt || cc == ge); // remaining cases 713 DCHECK(cc == gt || cc == ge); // remaining cases
696 ncr = LESS; 714 ncr = LESS;
697 } 715 }
698 __ LoadSmiLiteral(r3, Smi::FromInt(ncr)); 716 __ LoadSmiLiteral(r3, Smi::FromInt(ncr));
699 __ push(r3); 717 __ push(r3);
700 } 718 }
(...skipping 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 __ bind(&equal); 3791 __ bind(&equal);
3774 __ li(r3, Operand(EQUAL)); 3792 __ li(r3, Operand(EQUAL));
3775 __ Ret(); 3793 __ Ret();
3776 __ bind(&less_than); 3794 __ bind(&less_than);
3777 __ li(r3, Operand(LESS)); 3795 __ li(r3, Operand(LESS));
3778 __ Ret(); 3796 __ Ret();
3779 } 3797 }
3780 3798
3781 __ bind(&unordered); 3799 __ bind(&unordered);
3782 __ bind(&generic_stub); 3800 __ bind(&generic_stub);
3783 CompareICStub stub(isolate(), op(), CompareICState::GENERIC, 3801 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC,
3784 CompareICState::GENERIC, CompareICState::GENERIC); 3802 CompareICState::GENERIC, CompareICState::GENERIC);
3785 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 3803 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
3786 3804
3787 __ bind(&maybe_undefined1); 3805 __ bind(&maybe_undefined1);
3788 if (Token::IsOrderedRelationalCompareOp(op())) { 3806 if (Token::IsOrderedRelationalCompareOp(op())) {
3789 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); 3807 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex);
3790 __ bne(&miss); 3808 __ bne(&miss);
3791 __ JumpIfSmi(r4, &unordered); 3809 __ JumpIfSmi(r4, &unordered);
3792 __ CompareObjectType(r4, r5, r5, HEAP_NUMBER_TYPE); 3810 __ CompareObjectType(r4, r5, r5, HEAP_NUMBER_TYPE);
3793 __ bne(&maybe_undefined2); 3811 __ bne(&maybe_undefined2);
(...skipping 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after
5589 kStackUnwindSpace, NULL, 5607 kStackUnwindSpace, NULL,
5590 MemOperand(fp, 6 * kPointerSize), NULL); 5608 MemOperand(fp, 6 * kPointerSize), NULL);
5591 } 5609 }
5592 5610
5593 5611
5594 #undef __ 5612 #undef __
5595 } 5613 }
5596 } // namespace v8::internal 5614 } // namespace v8::internal
5597 5615
5598 #endif // V8_TARGET_ARCH_PPC 5616 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/mips64/lithium-mips64.h ('k') | src/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698