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

Side by Side Diff: src/arm/full-codegen-arm.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 | « no previous file | src/full-codegen.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 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 } 900 }
901 901
902 if (result_saved) { 902 if (result_saved) {
903 ApplyTOS(context_); 903 ApplyTOS(context_);
904 } else { 904 } else {
905 Apply(context_, r0); 905 Apply(context_, r0);
906 } 906 }
907 } 907 }
908 908
909 909
910 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
911 Comment cmnt(masm_, "[ Assignment");
912 ASSERT(expr->op() != Token::INIT_CONST);
913 // Left-hand side can only be a property, a global or a (parameter or local)
914 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
915 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
916 LhsKind assign_type = VARIABLE;
917 Property* prop = expr->target()->AsProperty();
918 if (prop != NULL) {
919 assign_type =
920 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
921 }
922
923 // Evaluate LHS expression.
924 switch (assign_type) {
925 case VARIABLE:
926 // Nothing to do here.
927 break;
928 case NAMED_PROPERTY:
929 if (expr->is_compound()) {
930 // We need the receiver both on the stack and in the accumulator.
931 VisitForValue(prop->obj(), kAccumulator);
932 __ push(result_register());
933 } else {
934 VisitForValue(prop->obj(), kStack);
935 }
936 break;
937 case KEYED_PROPERTY:
938 VisitForValue(prop->obj(), kStack);
939 VisitForValue(prop->key(), kStack);
940 break;
941 }
942
943 // If we have a compound assignment: Get value of LHS expression and
944 // store in on top of the stack.
945 if (expr->is_compound()) {
946 Location saved_location = location_;
947 location_ = kStack;
948 switch (assign_type) {
949 case VARIABLE:
950 EmitVariableLoad(expr->target()->AsVariableProxy()->var(),
951 Expression::kValue);
952 break;
953 case NAMED_PROPERTY:
954 EmitNamedPropertyLoad(prop);
955 __ push(result_register());
956 break;
957 case KEYED_PROPERTY:
958 EmitKeyedPropertyLoad(prop);
959 __ push(result_register());
960 break;
961 }
962 location_ = saved_location;
963 }
964
965 // Evaluate RHS expression.
966 Expression* rhs = expr->value();
967 VisitForValue(rhs, kAccumulator);
968
969 // If we have a compound assignment: Apply operator.
970 if (expr->is_compound()) {
971 Location saved_location = location_;
972 location_ = kAccumulator;
973 EmitBinaryOp(expr->binary_op(), Expression::kValue);
974 location_ = saved_location;
975 }
976
977 // Record source position before possible IC call.
978 SetSourcePosition(expr->position());
979
980 // Store the value.
981 switch (assign_type) {
982 case VARIABLE:
983 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
984 context_);
985 break;
986 case NAMED_PROPERTY:
987 EmitNamedPropertyAssignment(expr);
988 break;
989 case KEYED_PROPERTY:
990 EmitKeyedPropertyAssignment(expr);
991 break;
992 }
993 }
994
995
910 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { 996 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
911 SetSourcePosition(prop->position()); 997 SetSourcePosition(prop->position());
912 Literal* key = prop->key()->AsLiteral(); 998 Literal* key = prop->key()->AsLiteral();
913 __ mov(r2, Operand(key->handle())); 999 __ mov(r2, Operand(key->handle()));
914 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); 1000 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize));
915 __ Call(ic, RelocInfo::CODE_TARGET); 1001 __ Call(ic, RelocInfo::CODE_TARGET);
916 } 1002 }
917 1003
918 1004
919 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { 1005 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 __ pop(result_register()); 1856 __ pop(result_register());
1771 ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); 1857 ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize);
1772 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. 1858 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value.
1773 __ add(pc, r1, Operand(masm_->CodeObject())); 1859 __ add(pc, r1, Operand(masm_->CodeObject()));
1774 } 1860 }
1775 1861
1776 1862
1777 #undef __ 1863 #undef __
1778 1864
1779 } } // namespace v8::internal 1865 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698