| OLD | NEW |
| 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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 | 857 |
| 858 | 858 |
| 859 void LCodeGen::DoMulI(LMulI* instr) { | 859 void LCodeGen::DoMulI(LMulI* instr) { |
| 860 Register left = ToRegister(instr->InputAt(0)); | 860 Register left = ToRegister(instr->InputAt(0)); |
| 861 LOperand* right = instr->InputAt(1); | 861 LOperand* right = instr->InputAt(1); |
| 862 | 862 |
| 863 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 863 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 864 __ movl(kScratchRegister, left); | 864 __ movl(kScratchRegister, left); |
| 865 } | 865 } |
| 866 | 866 |
| 867 bool can_overflow = |
| 868 instr->hydrogen()->CheckFlag(HValue::kCanOverflow); |
| 867 if (right->IsConstantOperand()) { | 869 if (right->IsConstantOperand()) { |
| 868 int right_value = ToInteger32(LConstantOperand::cast(right)); | 870 int right_value = ToInteger32(LConstantOperand::cast(right)); |
| 869 __ imull(left, left, Immediate(right_value)); | 871 if (right_value == -1) { |
| 872 __ negl(left); |
| 873 } else if (right_value == 0) { |
| 874 __ xorl(left, left); |
| 875 } else if (right_value == 2) { |
| 876 __ addl(left, left); |
| 877 } else if (!can_overflow) { |
| 878 // If the multiplication is known to not overflow, we |
| 879 // can use operations that don't set the overflow flag |
| 880 // correctly. |
| 881 switch (right_value) { |
| 882 case 1: |
| 883 // Do nothing. |
| 884 break; |
| 885 case 3: |
| 886 __ leal(left, Operand(left, left, times_2, 0)); |
| 887 break; |
| 888 case 4: |
| 889 __ shll(left, Immediate(2)); |
| 890 break; |
| 891 case 5: |
| 892 __ leal(left, Operand(left, left, times_4, 0)); |
| 893 break; |
| 894 case 8: |
| 895 __ shll(left, Immediate(3)); |
| 896 break; |
| 897 case 9: |
| 898 __ leal(left, Operand(left, left, times_8, 0)); |
| 899 break; |
| 900 case 16: |
| 901 __ shll(left, Immediate(4)); |
| 902 break; |
| 903 default: |
| 904 __ imull(left, left, Immediate(right_value)); |
| 905 break; |
| 906 } |
| 907 } else { |
| 908 __ imull(left, left, Immediate(right_value)); |
| 909 } |
| 870 } else if (right->IsStackSlot()) { | 910 } else if (right->IsStackSlot()) { |
| 871 __ imull(left, ToOperand(right)); | 911 __ imull(left, ToOperand(right)); |
| 872 } else { | 912 } else { |
| 873 __ imull(left, ToRegister(right)); | 913 __ imull(left, ToRegister(right)); |
| 874 } | 914 } |
| 875 | 915 |
| 876 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | 916 if (can_overflow) { |
| 877 DeoptimizeIf(overflow, instr->environment()); | 917 DeoptimizeIf(overflow, instr->environment()); |
| 878 } | 918 } |
| 879 | 919 |
| 880 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 920 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| 881 // Bail out if the result is supposed to be negative zero. | 921 // Bail out if the result is supposed to be negative zero. |
| 882 NearLabel done; | 922 NearLabel done; |
| 883 __ testl(left, left); | 923 __ testl(left, left); |
| 884 __ j(not_zero, &done); | 924 __ j(not_zero, &done); |
| 885 if (right->IsConstantOperand()) { | 925 if (right->IsConstantOperand()) { |
| 886 if (ToInteger32(LConstantOperand::cast(right)) <= 0) { | 926 if (ToInteger32(LConstantOperand::cast(right)) <= 0) { |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2335 } | 2375 } |
| 2336 | 2376 |
| 2337 | 2377 |
| 2338 void LCodeGen::DoGlobalObject(LGlobalObject* instr) { | 2378 void LCodeGen::DoGlobalObject(LGlobalObject* instr) { |
| 2339 Register result = ToRegister(instr->result()); | 2379 Register result = ToRegister(instr->result()); |
| 2340 __ movq(result, GlobalObjectOperand()); | 2380 __ movq(result, GlobalObjectOperand()); |
| 2341 } | 2381 } |
| 2342 | 2382 |
| 2343 | 2383 |
| 2344 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { | 2384 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) { |
| 2385 Register global = ToRegister(instr->global()); |
| 2345 Register result = ToRegister(instr->result()); | 2386 Register result = ToRegister(instr->result()); |
| 2346 __ movq(result, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 2387 __ movq(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset)); |
| 2347 __ movq(result, FieldOperand(result, GlobalObject::kGlobalReceiverOffset)); | |
| 2348 } | 2388 } |
| 2349 | 2389 |
| 2350 | 2390 |
| 2351 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 2391 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
| 2352 int arity, | 2392 int arity, |
| 2353 LInstruction* instr) { | 2393 LInstruction* instr) { |
| 2354 // Change context if needed. | 2394 // Change context if needed. |
| 2355 bool change_context = | 2395 bool change_context = |
| 2356 (info()->closure()->context() != function->context()) || | 2396 (info()->closure()->context() != function->context()) || |
| 2357 scope()->contains_with() || | 2397 scope()->contains_with() || |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3290 __ andl(result_reg, Immediate(1)); | 3330 __ andl(result_reg, Immediate(1)); |
| 3291 DeoptimizeIf(not_zero, instr->environment()); | 3331 DeoptimizeIf(not_zero, instr->environment()); |
| 3292 __ bind(&done); | 3332 __ bind(&done); |
| 3293 } | 3333 } |
| 3294 } | 3334 } |
| 3295 } | 3335 } |
| 3296 | 3336 |
| 3297 | 3337 |
| 3298 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { | 3338 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { |
| 3299 LOperand* input = instr->InputAt(0); | 3339 LOperand* input = instr->InputAt(0); |
| 3300 ASSERT(input->IsRegister()); | |
| 3301 Condition cc = masm()->CheckSmi(ToRegister(input)); | 3340 Condition cc = masm()->CheckSmi(ToRegister(input)); |
| 3302 if (instr->condition() != equal) { | 3341 DeoptimizeIf(NegateCondition(cc), instr->environment()); |
| 3303 cc = NegateCondition(cc); | 3342 } |
| 3304 } | 3343 |
| 3344 |
| 3345 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) { |
| 3346 LOperand* input = instr->InputAt(0); |
| 3347 Condition cc = masm()->CheckSmi(ToRegister(input)); |
| 3305 DeoptimizeIf(cc, instr->environment()); | 3348 DeoptimizeIf(cc, instr->environment()); |
| 3306 } | 3349 } |
| 3307 | 3350 |
| 3308 | 3351 |
| 3309 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { | 3352 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) { |
| 3310 Register input = ToRegister(instr->InputAt(0)); | 3353 Register input = ToRegister(instr->InputAt(0)); |
| 3311 InstanceType first = instr->hydrogen()->first(); | 3354 InstanceType first = instr->hydrogen()->first(); |
| 3312 InstanceType last = instr->hydrogen()->last(); | 3355 InstanceType last = instr->hydrogen()->last(); |
| 3313 | 3356 |
| 3314 __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset)); | 3357 __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset)); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3489 __ movq(FieldOperand(rax, size - kPointerSize), rdx); | 3532 __ movq(FieldOperand(rax, size - kPointerSize), rdx); |
| 3490 } | 3533 } |
| 3491 } | 3534 } |
| 3492 | 3535 |
| 3493 | 3536 |
| 3494 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { | 3537 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { |
| 3495 // Use the fast case closure allocation code that allocates in new | 3538 // Use the fast case closure allocation code that allocates in new |
| 3496 // space for nested functions that don't need literals cloning. | 3539 // space for nested functions that don't need literals cloning. |
| 3497 Handle<SharedFunctionInfo> shared_info = instr->shared_info(); | 3540 Handle<SharedFunctionInfo> shared_info = instr->shared_info(); |
| 3498 bool pretenure = instr->hydrogen()->pretenure(); | 3541 bool pretenure = instr->hydrogen()->pretenure(); |
| 3499 if (shared_info->num_literals() == 0 && !pretenure) { | 3542 if (!pretenure && shared_info->num_literals() == 0) { |
| 3500 FastNewClosureStub stub; | 3543 FastNewClosureStub stub( |
| 3544 shared_info->strict_mode() ? kStrictMode : kNonStrictMode); |
| 3501 __ Push(shared_info); | 3545 __ Push(shared_info); |
| 3502 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 3546 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 3503 } else { | 3547 } else { |
| 3504 __ push(rsi); | 3548 __ push(rsi); |
| 3505 __ Push(shared_info); | 3549 __ Push(shared_info); |
| 3506 __ PushRoot(pretenure ? | 3550 __ PushRoot(pretenure ? |
| 3507 Heap::kTrueValueRootIndex : | 3551 Heap::kTrueValueRootIndex : |
| 3508 Heap::kFalseValueRootIndex); | 3552 Heap::kFalseValueRootIndex); |
| 3509 CallRuntime(Runtime::kNewClosure, 3, instr); | 3553 CallRuntime(Runtime::kNewClosure, 3, instr); |
| 3510 } | 3554 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3763 RegisterEnvironmentForDeoptimization(environment); | 3807 RegisterEnvironmentForDeoptimization(environment); |
| 3764 ASSERT(osr_pc_offset_ == -1); | 3808 ASSERT(osr_pc_offset_ == -1); |
| 3765 osr_pc_offset_ = masm()->pc_offset(); | 3809 osr_pc_offset_ = masm()->pc_offset(); |
| 3766 } | 3810 } |
| 3767 | 3811 |
| 3768 #undef __ | 3812 #undef __ |
| 3769 | 3813 |
| 3770 } } // namespace v8::internal | 3814 } } // namespace v8::internal |
| 3771 | 3815 |
| 3772 #endif // V8_TARGET_ARCH_X64 | 3816 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |