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

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

Issue 7482044: Tiny cleanup of LCodeGen::DoBranch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 4 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 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 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 Register reg = ToRegister(instr->InputAt(0)); 1385 Register reg = ToRegister(instr->InputAt(0));
1386 __ test(reg, Operand(reg)); 1386 __ test(reg, Operand(reg));
1387 EmitBranch(true_block, false_block, not_zero); 1387 EmitBranch(true_block, false_block, not_zero);
1388 } else if (r.IsDouble()) { 1388 } else if (r.IsDouble()) {
1389 XMMRegister reg = ToDoubleRegister(instr->InputAt(0)); 1389 XMMRegister reg = ToDoubleRegister(instr->InputAt(0));
1390 __ xorps(xmm0, xmm0); 1390 __ xorps(xmm0, xmm0);
1391 __ ucomisd(reg, xmm0); 1391 __ ucomisd(reg, xmm0);
1392 EmitBranch(true_block, false_block, not_equal); 1392 EmitBranch(true_block, false_block, not_equal);
1393 } else { 1393 } else {
1394 ASSERT(r.IsTagged()); 1394 ASSERT(r.IsTagged());
1395 Factory* factory = this->factory();
1396 Register reg = ToRegister(instr->InputAt(0)); 1395 Register reg = ToRegister(instr->InputAt(0));
1397 if (instr->hydrogen()->value()->type().IsBoolean()) { 1396 if (instr->hydrogen()->value()->type().IsBoolean()) {
1398 __ cmp(reg, factory->true_value()); 1397 __ cmp(reg, factory()->true_value());
1399 EmitBranch(true_block, false_block, equal); 1398 EmitBranch(true_block, false_block, equal);
1400 } else { 1399 } else {
1401 Label* true_label = chunk_->GetAssemblyLabel(true_block); 1400 Label* true_label = chunk_->GetAssemblyLabel(true_block);
1402 Label* false_label = chunk_->GetAssemblyLabel(false_block); 1401 Label* false_label = chunk_->GetAssemblyLabel(false_block);
1403 1402
1404 ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types(); 1403 ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types();
1405 // Avoid deopts in the case where we've never executed this path before. 1404 // Avoid deopts in the case where we've never executed this path before.
1406 if (expected.IsEmpty()) expected = ToBooleanStub::all_types(); 1405 if (expected.IsEmpty()) expected = ToBooleanStub::all_types();
1407 1406
1408 if (expected.Contains(ToBooleanStub::UNDEFINED)) { 1407 if (expected.Contains(ToBooleanStub::UNDEFINED)) {
1409 // undefined -> false. 1408 // undefined -> false.
1410 __ cmp(reg, factory->undefined_value()); 1409 __ cmp(reg, factory()->undefined_value());
1411 __ j(equal, false_label); 1410 __ j(equal, false_label);
1412 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) { 1411 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
1413 // We've seen undefined for the first time -> deopt. 1412 // We've seen undefined for the first time -> deopt.
1414 __ cmp(reg, factory->undefined_value()); 1413 __ cmp(reg, factory()->undefined_value());
1415 DeoptimizeIf(equal, instr->environment()); 1414 DeoptimizeIf(equal, instr->environment());
1416 } 1415 }
1417 1416
1418 if (expected.Contains(ToBooleanStub::BOOLEAN)) { 1417 if (expected.Contains(ToBooleanStub::BOOLEAN)) {
1419 // true -> true. 1418 // true -> true.
1420 __ cmp(reg, factory->true_value()); 1419 __ cmp(reg, factory()->true_value());
1421 __ j(equal, true_label); 1420 __ j(equal, true_label);
1422 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) { 1421 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
1423 // We've seen a string for the first time -> deopt. 1422 // We've seen a boolean for the first time -> deopt.
1424 __ cmp(reg, factory->true_value()); 1423 __ cmp(reg, factory()->true_value());
1425 DeoptimizeIf(equal, instr->environment()); 1424 DeoptimizeIf(equal, instr->environment());
1426 } 1425 }
1427 1426
1428 if (expected.Contains(ToBooleanStub::BOOLEAN)) { 1427 if (expected.Contains(ToBooleanStub::BOOLEAN)) {
1429 // false -> false. 1428 // false -> false.
1430 __ cmp(reg, factory->false_value()); 1429 __ cmp(reg, factory()->false_value());
1431 __ j(equal, false_label); 1430 __ j(equal, false_label);
1432 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) { 1431 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
1433 // We've seen a string for the first time -> deopt. 1432 // We've seen a boolean for the first time -> deopt.
1434 __ cmp(reg, factory->false_value()); 1433 __ cmp(reg, factory()->false_value());
1435 DeoptimizeIf(equal, instr->environment()); 1434 DeoptimizeIf(equal, instr->environment());
1436 } 1435 }
1437 1436
1438 if (expected.Contains(ToBooleanStub::NULL_TYPE)) { 1437 if (expected.Contains(ToBooleanStub::NULL_TYPE)) {
1439 // 'null' -> false. 1438 // 'null' -> false.
1440 __ cmp(reg, factory->null_value()); 1439 __ cmp(reg, factory()->null_value());
1441 __ j(equal, false_label); 1440 __ j(equal, false_label);
1442 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) { 1441 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
1443 // We've seen null for the first time -> deopt. 1442 // We've seen null for the first time -> deopt.
1444 __ cmp(reg, factory->null_value()); 1443 __ cmp(reg, factory()->null_value());
1445 DeoptimizeIf(equal, instr->environment()); 1444 DeoptimizeIf(equal, instr->environment());
1446 } 1445 }
1447 1446
1448 if (expected.Contains(ToBooleanStub::SMI)) { 1447 if (expected.Contains(ToBooleanStub::SMI)) {
1449 // Smis: 0 -> false, all other -> true. 1448 // Smis: 0 -> false, all other -> true.
1450 __ test(reg, Operand(reg)); 1449 __ test(reg, Operand(reg));
1451 __ j(equal, false_label); 1450 __ j(equal, false_label);
1452 __ JumpIfSmi(reg, true_label); 1451 __ JumpIfSmi(reg, true_label);
1453 } else if (expected.NeedsMap()) { 1452 } else if (expected.NeedsMap()) {
1454 // If we need a map later and have a Smi -> deopt. 1453 // If we need a map later and have a Smi -> deopt.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) { 1489 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
1491 // We've seen a string for the first time -> deopt 1490 // We've seen a string for the first time -> deopt
1492 __ CmpInstanceType(map, FIRST_NONSTRING_TYPE); 1491 __ CmpInstanceType(map, FIRST_NONSTRING_TYPE);
1493 DeoptimizeIf(below, instr->environment()); 1492 DeoptimizeIf(below, instr->environment());
1494 } 1493 }
1495 1494
1496 if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) { 1495 if (expected.Contains(ToBooleanStub::HEAP_NUMBER)) {
1497 // heap number -> false iff +0, -0, or NaN. 1496 // heap number -> false iff +0, -0, or NaN.
1498 Label not_heap_number; 1497 Label not_heap_number;
1499 __ cmp(FieldOperand(reg, HeapObject::kMapOffset), 1498 __ cmp(FieldOperand(reg, HeapObject::kMapOffset),
1500 factory->heap_number_map()); 1499 factory()->heap_number_map());
1501 __ j(not_equal, &not_heap_number, Label::kNear); 1500 __ j(not_equal, &not_heap_number, Label::kNear);
1502 __ fldz(); 1501 __ fldz();
1503 __ fld_d(FieldOperand(reg, HeapNumber::kValueOffset)); 1502 __ fld_d(FieldOperand(reg, HeapNumber::kValueOffset));
1504 __ FCmp(); 1503 __ FCmp();
1505 __ j(zero, false_label); 1504 __ j(zero, false_label);
1506 __ jmp(true_label); 1505 __ jmp(true_label);
1507 __ bind(&not_heap_number); 1506 __ bind(&not_heap_number);
1508 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) { 1507 } else if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
1509 // We've seen a heap number for the first time -> deopt. 1508 // We've seen a heap number for the first time -> deopt.
1510 __ cmp(FieldOperand(reg, HeapObject::kMapOffset), 1509 __ cmp(FieldOperand(reg, HeapObject::kMapOffset),
1511 factory->heap_number_map()); 1510 factory()->heap_number_map());
1512 DeoptimizeIf(equal, instr->environment()); 1511 DeoptimizeIf(equal, instr->environment());
1513 } 1512 }
1514 1513
1515 if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) { 1514 if (expected.Contains(ToBooleanStub::INTERNAL_OBJECT)) {
1516 // internal objects -> true 1515 // internal objects -> true
1517 __ jmp(true_label); 1516 __ jmp(true_label);
1518 } else { 1517 } else {
1519 // We've seen something for the first time -> deopt. 1518 // We've seen something for the first time -> deopt.
1520 DeoptimizeIf(no_condition, instr->environment()); 1519 DeoptimizeIf(no_condition, instr->environment());
1521 } 1520 }
(...skipping 2874 matching lines...) Expand 10 before | Expand all | Expand 10 after
4396 env->deoptimization_index()); 4395 env->deoptimization_index());
4397 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4396 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4398 } 4397 }
4399 4398
4400 4399
4401 #undef __ 4400 #undef __
4402 4401
4403 } } // namespace v8::internal 4402 } } // namespace v8::internal
4404 4403
4405 #endif // V8_TARGET_ARCH_IA32 4404 #endif // V8_TARGET_ARCH_IA32
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