| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 #endif | 100 #endif |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 | 103 |
| 104 // Generate code for a JS function. On entry to the function the receiver | 104 // Generate code for a JS function. On entry to the function the receiver |
| 105 // and arguments have been pushed on the stack left to right, with the | 105 // and arguments have been pushed on the stack left to right, with the |
| 106 // return address on top of them. The actual argument count matches the | 106 // return address on top of them. The actual argument count matches the |
| 107 // formal parameter count expected by the function. | 107 // formal parameter count expected by the function. |
| 108 // | 108 // |
| 109 // The live registers are: | 109 // The live registers are: |
| 110 // o ecx: CallKind | |
| 111 // o edi: the JS function object being called (i.e. ourselves) | 110 // o edi: the JS function object being called (i.e. ourselves) |
| 112 // o esi: our context | 111 // o esi: our context |
| 113 // o ebp: our caller's frame pointer | 112 // o ebp: our caller's frame pointer |
| 114 // o esp: stack pointer (pointing to return address) | 113 // o esp: stack pointer (pointing to return address) |
| 115 // | 114 // |
| 116 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 115 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
| 117 // frames-ia32.h for its layout. | 116 // frames-ia32.h for its layout. |
| 118 void FullCodeGenerator::Generate() { | 117 void FullCodeGenerator::Generate() { |
| 119 CompilationInfo* info = info_; | 118 CompilationInfo* info = info_; |
| 120 handler_table_ = | 119 handler_table_ = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 131 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 130 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
| 132 __ int3(); | 131 __ int3(); |
| 133 } | 132 } |
| 134 #endif | 133 #endif |
| 135 | 134 |
| 136 // Classic mode functions and builtins need to replace the receiver with the | 135 // Classic mode functions and builtins need to replace the receiver with the |
| 137 // global proxy when called as functions (without an explicit receiver | 136 // global proxy when called as functions (without an explicit receiver |
| 138 // object). | 137 // object). |
| 139 if (info->is_classic_mode() && !info->is_native()) { | 138 if (info->is_classic_mode() && !info->is_native()) { |
| 140 Label ok; | 139 Label ok; |
| 141 __ test(ecx, ecx); | |
| 142 __ j(zero, &ok, Label::kNear); | |
| 143 | |
| 144 // +1 for return address. | 140 // +1 for return address. |
| 145 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; | 141 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; |
| 146 __ mov(ecx, Operand(esp, receiver_offset)); | 142 __ mov(ecx, Operand(esp, receiver_offset)); |
| 147 | 143 |
| 148 __ cmp(ecx, isolate()->factory()->undefined_value()); | 144 __ cmp(ecx, isolate()->factory()->undefined_value()); |
| 149 __ j(not_equal, &ok, Label::kNear); | 145 __ j(not_equal, &ok, Label::kNear); |
| 150 | 146 |
| 151 __ mov(ecx, GlobalObjectOperand()); | 147 __ mov(ecx, GlobalObjectOperand()); |
| 152 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); | 148 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); |
| 153 | 149 |
| (...skipping 3532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3686 | 3682 |
| 3687 Label runtime, done; | 3683 Label runtime, done; |
| 3688 // Check for non-function argument (including proxy). | 3684 // Check for non-function argument (including proxy). |
| 3689 __ JumpIfSmi(eax, &runtime); | 3685 __ JumpIfSmi(eax, &runtime); |
| 3690 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); | 3686 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); |
| 3691 __ j(not_equal, &runtime); | 3687 __ j(not_equal, &runtime); |
| 3692 | 3688 |
| 3693 // InvokeFunction requires the function in edi. Move it in there. | 3689 // InvokeFunction requires the function in edi. Move it in there. |
| 3694 __ mov(edi, result_register()); | 3690 __ mov(edi, result_register()); |
| 3695 ParameterCount count(arg_count); | 3691 ParameterCount count(arg_count); |
| 3696 __ InvokeFunction(edi, count, CALL_FUNCTION, | 3692 __ InvokeFunction(edi, count, CALL_FUNCTION, NullCallWrapper()); |
| 3697 NullCallWrapper(), CALL_AS_FUNCTION); | |
| 3698 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3693 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 3699 __ jmp(&done); | 3694 __ jmp(&done); |
| 3700 | 3695 |
| 3701 __ bind(&runtime); | 3696 __ bind(&runtime); |
| 3702 __ push(eax); | 3697 __ push(eax); |
| 3703 __ CallRuntime(Runtime::kCall, args->length()); | 3698 __ CallRuntime(Runtime::kCall, args->length()); |
| 3704 __ bind(&done); | 3699 __ bind(&done); |
| 3705 | 3700 |
| 3706 context()->Plug(eax); | 3701 context()->Plug(eax); |
| 3707 } | 3702 } |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4890 | 4885 |
| 4891 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4886 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4892 Assembler::target_address_at(call_target_address)); | 4887 Assembler::target_address_at(call_target_address)); |
| 4893 return OSR_AFTER_STACK_CHECK; | 4888 return OSR_AFTER_STACK_CHECK; |
| 4894 } | 4889 } |
| 4895 | 4890 |
| 4896 | 4891 |
| 4897 } } // namespace v8::internal | 4892 } } // namespace v8::internal |
| 4898 | 4893 |
| 4899 #endif // V8_TARGET_ARCH_IA32 | 4894 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |