Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/x87/full-codegen-x87.cc

Issue 1179893002: Add script context with context-allocated "const this" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Factor out Variable::HasThisName Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/unittests/compiler/js-type-feedback-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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.
4680 DCHECK(is_sloppy(language_mode()) || var->is_this()); 4675 bool is_this = var->HasThisName(isolate());
4676 DCHECK(is_sloppy(language_mode()) || is_this);
4681 if (var->IsUnallocated()) { 4677 if (var->IsUnallocated()) {
4682 __ push(GlobalObjectOperand()); 4678 __ push(GlobalObjectOperand());
4683 __ push(Immediate(var->name())); 4679 __ push(Immediate(var->name()));
4684 __ push(Immediate(Smi::FromInt(SLOPPY))); 4680 __ push(Immediate(Smi::FromInt(SLOPPY)));
4685 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); 4681 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
4686 context()->Plug(eax); 4682 context()->Plug(eax);
4687 } else if (var->IsStackAllocated() || var->IsContextSlot()) { 4683 } else if (var->IsStackAllocated() || var->IsContextSlot()) {
4688 // Result of deleting non-global variables is false. 'this' is 4684 // Result of deleting non-global variables is false. 'this' is
4689 // not really a variable, though we implement it as one. The 4685 // not really a variable, though we implement it as one. The
4690 // subexpression does not have side effects. 4686 // subexpression does not have side effects.
4691 context()->Plug(var->is_this()); 4687 context()->Plug(is_this);
4692 } else { 4688 } else {
4693 // Non-global variable. Call the runtime to try to delete from the 4689 // Non-global variable. Call the runtime to try to delete from the
4694 // context where the variable was introduced. 4690 // context where the variable was introduced.
4695 __ push(context_register()); 4691 __ push(context_register());
4696 __ push(Immediate(var->name())); 4692 __ push(Immediate(var->name()));
4697 __ CallRuntime(Runtime::kDeleteLookupSlot, 2); 4693 __ CallRuntime(Runtime::kDeleteLookupSlot, 2);
4698 context()->Plug(eax); 4694 context()->Plug(eax);
4699 } 4695 }
4700 } else { 4696 } else {
4701 // Result of deleting non-property, non-variable reference is true. 4697 // Result of deleting non-property, non-variable reference is true.
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
5437 Assembler::target_address_at(call_target_address, 5433 Assembler::target_address_at(call_target_address,
5438 unoptimized_code)); 5434 unoptimized_code));
5439 return OSR_AFTER_STACK_CHECK; 5435 return OSR_AFTER_STACK_CHECK;
5440 } 5436 }
5441 5437
5442 5438
5443 } // namespace internal 5439 } // namespace internal
5444 } // namespace v8 5440 } // namespace v8
5445 5441
5446 #endif // V8_TARGET_ARCH_X87 5442 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | test/unittests/compiler/js-type-feedback-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698