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

Side by Side Diff: src/compiler.cc

Issue 496009: Added pre- and postfix count operations to top-level compiler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 11 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/arm/fast-codegen-arm.cc ('k') | src/fast-codegen.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 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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 for (int i = 0, len = stmts->length(); i < len; i++) { 642 for (int i = 0, len = stmts->length(); i < len; i++) {
643 Visit(stmts->at(i)); 643 Visit(stmts->at(i));
644 CHECK_BAILOUT; 644 CHECK_BAILOUT;
645 } 645 }
646 } 646 }
647 647
648 648
649 void CodeGenSelector::VisitDeclaration(Declaration* decl) { 649 void CodeGenSelector::VisitDeclaration(Declaration* decl) {
650 Property* prop = decl->proxy()->AsProperty(); 650 Property* prop = decl->proxy()->AsProperty();
651 if (prop != NULL) { 651 if (prop != NULL) {
652 // Property rewrites are shared, ensure we are not changing its
653 // expression context state.
654 ASSERT(prop->obj()->context() == Expression::kUninitialized ||
655 prop->obj()->context() == Expression::kValue);
656 ASSERT(prop->key()->context() == Expression::kUninitialized ||
657 prop->key()->context() == Expression::kValue);
658 ProcessExpression(prop->obj(), Expression::kValue); 652 ProcessExpression(prop->obj(), Expression::kValue);
659 ProcessExpression(prop->key(), Expression::kValue); 653 ProcessExpression(prop->key(), Expression::kValue);
660 } 654 }
661 655
662 if (decl->fun() != NULL) { 656 if (decl->fun() != NULL) {
663 ProcessExpression(decl->fun(), Expression::kValue); 657 ProcessExpression(decl->fun(), Expression::kValue);
664 } 658 }
665 } 659 }
666 660
667 661
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 if (var != NULL) { 890 if (var != NULL) {
897 // All global variables are supported. 891 // All global variables are supported.
898 if (!var->is_global()) { 892 if (!var->is_global()) {
899 ASSERT(var->slot() != NULL); 893 ASSERT(var->slot() != NULL);
900 Slot::Type type = var->slot()->type(); 894 Slot::Type type = var->slot()->type();
901 if (type == Slot::LOOKUP) { 895 if (type == Slot::LOOKUP) {
902 BAILOUT("Lookup slot"); 896 BAILOUT("Lookup slot");
903 } 897 }
904 } 898 }
905 } else if (prop != NULL) { 899 } else if (prop != NULL) {
906 ASSERT(prop->obj()->context() == Expression::kUninitialized ||
907 prop->obj()->context() == Expression::kValue);
908 ProcessExpression(prop->obj(), Expression::kValue); 900 ProcessExpression(prop->obj(), Expression::kValue);
909 CHECK_BAILOUT; 901 CHECK_BAILOUT;
910 // We will only visit the key during code generation for keyed property 902 // We will only visit the key during code generation for keyed property
911 // stores. Leave its expression context uninitialized for named 903 // stores. Leave its expression context uninitialized for named
912 // property stores. 904 // property stores.
913 Literal* lit = prop->key()->AsLiteral(); 905 Literal* lit = prop->key()->AsLiteral();
914 uint32_t ignored; 906 uint32_t ignored;
915 if (lit == NULL || 907 if (lit == NULL ||
916 !lit->handle()->IsSymbol() || 908 !lit->handle()->IsSymbol() ||
917 String::cast(*(lit->handle()))->AsArrayIndex(&ignored)) { 909 String::cast(*(lit->handle()))->AsArrayIndex(&ignored)) {
918 ASSERT(prop->key()->context() == Expression::kUninitialized ||
919 prop->key()->context() == Expression::kValue);
920 ProcessExpression(prop->key(), Expression::kValue); 910 ProcessExpression(prop->key(), Expression::kValue);
921 CHECK_BAILOUT; 911 CHECK_BAILOUT;
922 } 912 }
923 } else { 913 } else {
924 // This is a throw reference error. 914 // This is a throw reference error.
925 BAILOUT("non-variable/non-property assignment"); 915 BAILOUT("non-variable/non-property assignment");
926 } 916 }
927 917
928 ProcessExpression(expr->value(), Expression::kValue); 918 ProcessExpression(expr->value(), Expression::kValue);
929 } 919 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 case Token::TYPEOF: 1005 case Token::TYPEOF:
1016 ProcessExpression(expr->expression(), Expression::kValue); 1006 ProcessExpression(expr->expression(), Expression::kValue);
1017 break; 1007 break;
1018 default: 1008 default:
1019 BAILOUT("UnaryOperation"); 1009 BAILOUT("UnaryOperation");
1020 } 1010 }
1021 } 1011 }
1022 1012
1023 1013
1024 void CodeGenSelector::VisitCountOperation(CountOperation* expr) { 1014 void CodeGenSelector::VisitCountOperation(CountOperation* expr) {
1025 // We support postfix count operations on global variables.
1026 if (expr->is_prefix()) BAILOUT("Prefix CountOperation");
1027 Variable* var = expr->expression()->AsVariableProxy()->AsVariable(); 1015 Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
1028 if (var == NULL || !var->is_global()) BAILOUT("non-global postincrement"); 1016 Property* prop = expr->expression()->AsProperty();
1029 ProcessExpression(expr->expression(), Expression::kValue); 1017 ASSERT(var == NULL || prop == NULL);
1018 if (var != NULL) {
1019 // All global variables are supported.
1020 if (!var->is_global()) {
1021 ASSERT(var->slot() != NULL);
1022 Slot::Type type = var->slot()->type();
1023 if (type == Slot::LOOKUP) {
1024 BAILOUT("CountOperation with lookup slot");
1025 }
1026 }
1027 } else if (prop != NULL) {
1028 ProcessExpression(prop->obj(), Expression::kValue);
1029 CHECK_BAILOUT;
1030 // We will only visit the key during code generation for keyed property
1031 // stores. Leave its expression context uninitialized for named
1032 // property stores.
1033 Literal* lit = prop->key()->AsLiteral();
1034 uint32_t ignored;
1035 if (lit == NULL ||
1036 !lit->handle()->IsSymbol() ||
1037 String::cast(*(lit->handle()))->AsArrayIndex(&ignored)) {
1038 ProcessExpression(prop->key(), Expression::kValue);
1039 CHECK_BAILOUT;
1040 }
1041 } else {
1042 // This is a throw reference error.
1043 BAILOUT("CountOperation non-variable/non-property expression");
1044 }
1030 } 1045 }
1031 1046
1032 1047
1033 void CodeGenSelector::VisitBinaryOperation(BinaryOperation* expr) { 1048 void CodeGenSelector::VisitBinaryOperation(BinaryOperation* expr) {
1034 switch (expr->op()) { 1049 switch (expr->op()) {
1035 case Token::COMMA: 1050 case Token::COMMA:
1036 ProcessExpression(expr->left(), Expression::kEffect); 1051 ProcessExpression(expr->left(), Expression::kEffect);
1037 CHECK_BAILOUT; 1052 CHECK_BAILOUT;
1038 ProcessExpression(expr->right(), context_); 1053 ProcessExpression(expr->right(), context_);
1039 break; 1054 break;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1128
1114 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) { 1129 void CodeGenSelector::VisitThisFunction(ThisFunction* expr) {
1115 // ThisFunction is supported. 1130 // ThisFunction is supported.
1116 } 1131 }
1117 1132
1118 #undef BAILOUT 1133 #undef BAILOUT
1119 #undef CHECK_BAILOUT 1134 #undef CHECK_BAILOUT
1120 1135
1121 1136
1122 } } // namespace v8::internal 1137 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/fast-codegen-arm.cc ('k') | src/fast-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698