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/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2986 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2987 // Push copy of the first argument or undefined if it doesn't exist. | 2987 // Push copy of the first argument or undefined if it doesn't exist. |
2988 if (arg_count > 0) { | 2988 if (arg_count > 0) { |
2989 __ push(Operand(esp, arg_count * kPointerSize)); | 2989 __ push(Operand(esp, arg_count * kPointerSize)); |
2990 } else { | 2990 } else { |
2991 __ push(Immediate(isolate()->factory()->undefined_value())); | 2991 __ push(Immediate(isolate()->factory()->undefined_value())); |
2992 } | 2992 } |
2993 | 2993 |
2994 // Push the enclosing function. | 2994 // Push the enclosing function. |
2995 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 2995 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
2996 // Push the receiver of the enclosing function. | 2996 |
2997 Variable* this_var = scope()->LookupThis(); | |
2998 DCHECK_NOT_NULL(this_var); | |
2999 __ push(VarOperand(this_var, ecx)); | |
3000 // Push the language mode. | 2997 // Push the language mode. |
3001 __ push(Immediate(Smi::FromInt(language_mode()))); | 2998 __ push(Immediate(Smi::FromInt(language_mode()))); |
3002 | 2999 |
3003 // Push the start position of the scope the calls resides in. | 3000 // Push the start position of the scope the calls resides in. |
3004 __ push(Immediate(Smi::FromInt(scope()->start_position()))); | 3001 __ push(Immediate(Smi::FromInt(scope()->start_position()))); |
3005 | 3002 |
3006 // Do the runtime call. | 3003 // Do the runtime call. |
3007 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); | 3004 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); |
3008 } | 3005 } |
3009 | 3006 |
3010 | 3007 |
3011 void FullCodeGenerator::EmitInitializeThisAfterSuper( | 3008 void FullCodeGenerator::EmitInitializeThisAfterSuper( |
3012 SuperCallReference* super_call_ref, FeedbackVectorICSlot slot) { | 3009 SuperCallReference* super_call_ref, FeedbackVectorICSlot slot) { |
3013 Variable* this_var = super_call_ref->this_var()->var(); | 3010 Variable* this_var = super_call_ref->this_var()->var(); |
3014 GetVar(ecx, this_var); | 3011 GetVar(ecx, this_var); |
3015 __ cmp(ecx, isolate()->factory()->the_hole_value()); | 3012 __ cmp(ecx, isolate()->factory()->the_hole_value()); |
3016 Label uninitialized_this; | 3013 Label uninitialized_this; |
3017 __ j(equal, &uninitialized_this); | 3014 __ j(equal, &uninitialized_this); |
(...skipping 11 matching lines...) Expand all Loading... |
3029 // through this function. Avoid early returns. | 3026 // through this function. Avoid early returns. |
3030 expr->return_is_recorded_ = false; | 3027 expr->return_is_recorded_ = false; |
3031 #endif | 3028 #endif |
3032 | 3029 |
3033 Comment cmnt(masm_, "[ Call"); | 3030 Comment cmnt(masm_, "[ Call"); |
3034 Expression* callee = expr->expression(); | 3031 Expression* callee = expr->expression(); |
3035 Call::CallType call_type = expr->GetCallType(isolate()); | 3032 Call::CallType call_type = expr->GetCallType(isolate()); |
3036 | 3033 |
3037 if (call_type == Call::POSSIBLY_EVAL_CALL) { | 3034 if (call_type == Call::POSSIBLY_EVAL_CALL) { |
3038 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval | 3035 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval |
3039 // to resolve the function we need to call and the receiver of the call. | 3036 // to resolve the function we need to call. Then we call the resolved |
3040 // Then we call the resolved function using the given arguments. | 3037 // function using the given arguments. |
3041 ZoneList<Expression*>* args = expr->arguments(); | 3038 ZoneList<Expression*>* args = expr->arguments(); |
3042 int arg_count = args->length(); | 3039 int arg_count = args->length(); |
3043 { PreservePositionScope pos_scope(masm()->positions_recorder()); | 3040 { PreservePositionScope pos_scope(masm()->positions_recorder()); |
3044 VisitForStackValue(callee); | 3041 VisitForStackValue(callee); |
3045 // Reserved receiver slot. | 3042 // Reserved receiver slot. |
3046 __ push(Immediate(isolate()->factory()->undefined_value())); | 3043 __ push(Immediate(isolate()->factory()->undefined_value())); |
3047 // Push the arguments. | 3044 // Push the arguments. |
3048 for (int i = 0; i < arg_count; i++) { | 3045 for (int i = 0; i < arg_count; i++) { |
3049 VisitForStackValue(args->at(i)); | 3046 VisitForStackValue(args->at(i)); |
3050 } | 3047 } |
3051 | 3048 |
3052 // Push a copy of the function (found below the arguments) and | 3049 // Push a copy of the function (found below the arguments) and |
3053 // resolve eval. | 3050 // resolve eval. |
3054 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); | 3051 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); |
3055 EmitResolvePossiblyDirectEval(arg_count); | 3052 EmitResolvePossiblyDirectEval(arg_count); |
3056 | 3053 |
3057 // The runtime call returns a pair of values in eax (function) and | 3054 // Touch up the stack with the resolved function. |
3058 // edx (receiver). Touch up the stack with the right values. | |
3059 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx); | |
3060 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); | 3055 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
3061 | 3056 |
3062 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); | 3057 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); |
3063 } | 3058 } |
3064 // Record source position for debugger. | 3059 // Record source position for debugger. |
3065 SetSourcePosition(expr->position()); | 3060 SetSourcePosition(expr->position()); |
3066 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 3061 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
3067 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 3062 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
3068 __ CallStub(&stub); | 3063 __ CallStub(&stub); |
3069 RecordJSReturnSite(expr); | 3064 RecordJSReturnSite(expr); |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4668 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 4663 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
4669 | 4664 |
4670 if (property != NULL) { | 4665 if (property != NULL) { |
4671 VisitForStackValue(property->obj()); | 4666 VisitForStackValue(property->obj()); |
4672 VisitForStackValue(property->key()); | 4667 VisitForStackValue(property->key()); |
4673 __ push(Immediate(Smi::FromInt(language_mode()))); | 4668 __ push(Immediate(Smi::FromInt(language_mode()))); |
4674 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); | 4669 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); |
4675 context()->Plug(eax); | 4670 context()->Plug(eax); |
4676 } else if (proxy != NULL) { | 4671 } else if (proxy != NULL) { |
4677 Variable* var = proxy->var(); | 4672 Variable* var = proxy->var(); |
4678 // Delete of an unqualified identifier is disallowed in strict mode | 4673 // Delete of an unqualified identifier is disallowed in strict mode but |
4679 // but "delete this" is allowed. | 4674 // "delete this" is allowed. (It could be that the "this" variable has |
4680 DCHECK(is_sloppy(language_mode()) || var->is_this()); | 4675 // DYNAMIC resolution though so we haven't been able to map it to |
| 4676 // Variable::THIS, but regardless if its name is "this" then it is |
| 4677 // "this".) |
| 4678 bool is_this = *var->name() == *isolate()->factory()->this_string(); |
| 4679 DCHECK(is_sloppy(language_mode()) || is_this); |
4681 if (var->IsUnallocated()) { | 4680 if (var->IsUnallocated()) { |
4682 __ push(GlobalObjectOperand()); | 4681 __ push(GlobalObjectOperand()); |
4683 __ push(Immediate(var->name())); | 4682 __ push(Immediate(var->name())); |
4684 __ push(Immediate(Smi::FromInt(SLOPPY))); | 4683 __ push(Immediate(Smi::FromInt(SLOPPY))); |
4685 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); | 4684 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); |
4686 context()->Plug(eax); | 4685 context()->Plug(eax); |
4687 } else if (var->IsStackAllocated() || var->IsContextSlot()) { | 4686 } else if (var->IsStackAllocated() || var->IsContextSlot()) { |
4688 // Result of deleting non-global variables is false. 'this' is | 4687 // Result of deleting non-global variables is false. 'this' is |
4689 // not really a variable, though we implement it as one. The | 4688 // not really a variable, though we implement it as one. The |
4690 // subexpression does not have side effects. | 4689 // subexpression does not have side effects. |
4691 context()->Plug(var->is_this()); | 4690 context()->Plug(is_this); |
4692 } else { | 4691 } else { |
4693 // Non-global variable. Call the runtime to try to delete from the | 4692 // Non-global variable. Call the runtime to try to delete from the |
4694 // context where the variable was introduced. | 4693 // context where the variable was introduced. |
4695 __ push(context_register()); | 4694 __ push(context_register()); |
4696 __ push(Immediate(var->name())); | 4695 __ push(Immediate(var->name())); |
4697 __ CallRuntime(Runtime::kDeleteLookupSlot, 2); | 4696 __ CallRuntime(Runtime::kDeleteLookupSlot, 2); |
4698 context()->Plug(eax); | 4697 context()->Plug(eax); |
4699 } | 4698 } |
4700 } else { | 4699 } else { |
4701 // Result of deleting non-property, non-variable reference is true. | 4700 // Result of deleting non-property, non-variable reference is true. |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5437 Assembler::target_address_at(call_target_address, | 5436 Assembler::target_address_at(call_target_address, |
5438 unoptimized_code)); | 5437 unoptimized_code)); |
5439 return OSR_AFTER_STACK_CHECK; | 5438 return OSR_AFTER_STACK_CHECK; |
5440 } | 5439 } |
5441 | 5440 |
5442 | 5441 |
5443 } // namespace internal | 5442 } // namespace internal |
5444 } // namespace v8 | 5443 } // namespace v8 |
5445 | 5444 |
5446 #endif // V8_TARGET_ARCH_X87 | 5445 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |