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

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

Issue 200473003: Make invalid LHSs a parse-time (reference) error (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment Created 6 years, 9 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/arm/full-codegen-arm.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 if (result_saved) { 1841 if (result_saved) {
1842 __ Drop(1); // literal index 1842 __ Drop(1); // literal index
1843 context()->PlugTOS(); 1843 context()->PlugTOS();
1844 } else { 1844 } else {
1845 context()->Plug(x0); 1845 context()->Plug(x0);
1846 } 1846 }
1847 } 1847 }
1848 1848
1849 1849
1850 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1850 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1851 ASSERT(expr->target()->IsValidLeftHandSide());
1852
1851 Comment cmnt(masm_, "[ Assignment"); 1853 Comment cmnt(masm_, "[ Assignment");
1852 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
1853 // on the left-hand side.
1854 if (!expr->target()->IsValidLeftHandSide()) {
1855 VisitForEffect(expr->target());
1856 return;
1857 }
1858 1854
1859 // Left-hand side can only be a property, a global or a (parameter or local) 1855 // Left-hand side can only be a property, a global or a (parameter or local)
1860 // slot. 1856 // slot.
1861 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 1857 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1862 LhsKind assign_type = VARIABLE; 1858 LhsKind assign_type = VARIABLE;
1863 Property* property = expr->target()->AsProperty(); 1859 Property* property = expr->target()->AsProperty();
1864 if (property != NULL) { 1860 if (property != NULL) {
1865 assign_type = (property->key()->IsPropertyName()) 1861 assign_type = (property->key()->IsPropertyName())
1866 ? NAMED_PROPERTY 1862 ? NAMED_PROPERTY
1867 : KEYED_PROPERTY; 1863 : KEYED_PROPERTY;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 { 2082 {
2087 Assembler::BlockPoolsScope scope(masm_); 2083 Assembler::BlockPoolsScope scope(masm_);
2088 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId()); 2084 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId());
2089 patch_site.EmitPatchInfo(); 2085 patch_site.EmitPatchInfo();
2090 } 2086 }
2091 context()->Plug(x0); 2087 context()->Plug(x0);
2092 } 2088 }
2093 2089
2094 2090
2095 void FullCodeGenerator::EmitAssignment(Expression* expr) { 2091 void FullCodeGenerator::EmitAssignment(Expression* expr) {
2096 // Invalid left-hand sides are rewritten to have a 'throw 2092 ASSERT(expr->IsValidLeftHandSide());
2097 // ReferenceError' on the left-hand side.
2098 if (!expr->IsValidLeftHandSide()) {
2099 VisitForEffect(expr);
2100 return;
2101 }
2102 2093
2103 // Left-hand side can only be a property, a global or a (parameter or local) 2094 // Left-hand side can only be a property, a global or a (parameter or local)
2104 // slot. 2095 // slot.
2105 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 2096 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
2106 LhsKind assign_type = VARIABLE; 2097 LhsKind assign_type = VARIABLE;
2107 Property* prop = expr->AsProperty(); 2098 Property* prop = expr->AsProperty();
2108 if (prop != NULL) { 2099 if (prop != NULL) {
2109 assign_type = (prop->key()->IsPropertyName()) 2100 assign_type = (prop->key()->IsPropertyName())
2110 ? NAMED_PROPERTY 2101 ? NAMED_PROPERTY
2111 : KEYED_PROPERTY; 2102 : KEYED_PROPERTY;
(...skipping 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after
3971 context()->Plug(x0); 3962 context()->Plug(x0);
3972 break; 3963 break;
3973 } 3964 }
3974 default: 3965 default:
3975 UNREACHABLE(); 3966 UNREACHABLE();
3976 } 3967 }
3977 } 3968 }
3978 3969
3979 3970
3980 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { 3971 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
3972 ASSERT(expr->expression()->IsValidLeftHandSide());
3973
3981 Comment cmnt(masm_, "[ CountOperation"); 3974 Comment cmnt(masm_, "[ CountOperation");
3982 SetSourcePosition(expr->position()); 3975 SetSourcePosition(expr->position());
3983 3976
3984 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
3985 // as the left-hand side.
3986 if (!expr->expression()->IsValidLeftHandSide()) {
3987 VisitForEffect(expr->expression());
3988 return;
3989 }
3990
3991 // Expression can only be a property, a global or a (parameter or local) 3977 // Expression can only be a property, a global or a (parameter or local)
3992 // slot. 3978 // slot.
3993 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 3979 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
3994 LhsKind assign_type = VARIABLE; 3980 LhsKind assign_type = VARIABLE;
3995 Property* prop = expr->expression()->AsProperty(); 3981 Property* prop = expr->expression()->AsProperty();
3996 // In case of a property we use the uninitialized expression context 3982 // In case of a property we use the uninitialized expression context
3997 // of the key to detect a named property. 3983 // of the key to detect a named property.
3998 if (prop != NULL) { 3984 if (prop != NULL) {
3999 assign_type = 3985 assign_type =
4000 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; 3986 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
4967 return previous_; 4953 return previous_;
4968 } 4954 }
4969 4955
4970 4956
4971 #undef __ 4957 #undef __
4972 4958
4973 4959
4974 } } // namespace v8::internal 4960 } } // namespace v8::internal
4975 4961
4976 #endif // V8_TARGET_ARCH_A64 4962 #endif // V8_TARGET_ARCH_A64
OLDNEW
« no previous file with comments | « no previous file | src/arm/full-codegen-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698