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

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

Issue 40023: Streamline CodeGenerator::Comparison in the IA32 code generator. When... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 Result right_side(this); 1299 Result right_side(this);
1300 // Implement '>' and '<=' by reversal to obtain ECMA-262 conversion order. 1300 // Implement '>' and '<=' by reversal to obtain ECMA-262 conversion order.
1301 if (cc == greater || cc == less_equal) { 1301 if (cc == greater || cc == less_equal) {
1302 cc = ReverseCondition(cc); 1302 cc = ReverseCondition(cc);
1303 left_side = frame_->Pop(); 1303 left_side = frame_->Pop();
1304 right_side = frame_->Pop(); 1304 right_side = frame_->Pop();
1305 } else { 1305 } else {
1306 right_side = frame_->Pop(); 1306 right_side = frame_->Pop();
1307 left_side = frame_->Pop(); 1307 left_side = frame_->Pop();
1308 } 1308 }
1309 ASSERT(cc == less || cc == equal || cc == greater_equal);
1310
1309 // If either side is a constant smi, optimize the comparison. 1311 // If either side is a constant smi, optimize the comparison.
1310 bool left_side_constant_smi = 1312 bool left_side_constant_smi =
1311 left_side.is_constant() && left_side.handle()->IsSmi(); 1313 left_side.is_constant() && left_side.handle()->IsSmi();
1312 bool right_side_constant_smi = 1314 bool right_side_constant_smi =
1313 right_side.is_constant() && right_side.handle()->IsSmi(); 1315 right_side.is_constant() && right_side.handle()->IsSmi();
1314 bool left_side_constant_null = 1316 bool left_side_constant_null =
1315 left_side.is_constant() && left_side.handle()->IsNull(); 1317 left_side.is_constant() && left_side.handle()->IsNull();
1316 bool right_side_constant_null = 1318 bool right_side_constant_null =
1317 right_side.is_constant() && right_side.handle()->IsNull(); 1319 right_side.is_constant() && right_side.handle()->IsNull();
1318 1320
1319 if (left_side_constant_smi || right_side_constant_smi) { 1321 if (left_side_constant_smi || right_side_constant_smi) {
1320 if (left_side_constant_smi && right_side_constant_smi) { 1322 if (left_side_constant_smi && right_side_constant_smi) {
1321 // Trivial case, comparing two constants. 1323 // Trivial case, comparing two constants.
1322 int left_value = Smi::cast(*left_side.handle())->value(); 1324 int left_value = Smi::cast(*left_side.handle())->value();
1323 int right_value = Smi::cast(*right_side.handle())->value(); 1325 int right_value = Smi::cast(*right_side.handle())->value();
1324 if (left_value < right_value && 1326 switch (cc) {
1325 (cc == less || cc == less_equal || cc == not_equal) || 1327 case less:
1326 left_value == right_value && 1328 dest->Goto(left_value < right_value);
1327 (cc == less_equal || cc == equal || cc == greater_equal) || 1329 break;
1328 left_value > right_value && 1330 case equal:
1329 (cc == greater || cc == greater_equal || cc == not_equal)) { 1331 dest->Goto(left_value == right_value);
1330 // The comparison is unconditionally true. 1332 break;
1331 dest->Goto(true); 1333 case greater_equal:
1332 } else { 1334 dest->Goto(left_value >= right_value);
1333 // The comparison is unconditionally false. 1335 break;
1334 dest->Goto(false); 1336 default:
1337 UNREACHABLE();
1335 } 1338 }
1336 } else { // Only one side is a constant Smi. 1339 } else { // Only one side is a constant Smi.
1337 // If left side is a constant Smi, reverse the operands. 1340 // If left side is a constant Smi, reverse the operands.
1338 // Since one side is a constant Smi, conversion order does not matter. 1341 // Since one side is a constant Smi, conversion order does not matter.
1339 if (left_side_constant_smi) { 1342 if (left_side_constant_smi) {
1340 Result temp = left_side; 1343 Result temp = left_side;
1341 left_side = right_side; 1344 left_side = right_side;
1342 right_side = temp; 1345 right_side = temp;
1343 cc = ReverseCondition(cc); 1346 cc = ReverseCondition(cc);
1344 // This may reintroduce greater or less_equal as the value of cc. 1347 // This may reintroduce greater or less_equal as the value of cc.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 __ movzx_b(temp.reg(), 1413 __ movzx_b(temp.reg(),
1411 FieldOperand(temp.reg(), Map::kBitFieldOffset)); 1414 FieldOperand(temp.reg(), Map::kBitFieldOffset));
1412 __ test(temp.reg(), Immediate(1 << Map::kIsUndetectable)); 1415 __ test(temp.reg(), Immediate(1 << Map::kIsUndetectable));
1413 temp.Unuse(); 1416 temp.Unuse();
1414 operand.Unuse(); 1417 operand.Unuse();
1415 dest->Split(not_zero); 1418 dest->Split(not_zero);
1416 } 1419 }
1417 } else { // Neither side is a constant Smi or null. 1420 } else { // Neither side is a constant Smi or null.
1418 // If either side is a non-smi constant, skip the smi check. 1421 // If either side is a non-smi constant, skip the smi check.
1419 bool known_non_smi = 1422 bool known_non_smi =
1420 left_side.is_constant() && !left_side.handle()->IsSmi() || 1423 (left_side.is_constant() && !left_side.handle()->IsSmi()) ||
1421 right_side.is_constant() && !right_side.handle()->IsSmi(); 1424 (right_side.is_constant() && !right_side.handle()->IsSmi());
1422 left_side.ToRegister(); 1425 left_side.ToRegister();
1423 right_side.ToRegister(); 1426 right_side.ToRegister();
1424 JumpTarget is_smi(this); 1427 JumpTarget is_smi(this);
1425 if (!known_non_smi) { 1428 if (!known_non_smi) {
1426 // Check for the smi case. 1429 // Check for the smi case.
1427 Result temp = allocator_->Allocate(); 1430 Result temp = allocator_->Allocate();
1428 ASSERT(temp.is_valid()); 1431 ASSERT(temp.is_valid());
1429 __ mov(temp.reg(), left_side.reg()); 1432 __ mov(temp.reg(), left_side.reg());
1430 __ or_(temp.reg(), Operand(right_side.reg())); 1433 __ or_(temp.reg(), Operand(right_side.reg()));
1431 __ test(temp.reg(), Immediate(kSmiTagMask)); 1434 __ test(temp.reg(), Immediate(kSmiTagMask));
(...skipping 5381 matching lines...) Expand 10 before | Expand all | Expand 10 after
6813 6816
6814 // Slow-case: Go through the JavaScript implementation. 6817 // Slow-case: Go through the JavaScript implementation.
6815 __ bind(&slow); 6818 __ bind(&slow);
6816 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); 6819 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION);
6817 } 6820 }
6818 6821
6819 6822
6820 #undef __ 6823 #undef __
6821 6824
6822 } } // namespace v8::internal 6825 } } // namespace v8::internal
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