OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 __ add(Operand(esp), Immediate(kDoubleSize)); | 2029 __ add(Operand(esp), Immediate(kDoubleSize)); |
2030 break; | 2030 break; |
2031 } | 2031 } |
2032 default: | 2032 default: |
2033 UNREACHABLE(); | 2033 UNREACHABLE(); |
2034 break; | 2034 break; |
2035 } | 2035 } |
2036 } | 2036 } |
2037 | 2037 |
2038 | 2038 |
2039 void LCodeGen::DoNegateNoSSE2D(LNegateNoSSE2D* instr) { | |
2040 __ push(Immediate(-1)); | |
2041 __ fild_s(Operand(esp, 0)); | |
2042 __ add(esp, Immediate(kPointerSize)); | |
2043 __ fmulp(); | |
2044 CurrentInstructionReturnsX87Result(); | |
2045 } | |
2046 | |
2047 | |
2048 | |
2049 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { | 2039 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { |
2050 ASSERT(ToRegister(instr->context()).is(esi)); | 2040 ASSERT(ToRegister(instr->context()).is(esi)); |
2051 ASSERT(ToRegister(instr->left()).is(edx)); | 2041 ASSERT(ToRegister(instr->left()).is(edx)); |
2052 ASSERT(ToRegister(instr->right()).is(eax)); | 2042 ASSERT(ToRegister(instr->right()).is(eax)); |
2053 ASSERT(ToRegister(instr->result()).is(eax)); | 2043 ASSERT(ToRegister(instr->result()).is(eax)); |
2054 | 2044 |
2055 BinaryOpStub stub(instr->op(), NO_OVERWRITE); | 2045 BinaryOpStub stub(instr->op(), NO_OVERWRITE); |
2056 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 2046 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
2057 __ nop(); // Signals no inlined code. | 2047 __ nop(); // Signals no inlined code. |
2058 } | 2048 } |
2059 | 2049 |
2060 | 2050 |
2061 int LCodeGen::GetNextEmittedBlock() const { | 2051 int LCodeGen::GetNextEmittedBlock() const { |
2062 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { | 2052 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { |
2063 if (!chunk_->GetLabel(i)->HasReplacement()) return i; | 2053 if (!chunk_->GetLabel(i)->HasReplacement()) return i; |
2064 } | 2054 } |
2065 return -1; | 2055 return -1; |
2066 } | 2056 } |
2067 | 2057 |
2068 | 2058 |
2069 template<class InstrType> | 2059 template<class InstrType> |
2070 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { | 2060 void LCodeGen::EmitBranch(InstrType instr, Condition cc) { |
| 2061 int right_block = instr->FalseDestination(chunk_); |
2071 int left_block = instr->TrueDestination(chunk_); | 2062 int left_block = instr->TrueDestination(chunk_); |
2072 int right_block = instr->FalseDestination(chunk_); | |
2073 | 2063 |
2074 int next_block = GetNextEmittedBlock(); | 2064 int next_block = GetNextEmittedBlock(); |
2075 | 2065 |
2076 if (right_block == left_block || cc == no_condition) { | 2066 if (right_block == left_block) { |
2077 EmitGoto(left_block); | 2067 EmitGoto(left_block); |
2078 } else if (left_block == next_block) { | 2068 } else if (left_block == next_block) { |
2079 __ j(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block)); | 2069 __ j(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block)); |
2080 } else if (right_block == next_block) { | 2070 } else if (right_block == next_block) { |
2081 __ j(cc, chunk_->GetAssemblyLabel(left_block)); | 2071 __ j(cc, chunk_->GetAssemblyLabel(left_block)); |
2082 } else { | 2072 } else { |
2083 __ j(cc, chunk_->GetAssemblyLabel(left_block)); | 2073 __ j(cc, chunk_->GetAssemblyLabel(left_block)); |
2084 __ jmp(chunk_->GetAssemblyLabel(right_block)); | 2074 __ jmp(chunk_->GetAssemblyLabel(right_block)); |
2085 } | 2075 } |
2086 } | 2076 } |
2087 | 2077 |
2088 | 2078 |
2089 void LCodeGen::DoIsNumberAndBranch(LIsNumberAndBranch* instr) { | |
2090 Representation r = instr->hydrogen()->value()->representation(); | |
2091 if (r.IsSmiOrInteger32() || r.IsDouble()) { | |
2092 EmitBranch(instr, no_condition); | |
2093 } else { | |
2094 ASSERT(r.IsTagged()); | |
2095 Register reg = ToRegister(instr->value()); | |
2096 HType type = instr->hydrogen()->value()->type(); | |
2097 if (type.IsTaggedNumber()) { | |
2098 EmitBranch(instr, no_condition); | |
2099 } | |
2100 __ JumpIfSmi(reg, instr->TrueLabel(chunk_)); | |
2101 __ cmp(FieldOperand(reg, HeapObject::kMapOffset), | |
2102 factory()->heap_number_map()); | |
2103 EmitBranch(instr, equal); | |
2104 } | |
2105 } | |
2106 | |
2107 | |
2108 void LCodeGen::DoBranch(LBranch* instr) { | 2079 void LCodeGen::DoBranch(LBranch* instr) { |
2109 Representation r = instr->hydrogen()->value()->representation(); | 2080 Representation r = instr->hydrogen()->value()->representation(); |
2110 if (r.IsSmiOrInteger32()) { | 2081 if (r.IsSmiOrInteger32()) { |
2111 ASSERT(!info()->IsStub()); | 2082 ASSERT(!info()->IsStub()); |
2112 Register reg = ToRegister(instr->value()); | 2083 Register reg = ToRegister(instr->value()); |
2113 __ test(reg, Operand(reg)); | 2084 __ test(reg, Operand(reg)); |
2114 EmitBranch(instr, not_zero); | 2085 EmitBranch(instr, not_zero); |
2115 } else if (r.IsDouble()) { | 2086 } else if (r.IsDouble()) { |
2116 ASSERT(!info()->IsStub()); | 2087 ASSERT(!info()->IsStub()); |
2117 CpuFeatureScope scope(masm(), SSE2); | 2088 CpuFeatureScope scope(masm(), SSE2); |
(...skipping 4454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6572 FixedArray::kHeaderSize - kPointerSize)); | 6543 FixedArray::kHeaderSize - kPointerSize)); |
6573 __ bind(&done); | 6544 __ bind(&done); |
6574 } | 6545 } |
6575 | 6546 |
6576 | 6547 |
6577 #undef __ | 6548 #undef __ |
6578 | 6549 |
6579 } } // namespace v8::internal | 6550 } } // namespace v8::internal |
6580 | 6551 |
6581 #endif // V8_TARGET_ARCH_IA32 | 6552 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |