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

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

Issue 3496007: Fix error in x64 inlined optimized shift operators. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 2 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 | « no previous file | 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 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 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 // Check that both operands are smis using the answer register as a 1343 // Check that both operands are smis using the answer register as a
1344 // temporary. 1344 // temporary.
1345 DeferredInlineBinaryOperation* deferred = 1345 DeferredInlineBinaryOperation* deferred =
1346 new DeferredInlineBinaryOperation(op, 1346 new DeferredInlineBinaryOperation(op,
1347 answer.reg(), 1347 answer.reg(),
1348 left->reg(), 1348 left->reg(),
1349 rcx, 1349 rcx,
1350 overwrite_mode); 1350 overwrite_mode);
1351 1351
1352 Label do_op; 1352 Label do_op;
1353 // Left operand must be unchanged in left->reg() for deferred code.
1354 // Left operand is in answer.reg(), possibly converted to int32, for
1355 // inline code.
1356 __ movq(answer.reg(), left->reg());
1353 if (right_type_info.IsSmi()) { 1357 if (right_type_info.IsSmi()) {
1354 if (FLAG_debug_code) { 1358 if (FLAG_debug_code) {
1355 __ AbortIfNotSmi(right->reg()); 1359 __ AbortIfNotSmi(right->reg());
1356 } 1360 }
1357 __ movq(answer.reg(), left->reg());
1358 // If left is not known to be a smi, check if it is. 1361 // If left is not known to be a smi, check if it is.
1359 // If left is not known to be a number, and it isn't a smi, check if 1362 // If left is not known to be a number, and it isn't a smi, check if
1360 // it is a HeapNumber. 1363 // it is a HeapNumber.
1361 if (!left_type_info.IsSmi()) { 1364 if (!left_type_info.IsSmi()) {
1362 __ JumpIfSmi(answer.reg(), &do_op); 1365 __ JumpIfSmi(answer.reg(), &do_op);
1363 if (!left_type_info.IsNumber()) { 1366 if (!left_type_info.IsNumber()) {
1364 // Branch if not a heapnumber. 1367 // Branch if not a heapnumber.
1365 __ Cmp(FieldOperand(answer.reg(), HeapObject::kMapOffset), 1368 __ Cmp(FieldOperand(answer.reg(), HeapObject::kMapOffset),
1366 Factory::heap_number_map()); 1369 Factory::heap_number_map());
1367 deferred->Branch(not_equal); 1370 deferred->Branch(not_equal);
1368 } 1371 }
1369 // Load integer value into answer register using truncation. 1372 // Load integer value into answer register using truncation.
1370 __ cvttsd2si(answer.reg(), 1373 __ cvttsd2si(answer.reg(),
1371 FieldOperand(answer.reg(), HeapNumber::kValueOffset)); 1374 FieldOperand(answer.reg(), HeapNumber::kValueOffset));
1372 // Branch if we might have overflowed. 1375 // Branch if we might have overflowed.
1373 // (False negative for Smi::kMinValue) 1376 // (False negative for Smi::kMinValue)
1374 __ cmpq(answer.reg(), Immediate(0x80000000)); 1377 __ cmpl(answer.reg(), Immediate(0x80000000));
1375 deferred->Branch(equal); 1378 deferred->Branch(equal);
1376 // TODO(lrn): Inline shifts on int32 here instead of first smi-tagging. 1379 // TODO(lrn): Inline shifts on int32 here instead of first smi-tagging.
1377 __ Integer32ToSmi(answer.reg(), answer.reg()); 1380 __ Integer32ToSmi(answer.reg(), answer.reg());
1378 } else { 1381 } else {
1379 // Fast case - both are actually smis. 1382 // Fast case - both are actually smis.
1380 if (FLAG_debug_code) { 1383 if (FLAG_debug_code) {
1381 __ AbortIfNotSmi(left->reg()); 1384 __ AbortIfNotSmi(left->reg());
1382 } 1385 }
1383 } 1386 }
1384 } else { 1387 } else {
1385 JumpIfNotBothSmiUsingTypeInfo(left->reg(), rcx, 1388 JumpIfNotBothSmiUsingTypeInfo(left->reg(), rcx,
1386 left_type_info, right_type_info, deferred); 1389 left_type_info, right_type_info, deferred);
1387 } 1390 }
1388 __ bind(&do_op); 1391 __ bind(&do_op);
1389 1392
1390 // Perform the operation. 1393 // Perform the operation.
1391 switch (op) { 1394 switch (op) {
1392 case Token::SAR: 1395 case Token::SAR:
1393 __ SmiShiftArithmeticRight(answer.reg(), left->reg(), rcx); 1396 __ SmiShiftArithmeticRight(answer.reg(), answer.reg(), rcx);
1394 break; 1397 break;
1395 case Token::SHR: { 1398 case Token::SHR: {
1396 __ SmiShiftLogicalRight(answer.reg(), 1399 __ SmiShiftLogicalRight(answer.reg(),
1397 left->reg(), 1400 answer.reg(),
1398 rcx, 1401 rcx,
1399 deferred->entry_label()); 1402 deferred->entry_label());
1400 break; 1403 break;
1401 } 1404 }
1402 case Token::SHL: { 1405 case Token::SHL: {
1403 __ SmiShiftLeft(answer.reg(), 1406 __ SmiShiftLeft(answer.reg(),
1404 left->reg(), 1407 answer.reg(),
1405 rcx); 1408 rcx);
1406 break; 1409 break;
1407 } 1410 }
1408 default: 1411 default:
1409 UNREACHABLE(); 1412 UNREACHABLE();
1410 } 1413 }
1411 deferred->BindExit(); 1414 deferred->BindExit();
1412 left->Unuse(); 1415 left->Unuse();
1413 right->Unuse(); 1416 right->Unuse();
1414 ASSERT(answer.is_valid()); 1417 ASSERT(answer.is_valid());
(...skipping 7507 matching lines...) Expand 10 before | Expand all | Expand 10 after
8922 #undef __ 8925 #undef __
8923 8926
8924 void RecordWriteStub::Generate(MacroAssembler* masm) { 8927 void RecordWriteStub::Generate(MacroAssembler* masm) {
8925 masm->RecordWriteHelper(object_, addr_, scratch_); 8928 masm->RecordWriteHelper(object_, addr_, scratch_);
8926 masm->ret(0); 8929 masm->ret(0);
8927 } 8930 }
8928 8931
8929 } } // namespace v8::internal 8932 } } // namespace v8::internal
8930 8933
8931 #endif // V8_TARGET_ARCH_X64 8934 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698