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 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2601 | 2601 |
2602 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 2602 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
2603 Register receiver = ToRegister(instr->receiver()); | 2603 Register receiver = ToRegister(instr->receiver()); |
2604 Register function = ToRegister(instr->function()); | 2604 Register function = ToRegister(instr->function()); |
2605 Register length = ToRegister(instr->length()); | 2605 Register length = ToRegister(instr->length()); |
2606 Register elements = ToRegister(instr->elements()); | 2606 Register elements = ToRegister(instr->elements()); |
2607 ASSERT(receiver.is(rax)); // Used for parameter count. | 2607 ASSERT(receiver.is(rax)); // Used for parameter count. |
2608 ASSERT(function.is(rdi)); // Required by InvokeFunction. | 2608 ASSERT(function.is(rdi)); // Required by InvokeFunction. |
2609 ASSERT(ToRegister(instr->result()).is(rax)); | 2609 ASSERT(ToRegister(instr->result()).is(rax)); |
2610 | 2610 |
2611 // TODO(1412): This is not correct if the called function is a | 2611 // If the receiver is null or undefined, we have to pass the global |
2612 // strict mode function or a native. | 2612 // object as a receiver to normal functions. Values have to be |
2613 // | 2613 // passed unchanged to builtins and strict-mode functions. |
2614 // If the receiver is null or undefined, we have to pass the global object | |
2615 // as a receiver. | |
2616 Label global_object, receiver_ok; | 2614 Label global_object, receiver_ok; |
2615 | |
2616 // Do not transform the receiver to object for strict mode | |
2617 // functions. | |
2618 __ movq(kScratchRegister, | |
2619 FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); | |
2620 __ testb(FieldOperand(kScratchRegister, | |
2621 SharedFunctionInfo::kStrictModeByteOffset), | |
2622 Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | |
2623 __ j(not_equal, &receiver_ok, Label::kNear); | |
2624 | |
2625 // Do not transform the receiver to object for builtins. | |
2626 __ testb(FieldOperand(kScratchRegister, | |
2627 SharedFunctionInfo::kNativeByteOffset), | |
2628 Immediate(1 << SharedFunctionInfo::kNativeBitWithinByte)); | |
2629 __ j(not_zero, &receiver_ok, Label::kNear); | |
Rico
2011/05/31 10:31:15
__ j(not_equal to be consistent (I wonder who orig
Mads Ager (chromium)
2011/05/31 10:33:22
Done. Also in builtins-x64.cc.
| |
2630 | |
2631 // Normal function. Replace undefined or null with global receiver. | |
2617 __ CompareRoot(receiver, Heap::kNullValueRootIndex); | 2632 __ CompareRoot(receiver, Heap::kNullValueRootIndex); |
2618 __ j(equal, &global_object, Label::kNear); | 2633 __ j(equal, &global_object, Label::kNear); |
2619 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); | 2634 __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex); |
2620 __ j(equal, &global_object, Label::kNear); | 2635 __ j(equal, &global_object, Label::kNear); |
2621 | 2636 |
2622 // The receiver should be a JS object. | 2637 // The receiver should be a JS object. |
2623 Condition is_smi = __ CheckSmi(receiver); | 2638 Condition is_smi = __ CheckSmi(receiver); |
2624 DeoptimizeIf(is_smi, instr->environment()); | 2639 DeoptimizeIf(is_smi, instr->environment()); |
2625 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, kScratchRegister); | 2640 __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, kScratchRegister); |
2626 DeoptimizeIf(below, instr->environment()); | 2641 DeoptimizeIf(below, instr->environment()); |
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4263 RegisterEnvironmentForDeoptimization(environment); | 4278 RegisterEnvironmentForDeoptimization(environment); |
4264 ASSERT(osr_pc_offset_ == -1); | 4279 ASSERT(osr_pc_offset_ == -1); |
4265 osr_pc_offset_ = masm()->pc_offset(); | 4280 osr_pc_offset_ = masm()->pc_offset(); |
4266 } | 4281 } |
4267 | 4282 |
4268 #undef __ | 4283 #undef __ |
4269 | 4284 |
4270 } } // namespace v8::internal | 4285 } } // namespace v8::internal |
4271 | 4286 |
4272 #endif // V8_TARGET_ARCH_X64 | 4287 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |