OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
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 5440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5451 void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) { | 5451 void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) { |
5452 Register input = ToRegister(instr->value()); | 5452 Register input = ToRegister(instr->value()); |
5453 | 5453 |
5454 Register cmp1 = no_reg; | 5454 Register cmp1 = no_reg; |
5455 Operand cmp2 = Operand(no_reg); | 5455 Operand cmp2 = Operand(no_reg); |
5456 | 5456 |
5457 Condition final_branch_condition = EmitTypeofIs(instr->TrueLabel(chunk_), | 5457 Condition final_branch_condition = EmitTypeofIs(instr->TrueLabel(chunk_), |
5458 instr->FalseLabel(chunk_), | 5458 instr->FalseLabel(chunk_), |
5459 input, | 5459 input, |
5460 instr->type_literal(), | 5460 instr->type_literal(), |
5461 cmp1, | 5461 &cmp1, |
5462 cmp2); | 5462 &cmp2); |
5463 | 5463 |
5464 ASSERT(cmp1.is_valid()); | 5464 ASSERT(cmp1.is_valid()); |
5465 ASSERT(!cmp2.is_reg() || cmp2.rm().is_valid()); | 5465 ASSERT(!cmp2.is_reg() || cmp2.rm().is_valid()); |
5466 | 5466 |
5467 if (final_branch_condition != kNoCondition) { | 5467 if (final_branch_condition != kNoCondition) { |
5468 EmitBranch(instr, final_branch_condition, cmp1, cmp2); | 5468 EmitBranch(instr, final_branch_condition, cmp1, cmp2); |
5469 } | 5469 } |
5470 } | 5470 } |
5471 | 5471 |
5472 | 5472 |
5473 Condition LCodeGen::EmitTypeofIs(Label* true_label, | 5473 Condition LCodeGen::EmitTypeofIs(Label* true_label, |
5474 Label* false_label, | 5474 Label* false_label, |
5475 Register input, | 5475 Register input, |
5476 Handle<String> type_name, | 5476 Handle<String> type_name, |
5477 Register& cmp1, | 5477 Register* cmp1, |
5478 Operand& cmp2) { | 5478 Operand* cmp2) { |
5479 // This function utilizes the delay slot heavily. This is used to load | 5479 // This function utilizes the delay slot heavily. This is used to load |
5480 // values that are always usable without depending on the type of the input | 5480 // values that are always usable without depending on the type of the input |
5481 // register. | 5481 // register. |
5482 Condition final_branch_condition = kNoCondition; | 5482 Condition final_branch_condition = kNoCondition; |
5483 Register scratch = scratch0(); | 5483 Register scratch = scratch0(); |
5484 Factory* factory = isolate()->factory(); | 5484 Factory* factory = isolate()->factory(); |
5485 if (String::Equals(type_name, factory->number_string())) { | 5485 if (String::Equals(type_name, factory->number_string())) { |
5486 __ JumpIfSmi(input, true_label); | 5486 __ JumpIfSmi(input, true_label); |
5487 __ lw(input, FieldMemOperand(input, HeapObject::kMapOffset)); | 5487 __ lw(input, FieldMemOperand(input, HeapObject::kMapOffset)); |
5488 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); | 5488 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); |
5489 cmp1 = input; | 5489 *cmp1 = input; |
5490 cmp2 = Operand(at); | 5490 *cmp2 = Operand(at); |
5491 final_branch_condition = eq; | 5491 final_branch_condition = eq; |
5492 | 5492 |
5493 } else if (String::Equals(type_name, factory->string_string())) { | 5493 } else if (String::Equals(type_name, factory->string_string())) { |
5494 __ JumpIfSmi(input, false_label); | 5494 __ JumpIfSmi(input, false_label); |
5495 __ GetObjectType(input, input, scratch); | 5495 __ GetObjectType(input, input, scratch); |
5496 __ Branch(USE_DELAY_SLOT, false_label, | 5496 __ Branch(USE_DELAY_SLOT, false_label, |
5497 ge, scratch, Operand(FIRST_NONSTRING_TYPE)); | 5497 ge, scratch, Operand(FIRST_NONSTRING_TYPE)); |
5498 // input is an object so we can load the BitFieldOffset even if we take the | 5498 // input is an object so we can load the BitFieldOffset even if we take the |
5499 // other branch. | 5499 // other branch. |
5500 __ lbu(at, FieldMemOperand(input, Map::kBitFieldOffset)); | 5500 __ lbu(at, FieldMemOperand(input, Map::kBitFieldOffset)); |
5501 __ And(at, at, 1 << Map::kIsUndetectable); | 5501 __ And(at, at, 1 << Map::kIsUndetectable); |
5502 cmp1 = at; | 5502 *cmp1 = at; |
5503 cmp2 = Operand(zero_reg); | 5503 *cmp2 = Operand(zero_reg); |
5504 final_branch_condition = eq; | 5504 final_branch_condition = eq; |
5505 | 5505 |
5506 } else if (String::Equals(type_name, factory->symbol_string())) { | 5506 } else if (String::Equals(type_name, factory->symbol_string())) { |
5507 __ JumpIfSmi(input, false_label); | 5507 __ JumpIfSmi(input, false_label); |
5508 __ GetObjectType(input, input, scratch); | 5508 __ GetObjectType(input, input, scratch); |
5509 cmp1 = scratch; | 5509 *cmp1 = scratch; |
5510 cmp2 = Operand(SYMBOL_TYPE); | 5510 *cmp2 = Operand(SYMBOL_TYPE); |
5511 final_branch_condition = eq; | 5511 final_branch_condition = eq; |
5512 | 5512 |
5513 } else if (String::Equals(type_name, factory->boolean_string())) { | 5513 } else if (String::Equals(type_name, factory->boolean_string())) { |
5514 __ LoadRoot(at, Heap::kTrueValueRootIndex); | 5514 __ LoadRoot(at, Heap::kTrueValueRootIndex); |
5515 __ Branch(USE_DELAY_SLOT, true_label, eq, at, Operand(input)); | 5515 __ Branch(USE_DELAY_SLOT, true_label, eq, at, Operand(input)); |
5516 __ LoadRoot(at, Heap::kFalseValueRootIndex); | 5516 __ LoadRoot(at, Heap::kFalseValueRootIndex); |
5517 cmp1 = at; | 5517 *cmp1 = at; |
5518 cmp2 = Operand(input); | 5518 *cmp2 = Operand(input); |
5519 final_branch_condition = eq; | 5519 final_branch_condition = eq; |
5520 | 5520 |
5521 } else if (FLAG_harmony_typeof && | 5521 } else if (FLAG_harmony_typeof && |
5522 String::Equals(type_name, factory->null_string())) { | 5522 String::Equals(type_name, factory->null_string())) { |
5523 __ LoadRoot(at, Heap::kNullValueRootIndex); | 5523 __ LoadRoot(at, Heap::kNullValueRootIndex); |
5524 cmp1 = at; | 5524 *cmp1 = at; |
5525 cmp2 = Operand(input); | 5525 *cmp2 = Operand(input); |
5526 final_branch_condition = eq; | 5526 final_branch_condition = eq; |
5527 | 5527 |
5528 } else if (String::Equals(type_name, factory->undefined_string())) { | 5528 } else if (String::Equals(type_name, factory->undefined_string())) { |
5529 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 5529 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
5530 __ Branch(USE_DELAY_SLOT, true_label, eq, at, Operand(input)); | 5530 __ Branch(USE_DELAY_SLOT, true_label, eq, at, Operand(input)); |
5531 // The first instruction of JumpIfSmi is an And - it is safe in the delay | 5531 // The first instruction of JumpIfSmi is an And - it is safe in the delay |
5532 // slot. | 5532 // slot. |
5533 __ JumpIfSmi(input, false_label); | 5533 __ JumpIfSmi(input, false_label); |
5534 // Check for undetectable objects => true. | 5534 // Check for undetectable objects => true. |
5535 __ lw(input, FieldMemOperand(input, HeapObject::kMapOffset)); | 5535 __ lw(input, FieldMemOperand(input, HeapObject::kMapOffset)); |
5536 __ lbu(at, FieldMemOperand(input, Map::kBitFieldOffset)); | 5536 __ lbu(at, FieldMemOperand(input, Map::kBitFieldOffset)); |
5537 __ And(at, at, 1 << Map::kIsUndetectable); | 5537 __ And(at, at, 1 << Map::kIsUndetectable); |
5538 cmp1 = at; | 5538 *cmp1 = at; |
5539 cmp2 = Operand(zero_reg); | 5539 *cmp2 = Operand(zero_reg); |
5540 final_branch_condition = ne; | 5540 final_branch_condition = ne; |
5541 | 5541 |
5542 } else if (String::Equals(type_name, factory->function_string())) { | 5542 } else if (String::Equals(type_name, factory->function_string())) { |
5543 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); | 5543 STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
5544 __ JumpIfSmi(input, false_label); | 5544 __ JumpIfSmi(input, false_label); |
5545 __ GetObjectType(input, scratch, input); | 5545 __ GetObjectType(input, scratch, input); |
5546 __ Branch(true_label, eq, input, Operand(JS_FUNCTION_TYPE)); | 5546 __ Branch(true_label, eq, input, Operand(JS_FUNCTION_TYPE)); |
5547 cmp1 = input; | 5547 *cmp1 = input; |
5548 cmp2 = Operand(JS_FUNCTION_PROXY_TYPE); | 5548 *cmp2 = Operand(JS_FUNCTION_PROXY_TYPE); |
5549 final_branch_condition = eq; | 5549 final_branch_condition = eq; |
5550 | 5550 |
5551 } else if (String::Equals(type_name, factory->object_string())) { | 5551 } else if (String::Equals(type_name, factory->object_string())) { |
5552 __ JumpIfSmi(input, false_label); | 5552 __ JumpIfSmi(input, false_label); |
5553 if (!FLAG_harmony_typeof) { | 5553 if (!FLAG_harmony_typeof) { |
5554 __ LoadRoot(at, Heap::kNullValueRootIndex); | 5554 __ LoadRoot(at, Heap::kNullValueRootIndex); |
5555 __ Branch(USE_DELAY_SLOT, true_label, eq, at, Operand(input)); | 5555 __ Branch(USE_DELAY_SLOT, true_label, eq, at, Operand(input)); |
5556 } | 5556 } |
5557 Register map = input; | 5557 Register map = input; |
5558 __ GetObjectType(input, map, scratch); | 5558 __ GetObjectType(input, map, scratch); |
5559 __ Branch(false_label, | 5559 __ Branch(false_label, |
5560 lt, scratch, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 5560 lt, scratch, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
5561 __ Branch(USE_DELAY_SLOT, false_label, | 5561 __ Branch(USE_DELAY_SLOT, false_label, |
5562 gt, scratch, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); | 5562 gt, scratch, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
5563 // map is still valid, so the BitField can be loaded in delay slot. | 5563 // map is still valid, so the BitField can be loaded in delay slot. |
5564 // Check for undetectable objects => false. | 5564 // Check for undetectable objects => false. |
5565 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset)); | 5565 __ lbu(at, FieldMemOperand(map, Map::kBitFieldOffset)); |
5566 __ And(at, at, 1 << Map::kIsUndetectable); | 5566 __ And(at, at, 1 << Map::kIsUndetectable); |
5567 cmp1 = at; | 5567 *cmp1 = at; |
5568 cmp2 = Operand(zero_reg); | 5568 *cmp2 = Operand(zero_reg); |
5569 final_branch_condition = eq; | 5569 final_branch_condition = eq; |
5570 | 5570 |
5571 } else { | 5571 } else { |
5572 cmp1 = at; | 5572 *cmp1 = at; |
5573 cmp2 = Operand(zero_reg); // Set to valid regs, to avoid caller assertion. | 5573 *cmp2 = Operand(zero_reg); // Set to valid regs, to avoid caller assertion. |
5574 __ Branch(false_label); | 5574 __ Branch(false_label); |
5575 } | 5575 } |
5576 | 5576 |
5577 return final_branch_condition; | 5577 return final_branch_condition; |
5578 } | 5578 } |
5579 | 5579 |
5580 | 5580 |
5581 void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) { | 5581 void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) { |
5582 Register temp1 = ToRegister(instr->temp()); | 5582 Register temp1 = ToRegister(instr->temp()); |
5583 | 5583 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5867 __ lw(result, FieldMemOperand(scratch, | 5867 __ lw(result, FieldMemOperand(scratch, |
5868 FixedArray::kHeaderSize - kPointerSize)); | 5868 FixedArray::kHeaderSize - kPointerSize)); |
5869 __ bind(deferred->exit()); | 5869 __ bind(deferred->exit()); |
5870 __ bind(&done); | 5870 __ bind(&done); |
5871 } | 5871 } |
5872 | 5872 |
5873 | 5873 |
5874 #undef __ | 5874 #undef __ |
5875 | 5875 |
5876 } } // namespace v8::internal | 5876 } } // namespace v8::internal |
OLD | NEW |