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

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

Issue 1693833002: Remove strong mode support from binary operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 4 years, 10 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
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 #if V8_TARGET_ARCH_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 84
85 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( 85 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor(
86 CodeStubDescriptor* descriptor) { 86 CodeStubDescriptor* descriptor) {
87 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); 87 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1);
88 } 88 }
89 89
90 90
91 #define __ ACCESS_MASM(masm) 91 #define __ ACCESS_MASM(masm)
92 92
93
94 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, 93 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
95 Condition cc, Strength strength); 94 Condition cc);
96 static void EmitSmiNonsmiComparison(MacroAssembler* masm, 95 static void EmitSmiNonsmiComparison(MacroAssembler* masm,
97 Register lhs, 96 Register lhs,
98 Register rhs, 97 Register rhs,
99 Label* rhs_not_nan, 98 Label* rhs_not_nan,
100 Label* slow, 99 Label* slow,
101 bool strict); 100 bool strict);
102 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, 101 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm,
103 Register lhs, 102 Register lhs,
104 Register rhs); 103 Register rhs);
105 104
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 265
267 __ Pop(scratch, scratch2, scratch3); 266 __ Pop(scratch, scratch2, scratch3);
268 __ Ret(); 267 __ Ret();
269 } 268 }
270 269
271 270
272 // Handle the case where the lhs and rhs are the same object. 271 // Handle the case where the lhs and rhs are the same object.
273 // Equality is almost reflexive (everything but NaN), so this is a test 272 // Equality is almost reflexive (everything but NaN), so this is a test
274 // for "identity and not NaN". 273 // for "identity and not NaN".
275 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, 274 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow,
276 Condition cc, Strength strength) { 275 Condition cc) {
277 Label not_identical; 276 Label not_identical;
278 Label heap_number, return_equal; 277 Label heap_number, return_equal;
279 Register exp_mask_reg = t1; 278 Register exp_mask_reg = t1;
280 279
281 __ Branch(&not_identical, ne, a0, Operand(a1)); 280 __ Branch(&not_identical, ne, a0, Operand(a1));
282 281
283 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); 282 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask));
284 283
285 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), 284 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(),
286 // so we do the second best thing - test it ourselves. 285 // so we do the second best thing - test it ourselves.
287 // They are both equal and they are not both Smis so both of them are not 286 // They are both equal and they are not both Smis so both of them are not
288 // Smis. If it's not a heap number, then return equal. 287 // Smis. If it's not a heap number, then return equal.
289 __ GetObjectType(a0, t0, t0); 288 __ GetObjectType(a0, t0, t0);
290 if (cc == less || cc == greater) { 289 if (cc == less || cc == greater) {
291 // Call runtime on identical JSObjects. 290 // Call runtime on identical JSObjects.
292 __ Branch(slow, greater, t0, Operand(FIRST_JS_RECEIVER_TYPE)); 291 __ Branch(slow, greater, t0, Operand(FIRST_JS_RECEIVER_TYPE));
293 // Call runtime on identical symbols since we need to throw a TypeError. 292 // Call runtime on identical symbols since we need to throw a TypeError.
294 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); 293 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE));
295 // Call runtime on identical SIMD values since we must throw a TypeError. 294 // Call runtime on identical SIMD values since we must throw a TypeError.
296 __ Branch(slow, eq, t0, Operand(SIMD128_VALUE_TYPE)); 295 __ Branch(slow, eq, t0, Operand(SIMD128_VALUE_TYPE));
297 if (is_strong(strength)) {
298 // Call the runtime on anything that is converted in the semantics, since
299 // we need to throw a TypeError. Smis have already been ruled out.
300 __ Branch(&return_equal, eq, t0, Operand(HEAP_NUMBER_TYPE));
301 __ And(t0, t0, Operand(kIsNotStringMask));
302 __ Branch(slow, ne, t0, Operand(zero_reg));
303 }
304 } else { 296 } else {
305 __ Branch(&heap_number, eq, t0, Operand(HEAP_NUMBER_TYPE)); 297 __ Branch(&heap_number, eq, t0, Operand(HEAP_NUMBER_TYPE));
306 // Comparing JS objects with <=, >= is complicated. 298 // Comparing JS objects with <=, >= is complicated.
307 if (cc != eq) { 299 if (cc != eq) {
308 __ Branch(slow, greater, t0, Operand(FIRST_JS_RECEIVER_TYPE)); 300 __ Branch(slow, greater, t0, Operand(FIRST_JS_RECEIVER_TYPE));
309 // Call runtime on identical symbols since we need to throw a TypeError. 301 // Call runtime on identical symbols since we need to throw a TypeError.
310 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); 302 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE));
311 // Call runtime on identical SIMD values since we must throw a TypeError. 303 // Call runtime on identical SIMD values since we must throw a TypeError.
312 __ Branch(slow, eq, t0, Operand(SIMD128_VALUE_TYPE)); 304 __ Branch(slow, eq, t0, Operand(SIMD128_VALUE_TYPE));
313 if (is_strong(strength)) {
314 // Call the runtime on anything that is converted in the semantics,
315 // since we need to throw a TypeError. Smis and heap numbers have
316 // already been ruled out.
317 __ And(t0, t0, Operand(kIsNotStringMask));
318 __ Branch(slow, ne, t0, Operand(zero_reg));
319 }
320 // Normally here we fall through to return_equal, but undefined is 305 // Normally here we fall through to return_equal, but undefined is
321 // special: (undefined == undefined) == true, but 306 // special: (undefined == undefined) == true, but
322 // (undefined <= undefined) == false! See ECMAScript 11.8.5. 307 // (undefined <= undefined) == false! See ECMAScript 11.8.5.
323 if (cc == less_equal || cc == greater_equal) { 308 if (cc == less_equal || cc == greater_equal) {
324 __ Branch(&return_equal, ne, t0, Operand(ODDBALL_TYPE)); 309 __ Branch(&return_equal, ne, t0, Operand(ODDBALL_TYPE));
325 __ LoadRoot(a6, Heap::kUndefinedValueRootIndex); 310 __ LoadRoot(a6, Heap::kUndefinedValueRootIndex);
326 __ Branch(&return_equal, ne, a0, Operand(a6)); 311 __ Branch(&return_equal, ne, a0, Operand(a6));
327 DCHECK(is_int16(GREATER) && is_int16(LESS)); 312 DCHECK(is_int16(GREATER) && is_int16(LESS));
328 __ Ret(USE_DELAY_SLOT); 313 __ Ret(USE_DELAY_SLOT);
329 if (cc == le) { 314 if (cc == le) {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 588
604 __ Ret(USE_DELAY_SLOT); 589 __ Ret(USE_DELAY_SLOT);
605 __ dsubu(v0, a1, a0); 590 __ dsubu(v0, a1, a0);
606 __ bind(&not_two_smis); 591 __ bind(&not_two_smis);
607 592
608 // NOTICE! This code is only reached after a smi-fast-case check, so 593 // NOTICE! This code is only reached after a smi-fast-case check, so
609 // it is certain that at least one operand isn't a smi. 594 // it is certain that at least one operand isn't a smi.
610 595
611 // Handle the case where the objects are identical. Either returns the answer 596 // Handle the case where the objects are identical. Either returns the answer
612 // or goes to slow. Only falls through if the objects were not identical. 597 // or goes to slow. Only falls through if the objects were not identical.
613 EmitIdenticalObjectComparison(masm, &slow, cc, strength()); 598 EmitIdenticalObjectComparison(masm, &slow, cc);
614 599
615 // If either is a Smi (we know that not both are), then they can only 600 // If either is a Smi (we know that not both are), then they can only
616 // be strictly equal if the other is a HeapNumber. 601 // be strictly equal if the other is a HeapNumber.
617 STATIC_ASSERT(kSmiTag == 0); 602 STATIC_ASSERT(kSmiTag == 0);
618 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); 603 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0));
619 __ And(a6, lhs, Operand(rhs)); 604 __ And(a6, lhs, Operand(rhs));
620 __ JumpIfNotSmi(a6, &not_smis, a4); 605 __ JumpIfNotSmi(a6, &not_smis, a4);
621 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: 606 // One operand is a smi. EmitSmiNonsmiComparison generates code that can:
622 // 1) Return the answer. 607 // 1) Return the answer.
623 // 2) Go to slow. 608 // 2) Go to slow.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 ncr = GREATER; 727 ncr = GREATER;
743 } else { 728 } else {
744 DCHECK(cc == gt || cc == ge); // Remaining cases. 729 DCHECK(cc == gt || cc == ge); // Remaining cases.
745 ncr = LESS; 730 ncr = LESS;
746 } 731 }
747 __ li(a0, Operand(Smi::FromInt(ncr))); 732 __ li(a0, Operand(Smi::FromInt(ncr)));
748 __ push(a0); 733 __ push(a0);
749 734
750 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) 735 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater)
751 // tagged as a small integer. 736 // tagged as a small integer.
752 __ TailCallRuntime(is_strong(strength()) ? Runtime::kCompare_Strong 737 __ TailCallRuntime(Runtime::kCompare);
753 : Runtime::kCompare);
754 } 738 }
755 739
756 __ bind(&miss); 740 __ bind(&miss);
757 GenerateMiss(masm); 741 GenerateMiss(masm);
758 } 742 }
759 743
760 744
761 void StoreRegistersStateStub::Generate(MacroAssembler* masm) { 745 void StoreRegistersStateStub::Generate(MacroAssembler* masm) {
762 __ mov(t9, ra); 746 __ mov(t9, ra);
763 __ pop(ra); 747 __ pop(ra);
(...skipping 2311 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 __ TailCallStub(&stub); 3059 __ TailCallStub(&stub);
3076 } 3060 }
3077 3061
3078 3062
3079 void CompareICStub::GenerateBooleans(MacroAssembler* masm) { 3063 void CompareICStub::GenerateBooleans(MacroAssembler* masm) {
3080 DCHECK_EQ(CompareICState::BOOLEAN, state()); 3064 DCHECK_EQ(CompareICState::BOOLEAN, state());
3081 Label miss; 3065 Label miss;
3082 3066
3083 __ CheckMap(a1, a2, Heap::kBooleanMapRootIndex, &miss, DO_SMI_CHECK); 3067 __ CheckMap(a1, a2, Heap::kBooleanMapRootIndex, &miss, DO_SMI_CHECK);
3084 __ CheckMap(a0, a3, Heap::kBooleanMapRootIndex, &miss, DO_SMI_CHECK); 3068 __ CheckMap(a0, a3, Heap::kBooleanMapRootIndex, &miss, DO_SMI_CHECK);
3085 if (op() != Token::EQ_STRICT && is_strong(strength())) { 3069 if (!Token::IsEqualityOp(op())) {
3086 __ TailCallRuntime(Runtime::kThrowStrongModeImplicitConversion); 3070 __ ld(a1, FieldMemOperand(a1, Oddball::kToNumberOffset));
3087 } else { 3071 __ AssertSmi(a1);
3088 if (!Token::IsEqualityOp(op())) { 3072 __ ld(a0, FieldMemOperand(a0, Oddball::kToNumberOffset));
3089 __ ld(a1, FieldMemOperand(a1, Oddball::kToNumberOffset)); 3073 __ AssertSmi(a0);
3090 __ AssertSmi(a1);
3091 __ ld(a0, FieldMemOperand(a0, Oddball::kToNumberOffset));
3092 __ AssertSmi(a0);
3093 }
3094 __ Ret(USE_DELAY_SLOT);
3095 __ Dsubu(v0, a1, a0);
3096 } 3074 }
3075 __ Ret(USE_DELAY_SLOT);
3076 __ Dsubu(v0, a1, a0);
3097 3077
3098 __ bind(&miss); 3078 __ bind(&miss);
3099 GenerateMiss(masm); 3079 GenerateMiss(masm);
3100 } 3080 }
3101 3081
3102 3082
3103 void CompareICStub::GenerateSmis(MacroAssembler* masm) { 3083 void CompareICStub::GenerateSmis(MacroAssembler* masm) {
3104 DCHECK(state() == CompareICState::SMI); 3084 DCHECK(state() == CompareICState::SMI);
3105 Label miss; 3085 Label miss;
3106 __ Or(a2, a1, a0); 3086 __ Or(a2, a1, a0);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3184 __ bind(&fpu_eq); 3164 __ bind(&fpu_eq);
3185 __ Ret(USE_DELAY_SLOT); 3165 __ Ret(USE_DELAY_SLOT);
3186 __ li(v0, Operand(EQUAL)); 3166 __ li(v0, Operand(EQUAL));
3187 3167
3188 __ bind(&fpu_lt); 3168 __ bind(&fpu_lt);
3189 __ Ret(USE_DELAY_SLOT); 3169 __ Ret(USE_DELAY_SLOT);
3190 __ li(v0, Operand(LESS)); 3170 __ li(v0, Operand(LESS));
3191 3171
3192 __ bind(&unordered); 3172 __ bind(&unordered);
3193 __ bind(&generic_stub); 3173 __ bind(&generic_stub);
3194 CompareICStub stub(isolate(), op(), strength(), CompareICState::GENERIC, 3174 CompareICStub stub(isolate(), op(), CompareICState::GENERIC,
3195 CompareICState::GENERIC, CompareICState::GENERIC); 3175 CompareICState::GENERIC, CompareICState::GENERIC);
3196 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); 3176 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET);
3197 3177
3198 __ bind(&maybe_undefined1); 3178 __ bind(&maybe_undefined1);
3199 if (Token::IsOrderedRelationalCompareOp(op())) { 3179 if (Token::IsOrderedRelationalCompareOp(op())) {
3200 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 3180 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
3201 __ Branch(&miss, ne, a0, Operand(at)); 3181 __ Branch(&miss, ne, a0, Operand(at));
3202 __ JumpIfSmi(a1, &unordered); 3182 __ JumpIfSmi(a1, &unordered);
3203 __ GetObjectType(a1, a2, a2); 3183 __ GetObjectType(a1, a2, a2);
3204 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); 3184 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE));
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 __ JumpIfSmi(a2, &miss); 3394 __ JumpIfSmi(a2, &miss);
3415 __ GetWeakValue(a4, cell); 3395 __ GetWeakValue(a4, cell);
3416 __ ld(a2, FieldMemOperand(a0, HeapObject::kMapOffset)); 3396 __ ld(a2, FieldMemOperand(a0, HeapObject::kMapOffset));
3417 __ ld(a3, FieldMemOperand(a1, HeapObject::kMapOffset)); 3397 __ ld(a3, FieldMemOperand(a1, HeapObject::kMapOffset));
3418 __ Branch(&miss, ne, a2, Operand(a4)); 3398 __ Branch(&miss, ne, a2, Operand(a4));
3419 __ Branch(&miss, ne, a3, Operand(a4)); 3399 __ Branch(&miss, ne, a3, Operand(a4));
3420 3400
3421 if (Token::IsEqualityOp(op())) { 3401 if (Token::IsEqualityOp(op())) {
3422 __ Ret(USE_DELAY_SLOT); 3402 __ Ret(USE_DELAY_SLOT);
3423 __ dsubu(v0, a0, a1); 3403 __ dsubu(v0, a0, a1);
3424 } else if (is_strong(strength())) {
3425 __ TailCallRuntime(Runtime::kThrowStrongModeImplicitConversion);
3426 } else { 3404 } else {
3427 if (op() == Token::LT || op() == Token::LTE) { 3405 if (op() == Token::LT || op() == Token::LTE) {
3428 __ li(a2, Operand(Smi::FromInt(GREATER))); 3406 __ li(a2, Operand(Smi::FromInt(GREATER)));
3429 } else { 3407 } else {
3430 __ li(a2, Operand(Smi::FromInt(LESS))); 3408 __ li(a2, Operand(Smi::FromInt(LESS)));
3431 } 3409 }
3432 __ Push(a1, a0, a2); 3410 __ Push(a1, a0, a2);
3433 __ TailCallRuntime(Runtime::kCompare); 3411 __ TailCallRuntime(Runtime::kCompare);
3434 } 3412 }
3435 3413
(...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after
5711 return_value_operand, NULL); 5689 return_value_operand, NULL);
5712 } 5690 }
5713 5691
5714 5692
5715 #undef __ 5693 #undef __
5716 5694
5717 } // namespace internal 5695 } // namespace internal
5718 } // namespace v8 5696 } // namespace v8
5719 5697
5720 #endif // V8_TARGET_ARCH_MIPS64 5698 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698