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

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

Issue 342058: Support for post-fix count operations (x++, x--) where x is a global... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 1 month 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/fast-codegen.cc ('k') | src/x64/fast-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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 break; 925 break;
926 } 926 }
927 break; 927 break;
928 928
929 default: 929 default:
930 UNREACHABLE(); 930 UNREACHABLE();
931 } 931 }
932 } 932 }
933 933
934 934
935 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) {
936 VariableProxy* v = expr->expression()->AsVariableProxy();
937 ASSERT(v->AsVariable() != NULL);
938 ASSERT(v->AsVariable()->is_global());
939
940 Visit(v);
941
942 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
943
944 switch (expr->context()) {
945 case Expression::kUninitialized:
946 UNREACHABLE();
947 case Expression::kValue: // Fall through
948 case Expression::kTest: // Fall through
949 case Expression::kTestValue: // Fall through
950 case Expression::kValueTest:
951 // Duplicate the result on the stack.
952 __ push(eax);
953 break;
954 case Expression::kEffect:
955 // Do not save result.
956 break;
957 }
958 // Call runtime for +1/-1.
959 __ push(eax);
960 __ push(Immediate(Smi::FromInt(1)));
961 if (expr->op() == Token::INC) {
962 __ CallRuntime(Runtime::kNumberAdd, 2);
963 } else {
964 __ CallRuntime(Runtime::kNumberSub, 2);
965 }
966 // Call Store IC.
967 __ mov(ecx, v->AsVariable()->name());
968 __ push(CodeGenerator::GlobalObject());
969 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
970 __ call(ic, RelocInfo::CODE_TARGET);
971 // Restore up stack after store IC.
972 __ add(Operand(esp), Immediate(kPointerSize));
973
974 switch (expr->context()) {
975 case Expression::kUninitialized:
976 UNREACHABLE();
977 case Expression::kEffect: // Fall through
978 case Expression::kValue:
979 // Do nothing. Result in either on the stack for value context
980 // or discarded for effect context.
981 break;
982 case Expression::kTest:
983 __ pop(eax);
984 TestAndBranch(eax, true_label_, false_label_);
985 break;
986 case Expression::kValueTest: {
987 Label discard;
988 __ mov(eax, Operand(esp, 0));
989 TestAndBranch(eax, true_label_, &discard);
990 __ bind(&discard);
991 __ add(Operand(esp), Immediate(kPointerSize));
992 __ jmp(false_label_);
993 break;
994 }
995 case Expression::kTestValue: {
996 Label discard;
997 __ mov(eax, Operand(esp, 0));
998 TestAndBranch(eax, &discard, false_label_);
999 __ bind(&discard);
1000 __ add(Operand(esp), Immediate(kPointerSize));
1001 __ jmp(true_label_);
1002 break;
1003 }
1004 }
1005 }
1006
1007
935 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { 1008 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) {
936 switch (expr->op()) { 1009 switch (expr->op()) {
937 case Token::COMMA: 1010 case Token::COMMA:
938 ASSERT_EQ(Expression::kEffect, expr->left()->context()); 1011 ASSERT_EQ(Expression::kEffect, expr->left()->context());
939 ASSERT_EQ(expr->context(), expr->right()->context()); 1012 ASSERT_EQ(expr->context(), expr->right()->context());
940 Visit(expr->left()); 1013 Visit(expr->left());
941 Visit(expr->right()); 1014 Visit(expr->right());
942 break; 1015 break;
943 1016
944 case Token::OR: 1017 case Token::OR:
(...skipping 28 matching lines...) Expand all
973 default: 1046 default:
974 UNREACHABLE(); 1047 UNREACHABLE();
975 } 1048 }
976 } 1049 }
977 1050
978 1051
979 #undef __ 1052 #undef __
980 1053
981 1054
982 } } // namespace v8::internal 1055 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/fast-codegen.cc ('k') | src/x64/fast-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698