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

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

Issue 646009: Fix error in compound assignment to keyed load by making platform-independent... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | « src/full-codegen.cc ('k') | src/x64/full-codegen-x64.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 } 1006 }
1007 1007
1008 if (result_saved) { 1008 if (result_saved) {
1009 ApplyTOS(context_); 1009 ApplyTOS(context_);
1010 } else { 1010 } else {
1011 Apply(context_, eax); 1011 Apply(context_, eax);
1012 } 1012 }
1013 } 1013 }
1014 1014
1015 1015
1016 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1017 Comment cmnt(masm_, "[ Assignment");
1018 ASSERT(expr->op() != Token::INIT_CONST);
1019 // Left-hand side can only be a property, a global or a (parameter or local)
1020 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
1021 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1022 LhsKind assign_type = VARIABLE;
1023 Property* prop = expr->target()->AsProperty();
1024 if (prop != NULL) {
1025 assign_type =
1026 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
1027 }
1028
1029 // Evaluate LHS expression.
1030 switch (assign_type) {
1031 case VARIABLE:
1032 // Nothing to do here.
1033 break;
1034 case NAMED_PROPERTY:
1035 if (expr->is_compound()) {
1036 // We need the receiver both on the stack and in the accumulator.
1037 VisitForValue(prop->obj(), kAccumulator);
1038 __ push(result_register());
1039 } else {
1040 VisitForValue(prop->obj(), kStack);
1041 }
1042 break;
1043 case KEYED_PROPERTY:
1044 if (expr->is_compound()) {
1045 VisitForValue(prop->obj(), kStack);
1046 VisitForValue(prop->key(), kAccumulator);
1047 __ mov(edx, Operand(esp, 0));
1048 __ push(eax);
1049 } else {
1050 VisitForValue(prop->obj(), kStack);
1051 VisitForValue(prop->key(), kStack);
1052 }
1053 break;
1054 }
1055
1056 // If we have a compound assignment: Get value of LHS expression and
1057 // store in on top of the stack.
1058 if (expr->is_compound()) {
1059 Location saved_location = location_;
1060 location_ = kStack;
1061 switch (assign_type) {
1062 case VARIABLE:
1063 EmitVariableLoad(expr->target()->AsVariableProxy()->var(),
1064 Expression::kValue);
1065 break;
1066 case NAMED_PROPERTY:
1067 EmitNamedPropertyLoad(prop);
1068 __ push(result_register());
1069 break;
1070 case KEYED_PROPERTY:
1071 EmitKeyedPropertyLoad(prop);
1072 __ push(result_register());
1073 break;
1074 }
1075 location_ = saved_location;
1076 }
1077
1078 // Evaluate RHS expression.
1079 Expression* rhs = expr->value();
1080 VisitForValue(rhs, kAccumulator);
1081
1082 // If we have a compound assignment: Apply operator.
1083 if (expr->is_compound()) {
1084 Location saved_location = location_;
1085 location_ = kAccumulator;
1086 EmitBinaryOp(expr->binary_op(), Expression::kValue);
1087 location_ = saved_location;
1088 }
1089
1090 // Record source position before possible IC call.
1091 SetSourcePosition(expr->position());
1092
1093 // Store the value.
1094 switch (assign_type) {
1095 case VARIABLE:
1096 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
1097 context_);
1098 break;
1099 case NAMED_PROPERTY:
1100 EmitNamedPropertyAssignment(expr);
1101 break;
1102 case KEYED_PROPERTY:
1103 EmitKeyedPropertyAssignment(expr);
1104 break;
1105 }
1106 }
1107
1108
1016 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 1109 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1017 SetSourcePosition(prop->position()); 1110 SetSourcePosition(prop->position());
1018 Literal* key = prop->key()->AsLiteral(); 1111 Literal* key = prop->key()->AsLiteral();
1019 __ mov(ecx, Immediate(key->handle())); 1112 __ mov(ecx, Immediate(key->handle()));
1020 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 1113 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
1021 __ call(ic, RelocInfo::CODE_TARGET); 1114 __ call(ic, RelocInfo::CODE_TARGET);
1022 __ nop(); 1115 __ nop();
1023 } 1116 }
1024 1117
1025 1118
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 __ add(Operand(edx), Immediate(masm_->CodeObject())); 1995 __ add(Operand(edx), Immediate(masm_->CodeObject()));
1903 __ mov(Operand(esp, 0), edx); 1996 __ mov(Operand(esp, 0), edx);
1904 // And return. 1997 // And return.
1905 __ ret(0); 1998 __ ret(0);
1906 } 1999 }
1907 2000
1908 2001
1909 #undef __ 2002 #undef __
1910 2003
1911 } } // namespace v8::internal 2004 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698