OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3154 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { | 3154 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
3155 Register receiver = ToRegister(instr->receiver()); | 3155 Register receiver = ToRegister(instr->receiver()); |
3156 Register function = ToRegister(instr->function()); | 3156 Register function = ToRegister(instr->function()); |
3157 | 3157 |
3158 // If the receiver is null or undefined, we have to pass the global | 3158 // If the receiver is null or undefined, we have to pass the global |
3159 // object as a receiver to normal functions. Values have to be | 3159 // object as a receiver to normal functions. Values have to be |
3160 // passed unchanged to builtins and strict-mode functions. | 3160 // passed unchanged to builtins and strict-mode functions. |
3161 Label global_object, receiver_ok; | 3161 Label global_object, receiver_ok; |
3162 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; | 3162 Label::Distance dist = DeoptEveryNTimes() ? Label::kFar : Label::kNear; |
3163 | 3163 |
3164 // Do not transform the receiver to object for strict mode | 3164 if (!instr->hydrogen()->known_function()) { |
3165 // functions. | 3165 // Do not transform the receiver to object for strict mode |
3166 __ movp(kScratchRegister, | 3166 // functions. |
3167 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | 3167 __ movp(kScratchRegister, |
3168 __ testb(FieldOperand(kScratchRegister, | 3168 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); |
3169 SharedFunctionInfo::kStrictModeByteOffset), | 3169 __ testb(FieldOperand(kScratchRegister, |
3170 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | 3170 SharedFunctionInfo::kStrictModeByteOffset), |
3171 __ j(not_equal, &receiver_ok, dist); | 3171 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
| 3172 __ j(not_equal, &receiver_ok, dist); |
3172 | 3173 |
3173 // Do not transform the receiver to object for builtins. | 3174 // Do not transform the receiver to object for builtins. |
3174 __ testb(FieldOperand(kScratchRegister, | 3175 __ testb(FieldOperand(kScratchRegister, |
3175 SharedFunctionInfo::kNativeByteOffset), | 3176 SharedFunctionInfo::kNativeByteOffset), |
3176 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); | 3177 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); |
3177 __ j(not_equal, &receiver_ok, dist); | 3178 __ j(not_equal, &receiver_ok, dist); |
| 3179 } |
3178 | 3180 |
3179 // Normal function. Replace undefined or null with global receiver. | 3181 // Normal function. Replace undefined or null with global receiver. |
3180 __ CompareRoot(receiver, Heap::kNullValueRootIndex); | 3182 __ CompareRoot(receiver, Heap::kNullValueRootIndex); |
3181 __ j(equal, &global_object, Label::kNear); | 3183 __ j(equal, &global_object, Label::kNear); |
3182 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); | 3184 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); |
3183 __ j(equal, &global_object, Label::kNear); | 3185 __ j(equal, &global_object, Label::kNear); |
3184 | 3186 |
3185 // The receiver should be a JS object. | 3187 // The receiver should be a JS object. |
3186 Condition is_smi = __ CheckSmi(receiver); | 3188 Condition is_smi = __ CheckSmi(receiver); |
3187 DeoptimizeIf(is_smi, instr->environment()); | 3189 DeoptimizeIf(is_smi, instr->environment()); |
3188 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, kScratchRegister); | 3190 __ CmpObjectType(receiver, FIRST_SPEC_OBJECT_TYPE, kScratchRegister); |
3189 DeoptimizeIf(below, instr->environment()); | 3191 DeoptimizeIf(below, instr->environment()); |
| 3192 |
3190 __ jmp(&receiver_ok, Label::kNear); | 3193 __ jmp(&receiver_ok, Label::kNear); |
3191 | |
3192 __ bind(&global_object); | 3194 __ bind(&global_object); |
3193 __ movp(receiver, FieldOperand(function, JSFunction::kContextOffset)); | 3195 __ movp(receiver, FieldOperand(function, JSFunction::kContextOffset)); |
3194 __ movp(receiver, | 3196 __ movp(receiver, |
3195 Operand(receiver, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 3197 Operand(receiver, |
| 3198 Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
3196 __ movp(receiver, | 3199 __ movp(receiver, |
3197 FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset)); | 3200 FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset)); |
| 3201 |
3198 __ bind(&receiver_ok); | 3202 __ bind(&receiver_ok); |
3199 } | 3203 } |
3200 | 3204 |
3201 | 3205 |
3202 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 3206 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
3203 Register receiver = ToRegister(instr->receiver()); | 3207 Register receiver = ToRegister(instr->receiver()); |
3204 Register function = ToRegister(instr->function()); | 3208 Register function = ToRegister(instr->function()); |
3205 Register length = ToRegister(instr->length()); | 3209 Register length = ToRegister(instr->length()); |
3206 Register elements = ToRegister(instr->elements()); | 3210 Register elements = ToRegister(instr->elements()); |
3207 ASSERT(receiver.is(rax)); // Used for parameter count. | 3211 ASSERT(receiver.is(rax)); // Used for parameter count. |
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5546 FixedArray::kHeaderSize - kPointerSize)); | 5550 FixedArray::kHeaderSize - kPointerSize)); |
5547 __ bind(&done); | 5551 __ bind(&done); |
5548 } | 5552 } |
5549 | 5553 |
5550 | 5554 |
5551 #undef __ | 5555 #undef __ |
5552 | 5556 |
5553 } } // namespace v8::internal | 5557 } } // namespace v8::internal |
5554 | 5558 |
5555 #endif // V8_TARGET_ARCH_X64 | 5559 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |