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

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 125184: Add fast negative checks for symbol equality: If we're comparing... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/date-delay.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 bool strict_; 1799 bool strict_;
1800 1800
1801 Major MajorKey() { return Compare; } 1801 Major MajorKey() { return Compare; }
1802 1802
1803 int MinorKey() { 1803 int MinorKey() {
1804 // Encode the three parameters in a unique 16 bit value. 1804 // Encode the three parameters in a unique 16 bit value.
1805 ASSERT(static_cast<int>(cc_) < (1 << 15)); 1805 ASSERT(static_cast<int>(cc_) < (1 << 15));
1806 return (static_cast<int>(cc_) << 1) | (strict_ ? 1 : 0); 1806 return (static_cast<int>(cc_) << 1) | (strict_ ? 1 : 0);
1807 } 1807 }
1808 1808
1809 // Branch to the label if the given object isn't a symbol.
1810 void BranchIfNonSymbol(MacroAssembler* masm,
1811 Label* label,
1812 Register object,
1813 Register scratch);
1814
1809 #ifdef DEBUG 1815 #ifdef DEBUG
1810 void Print() { 1816 void Print() {
1811 PrintF("CompareStub (cc %d), (strict %s)\n", 1817 PrintF("CompareStub (cc %d), (strict %s)\n",
1812 static_cast<int>(cc_), 1818 static_cast<int>(cc_),
1813 strict_ ? "true" : "false"); 1819 strict_ ? "true" : "false");
1814 } 1820 }
1815 #endif 1821 #endif
1816 }; 1822 };
1817 1823
1818 1824
(...skipping 5166 matching lines...) Expand 10 before | Expand all | Expand 10 after
6985 6991
6986 // Check for oddballs: true, false, null, undefined. 6992 // Check for oddballs: true, false, null, undefined.
6987 __ cmp(ecx, ODDBALL_TYPE); 6993 __ cmp(ecx, ODDBALL_TYPE);
6988 __ j(equal, &return_not_equal); 6994 __ j(equal, &return_not_equal);
6989 6995
6990 // Fall through to the general case. 6996 // Fall through to the general case.
6991 } 6997 }
6992 __ bind(&slow); 6998 __ bind(&slow);
6993 } 6999 }
6994 7000
6995 // Save the return address (and get it off the stack). 7001 // Push arguments below the return address.
6996 __ pop(ecx); 7002 __ pop(ecx);
6997
6998 // Push arguments.
6999 __ push(eax); 7003 __ push(eax);
7000 __ push(edx); 7004 __ push(edx);
7001 __ push(ecx); 7005 __ push(ecx);
7002 7006
7003 // Inlined floating point compare. 7007 // Inlined floating point compare.
7004 // Call builtin if operands are not floating point or smi. 7008 // Call builtin if operands are not floating point or smi.
7005 FloatingPointHelper::CheckFloatOperands(masm, &call_builtin, ebx); 7009 Label check_for_symbols;
7010 FloatingPointHelper::CheckFloatOperands(masm, &check_for_symbols, ebx);
7006 FloatingPointHelper::LoadFloatOperands(masm, ecx); 7011 FloatingPointHelper::LoadFloatOperands(masm, ecx);
7007 __ FCmp(); 7012 __ FCmp();
7008 7013
7009 // Jump to builtin for NaN. 7014 // Jump to builtin for NaN.
7010 __ j(parity_even, &call_builtin, not_taken); 7015 __ j(parity_even, &call_builtin, not_taken);
7011 7016
7012 // TODO(1243847): Use cmov below once CpuFeatures are properly hooked up. 7017 // TODO(1243847): Use cmov below once CpuFeatures are properly hooked up.
7013 Label below_lbl, above_lbl; 7018 Label below_lbl, above_lbl;
7014 // use edx, eax to convert unsigned to signed comparison 7019 // use edx, eax to convert unsigned to signed comparison
7015 __ j(below, &below_lbl, not_taken); 7020 __ j(below, &below_lbl, not_taken);
7016 __ j(above, &above_lbl, not_taken); 7021 __ j(above, &above_lbl, not_taken);
7017 7022
7018 __ xor_(eax, Operand(eax)); // equal 7023 __ xor_(eax, Operand(eax)); // equal
7019 __ ret(2 * kPointerSize); 7024 __ ret(2 * kPointerSize);
7020 7025
7021 __ bind(&below_lbl); 7026 __ bind(&below_lbl);
7022 __ mov(eax, -1); 7027 __ mov(eax, -1);
7023 __ ret(2 * kPointerSize); 7028 __ ret(2 * kPointerSize);
7024 7029
7025 __ bind(&above_lbl); 7030 __ bind(&above_lbl);
7026 __ mov(eax, 1); 7031 __ mov(eax, 1);
7027 __ ret(2 * kPointerSize); // eax, edx were pushed 7032 __ ret(2 * kPointerSize); // eax, edx were pushed
7028 7033
7034 // Fast negative check for symbol-to-symbol equality.
7035 __ bind(&check_for_symbols);
7036 if (cc_ == equal) {
7037 BranchIfNonSymbol(masm, &call_builtin, eax, ecx);
7038 BranchIfNonSymbol(masm, &call_builtin, edx, ecx);
7039
7040 // We've already checked for object identity, so if both operands
7041 // are symbols they aren't equal. Register eax already holds a
7042 // non-zero value, which indicates not equal, so just return.
7043 __ ret(2 * kPointerSize);
7044 }
7045
7029 __ bind(&call_builtin); 7046 __ bind(&call_builtin);
7030 // must swap argument order 7047 // must swap argument order
7031 __ pop(ecx); 7048 __ pop(ecx);
7032 __ pop(edx); 7049 __ pop(edx);
7033 __ pop(eax); 7050 __ pop(eax);
7034 __ push(edx); 7051 __ push(edx);
7035 __ push(eax); 7052 __ push(eax);
7036 7053
7037 // Figure out which native to call and setup the arguments. 7054 // Figure out which native to call and setup the arguments.
7038 Builtins::JavaScript builtin; 7055 Builtins::JavaScript builtin;
(...skipping 13 matching lines...) Expand all
7052 7069
7053 // Restore return address on the stack. 7070 // Restore return address on the stack.
7054 __ push(ecx); 7071 __ push(ecx);
7055 7072
7056 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater) 7073 // Call the native; it returns -1 (less), 0 (equal), or 1 (greater)
7057 // tagged as a small integer. 7074 // tagged as a small integer.
7058 __ InvokeBuiltin(builtin, JUMP_FUNCTION); 7075 __ InvokeBuiltin(builtin, JUMP_FUNCTION);
7059 } 7076 }
7060 7077
7061 7078
7079 void CompareStub::BranchIfNonSymbol(MacroAssembler* masm,
7080 Label* label,
7081 Register object,
7082 Register scratch) {
7083 __ test(object, Immediate(kSmiTagMask));
7084 __ j(zero, label);
7085 __ mov(scratch, FieldOperand(object, HeapObject::kMapOffset));
7086 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
7087 __ and_(scratch, kIsSymbolMask | kIsNotStringMask);
7088 __ cmp(scratch, kSymbolTag | kStringTag);
7089 __ j(not_equal, label);
7090 }
7091
7092
7062 void StackCheckStub::Generate(MacroAssembler* masm) { 7093 void StackCheckStub::Generate(MacroAssembler* masm) {
7063 // Because builtins always remove the receiver from the stack, we 7094 // Because builtins always remove the receiver from the stack, we
7064 // have to fake one to avoid underflowing the stack. The receiver 7095 // have to fake one to avoid underflowing the stack. The receiver
7065 // must be inserted below the return address on the stack so we 7096 // must be inserted below the return address on the stack so we
7066 // temporarily store that in a register. 7097 // temporarily store that in a register.
7067 __ pop(eax); 7098 __ pop(eax);
7068 __ push(Immediate(Smi::FromInt(0))); 7099 __ push(Immediate(Smi::FromInt(0)));
7069 __ push(eax); 7100 __ push(eax);
7070 7101
7071 // Do tail-call to runtime routine. 7102 // Do tail-call to runtime routine.
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
7482 7513
7483 // Slow-case: Go through the JavaScript implementation. 7514 // Slow-case: Go through the JavaScript implementation.
7484 __ bind(&slow); 7515 __ bind(&slow);
7485 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 7516 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
7486 } 7517 }
7487 7518
7488 7519
7489 #undef __ 7520 #undef __
7490 7521
7491 } } // namespace v8::internal 7522 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/date-delay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698