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/x64/codegen-x64.cc

Issue 3388005: Make the CompareStub and the UnaryOpStub accept smi inputs.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: x64 and ARM port Created 10 years, 3 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 case less_equal: return below_equal; 1933 case less_equal: return below_equal;
1934 case greater: return above; 1934 case greater: return above;
1935 case greater_equal: return above_equal; 1935 case greater_equal: return above_equal;
1936 default: UNREACHABLE(); 1936 default: UNREACHABLE();
1937 } 1937 }
1938 UNREACHABLE(); 1938 UNREACHABLE();
1939 return equal; 1939 return equal;
1940 } 1940 }
1941 1941
1942 1942
1943 static CompareFlags ComputeCompareFlags(NaNInformation nan_info,
1944 bool inline_number_compare) {
1945 CompareFlags flags = NO_SMI_COMPARE_IN_STUB;
1946 if (nan_info == kCantBothBeNaN) {
1947 flags = static_cast<CompareFlags>(flags | CANT_BOTH_BE_NAN);
1948 }
1949 if (inline_number_compare) {
1950 flags = static_cast<CompareFlags>(flags | NO_NUMBER_COMPARE_IN_STUB);
1951 }
1952 return flags;
1953 }
1954
1955
1943 void CodeGenerator::Comparison(AstNode* node, 1956 void CodeGenerator::Comparison(AstNode* node,
1944 Condition cc, 1957 Condition cc,
1945 bool strict, 1958 bool strict,
1946 ControlDestination* dest) { 1959 ControlDestination* dest) {
1947 // Strict only makes sense for equality comparisons. 1960 // Strict only makes sense for equality comparisons.
1948 ASSERT(!strict || cc == equal); 1961 ASSERT(!strict || cc == equal);
1949 1962
1950 Result left_side; 1963 Result left_side;
1951 Result right_side; 1964 Result right_side;
1952 // Implement '>' and '<=' by reversal to obtain ECMA-262 conversion order. 1965 // Implement '>' and '<=' by reversal to obtain ECMA-262 conversion order.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2063 Immediate(kIsNotStringMask | 2076 Immediate(kIsNotStringMask |
2064 kStringRepresentationMask | 2077 kStringRepresentationMask |
2065 kStringEncodingMask)); 2078 kStringEncodingMask));
2066 __ cmpb(temp.reg(), 2079 __ cmpb(temp.reg(),
2067 Immediate(kStringTag | kSeqStringTag | kAsciiStringTag)); 2080 Immediate(kStringTag | kSeqStringTag | kAsciiStringTag));
2068 temp.Unuse(); 2081 temp.Unuse();
2069 is_string.Branch(equal, &left_side); 2082 is_string.Branch(equal, &left_side);
2070 2083
2071 // Setup and call the compare stub. 2084 // Setup and call the compare stub.
2072 is_not_string.Bind(&left_side); 2085 is_not_string.Bind(&left_side);
2073 CompareStub stub(cc, strict, kCantBothBeNaN); 2086 CompareFlags flags =
2087 static_cast<CompareFlags>(CANT_BOTH_BE_NAN | NO_SMI_CODE_IN_STUB);
2088 CompareStub stub(cc, strict, flags);
2074 Result result = frame_->CallStub(&stub, &left_side, &right_side); 2089 Result result = frame_->CallStub(&stub, &left_side, &right_side);
2075 result.ToRegister(); 2090 result.ToRegister();
2076 __ testq(result.reg(), result.reg()); 2091 __ testq(result.reg(), result.reg());
2077 result.Unuse(); 2092 result.Unuse();
2078 dest->true_target()->Branch(cc); 2093 dest->true_target()->Branch(cc);
2079 dest->false_target()->Jump(); 2094 dest->false_target()->Jump();
2080 2095
2081 is_string.Bind(&left_side); 2096 is_string.Bind(&left_side);
2082 // left_side is a sequential ASCII string. 2097 // left_side is a sequential ASCII string.
2083 ASSERT(left_side.reg().is(left_reg)); 2098 ASSERT(left_side.reg().is(left_reg));
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2167 dest->true_target()->Branch(equal); 2182 dest->true_target()->Branch(equal);
2168 } 2183 }
2169 2184
2170 // Inlined number comparison: 2185 // Inlined number comparison:
2171 if (inline_number_compare) { 2186 if (inline_number_compare) {
2172 GenerateInlineNumberComparison(&left_side, &right_side, cc, dest); 2187 GenerateInlineNumberComparison(&left_side, &right_side, cc, dest);
2173 } 2188 }
2174 2189
2175 // End of in-line compare, call out to the compare stub. Don't include 2190 // End of in-line compare, call out to the compare stub. Don't include
2176 // number comparison in the stub if it was inlined. 2191 // number comparison in the stub if it was inlined.
2177 CompareStub stub(cc, strict, nan_info, !inline_number_compare); 2192 CompareFlags flags = ComputeCompareFlags(nan_info, inline_number_compare);
2193 CompareStub stub(cc, strict, flags);
2178 Result answer = frame_->CallStub(&stub, &left_side, &right_side); 2194 Result answer = frame_->CallStub(&stub, &left_side, &right_side);
2179 __ testq(answer.reg(), answer.reg()); // Sets both zero and sign flag. 2195 __ testq(answer.reg(), answer.reg()); // Sets both zero and sign flag.
2180 answer.Unuse(); 2196 answer.Unuse();
2181 dest->Split(cc); 2197 dest->Split(cc);
2182 } else { 2198 } else {
2183 // Here we split control flow to the stub call and inlined cases 2199 // Here we split control flow to the stub call and inlined cases
2184 // before finally splitting it to the control destination. We use 2200 // before finally splitting it to the control destination. We use
2185 // a jump target and branching to duplicate the virtual frame at 2201 // a jump target and branching to duplicate the virtual frame at
2186 // the first split. We manually handle the off-frame references 2202 // the first split. We manually handle the off-frame references
2187 // by reconstituting them on the non-fall-through path. 2203 // by reconstituting them on the non-fall-through path.
(...skipping 12 matching lines...) Expand all
2200 dest->true_target()->Branch(equal); 2216 dest->true_target()->Branch(equal);
2201 } 2217 }
2202 2218
2203 // Inlined number comparison: 2219 // Inlined number comparison:
2204 if (inline_number_compare) { 2220 if (inline_number_compare) {
2205 GenerateInlineNumberComparison(&left_side, &right_side, cc, dest); 2221 GenerateInlineNumberComparison(&left_side, &right_side, cc, dest);
2206 } 2222 }
2207 2223
2208 // End of in-line compare, call out to the compare stub. Don't include 2224 // End of in-line compare, call out to the compare stub. Don't include
2209 // number comparison in the stub if it was inlined. 2225 // number comparison in the stub if it was inlined.
2210 CompareStub stub(cc, strict, nan_info, !inline_number_compare); 2226 CompareFlags flags =
2227 ComputeCompareFlags(nan_info, inline_number_compare);
2228 CompareStub stub(cc, strict, flags);
2211 Result answer = frame_->CallStub(&stub, &left_side, &right_side); 2229 Result answer = frame_->CallStub(&stub, &left_side, &right_side);
2212 __ testq(answer.reg(), answer.reg()); // Sets both zero and sign flags. 2230 __ testq(answer.reg(), answer.reg()); // Sets both zero and sign flags.
2213 answer.Unuse(); 2231 answer.Unuse();
2214 if (is_smi.is_linked()) { 2232 if (is_smi.is_linked()) {
2215 dest->true_target()->Branch(cc); 2233 dest->true_target()->Branch(cc);
2216 dest->false_target()->Jump(); 2234 dest->false_target()->Jump();
2217 } else { 2235 } else {
2218 dest->Split(cc); 2236 dest->Split(cc);
2219 } 2237 }
2220 } 2238 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2325 __ ucomisd(xmm1, xmm0); 2343 __ ucomisd(xmm1, xmm0);
2326 // Jump to builtin for NaN. 2344 // Jump to builtin for NaN.
2327 not_number.Branch(parity_even, left_side); 2345 not_number.Branch(parity_even, left_side);
2328 left_side->Unuse(); 2346 left_side->Unuse();
2329 dest->true_target()->Branch(DoubleCondition(cc)); 2347 dest->true_target()->Branch(DoubleCondition(cc));
2330 dest->false_target()->Jump(); 2348 dest->false_target()->Jump();
2331 not_number.Bind(left_side); 2349 not_number.Bind(left_side);
2332 } 2350 }
2333 2351
2334 // Setup and call the compare stub. 2352 // Setup and call the compare stub.
2335 CompareStub stub(cc, strict, kCantBothBeNaN); 2353 CompareFlags flags =
2354 static_cast<CompareFlags>(CANT_BOTH_BE_NAN | NO_SMI_CODE_IN_STUB);
2355 CompareStub stub(cc, strict, flags);
2336 Result result = frame_->CallStub(&stub, left_side, right_side); 2356 Result result = frame_->CallStub(&stub, left_side, right_side);
2337 result.ToRegister(); 2357 result.ToRegister();
2338 __ testq(result.reg(), result.reg()); 2358 __ testq(result.reg(), result.reg());
2339 result.Unuse(); 2359 result.Unuse();
2340 if (cc == equal) { 2360 if (cc == equal) {
2341 dest->Split(cc); 2361 dest->Split(cc);
2342 } else { 2362 } else {
2343 dest->true_target()->Branch(cc); 2363 dest->true_target()->Branch(cc);
2344 dest->false_target()->Jump(); 2364 dest->false_target()->Jump();
2345 2365
(...skipping 5042 matching lines...) Expand 10 before | Expand all | Expand 10 after
7388 case Token::NOT: 7408 case Token::NOT:
7389 case Token::DELETE: 7409 case Token::DELETE:
7390 case Token::TYPEOF: 7410 case Token::TYPEOF:
7391 UNREACHABLE(); // handled above 7411 UNREACHABLE(); // handled above
7392 break; 7412 break;
7393 7413
7394 case Token::SUB: { 7414 case Token::SUB: {
7395 GenericUnaryOpStub stub( 7415 GenericUnaryOpStub stub(
7396 Token::SUB, 7416 Token::SUB,
7397 overwrite, 7417 overwrite,
7418 NO_UNARY_FLAGS,
7398 no_negative_zero ? kIgnoreNegativeZero : kStrictNegativeZero); 7419 no_negative_zero ? kIgnoreNegativeZero : kStrictNegativeZero);
7399 Result operand = frame_->Pop(); 7420 Result operand = frame_->Pop();
7400 Result answer = frame_->CallStub(&stub, &operand); 7421 Result answer = frame_->CallStub(&stub, &operand);
7401 answer.set_type_info(TypeInfo::Number()); 7422 answer.set_type_info(TypeInfo::Number());
7402 frame_->Push(&answer); 7423 frame_->Push(&answer);
7403 break; 7424 break;
7404 } 7425 }
7405 7426
7406 case Token::BIT_NOT: { 7427 case Token::BIT_NOT: {
7407 // Smi check. 7428 // Smi check.
7408 JumpTarget smi_label; 7429 JumpTarget smi_label;
7409 JumpTarget continue_label; 7430 JumpTarget continue_label;
7410 Result operand = frame_->Pop(); 7431 Result operand = frame_->Pop();
7411 operand.ToRegister(); 7432 operand.ToRegister();
7412 7433
7413 Condition is_smi = masm_->CheckSmi(operand.reg()); 7434 Condition is_smi = masm_->CheckSmi(operand.reg());
7414 smi_label.Branch(is_smi, &operand); 7435 smi_label.Branch(is_smi, &operand);
7415 7436
7416 GenericUnaryOpStub stub(Token::BIT_NOT, overwrite); 7437 GenericUnaryOpStub stub(Token::BIT_NOT,
7438 overwrite,
7439 NO_UNARY_SMI_CODE_IN_STUB);
7417 Result answer = frame_->CallStub(&stub, &operand); 7440 Result answer = frame_->CallStub(&stub, &operand);
7418 continue_label.Jump(&answer); 7441 continue_label.Jump(&answer);
7419 7442
7420 smi_label.Bind(&answer); 7443 smi_label.Bind(&answer);
7421 answer.ToRegister(); 7444 answer.ToRegister();
7422 frame_->Spill(answer.reg()); 7445 frame_->Spill(answer.reg());
7423 __ SmiNot(answer.reg(), answer.reg()); 7446 __ SmiNot(answer.reg(), answer.reg());
7424 continue_label.Bind(&answer); 7447 continue_label.Bind(&answer);
7425 answer.set_type_info(TypeInfo::Smi()); 7448 answer.set_type_info(TypeInfo::Smi());
7426 frame_->Push(&answer); 7449 frame_->Push(&answer);
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
8899 #undef __ 8922 #undef __
8900 8923
8901 void RecordWriteStub::Generate(MacroAssembler* masm) { 8924 void RecordWriteStub::Generate(MacroAssembler* masm) {
8902 masm->RecordWriteHelper(object_, addr_, scratch_); 8925 masm->RecordWriteHelper(object_, addr_, scratch_);
8903 masm->ret(0); 8926 masm->ret(0);
8904 } 8927 }
8905 8928
8906 } } // namespace v8::internal 8929 } } // namespace v8::internal
8907 8930
8908 #endif // V8_TARGET_ARCH_X64 8931 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698