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

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

Issue 1178903003: Add script context with context-allocated "const this" (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Add test 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/hydrogen.cc ('k') | src/mips/full-codegen-mips.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_IA32 7 #if V8_TARGET_ARCH_IA32
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 2988 matching lines...) Expand 10 before | Expand all | Expand 10 after
2999 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { 2999 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
3000 // Push copy of the first argument or undefined if it doesn't exist. 3000 // Push copy of the first argument or undefined if it doesn't exist.
3001 if (arg_count > 0) { 3001 if (arg_count > 0) {
3002 __ push(Operand(esp, arg_count * kPointerSize)); 3002 __ push(Operand(esp, arg_count * kPointerSize));
3003 } else { 3003 } else {
3004 __ push(Immediate(isolate()->factory()->undefined_value())); 3004 __ push(Immediate(isolate()->factory()->undefined_value()));
3005 } 3005 }
3006 3006
3007 // Push the enclosing function. 3007 // Push the enclosing function.
3008 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 3008 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
3009 // Push the receiver of the enclosing function. 3009
3010 Variable* this_var = scope()->LookupThis();
3011 DCHECK_NOT_NULL(this_var);
3012 __ push(VarOperand(this_var, ecx));
3013 // Push the language mode. 3010 // Push the language mode.
3014 __ push(Immediate(Smi::FromInt(language_mode()))); 3011 __ push(Immediate(Smi::FromInt(language_mode())));
3015 3012
3016 // Push the start position of the scope the calls resides in. 3013 // Push the start position of the scope the calls resides in.
3017 __ push(Immediate(Smi::FromInt(scope()->start_position()))); 3014 __ push(Immediate(Smi::FromInt(scope()->start_position())));
3018 3015
3019 // Do the runtime call. 3016 // Do the runtime call.
3020 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 6); 3017 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
3021 } 3018 }
3022 3019
3023 3020
3024 void FullCodeGenerator::EmitInitializeThisAfterSuper( 3021 void FullCodeGenerator::EmitInitializeThisAfterSuper(
3025 SuperCallReference* super_call_ref, FeedbackVectorICSlot slot) { 3022 SuperCallReference* super_call_ref, FeedbackVectorICSlot slot) {
3026 Variable* this_var = super_call_ref->this_var()->var(); 3023 Variable* this_var = super_call_ref->this_var()->var();
3027 GetVar(ecx, this_var); 3024 GetVar(ecx, this_var);
3028 __ cmp(ecx, isolate()->factory()->the_hole_value()); 3025 __ cmp(ecx, isolate()->factory()->the_hole_value());
3029 Label uninitialized_this; 3026 Label uninitialized_this;
3030 __ j(equal, &uninitialized_this); 3027 __ j(equal, &uninitialized_this);
(...skipping 11 matching lines...) Expand all
3042 // through this function. Avoid early returns. 3039 // through this function. Avoid early returns.
3043 expr->return_is_recorded_ = false; 3040 expr->return_is_recorded_ = false;
3044 #endif 3041 #endif
3045 3042
3046 Comment cmnt(masm_, "[ Call"); 3043 Comment cmnt(masm_, "[ Call");
3047 Expression* callee = expr->expression(); 3044 Expression* callee = expr->expression();
3048 Call::CallType call_type = expr->GetCallType(isolate()); 3045 Call::CallType call_type = expr->GetCallType(isolate());
3049 3046
3050 if (call_type == Call::POSSIBLY_EVAL_CALL) { 3047 if (call_type == Call::POSSIBLY_EVAL_CALL) {
3051 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval 3048 // In a call to eval, we first call RuntimeHidden_ResolvePossiblyDirectEval
3052 // to resolve the function we need to call and the receiver of the call. 3049 // to resolve the function we need to call. Then we call the resolved
3053 // Then we call the resolved function using the given arguments. 3050 // function using the given arguments.
3054 ZoneList<Expression*>* args = expr->arguments(); 3051 ZoneList<Expression*>* args = expr->arguments();
3055 int arg_count = args->length(); 3052 int arg_count = args->length();
3056 { PreservePositionScope pos_scope(masm()->positions_recorder()); 3053 { PreservePositionScope pos_scope(masm()->positions_recorder());
3057 VisitForStackValue(callee); 3054 VisitForStackValue(callee);
3058 // Reserved receiver slot. 3055 // Reserved receiver slot.
3059 __ push(Immediate(isolate()->factory()->undefined_value())); 3056 __ push(Immediate(isolate()->factory()->undefined_value()));
3060 // Push the arguments. 3057 // Push the arguments.
3061 for (int i = 0; i < arg_count; i++) { 3058 for (int i = 0; i < arg_count; i++) {
3062 VisitForStackValue(args->at(i)); 3059 VisitForStackValue(args->at(i));
3063 } 3060 }
3064 3061
3065 // Push a copy of the function (found below the arguments) and 3062 // Push a copy of the function (found below the arguments) and
3066 // resolve eval. 3063 // resolve eval.
3067 __ push(Operand(esp, (arg_count + 1) * kPointerSize)); 3064 __ push(Operand(esp, (arg_count + 1) * kPointerSize));
3068 EmitResolvePossiblyDirectEval(arg_count); 3065 EmitResolvePossiblyDirectEval(arg_count);
3069 3066
3070 // The runtime call returns a pair of values in eax (function) and 3067 // Touch up the stack with the resolved function.
3071 // edx (receiver). Touch up the stack with the right values.
3072 __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx);
3073 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); 3068 __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax);
3074 3069
3075 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); 3070 PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS);
3076 } 3071 }
3077 // Record source position for debugger. 3072 // Record source position for debugger.
3078 SetSourcePosition(expr->position()); 3073 SetSourcePosition(expr->position());
3079 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); 3074 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS);
3080 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); 3075 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
3081 __ CallStub(&stub); 3076 __ CallStub(&stub);
3082 RecordJSReturnSite(expr); 3077 RecordJSReturnSite(expr);
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
4696 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 4691 VariableProxy* proxy = expr->expression()->AsVariableProxy();
4697 4692
4698 if (property != NULL) { 4693 if (property != NULL) {
4699 VisitForStackValue(property->obj()); 4694 VisitForStackValue(property->obj());
4700 VisitForStackValue(property->key()); 4695 VisitForStackValue(property->key());
4701 __ push(Immediate(Smi::FromInt(language_mode()))); 4696 __ push(Immediate(Smi::FromInt(language_mode())));
4702 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); 4697 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
4703 context()->Plug(eax); 4698 context()->Plug(eax);
4704 } else if (proxy != NULL) { 4699 } else if (proxy != NULL) {
4705 Variable* var = proxy->var(); 4700 Variable* var = proxy->var();
4706 // Delete of an unqualified identifier is disallowed in strict mode 4701 // Delete of an unqualified identifier is disallowed in strict mode but
4707 // but "delete this" is allowed. 4702 // "delete this" is allowed.
4708 DCHECK(is_sloppy(language_mode()) || var->is_this()); 4703 bool is_this = var->HasThisName(isolate());
4704 DCHECK(is_sloppy(language_mode()) || is_this);
4709 if (var->IsUnallocated()) { 4705 if (var->IsUnallocated()) {
4710 __ push(GlobalObjectOperand()); 4706 __ push(GlobalObjectOperand());
4711 __ push(Immediate(var->name())); 4707 __ push(Immediate(var->name()));
4712 __ push(Immediate(Smi::FromInt(SLOPPY))); 4708 __ push(Immediate(Smi::FromInt(SLOPPY)));
4713 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); 4709 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
4714 context()->Plug(eax); 4710 context()->Plug(eax);
4715 } else if (var->IsStackAllocated() || var->IsContextSlot()) { 4711 } else if (var->IsStackAllocated() || var->IsContextSlot()) {
4716 // Result of deleting non-global variables is false. 'this' is 4712 // Result of deleting non-global variables is false. 'this' is
4717 // not really a variable, though we implement it as one. The 4713 // not really a variable, though we implement it as one. The
4718 // subexpression does not have side effects. 4714 // subexpression does not have side effects.
4719 context()->Plug(var->is_this()); 4715 context()->Plug(is_this);
4720 } else { 4716 } else {
4721 // Non-global variable. Call the runtime to try to delete from the 4717 // Non-global variable. Call the runtime to try to delete from the
4722 // context where the variable was introduced. 4718 // context where the variable was introduced.
4723 __ push(context_register()); 4719 __ push(context_register());
4724 __ push(Immediate(var->name())); 4720 __ push(Immediate(var->name()));
4725 __ CallRuntime(Runtime::kDeleteLookupSlot, 2); 4721 __ CallRuntime(Runtime::kDeleteLookupSlot, 2);
4726 context()->Plug(eax); 4722 context()->Plug(eax);
4727 } 4723 }
4728 } else { 4724 } else {
4729 // Result of deleting non-property, non-variable reference is true. 4725 // Result of deleting non-property, non-variable reference is true.
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
5465 Assembler::target_address_at(call_target_address, 5461 Assembler::target_address_at(call_target_address,
5466 unoptimized_code)); 5462 unoptimized_code));
5467 return OSR_AFTER_STACK_CHECK; 5463 return OSR_AFTER_STACK_CHECK;
5468 } 5464 }
5469 5465
5470 5466
5471 } // namespace internal 5467 } // namespace internal
5472 } // namespace v8 5468 } // namespace v8
5473 5469
5474 #endif // V8_TARGET_ARCH_IA32 5470 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698