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

Side by Side Diff: src/ia32/full-codegen-ia32.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 | « src/heap.h ('k') | src/messages.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 if (result_saved) { 1804 if (result_saved) {
1805 __ add(esp, Immediate(kPointerSize)); // literal index 1805 __ add(esp, Immediate(kPointerSize)); // literal index
1806 context()->PlugTOS(); 1806 context()->PlugTOS();
1807 } else { 1807 } else {
1808 context()->Plug(eax); 1808 context()->Plug(eax);
1809 } 1809 }
1810 } 1810 }
1811 1811
1812 1812
1813 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1813 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1814 ASSERT(expr->target()->IsValidLeftHandSide());
1815
1814 Comment cmnt(masm_, "[ Assignment"); 1816 Comment cmnt(masm_, "[ Assignment");
1815 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
1816 // on the left-hand side.
1817 if (!expr->target()->IsValidLeftHandSide()) {
1818 VisitForEffect(expr->target());
1819 return;
1820 }
1821 1817
1822 // Left-hand side can only be a property, a global or a (parameter or local) 1818 // Left-hand side can only be a property, a global or a (parameter or local)
1823 // slot. 1819 // slot.
1824 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 1820 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1825 LhsKind assign_type = VARIABLE; 1821 LhsKind assign_type = VARIABLE;
1826 Property* property = expr->target()->AsProperty(); 1822 Property* property = expr->target()->AsProperty();
1827 if (property != NULL) { 1823 if (property != NULL) {
1828 assign_type = (property->key()->IsPropertyName()) 1824 assign_type = (property->key()->IsPropertyName())
1829 ? NAMED_PROPERTY 1825 ? NAMED_PROPERTY
1830 : KEYED_PROPERTY; 1826 : KEYED_PROPERTY;
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 __ pop(edx); 2335 __ pop(edx);
2340 BinaryOpICStub stub(op, mode); 2336 BinaryOpICStub stub(op, mode);
2341 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. 2337 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code.
2342 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId()); 2338 CallIC(stub.GetCode(isolate()), expr->BinaryOperationFeedbackId());
2343 patch_site.EmitPatchInfo(); 2339 patch_site.EmitPatchInfo();
2344 context()->Plug(eax); 2340 context()->Plug(eax);
2345 } 2341 }
2346 2342
2347 2343
2348 void FullCodeGenerator::EmitAssignment(Expression* expr) { 2344 void FullCodeGenerator::EmitAssignment(Expression* expr) {
2349 // Invalid left-hand sides are rewritten by the parser to have a 'throw 2345 ASSERT(expr->IsValidLeftHandSide());
2350 // ReferenceError' on the left-hand side.
2351 if (!expr->IsValidLeftHandSide()) {
2352 VisitForEffect(expr);
2353 return;
2354 }
2355 2346
2356 // Left-hand side can only be a property, a global or a (parameter or local) 2347 // Left-hand side can only be a property, a global or a (parameter or local)
2357 // slot. 2348 // slot.
2358 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 2349 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
2359 LhsKind assign_type = VARIABLE; 2350 LhsKind assign_type = VARIABLE;
2360 Property* prop = expr->AsProperty(); 2351 Property* prop = expr->AsProperty();
2361 if (prop != NULL) { 2352 if (prop != NULL) {
2362 assign_type = (prop->key()->IsPropertyName()) 2353 assign_type = (prop->key()->IsPropertyName())
2363 ? NAMED_PROPERTY 2354 ? NAMED_PROPERTY
2364 : KEYED_PROPERTY; 2355 : KEYED_PROPERTY;
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after
4264 break; 4255 break;
4265 } 4256 }
4266 4257
4267 default: 4258 default:
4268 UNREACHABLE(); 4259 UNREACHABLE();
4269 } 4260 }
4270 } 4261 }
4271 4262
4272 4263
4273 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { 4264 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
4265 ASSERT(expr->expression()->IsValidLeftHandSide());
4266
4274 Comment cmnt(masm_, "[ CountOperation"); 4267 Comment cmnt(masm_, "[ CountOperation");
4275 SetSourcePosition(expr->position()); 4268 SetSourcePosition(expr->position());
4276 4269
4277 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
4278 // as the left-hand side.
4279 if (!expr->expression()->IsValidLeftHandSide()) {
4280 VisitForEffect(expr->expression());
4281 return;
4282 }
4283
4284 // Expression can only be a property, a global or a (parameter or local) 4270 // Expression can only be a property, a global or a (parameter or local)
4285 // slot. 4271 // slot.
4286 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 4272 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
4287 LhsKind assign_type = VARIABLE; 4273 LhsKind assign_type = VARIABLE;
4288 Property* prop = expr->expression()->AsProperty(); 4274 Property* prop = expr->expression()->AsProperty();
4289 // In case of a property we use the uninitialized expression context 4275 // In case of a property we use the uninitialized expression context
4290 // of the key to detect a named property. 4276 // of the key to detect a named property.
4291 if (prop != NULL) { 4277 if (prop != NULL) {
4292 assign_type = 4278 assign_type =
4293 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; 4279 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
4897 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), 4883 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(),
4898 Assembler::target_address_at(call_target_address, 4884 Assembler::target_address_at(call_target_address,
4899 unoptimized_code)); 4885 unoptimized_code));
4900 return OSR_AFTER_STACK_CHECK; 4886 return OSR_AFTER_STACK_CHECK;
4901 } 4887 }
4902 4888
4903 4889
4904 } } // namespace v8::internal 4890 } } // namespace v8::internal
4905 4891
4906 #endif // V8_TARGET_ARCH_IA32 4892 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698