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

Side by Side Diff: src/x64/fast-codegen-x64.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/ia32/fast-codegen-ia32.cc ('k') | test/mjsunit/compiler/globals.js » ('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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 int arg_count = args->length(); 907 int arg_count = args->length();
908 for (int i = 0; i < arg_count; i++) { 908 for (int i = 0; i < arg_count; i++) {
909 Visit(args->at(i)); 909 Visit(args->at(i));
910 ASSERT_EQ(Expression::kValue, args->at(i)->context()); 910 ASSERT_EQ(Expression::kValue, args->at(i)->context());
911 } 911 }
912 912
913 __ CallRuntime(function, arg_count); 913 __ CallRuntime(function, arg_count);
914 Move(expr->context(), rax); 914 Move(expr->context(), rax);
915 } 915 }
916 916
917 void FastCodeGenerator::VisitCountOperation(CountOperation* expr) {
918 VariableProxy* v = expr->expression()->AsVariableProxy();
919 ASSERT(v->AsVariable() != NULL);
920 ASSERT(v->AsVariable()->is_global());
921
922 Visit(v);
923
924 __ InvokeBuiltin(Builtins::TO_NUMBER, CALL_FUNCTION);
925
926 switch (expr->context()) {
927 case Expression::kUninitialized:
928 UNREACHABLE();
929 case Expression::kValue: // Fall through
930 case Expression::kTest: // Fall through
931 case Expression::kTestValue: // Fall through
932 case Expression::kValueTest:
933 // Duplicate the result on the stack.
934 __ push(rax);
935 break;
936 case Expression::kEffect:
937 // Do not save result.
938 break;
939 }
940 // Call runtime for +1/-1.
941 __ push(rax);
942 __ Push(Smi::FromInt(1));
943 if (expr->op() == Token::INC) {
944 __ CallRuntime(Runtime::kNumberAdd, 2);
945 } else {
946 __ CallRuntime(Runtime::kNumberSub, 2);
947 }
948 // Call Store IC.
949 __ Move(rcx, v->AsVariable()->name());
950 __ push(CodeGenerator::GlobalObject());
951 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize));
952 __ call(ic, RelocInfo::CODE_TARGET);
953 // Restore up stack after store IC
954 __ addq(rsp, Immediate(kPointerSize));
955
956 switch (expr->context()) {
957 case Expression::kUninitialized:
958 UNREACHABLE();
959 case Expression::kEffect: // Fall through
960 case Expression::kValue:
961 // Do nothing. Result in either on the stack for value context
962 // or discarded for effect context.
963 break;
964 case Expression::kTest:
965 __ pop(rax);
966 TestAndBranch(rax, true_label_, false_label_);
967 break;
968 case Expression::kValueTest: {
969 Label discard;
970 __ movq(rax, Operand(rsp, 0));
971 TestAndBranch(rax, true_label_, &discard);
972 __ bind(&discard);
973 __ addq(rsp, Immediate(kPointerSize));
974 __ jmp(false_label_);
975 break;
976 }
977 case Expression::kTestValue: {
978 Label discard;
979 __ movq(rax, Operand(rsp, 0));
980 TestAndBranch(rax, &discard, false_label_);
981 __ bind(&discard);
982 __ addq(rsp, Immediate(kPointerSize));
983 __ jmp(true_label_);
984 break;
985 }
986 }
987 }
988
917 989
918 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { 990 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
919 Comment cmnt(masm_, "[ UnaryOperation"); 991 Comment cmnt(masm_, "[ UnaryOperation");
920 992
921 switch (expr->op()) { 993 switch (expr->op()) {
922 case Token::VOID: 994 case Token::VOID:
923 Visit(expr->expression()); 995 Visit(expr->expression());
924 ASSERT_EQ(Expression::kEffect, expr->expression()->context()); 996 ASSERT_EQ(Expression::kEffect, expr->expression()->context());
925 switch (expr->context()) { 997 switch (expr->context()) {
926 case Expression::kUninitialized: 998 case Expression::kUninitialized:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 1058
987 break; 1059 break;
988 } 1060 }
989 default: 1061 default:
990 UNREACHABLE(); 1062 UNREACHABLE();
991 } 1063 }
992 } 1064 }
993 1065
994 1066
995 } } // namespace v8::internal 1067 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/fast-codegen-ia32.cc ('k') | test/mjsunit/compiler/globals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698