| OLD | NEW |
| 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 2410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2421 // If either side is a constant of some sort, we can probably optimize the | 2421 // If either side is a constant of some sort, we can probably optimize the |
| 2422 // comparison. | 2422 // comparison. |
| 2423 bool left_side_constant_smi = false; | 2423 bool left_side_constant_smi = false; |
| 2424 bool left_side_constant_null = false; | 2424 bool left_side_constant_null = false; |
| 2425 bool left_side_constant_1_char_string = false; | 2425 bool left_side_constant_1_char_string = false; |
| 2426 if (left_side.is_constant()) { | 2426 if (left_side.is_constant()) { |
| 2427 left_side_constant_smi = left_side.handle()->IsSmi(); | 2427 left_side_constant_smi = left_side.handle()->IsSmi(); |
| 2428 left_side_constant_null = left_side.handle()->IsNull(); | 2428 left_side_constant_null = left_side.handle()->IsNull(); |
| 2429 left_side_constant_1_char_string = | 2429 left_side_constant_1_char_string = |
| 2430 (left_side.handle()->IsString() && | 2430 (left_side.handle()->IsString() && |
| 2431 (String::cast(*left_side.handle())->length() == 1)); | 2431 String::cast(*left_side.handle())->length() == 1 && |
| 2432 String::cast(*left_side.handle())->IsAsciiRepresentation()); |
| 2432 } | 2433 } |
| 2433 bool right_side_constant_smi = false; | 2434 bool right_side_constant_smi = false; |
| 2434 bool right_side_constant_null = false; | 2435 bool right_side_constant_null = false; |
| 2435 bool right_side_constant_1_char_string = false; | 2436 bool right_side_constant_1_char_string = false; |
| 2436 if (right_side.is_constant()) { | 2437 if (right_side.is_constant()) { |
| 2437 right_side_constant_smi = right_side.handle()->IsSmi(); | 2438 right_side_constant_smi = right_side.handle()->IsSmi(); |
| 2438 right_side_constant_null = right_side.handle()->IsNull(); | 2439 right_side_constant_null = right_side.handle()->IsNull(); |
| 2439 right_side_constant_1_char_string = | 2440 right_side_constant_1_char_string = |
| 2440 (right_side.handle()->IsString() && | 2441 (right_side.handle()->IsString() && |
| 2441 (String::cast(*right_side.handle())->length() == 1)); | 2442 String::cast(*right_side.handle())->length() == 1 && |
| 2443 String::cast(*right_side.handle())->IsAsciiRepresentation()); |
| 2442 } | 2444 } |
| 2443 | 2445 |
| 2444 if (left_side_constant_smi || right_side_constant_smi) { | 2446 if (left_side_constant_smi || right_side_constant_smi) { |
| 2445 if (left_side_constant_smi && right_side_constant_smi) { | 2447 if (left_side_constant_smi && right_side_constant_smi) { |
| 2446 // Trivial case, comparing two constants. | 2448 // Trivial case, comparing two constants. |
| 2447 int left_value = Smi::cast(*left_side.handle())->value(); | 2449 int left_value = Smi::cast(*left_side.handle())->value(); |
| 2448 int right_value = Smi::cast(*right_side.handle())->value(); | 2450 int right_value = Smi::cast(*right_side.handle())->value(); |
| 2449 switch (cc) { | 2451 switch (cc) { |
| 2450 case less: | 2452 case less: |
| 2451 dest->Goto(left_value < right_value); | 2453 dest->Goto(left_value < right_value); |
| (...skipping 10112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12564 | 12566 |
| 12565 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 12567 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
| 12566 // tagged as a small integer. | 12568 // tagged as a small integer. |
| 12567 __ bind(&runtime); | 12569 __ bind(&runtime); |
| 12568 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 12570 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 12569 } | 12571 } |
| 12570 | 12572 |
| 12571 #undef __ | 12573 #undef __ |
| 12572 | 12574 |
| 12573 } } // namespace v8::internal | 12575 } } // namespace v8::internal |
| OLD | NEW |