| 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 translation->StoreLiteral(src_index); | 555 translation->StoreLiteral(src_index); |
| 556 } else { | 556 } else { |
| 557 UNREACHABLE(); | 557 UNREACHABLE(); |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 | 560 |
| 561 | 561 |
| 562 void LCodeGen::CallCode(Handle<Code> code, | 562 void LCodeGen::CallCode(Handle<Code> code, |
| 563 RelocInfo::Mode mode, | 563 RelocInfo::Mode mode, |
| 564 LInstruction* instr) { | 564 LInstruction* instr) { |
| 565 if (instr != NULL) { | 565 ASSERT(instr != NULL); |
| 566 LPointerMap* pointers = instr->pointer_map(); | 566 LPointerMap* pointers = instr->pointer_map(); |
| 567 RecordPosition(pointers->position()); | 567 RecordPosition(pointers->position()); |
| 568 __ Call(code, mode); | 568 __ Call(code, mode); |
| 569 RegisterLazyDeoptimization(instr); | 569 RegisterLazyDeoptimization(instr); |
| 570 } else { | |
| 571 LPointerMap no_pointers(0); | |
| 572 RecordPosition(no_pointers.position()); | |
| 573 __ Call(code, mode); | |
| 574 RecordSafepoint(&no_pointers, Safepoint::kNoDeoptimizationIndex); | |
| 575 } | |
| 576 } | 570 } |
| 577 | 571 |
| 578 | 572 |
| 579 void LCodeGen::CallRuntime(Runtime::Function* function, | 573 void LCodeGen::CallRuntime(Runtime::Function* function, |
| 580 int num_arguments, | 574 int num_arguments, |
| 581 LInstruction* instr) { | 575 LInstruction* instr) { |
| 582 ASSERT(instr != NULL); | 576 ASSERT(instr != NULL); |
| 583 LPointerMap* pointers = instr->pointer_map(); | 577 LPointerMap* pointers = instr->pointer_map(); |
| 584 ASSERT(pointers != NULL); | 578 ASSERT(pointers != NULL); |
| 585 RecordPosition(pointers->position()); | 579 RecordPosition(pointers->position()); |
| 586 | 580 |
| 587 __ CallRuntime(function, num_arguments); | 581 __ CallRuntime(function, num_arguments); |
| 588 // Runtime calls to Throw are not supposed to ever return at the | 582 RegisterLazyDeoptimization(instr); |
| 589 // call site, so don't register lazy deoptimization for these. We do | |
| 590 // however have to record a safepoint since throwing exceptions can | |
| 591 // cause garbage collections. | |
| 592 if (!instr->IsThrow()) { | |
| 593 RegisterLazyDeoptimization(instr); | |
| 594 } else { | |
| 595 RecordSafepoint(instr->pointer_map(), Safepoint::kNoDeoptimizationIndex); | |
| 596 } | |
| 597 } | 583 } |
| 598 | 584 |
| 599 | 585 |
| 600 void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { | 586 void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) { |
| 601 // Create the environment to bailout to. If the call has side effects | 587 // Create the environment to bailout to. If the call has side effects |
| 602 // execution has to continue after the call otherwise execution can continue | 588 // execution has to continue after the call otherwise execution can continue |
| 603 // from a previous bailout point repeating the call. | 589 // from a previous bailout point repeating the call. |
| 604 LEnvironment* deoptimization_environment; | 590 LEnvironment* deoptimization_environment; |
| 605 if (instr->HasDeoptimizationEnvironment()) { | 591 if (instr->HasDeoptimizationEnvironment()) { |
| 606 deoptimization_environment = instr->deoptimization_environment(); | 592 deoptimization_environment = instr->deoptimization_environment(); |
| (...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 // length is a small non-negative integer, due to the test above. | 2429 // length is a small non-negative integer, due to the test above. |
| 2444 __ tst(length, Operand(length)); | 2430 __ tst(length, Operand(length)); |
| 2445 __ b(eq, &invoke); | 2431 __ b(eq, &invoke); |
| 2446 __ bind(&loop); | 2432 __ bind(&loop); |
| 2447 __ ldr(scratch, MemOperand(elements, length, LSL, 2)); | 2433 __ ldr(scratch, MemOperand(elements, length, LSL, 2)); |
| 2448 __ push(scratch); | 2434 __ push(scratch); |
| 2449 __ sub(length, length, Operand(1), SetCC); | 2435 __ sub(length, length, Operand(1), SetCC); |
| 2450 __ b(ne, &loop); | 2436 __ b(ne, &loop); |
| 2451 | 2437 |
| 2452 __ bind(&invoke); | 2438 __ bind(&invoke); |
| 2453 // Invoke the function. The number of arguments is stored in receiver | 2439 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 2454 // which is r0, as expected by InvokeFunction. | 2440 LPointerMap* pointers = instr->pointer_map(); |
| 2441 LEnvironment* env = instr->deoptimization_environment(); |
| 2442 RecordPosition(pointers->position()); |
| 2443 RegisterEnvironmentForDeoptimization(env); |
| 2444 SafepointGenerator safepoint_generator(this, |
| 2445 pointers, |
| 2446 env->deoptimization_index()); |
| 2447 // The number of arguments is stored in receiver which is r0, as expected |
| 2448 // by InvokeFunction. |
| 2455 v8::internal::ParameterCount actual(receiver); | 2449 v8::internal::ParameterCount actual(receiver); |
| 2456 SafepointGenerator safepoint_generator(this, | |
| 2457 instr->pointer_map(), | |
| 2458 Safepoint::kNoDeoptimizationIndex); | |
| 2459 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); | 2450 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); |
| 2460 } | 2451 } |
| 2461 | 2452 |
| 2462 | 2453 |
| 2463 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2454 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
| 2464 LOperand* argument = instr->InputAt(0); | 2455 LOperand* argument = instr->InputAt(0); |
| 2465 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { | 2456 if (argument->IsDoubleRegister() || argument->IsDoubleStackSlot()) { |
| 2466 Abort("DoPushArgument not implemented for double type."); | 2457 Abort("DoPushArgument not implemented for double type."); |
| 2467 } else { | 2458 } else { |
| 2468 Register argument_reg = EmitLoadRegister(argument, ip); | 2459 Register argument_reg = EmitLoadRegister(argument, ip); |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3660 | 3651 |
| 3661 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { | 3652 void LCodeGen::DoDeoptimize(LDeoptimize* instr) { |
| 3662 DeoptimizeIf(kNoCondition, instr->environment()); | 3653 DeoptimizeIf(kNoCondition, instr->environment()); |
| 3663 } | 3654 } |
| 3664 | 3655 |
| 3665 | 3656 |
| 3666 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { | 3657 void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) { |
| 3667 Register object = ToRegister(instr->object()); | 3658 Register object = ToRegister(instr->object()); |
| 3668 Register key = ToRegister(instr->key()); | 3659 Register key = ToRegister(instr->key()); |
| 3669 __ Push(object, key); | 3660 __ Push(object, key); |
| 3670 RecordPosition(instr->pointer_map()->position()); | 3661 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 3662 LPointerMap* pointers = instr->pointer_map(); |
| 3663 LEnvironment* env = instr->deoptimization_environment(); |
| 3664 RecordPosition(pointers->position()); |
| 3665 RegisterEnvironmentForDeoptimization(env); |
| 3671 SafepointGenerator safepoint_generator(this, | 3666 SafepointGenerator safepoint_generator(this, |
| 3672 instr->pointer_map(), | 3667 pointers, |
| 3673 Safepoint::kNoDeoptimizationIndex); | 3668 env->deoptimization_index()); |
| 3674 __ InvokeBuiltin(Builtins::DELETE, CALL_JS, &safepoint_generator); | 3669 __ InvokeBuiltin(Builtins::DELETE, CALL_JS, &safepoint_generator); |
| 3675 } | 3670 } |
| 3676 | 3671 |
| 3677 | 3672 |
| 3678 void LCodeGen::DoStackCheck(LStackCheck* instr) { | 3673 void LCodeGen::DoStackCheck(LStackCheck* instr) { |
| 3679 // Perform stack overflow check. | 3674 // Perform stack overflow check. |
| 3680 Label ok; | 3675 Label ok; |
| 3681 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 3676 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
| 3682 __ cmp(sp, Operand(ip)); | 3677 __ cmp(sp, Operand(ip)); |
| 3683 __ b(hs, &ok); | 3678 __ b(hs, &ok); |
| 3684 StackCheckStub stub; | 3679 StackCheckStub stub; |
| 3685 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 3680 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 3686 __ bind(&ok); | 3681 __ bind(&ok); |
| 3687 } | 3682 } |
| 3688 | 3683 |
| 3689 | 3684 |
| 3690 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 3685 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
| 3691 Abort("DoOsrEntry unimplemented."); | 3686 Abort("DoOsrEntry unimplemented."); |
| 3692 } | 3687 } |
| 3693 | 3688 |
| 3694 | 3689 |
| 3695 #undef __ | 3690 #undef __ |
| 3696 | 3691 |
| 3697 } } // namespace v8::internal | 3692 } } // namespace v8::internal |
| OLD | NEW |