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

Side by Side Diff: src/codegen-arm.cc

Issue 20419: Optimize loads from variables that might be shadowed by variables... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/codegen-ia32.h » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 Variable* var = node->proxy()->var(); 1098 Variable* var = node->proxy()->var();
1099 ASSERT(var != NULL); // must have been resolved 1099 ASSERT(var != NULL); // must have been resolved
1100 Slot* slot = var->slot(); 1100 Slot* slot = var->slot();
1101 1101
1102 // If it was not possible to allocate the variable at compile time, 1102 // If it was not possible to allocate the variable at compile time,
1103 // we need to "declare" it at runtime to make sure it actually 1103 // we need to "declare" it at runtime to make sure it actually
1104 // exists in the local context. 1104 // exists in the local context.
1105 if (slot != NULL && slot->type() == Slot::LOOKUP) { 1105 if (slot != NULL && slot->type() == Slot::LOOKUP) {
1106 // Variables with a "LOOKUP" slot were introduced as non-locals 1106 // Variables with a "LOOKUP" slot were introduced as non-locals
1107 // during variable resolution and must have mode DYNAMIC. 1107 // during variable resolution and must have mode DYNAMIC.
1108 ASSERT(var->mode() == Variable::DYNAMIC); 1108 ASSERT(var->is_dynamic());
1109 // For now, just do a runtime call. 1109 // For now, just do a runtime call.
1110 frame_->Push(cp); 1110 frame_->Push(cp);
1111 __ mov(r0, Operand(var->name())); 1111 __ mov(r0, Operand(var->name()));
1112 frame_->Push(r0); 1112 frame_->Push(r0);
1113 // Declaration nodes are always declared in only two modes. 1113 // Declaration nodes are always declared in only two modes.
1114 ASSERT(node->mode() == Variable::VAR || node->mode() == Variable::CONST); 1114 ASSERT(node->mode() == Variable::VAR || node->mode() == Variable::CONST);
1115 PropertyAttributes attr = node->mode() == Variable::VAR ? NONE : READ_ONLY; 1115 PropertyAttributes attr = node->mode() == Variable::VAR ? NONE : READ_ONLY;
1116 __ mov(r0, Operand(Smi::FromInt(attr))); 1116 __ mov(r0, Operand(Smi::FromInt(attr)));
1117 frame_->Push(r0); 1117 frame_->Push(r0);
1118 // Push initial value, if any. 1118 // Push initial value, if any.
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 Load(node->then_expression(), typeof_state()); 1976 Load(node->then_expression(), typeof_state());
1977 __ b(&exit); 1977 __ b(&exit);
1978 __ bind(&else_); 1978 __ bind(&else_);
1979 Load(node->else_expression(), typeof_state()); 1979 Load(node->else_expression(), typeof_state());
1980 __ bind(&exit); 1980 __ bind(&exit);
1981 } 1981 }
1982 1982
1983 1983
1984 void CodeGenerator::LoadFromSlot(Slot* slot, TypeofState typeof_state) { 1984 void CodeGenerator::LoadFromSlot(Slot* slot, TypeofState typeof_state) {
1985 if (slot->type() == Slot::LOOKUP) { 1985 if (slot->type() == Slot::LOOKUP) {
1986 ASSERT(slot->var()->mode() == Variable::DYNAMIC); 1986 ASSERT(slot->var()->is_dynamic());
1987 1987
1988 // For now, just do a runtime call. 1988 // For now, just do a runtime call.
1989 frame_->Push(cp); 1989 frame_->Push(cp);
1990 __ mov(r0, Operand(slot->var()->name())); 1990 __ mov(r0, Operand(slot->var()->name()));
1991 frame_->Push(r0); 1991 frame_->Push(r0);
1992 1992
1993 if (typeof_state == INSIDE_TYPEOF) { 1993 if (typeof_state == INSIDE_TYPEOF) {
1994 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); 1994 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2);
1995 } else { 1995 } else {
1996 __ CallRuntime(Runtime::kLoadContextSlot, 2); 1996 __ CallRuntime(Runtime::kLoadContextSlot, 2);
1997 } 1997 }
1998 frame_->Push(r0); 1998 frame_->Push(r0);
1999 1999
2000 } else { 2000 } else {
2001 // Note: We would like to keep the assert below, but it fires because of 2001 // Note: We would like to keep the assert below, but it fires because of
2002 // some nasty code in LoadTypeofExpression() which should be removed... 2002 // some nasty code in LoadTypeofExpression() which should be removed...
2003 // ASSERT(slot->var()->mode() != Variable::DYNAMIC); 2003 // ASSERT(!slot->var()->is_dynamic());
2004 2004
2005 // Special handling for locals allocated in registers. 2005 // Special handling for locals allocated in registers.
2006 __ ldr(r0, SlotOperand(slot, r2)); 2006 __ ldr(r0, SlotOperand(slot, r2));
2007 frame_->Push(r0); 2007 frame_->Push(r0);
2008 if (slot->var()->mode() == Variable::CONST) { 2008 if (slot->var()->mode() == Variable::CONST) {
2009 // Const slots may contain 'the hole' value (the constant hasn't been 2009 // Const slots may contain 'the hole' value (the constant hasn't been
2010 // initialized yet) which needs to be converted into the 'undefined' 2010 // initialized yet) which needs to be converted into the 'undefined'
2011 // value. 2011 // value.
2012 Comment cmnt(masm_, "[ Unhole const"); 2012 Comment cmnt(masm_, "[ Unhole const");
2013 frame_->Pop(r0); 2013 frame_->Pop(r0);
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
3341 if (property != NULL) { 3341 if (property != NULL) {
3342 cgen_->CodeForSourcePosition(property->position()); 3342 cgen_->CodeForSourcePosition(property->position());
3343 } 3343 }
3344 3344
3345 switch (type_) { 3345 switch (type_) {
3346 case SLOT: { 3346 case SLOT: {
3347 Comment cmnt(masm, "[ Store to Slot"); 3347 Comment cmnt(masm, "[ Store to Slot");
3348 Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot(); 3348 Slot* slot = expression_->AsVariableProxy()->AsVariable()->slot();
3349 ASSERT(slot != NULL); 3349 ASSERT(slot != NULL);
3350 if (slot->type() == Slot::LOOKUP) { 3350 if (slot->type() == Slot::LOOKUP) {
3351 ASSERT(slot->var()->mode() == Variable::DYNAMIC); 3351 ASSERT(slot->var()->is_dynamic());
3352 3352
3353 // For now, just do a runtime call. 3353 // For now, just do a runtime call.
3354 frame->Push(cp); 3354 frame->Push(cp);
3355 __ mov(r0, Operand(slot->var()->name())); 3355 __ mov(r0, Operand(slot->var()->name()));
3356 frame->Push(r0); 3356 frame->Push(r0);
3357 3357
3358 if (init_state == CONST_INIT) { 3358 if (init_state == CONST_INIT) {
3359 // Same as the case for a normal store, but ignores attribute 3359 // Same as the case for a normal store, but ignores attribute
3360 // (e.g. READ_ONLY) of context slot so that we can initialize 3360 // (e.g. READ_ONLY) of context slot so that we can initialize
3361 // const properties (introduced via eval("const foo = (some 3361 // const properties (introduced via eval("const foo = (some
(...skipping 11 matching lines...) Expand all
3373 // context slot followed by initialization. 3373 // context slot followed by initialization.
3374 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); 3374 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3);
3375 } else { 3375 } else {
3376 __ CallRuntime(Runtime::kStoreContextSlot, 3); 3376 __ CallRuntime(Runtime::kStoreContextSlot, 3);
3377 } 3377 }
3378 // Storing a variable must keep the (new) value on the expression 3378 // Storing a variable must keep the (new) value on the expression
3379 // stack. This is necessary for compiling assignment expressions. 3379 // stack. This is necessary for compiling assignment expressions.
3380 frame->Push(r0); 3380 frame->Push(r0);
3381 3381
3382 } else { 3382 } else {
3383 ASSERT(slot->var()->mode() != Variable::DYNAMIC); 3383 ASSERT(!slot->var()->is_dynamic());
3384 3384
3385 Label exit; 3385 Label exit;
3386 if (init_state == CONST_INIT) { 3386 if (init_state == CONST_INIT) {
3387 ASSERT(slot->var()->mode() == Variable::CONST); 3387 ASSERT(slot->var()->mode() == Variable::CONST);
3388 // Only the first const initialization must be executed (the slot 3388 // Only the first const initialization must be executed (the slot
3389 // still contains 'the hole' value). When the assignment is 3389 // still contains 'the hole' value). When the assignment is
3390 // executed, the code is identical to a normal store (see below). 3390 // executed, the code is identical to a normal store (see below).
3391 Comment cmnt(masm, "[ Init const"); 3391 Comment cmnt(masm, "[ Init const");
3392 __ ldr(r2, cgen_->SlotOperand(slot, r2)); 3392 __ ldr(r2, cgen_->SlotOperand(slot, r2));
3393 __ cmp(r2, Operand(Factory::the_hole_value())); 3393 __ cmp(r2, Operand(Factory::the_hole_value()));
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
4361 __ mov(r2, Operand(0)); 4361 __ mov(r2, Operand(0));
4362 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); 4362 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION);
4363 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), 4363 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)),
4364 RelocInfo::CODE_TARGET); 4364 RelocInfo::CODE_TARGET);
4365 } 4365 }
4366 4366
4367 4367
4368 #undef __ 4368 #undef __
4369 4369
4370 } } // namespace v8::internal 4370 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698