| 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 7673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7684 // Smi-tagging is equivalent to multiplying by 2. | 7684 // Smi-tagging is equivalent to multiplying by 2. |
| 7685 STATIC_ASSERT(kSmiTag == 0); | 7685 STATIC_ASSERT(kSmiTag == 0); |
| 7686 STATIC_ASSERT(kSmiTagSize == 1); | 7686 STATIC_ASSERT(kSmiTagSize == 1); |
| 7687 | 7687 |
| 7688 // Check that both indices are smis. | 7688 // Check that both indices are smis. |
| 7689 __ mov(tmp2.reg(), index1.reg()); | 7689 __ mov(tmp2.reg(), index1.reg()); |
| 7690 __ or_(tmp2.reg(), Operand(index2.reg())); | 7690 __ or_(tmp2.reg(), Operand(index2.reg())); |
| 7691 __ test(tmp2.reg(), Immediate(kSmiTagMask)); | 7691 __ test(tmp2.reg(), Immediate(kSmiTagMask)); |
| 7692 deferred->Branch(not_zero); | 7692 deferred->Branch(not_zero); |
| 7693 | 7693 |
| 7694 // Check that both indices are valid. |
| 7695 __ mov(tmp2.reg(), FieldOperand(object.reg(), JSArray::kLengthOffset)); |
| 7696 __ cmp(tmp2.reg(), Operand(index1.reg())); |
| 7697 deferred->Branch(below_equal); |
| 7698 __ cmp(tmp2.reg(), Operand(index2.reg())); |
| 7699 deferred->Branch(below_equal); |
| 7700 |
| 7694 // Bring addresses into index1 and index2. | 7701 // Bring addresses into index1 and index2. |
| 7695 __ lea(index1.reg(), FixedArrayElementOperand(tmp1.reg(), index1.reg())); | 7702 __ lea(index1.reg(), FixedArrayElementOperand(tmp1.reg(), index1.reg())); |
| 7696 __ lea(index2.reg(), FixedArrayElementOperand(tmp1.reg(), index2.reg())); | 7703 __ lea(index2.reg(), FixedArrayElementOperand(tmp1.reg(), index2.reg())); |
| 7697 | 7704 |
| 7698 // Swap elements. | 7705 // Swap elements. |
| 7699 __ mov(object.reg(), Operand(index1.reg(), 0)); | 7706 __ mov(object.reg(), Operand(index1.reg(), 0)); |
| 7700 __ mov(tmp2.reg(), Operand(index2.reg(), 0)); | 7707 __ mov(tmp2.reg(), Operand(index2.reg(), 0)); |
| 7701 __ mov(Operand(index2.reg(), 0), object.reg()); | 7708 __ mov(Operand(index2.reg(), 0), object.reg()); |
| 7702 __ mov(Operand(index1.reg(), 0), tmp2.reg()); | 7709 __ mov(Operand(index1.reg(), 0), tmp2.reg()); |
| 7703 | 7710 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7915 | 7922 |
| 7916 done.Bind(&answer); | 7923 done.Bind(&answer); |
| 7917 frame()->Push(&answer); | 7924 frame()->Push(&answer); |
| 7918 } | 7925 } |
| 7919 } | 7926 } |
| 7920 | 7927 |
| 7921 | 7928 |
| 7922 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { | 7929 void CodeGenerator::GenerateMathSin(ZoneList<Expression*>* args) { |
| 7923 ASSERT_EQ(args->length(), 1); | 7930 ASSERT_EQ(args->length(), 1); |
| 7924 Load(args->at(0)); | 7931 Load(args->at(0)); |
| 7925 TranscendentalCacheStub stub(TranscendentalCache::SIN); | 7932 TranscendentalCacheStub stub(TranscendentalCache::SIN, |
| 7933 TranscendentalCacheStub::TAGGED); |
| 7926 Result result = frame_->CallStub(&stub, 1); | 7934 Result result = frame_->CallStub(&stub, 1); |
| 7927 frame_->Push(&result); | 7935 frame_->Push(&result); |
| 7928 } | 7936 } |
| 7929 | 7937 |
| 7930 | 7938 |
| 7931 void CodeGenerator::GenerateMathCos(ZoneList<Expression*>* args) { | 7939 void CodeGenerator::GenerateMathCos(ZoneList<Expression*>* args) { |
| 7932 ASSERT_EQ(args->length(), 1); | 7940 ASSERT_EQ(args->length(), 1); |
| 7933 Load(args->at(0)); | 7941 Load(args->at(0)); |
| 7934 TranscendentalCacheStub stub(TranscendentalCache::COS); | 7942 TranscendentalCacheStub stub(TranscendentalCache::COS, |
| 7943 TranscendentalCacheStub::TAGGED); |
| 7935 Result result = frame_->CallStub(&stub, 1); | 7944 Result result = frame_->CallStub(&stub, 1); |
| 7936 frame_->Push(&result); | 7945 frame_->Push(&result); |
| 7937 } | 7946 } |
| 7938 | 7947 |
| 7939 | 7948 |
| 7940 void CodeGenerator::GenerateMathLog(ZoneList<Expression*>* args) { | 7949 void CodeGenerator::GenerateMathLog(ZoneList<Expression*>* args) { |
| 7941 ASSERT_EQ(args->length(), 1); | 7950 ASSERT_EQ(args->length(), 1); |
| 7942 Load(args->at(0)); | 7951 Load(args->at(0)); |
| 7943 TranscendentalCacheStub stub(TranscendentalCache::LOG); | 7952 TranscendentalCacheStub stub(TranscendentalCache::LOG, |
| 7953 TranscendentalCacheStub::TAGGED); |
| 7944 Result result = frame_->CallStub(&stub, 1); | 7954 Result result = frame_->CallStub(&stub, 1); |
| 7945 frame_->Push(&result); | 7955 frame_->Push(&result); |
| 7946 } | 7956 } |
| 7947 | 7957 |
| 7948 | 7958 |
| 7949 // Generates the Math.sqrt method. Please note - this function assumes that | 7959 // Generates the Math.sqrt method. Please note - this function assumes that |
| 7950 // the callsite has executed ToNumber on the argument. | 7960 // the callsite has executed ToNumber on the argument. |
| 7951 void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) { | 7961 void CodeGenerator::GenerateMathSqrt(ZoneList<Expression*>* args) { |
| 7952 ASSERT_EQ(args->length(), 1); | 7962 ASSERT_EQ(args->length(), 1); |
| 7953 Load(args->at(0)); | 7963 Load(args->at(0)); |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9143 case Token::IN: { | 9153 case Token::IN: { |
| 9144 if (!left_already_loaded) Load(left); | 9154 if (!left_already_loaded) Load(left); |
| 9145 Load(right); | 9155 Load(right); |
| 9146 Result answer = frame_->InvokeBuiltin(Builtins::IN, CALL_FUNCTION, 2); | 9156 Result answer = frame_->InvokeBuiltin(Builtins::IN, CALL_FUNCTION, 2); |
| 9147 frame_->Push(&answer); // push the result | 9157 frame_->Push(&answer); // push the result |
| 9148 return; | 9158 return; |
| 9149 } | 9159 } |
| 9150 case Token::INSTANCEOF: { | 9160 case Token::INSTANCEOF: { |
| 9151 if (!left_already_loaded) Load(left); | 9161 if (!left_already_loaded) Load(left); |
| 9152 Load(right); | 9162 Load(right); |
| 9153 InstanceofStub stub; | 9163 InstanceofStub stub(InstanceofStub::kNoFlags); |
| 9154 Result answer = frame_->CallStub(&stub, 2); | 9164 Result answer = frame_->CallStub(&stub, 2); |
| 9155 answer.ToRegister(); | 9165 answer.ToRegister(); |
| 9156 __ test(answer.reg(), Operand(answer.reg())); | 9166 __ test(answer.reg(), Operand(answer.reg())); |
| 9157 answer.Unuse(); | 9167 answer.Unuse(); |
| 9158 destination()->Split(zero); | 9168 destination()->Split(zero); |
| 9159 return; | 9169 return; |
| 9160 } | 9170 } |
| 9161 default: | 9171 default: |
| 9162 UNREACHABLE(); | 9172 UNREACHABLE(); |
| 9163 } | 9173 } |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10244 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); | 10254 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); |
| 10245 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); | 10255 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); |
| 10246 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); | 10256 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); |
| 10247 } | 10257 } |
| 10248 | 10258 |
| 10249 #undef __ | 10259 #undef __ |
| 10250 | 10260 |
| 10251 } } // namespace v8::internal | 10261 } } // namespace v8::internal |
| 10252 | 10262 |
| 10253 #endif // V8_TARGET_ARCH_IA32 | 10263 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |