 Chromium Code Reviews
 Chromium Code Reviews Issue 6744006:
  Add binary-op stub variant to handle oddball objects more efficiently.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
    
  
    Issue 6744006:
  Add binary-op stub variant to handle oddball objects more efficiently.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/| OLD | NEW | 
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1055 GenerateSmiStub(masm); | 1055 GenerateSmiStub(masm); | 
| 1056 break; | 1056 break; | 
| 1057 case TRBinaryOpIC::INT32: | 1057 case TRBinaryOpIC::INT32: | 
| 1058 UNREACHABLE(); | 1058 UNREACHABLE(); | 
| 1059 // The int32 case is identical to the Smi case. We avoid creating this | 1059 // The int32 case is identical to the Smi case. We avoid creating this | 
| 1060 // ic state on x64. | 1060 // ic state on x64. | 
| 1061 break; | 1061 break; | 
| 1062 case TRBinaryOpIC::HEAP_NUMBER: | 1062 case TRBinaryOpIC::HEAP_NUMBER: | 
| 1063 GenerateHeapNumberStub(masm); | 1063 GenerateHeapNumberStub(masm); | 
| 1064 break; | 1064 break; | 
| 1065 case TRBinaryOpIC::ODDBALL: | |
| 1066 GenerateOddballStub(masm); | |
| 1067 break; | |
| 1065 case TRBinaryOpIC::STRING: | 1068 case TRBinaryOpIC::STRING: | 
| 1066 GenerateStringStub(masm); | 1069 GenerateStringStub(masm); | 
| 1067 break; | 1070 break; | 
| 1068 case TRBinaryOpIC::GENERIC: | 1071 case TRBinaryOpIC::GENERIC: | 
| 1069 GenerateGeneric(masm); | 1072 GenerateGeneric(masm); | 
| 1070 break; | 1073 break; | 
| 1071 default: | 1074 default: | 
| 1072 UNREACHABLE(); | 1075 UNREACHABLE(); | 
| 1073 } | 1076 } | 
| 1074 } | 1077 } | 
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 void TypeRecordingBinaryOpStub::GenerateStringStub(MacroAssembler* masm) { | 1434 void TypeRecordingBinaryOpStub::GenerateStringStub(MacroAssembler* masm) { | 
| 1432 ASSERT(operands_type_ == TRBinaryOpIC::STRING); | 1435 ASSERT(operands_type_ == TRBinaryOpIC::STRING); | 
| 1433 ASSERT(op_ == Token::ADD); | 1436 ASSERT(op_ == Token::ADD); | 
| 1434 GenerateStringAddCode(masm); | 1437 GenerateStringAddCode(masm); | 
| 1435 // Try to add arguments as strings, otherwise, transition to the generic | 1438 // Try to add arguments as strings, otherwise, transition to the generic | 
| 1436 // TRBinaryOpIC type. | 1439 // TRBinaryOpIC type. | 
| 1437 GenerateTypeTransition(masm); | 1440 GenerateTypeTransition(masm); | 
| 1438 } | 1441 } | 
| 1439 | 1442 | 
| 1440 | 1443 | 
| 1444 void TypeRecordingBinaryOpStub::GenerateOddballStub(MacroAssembler* masm) { | |
| 1445 Label call_runtime; | |
| 1446 | |
| 1447 if (op_ == Token::ADD) { | |
| 1448 // Handle string addition here, because it is the only operation | |
| 1449 // that does not do a ToNumber conversion on the operands. | |
| 1450 GenerateStringAddCode(masm); | |
| 1451 } | |
| 1452 | |
| 1453 // Convert odd ball arguments to numbers. | |
| 1454 NearLabel check, done; | |
| 1455 __ Cmp(rdx, FACTORY->undefined_value()); | |
| 
Erik Corry
2011/03/28 15:15:24
CompareRoot and LoadRoot.
 
fschneider
2011/03/28 16:28:59
Done.
 | |
| 1456 __ j(not_equal, &check); | |
| 1457 if (Token::IsBitOp(op_)) { | |
| 1458 __ xor_(rdx, rdx); | |
| 1459 } else { | |
| 1460 __ Move(rdx, FACTORY->nan_value()); | |
| 1461 } | |
| 1462 __ jmp(&done); | |
| 1463 __ bind(&check); | |
| 1464 __ Cmp(rax, FACTORY->undefined_value()); | |
| 1465 __ j(not_equal, &done); | |
| 1466 if (Token::IsBitOp(op_)) { | |
| 1467 __ xor_(rax, rax); | |
| 1468 } else { | |
| 1469 __ Move(rax, FACTORY->nan_value()); | |
| 1470 } | |
| 1471 __ bind(&done); | |
| 1472 | |
| 1473 GenerateHeapNumberStub(masm); | |
| 1474 } | |
| 1475 | |
| 1476 | |
| 1441 void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { | 1477 void TypeRecordingBinaryOpStub::GenerateHeapNumberStub(MacroAssembler* masm) { | 
| 1442 Label gc_required, not_number; | 1478 Label gc_required, not_number; | 
| 1443 GenerateFloatingPointCode(masm, &gc_required, ¬_number); | 1479 GenerateFloatingPointCode(masm, &gc_required, ¬_number); | 
| 1444 | 1480 | 
| 1445 __ bind(¬_number); | 1481 __ bind(¬_number); | 
| 1446 GenerateTypeTransition(masm); | 1482 GenerateTypeTransition(masm); | 
| 1447 | 1483 | 
| 1448 __ bind(&gc_required); | 1484 __ bind(&gc_required); | 
| 1449 GenerateCallRuntimeCode(masm); | 1485 GenerateCallRuntimeCode(masm); | 
| 1450 } | 1486 } | 
| (...skipping 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5089 // Do a tail call to the rewritten stub. | 5125 // Do a tail call to the rewritten stub. | 
| 5090 __ jmp(rdi); | 5126 __ jmp(rdi); | 
| 5091 } | 5127 } | 
| 5092 | 5128 | 
| 5093 | 5129 | 
| 5094 #undef __ | 5130 #undef __ | 
| 5095 | 5131 | 
| 5096 } } // namespace v8::internal | 5132 } } // namespace v8::internal | 
| 5097 | 5133 | 
| 5098 #endif // V8_TARGET_ARCH_X64 | 5134 #endif // V8_TARGET_ARCH_X64 | 
| OLD | NEW |