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

Unified Diff: src/ia32/code-stubs-ia32.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index 4d0a2953d12a9cab8727d064f8d974b7dadf30b4..9215ff06e7d89ea89b8ee4bdefee2c60fd4e9bdf 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -1666,7 +1666,7 @@ static void BranchIfNotInternalizedString(MacroAssembler* masm,
void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
- Label check_unequal_objects;
+ Label runtime_call, check_unequal_objects;
Condition cc = GetCondition();
Label miss;
@@ -1700,12 +1700,17 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
if (cc != equal) {
// Check for undefined. undefined OP undefined is false even though
// undefined == undefined.
- Label check_for_nan;
__ cmp(edx, isolate()->factory()->undefined_value());
- __ j(not_equal, &check_for_nan, Label::kNear);
- __ Move(eax, Immediate(Smi::FromInt(NegativeComparisonResult(cc))));
- __ ret(0);
- __ bind(&check_for_nan);
+ if (strong()) {
+ // In strong mode, this comparison must throw, so call the runtime.
+ __ j(equal, &runtime_call, Label::kFar);
+ } else {
+ Label check_for_nan;
+ __ j(not_equal, &check_for_nan, Label::kNear);
+ __ Move(eax, Immediate(Smi::FromInt(NegativeComparisonResult(cc))));
+ __ ret(0);
+ __ bind(&check_for_nan);
+ }
}
// Test for NaN. Compare heap numbers in a general way,
@@ -1714,12 +1719,20 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
Immediate(isolate()->factory()->heap_number_map()));
__ j(equal, &generic_heap_number_comparison, Label::kNear);
if (cc != equal) {
+ __ mov(ecx, FieldOperand(eax, HeapObject::kMapOffset));
+ __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset));
// Call runtime on identical JSObjects. Otherwise return equal.
- __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx);
- __ j(above_equal, &not_identical);
+ __ cmpb(ecx, static_cast<uint8_t>(FIRST_SPEC_OBJECT_TYPE));
+ __ j(above_equal, &runtime_call, Label::kFar);
// Call runtime on identical symbols since we need to throw a TypeError.
- __ CmpObjectType(eax, SYMBOL_TYPE, ecx);
- __ j(equal, &not_identical);
+ __ cmpb(ecx, static_cast<uint8_t>(SYMBOL_TYPE));
+ __ j(equal, &runtime_call, Label::kFar);
+ if (strong()) {
+ // We have already tested for smis and heap numbers, so if both
+ // arguments are not strings we must proceed to the slow case.
+ __ test(ecx, Immediate(kIsNotStringMask));
+ __ j(not_zero, &runtime_call, Label::kFar);
+ }
}
__ Move(eax, Immediate(Smi::FromInt(EQUAL)));
__ ret(0);
@@ -1864,7 +1877,6 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
// Non-strict equality. Objects are unequal if
// they are both JSObjects and not undetectable,
// and their pointers are different.
- Label not_both_objects;
Label return_unequal;
// At most one is a smi, so we can test for smi by adding the two.
// A smi plus a heap object has the low bit set, a heap object plus
@@ -1873,11 +1885,11 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
STATIC_ASSERT(kSmiTagMask == 1);
__ lea(ecx, Operand(eax, edx, times_1, 0));
__ test(ecx, Immediate(kSmiTagMask));
- __ j(not_zero, &not_both_objects, Label::kNear);
+ __ j(not_zero, &runtime_call, Label::kNear);
__ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx);
- __ j(below, &not_both_objects, Label::kNear);
+ __ j(below, &runtime_call, Label::kNear);
__ CmpObjectType(edx, FIRST_SPEC_OBJECT_TYPE, ebx);
- __ j(below, &not_both_objects, Label::kNear);
+ __ j(below, &runtime_call, Label::kNear);
// We do not bail out after this point. Both are JSObjects, and
// they are equal if and only if both are undetectable.
// The and of the undetectable flags is 1 if and only if they are equal.
@@ -1894,8 +1906,8 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
// Return non-equal by returning the non-zero object pointer in eax,
// or return equal if we fell through to here.
__ ret(0); // rax, rdx were pushed
- __ bind(&not_both_objects);
}
+ __ bind(&runtime_call);
// Push arguments below the return address.
__ pop(ecx);
@@ -1907,7 +1919,7 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
if (cc == equal) {
builtin = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS;
} else {
- builtin = Builtins::COMPARE;
+ builtin = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE;
__ push(Immediate(Smi::FromInt(NegativeComparisonResult(cc))));
}
@@ -3638,7 +3650,7 @@ void CompareICStub::GenerateNumbers(MacroAssembler* masm) {
__ bind(&unordered);
__ bind(&generic_stub);
- CompareICStub stub(isolate(), op(), CompareICState::GENERIC,
+ CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC,
CompareICState::GENERIC, CompareICState::GENERIC);
__ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698