| 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 3563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3574 __ SmiUntag(result); | 3574 __ SmiUntag(result); |
| 3575 | 3575 |
| 3576 // Argument length is in result register. | 3576 // Argument length is in result register. |
| 3577 __ bind(&done); | 3577 __ bind(&done); |
| 3578 } | 3578 } |
| 3579 | 3579 |
| 3580 | 3580 |
| 3581 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { | 3581 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
| 3582 Register receiver = ToRegister(instr->receiver()); | 3582 Register receiver = ToRegister(instr->receiver()); |
| 3583 Register function = ToRegister(instr->function()); | 3583 Register function = ToRegister(instr->function()); |
| 3584 Register scratch = ToRegister(instr->temp()); | |
| 3585 | 3584 |
| 3586 // If the receiver is null or undefined, we have to pass the global | 3585 // If the receiver is null or undefined, we have to pass the global |
| 3587 // object as a receiver to normal functions. Values have to be | 3586 // object as a receiver to normal functions. Values have to be |
| 3588 // passed unchanged to builtins and strict-mode functions. | 3587 // passed unchanged to builtins and strict-mode functions. |
| 3589 Label receiver_ok, global_object; | 3588 Label receiver_ok, global_object; |
| 3590 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; | 3589 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
| 3590 Register scratch = ToRegister(instr->temp()); |
| 3591 | 3591 |
| 3592 // Do not transform the receiver to object for strict mode | 3592 if (!instr->hydrogen()->known_function()) { |
| 3593 // functions. | 3593 // Do not transform the receiver to object for strict mode |
| 3594 __ mov(scratch, | 3594 // functions. |
| 3595 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 3595 __ mov(scratch, |
| 3596 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kStrictModeByteOffset), | 3596 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
| 3597 1 << SharedFunctionInfo::kStrictModeBitWithinByte); | 3597 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kStrictModeByteOffset), |
| 3598 __ j(not_equal, &receiver_ok, dist); | 3598 1 << SharedFunctionInfo::kStrictModeBitWithinByte); |
| 3599 __ j(not_equal, &receiver_ok, dist); |
| 3599 | 3600 |
| 3600 // Do not transform the receiver to object for builtins. | 3601 // Do not transform the receiver to object for builtins. |
| 3601 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kNativeByteOffset), | 3602 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kNativeByteOffset), |
| 3602 1 << SharedFunctionInfo::kNativeBitWithinByte); | 3603 1 << SharedFunctionInfo::kNativeBitWithinByte); |
| 3603 __ j(not_equal, &receiver_ok, dist); | 3604 __ j(not_equal, &receiver_ok, dist); |
| 3605 } |
| 3604 | 3606 |
| 3605 // Normal function. Replace undefined or null with global receiver. | 3607 // Normal function. Replace undefined or null with global receiver. |
| 3606 __ cmp(receiver, factory()->null_value()); | 3608 __ cmp(receiver, factory()->null_value()); |
| 3607 __ j(equal, &global_object, Label::kNear); | 3609 __ j(equal, &global_object, Label::kNear); |
| 3608 __ cmp(receiver, factory()->undefined_value()); | 3610 __ cmp(receiver, factory()->undefined_value()); |
| 3609 __ j(equal, &global_object, Label::kNear); | 3611 __ j(equal, &global_object, Label::kNear); |
| 3610 | 3612 |
| 3611 // The receiver should be a JS object. | 3613 // The receiver should be a JS object. |
| 3612 __ test(receiver, Immediate(kSmiTagMask)); | 3614 __ test(receiver, Immediate(kSmiTagMask)); |
| 3613 DeoptimizeIf(equal, instr->environment()); | 3615 DeoptimizeIf(equal, instr->environment()); |
| 3614 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, scratch); | 3616 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, scratch); |
| 3615 DeoptimizeIf(below, instr->environment()); | 3617 DeoptimizeIf(below, instr->environment()); |
| 3618 |
| 3616 __ jmp(&receiver_ok, Label::kNear); | 3619 __ jmp(&receiver_ok, Label::kNear); |
| 3617 | |
| 3618 __ bind(&global_object); | 3620 __ bind(&global_object); |
| 3619 __ mov(receiver, FieldOperand(function, JSFunction::kContextOffset)); | 3621 __ mov(receiver, FieldOperand(function, JSFunction::kContextOffset)); |
| 3620 __ mov(receiver, | 3622 const int global_offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX); |
| 3621 Operand(receiver, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 3623 __ mov(receiver, Operand(receiver, global_offset)); |
| 3622 __ mov(receiver, FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset)); | 3624 const int receiver_offset = GlobalObject::kGlobalReceiverOffset; |
| 3623 | 3625 __ mov(receiver, FieldOperand(receiver, receiver_offset)); |
| 3624 __ bind(&receiver_ok); | 3626 __ bind(&receiver_ok); |
| 3625 } | 3627 } |
| 3626 | 3628 |
| 3627 | 3629 |
| 3628 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 3630 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
| 3629 Register receiver = ToRegister(instr->receiver()); | 3631 Register receiver = ToRegister(instr->receiver()); |
| 3630 Register function = ToRegister(instr->function()); | 3632 Register function = ToRegister(instr->function()); |
| 3631 Register length = ToRegister(instr->length()); | 3633 Register length = ToRegister(instr->length()); |
| 3632 Register elements = ToRegister(instr->elements()); | 3634 Register elements = ToRegister(instr->elements()); |
| 3633 ASSERT(receiver.is(eax)); // Used for parameter count. | 3635 ASSERT(receiver.is(eax)); // Used for parameter count. |
| (...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6269 FixedArray::kHeaderSize - kPointerSize)); | 6271 FixedArray::kHeaderSize - kPointerSize)); |
| 6270 __ bind(&done); | 6272 __ bind(&done); |
| 6271 } | 6273 } |
| 6272 | 6274 |
| 6273 | 6275 |
| 6274 #undef __ | 6276 #undef __ |
| 6275 | 6277 |
| 6276 } } // namespace v8::internal | 6278 } } // namespace v8::internal |
| 6277 | 6279 |
| 6278 #endif // V8_TARGET_ARCH_IA32 | 6280 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |