| OLD | NEW |
| 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 7663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7674 // Smi-tagging is equivalent to multiplying by 2. | 7674 // Smi-tagging is equivalent to multiplying by 2. |
| 7675 STATIC_ASSERT(kSmiTag == 0); | 7675 STATIC_ASSERT(kSmiTag == 0); |
| 7676 STATIC_ASSERT(kSmiTagSize == 1); | 7676 STATIC_ASSERT(kSmiTagSize == 1); |
| 7677 | 7677 |
| 7678 // Check that both indices are smis. | 7678 // Check that both indices are smis. |
| 7679 __ mov(tmp2.reg(), index1.reg()); | 7679 __ mov(tmp2.reg(), index1.reg()); |
| 7680 __ or_(tmp2.reg(), Operand(index2.reg())); | 7680 __ or_(tmp2.reg(), Operand(index2.reg())); |
| 7681 __ test(tmp2.reg(), Immediate(kSmiTagMask)); | 7681 __ test(tmp2.reg(), Immediate(kSmiTagMask)); |
| 7682 deferred->Branch(not_zero); | 7682 deferred->Branch(not_zero); |
| 7683 | 7683 |
| 7684 // Check that both indices are valid. |
| 7685 __ mov(tmp2.reg(), FieldOperand(object.reg(), JSArray::kLengthOffset)); |
| 7686 __ cmp(tmp2.reg(), Operand(index1.reg())); |
| 7687 deferred->Branch(below_equal); |
| 7688 __ cmp(tmp2.reg(), Operand(index2.reg())); |
| 7689 deferred->Branch(below_equal); |
| 7690 |
| 7684 // Bring addresses into index1 and index2. | 7691 // Bring addresses into index1 and index2. |
| 7685 __ lea(index1.reg(), FixedArrayElementOperand(tmp1.reg(), index1.reg())); | 7692 __ lea(index1.reg(), FixedArrayElementOperand(tmp1.reg(), index1.reg())); |
| 7686 __ lea(index2.reg(), FixedArrayElementOperand(tmp1.reg(), index2.reg())); | 7693 __ lea(index2.reg(), FixedArrayElementOperand(tmp1.reg(), index2.reg())); |
| 7687 | 7694 |
| 7688 // Swap elements. | 7695 // Swap elements. |
| 7689 __ mov(object.reg(), Operand(index1.reg(), 0)); | 7696 __ mov(object.reg(), Operand(index1.reg(), 0)); |
| 7690 __ mov(tmp2.reg(), Operand(index2.reg(), 0)); | 7697 __ mov(tmp2.reg(), Operand(index2.reg(), 0)); |
| 7691 __ mov(Operand(index2.reg(), 0), object.reg()); | 7698 __ mov(Operand(index2.reg(), 0), object.reg()); |
| 7692 __ mov(Operand(index1.reg(), 0), tmp2.reg()); | 7699 __ mov(Operand(index1.reg(), 0), tmp2.reg()); |
| 7693 | 7700 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7903 | 7910 |
| 7904 done.Bind(&answer); | 7911 done.Bind(&answer); |
| 7905 frame()->Push(&answer); | 7912 frame()->Push(&answer); |
| 7906 } | 7913 } |
| 7907 } | 7914 } |
| 7908 | 7915 |
| 7909 | 7916 |
| 7910 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { | 7917 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { |
| 7911 ASSERT_EQ(args->length(), 1); | 7918 ASSERT_EQ(args->length(), 1); |
| 7912 Load(args->at(0)); | 7919 Load(args->at(0)); |
| 7913 TranscendentalCacheStub stub(TranscendentalCache::SIN); | 7920 TranscendentalCacheStub stub(TranscendentalCache::SIN, |
| 7921 TranscendentalCacheStub::TAGGED); |
| 7914 Result result = frame_->CallStub(&stub, 1); | 7922 Result result = frame_->CallStub(&stub, 1); |
| 7915 frame_->Push(&result); | 7923 frame_->Push(&result); |
| 7916 } | 7924 } |
| 7917 | 7925 |
| 7918 | 7926 |
| 7919 void CodeGenerator::GenerateMathCos(ZoneList<Expression*>* args) { | 7927 void CodeGenerator::GenerateMathCos(ZoneList<Expression*>* args) { |
| 7920 ASSERT_EQ(args->length(), 1); | 7928 ASSERT_EQ(args->length(), 1); |
| 7921 Load(args->at(0)); | 7929 Load(args->at(0)); |
| 7922 TranscendentalCacheStub stub(TranscendentalCache::COS); | 7930 TranscendentalCacheStub stub(TranscendentalCache::COS, |
| 7931 TranscendentalCacheStub::TAGGED); |
| 7923 Result result = frame_->CallStub(&stub, 1); | 7932 Result result = frame_->CallStub(&stub, 1); |
| 7924 frame_->Push(&result); | 7933 frame_->Push(&result); |
| 7925 } | 7934 } |
| 7926 | 7935 |
| 7927 | 7936 |
| 7928 void CodeGenerator::GenerateMathLog(ZoneList<Expression*>* args) { | 7937 void CodeGenerator::GenerateMathLog(ZoneList<Expression*>* args) { |
| 7929 ASSERT_EQ(args->length(), 1); | 7938 ASSERT_EQ(args->length(), 1); |
| 7930 Load(args->at(0)); | 7939 Load(args->at(0)); |
| 7931 TranscendentalCacheStub stub(TranscendentalCache::LOG); | 7940 TranscendentalCacheStub stub(TranscendentalCache::LOG, |
| 7941 TranscendentalCacheStub::TAGGED); |
| 7932 Result result = frame_->CallStub(&stub, 1); | 7942 Result result = frame_->CallStub(&stub, 1); |
| 7933 frame_->Push(&result); | 7943 frame_->Push(&result); |
| 7934 } | 7944 } |
| 7935 | 7945 |
| 7936 | 7946 |
| 7937 // Generates the Math.sqrt method. Please note - this function assumes that | 7947 // Generates the Math.sqrt method. Please note - this function assumes that |
| 7938 // the callsite has executed ToNumber on the argument. | 7948 // the callsite has executed ToNumber on the argument. |
| 7939 void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) { | 7949 void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) { |
| 7940 ASSERT_EQ(args->length(), 1); | 7950 ASSERT_EQ(args->length(), 1); |
| 7941 Load(args->at(0)); | 7951 Load(args->at(0)); |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9131 case Token::IN: { | 9141 case Token::IN: { |
| 9132 if (!left_already_loaded) Load(left); | 9142 if (!left_already_loaded) Load(left); |
| 9133 Load(right); | 9143 Load(right); |
| 9134 Result answer = frame_->InvokeBuiltin(Builtins::IN, CALL_FUNCTION, 2); | 9144 Result answer = frame_->InvokeBuiltin(Builtins::IN, CALL_FUNCTION, 2); |
| 9135 frame_->Push(&answer); // push the result | 9145 frame_->Push(&answer); // push the result |
| 9136 return; | 9146 return; |
| 9137 } | 9147 } |
| 9138 case Token::INSTANCEOF: { | 9148 case Token::INSTANCEOF: { |
| 9139 if (!left_already_loaded) Load(left); | 9149 if (!left_already_loaded) Load(left); |
| 9140 Load(right); | 9150 Load(right); |
| 9141 InstanceofStub stub; | 9151 InstanceofStub stub(InstanceofStub::kNoFlags); |
| 9142 Result answer = frame_->CallStub(&stub, 2); | 9152 Result answer = frame_->CallStub(&stub, 2); |
| 9143 answer.ToRegister(); | 9153 answer.ToRegister(); |
| 9144 __ test(answer.reg(), Operand(answer.reg())); | 9154 __ test(answer.reg(), Operand(answer.reg())); |
| 9145 answer.Unuse(); | 9155 answer.Unuse(); |
| 9146 destination()->Split(zero); | 9156 destination()->Split(zero); |
| 9147 return; | 9157 return; |
| 9148 } | 9158 } |
| 9149 default: | 9159 default: |
| 9150 UNREACHABLE(); | 9160 UNREACHABLE(); |
| 9151 } | 9161 } |
| (...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10227 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); | 10237 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); |
| 10228 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); | 10238 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); |
| 10229 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); | 10239 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); |
| 10230 } | 10240 } |
| 10231 | 10241 |
| 10232 #undef __ | 10242 #undef __ |
| 10233 | 10243 |
| 10234 } } // namespace v8::internal | 10244 } } // namespace v8::internal |
| 10235 | 10245 |
| 10236 #endif // V8_TARGET_ARCH_IA32 | 10246 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |