| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 3554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3565 | 3565 |
| 3566 | 3566 |
| 3567 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { | 3567 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
| 3568 Register receiver = ToRegister(instr->receiver()); | 3568 Register receiver = ToRegister(instr->receiver()); |
| 3569 Register function = ToRegister(instr->function()); | 3569 Register function = ToRegister(instr->function()); |
| 3570 | 3570 |
| 3571 // If the receiver is null or undefined, we have to pass the global | 3571 // If the receiver is null or undefined, we have to pass the global |
| 3572 // object as a receiver to normal functions. Values have to be | 3572 // object as a receiver to normal functions. Values have to be |
| 3573 // passed unchanged to builtins and strict-mode functions. | 3573 // passed unchanged to builtins and strict-mode functions. |
| 3574 Label receiver_ok, global_object; | 3574 Label receiver_ok, global_object; |
| 3575 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; | |
| 3576 Register scratch = ToRegister(instr->temp()); | 3575 Register scratch = ToRegister(instr->temp()); |
| 3577 | 3576 |
| 3578 if (!instr->hydrogen()->known_function()) { | 3577 if (!instr->hydrogen()->known_function()) { |
| 3579 // Do not transform the receiver to object for strict mode | 3578 // Do not transform the receiver to object for strict mode |
| 3580 // functions. | 3579 // functions. |
| 3581 __ mov(scratch, | 3580 __ mov(scratch, |
| 3582 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 3581 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
| 3583 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kStrictModeByteOffset), | 3582 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kStrictModeByteOffset), |
| 3584 1 << SharedFunctionInfo::kStrictModeBitWithinByte); | 3583 1 << SharedFunctionInfo::kStrictModeBitWithinByte); |
| 3585 __ j(not_equal, &receiver_ok, dist); | 3584 __ j(not_equal, &receiver_ok); |
| 3586 | 3585 |
| 3587 // Do not transform the receiver to object for builtins. | 3586 // Do not transform the receiver to object for builtins. |
| 3588 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kNativeByteOffset), | 3587 __ test_b(FieldOperand(scratch, SharedFunctionInfo::kNativeByteOffset), |
| 3589 1 << SharedFunctionInfo::kNativeBitWithinByte); | 3588 1 << SharedFunctionInfo::kNativeBitWithinByte); |
| 3590 __ j(not_equal, &receiver_ok, dist); | 3589 __ j(not_equal, &receiver_ok); |
| 3591 } | 3590 } |
| 3592 | 3591 |
| 3593 // Normal function. Replace undefined or null with global receiver. | 3592 // Normal function. Replace undefined or null with global receiver. |
| 3594 __ cmp(receiver, factory()->null_value()); | 3593 __ cmp(receiver, factory()->null_value()); |
| 3595 __ j(equal, &global_object, Label::kNear); | 3594 __ j(equal, &global_object); |
| 3596 __ cmp(receiver, factory()->undefined_value()); | 3595 __ cmp(receiver, factory()->undefined_value()); |
| 3597 __ j(equal, &global_object, Label::kNear); | 3596 __ j(equal, &global_object); |
| 3598 | 3597 |
| 3599 // The receiver should be a JS object. | 3598 // The receiver should be a JS object. |
| 3600 __ test(receiver, Immediate(kSmiTagMask)); | 3599 __ test(receiver, Immediate(kSmiTagMask)); |
| 3601 DeoptimizeIf(equal, instr, Deoptimizer::kSmi); | 3600 DeoptimizeIf(equal, instr, Deoptimizer::kSmi); |
| 3602 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, scratch); | 3601 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, scratch); |
| 3603 DeoptimizeIf(below, instr, Deoptimizer::kNotAJavaScriptObject); | 3602 DeoptimizeIf(below, instr, Deoptimizer::kNotAJavaScriptObject); |
| 3604 | 3603 |
| 3605 __ jmp(&receiver_ok, Label::kNear); | 3604 __ jmp(&receiver_ok, Label::kNear); |
| 3606 __ bind(&global_object); | 3605 __ bind(&global_object); |
| 3607 __ mov(receiver, FieldOperand(function, JSFunction::kContextOffset)); | 3606 __ mov(receiver, FieldOperand(function, JSFunction::kContextOffset)); |
| (...skipping 2763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6371 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6370 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
| 6372 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6371 RecordSafepoint(Safepoint::kNoLazyDeopt); |
| 6373 } | 6372 } |
| 6374 | 6373 |
| 6375 | 6374 |
| 6376 #undef __ | 6375 #undef __ |
| 6377 | 6376 |
| 6378 } } // namespace v8::internal | 6377 } } // namespace v8::internal |
| 6379 | 6378 |
| 6380 #endif // V8_TARGET_ARCH_X87 | 6379 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |