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

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

Issue 456024: Refactor code for generating assignments in the fast compiler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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/compiler.cc ('k') | src/ia32/fast-codegen-ia32.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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 499
500 500
501 void FastCodeGenerator::VisitAssignment(Assignment* expr) { 501 void FastCodeGenerator::VisitAssignment(Assignment* expr) {
502 Comment cmnt(masm_, "[ Assignment"); 502 Comment cmnt(masm_, "[ Assignment");
503 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); 503 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR);
504 504
505 // Record source code position of the (possible) IC call. 505 // Record source code position of the (possible) IC call.
506 SetSourcePosition(expr->position()); 506 SetSourcePosition(expr->position());
507 507
508 // Left-hand side can only be a property, a global or a (parameter or local)
509 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
510 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
511 LhsKind assign_type = VARIABLE;
512 Property* prop = expr->target()->AsProperty();
513 // In case of a property we use the uninitialized expression context
514 // of the key to detect a named property.
515 if (prop != NULL) {
516 assign_type = (prop->key()->context() == Expression::kUninitialized)
517 ? NAMED_PROPERTY
518 : KEYED_PROPERTY;
519 }
520
508 Expression* rhs = expr->value(); 521 Expression* rhs = expr->value();
509 // Left-hand side can only be a property, a global or a (parameter or 522 ASSERT_EQ(Expression::kValue, rhs->context());
510 // local) slot. 523
511 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); 524 switch (assign_type) {
512 Property* prop = expr->target()->AsProperty(); 525 case VARIABLE:
513 if (var != NULL) {
514 Visit(rhs);
515 ASSERT_EQ(Expression::kValue, rhs->context());
516 EmitVariableAssignment(expr);
517 } else if (prop != NULL) {
518 // Assignment to a property.
519 Visit(prop->obj());
520 ASSERT_EQ(Expression::kValue, prop->obj()->context());
521 // Use the expression context of the key subexpression to detect whether
522 // we have decided to us a named or keyed IC.
523 if (prop->key()->context() == Expression::kUninitialized) {
524 ASSERT(prop->key()->AsLiteral() != NULL);
525 Visit(rhs); 526 Visit(rhs);
526 ASSERT_EQ(Expression::kValue, rhs->context()); 527 EmitVariableAssignment(expr);
528 break;
529 case NAMED_PROPERTY:
530 Visit(prop->obj());
531 ASSERT_EQ(Expression::kValue, prop->obj()->context());
532 Visit(rhs);
527 EmitNamedPropertyAssignment(expr); 533 EmitNamedPropertyAssignment(expr);
528 } else { 534 break;
535 case KEYED_PROPERTY:
536 Visit(prop->obj());
537 ASSERT_EQ(Expression::kValue, prop->obj()->context());
529 Visit(prop->key()); 538 Visit(prop->key());
530 ASSERT_EQ(Expression::kValue, prop->key()->context()); 539 ASSERT_EQ(Expression::kValue, prop->key()->context());
531 Visit(rhs); 540 Visit(rhs);
532 ASSERT_EQ(Expression::kValue, rhs->context());
533 EmitKeyedPropertyAssignment(expr); 541 EmitKeyedPropertyAssignment(expr);
534 } 542 break;
535 } else {
536 UNREACHABLE();
537 } 543 }
538 } 544 }
539 545
540 546
541 void FastCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) { 547 void FastCodeGenerator::VisitCatchExtensionObject(CatchExtensionObject* expr) {
542 UNREACHABLE(); 548 UNREACHABLE();
543 } 549 }
544 550
545 551
546 void FastCodeGenerator::VisitThrow(Throw* expr) { 552 void FastCodeGenerator::VisitThrow(Throw* expr) {
547 UNREACHABLE(); 553 UNREACHABLE();
548 } 554 }
549 555
550 556
551 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { 557 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
552 UNREACHABLE(); 558 UNREACHABLE();
553 } 559 }
554 560
555 561
556 #undef __ 562 #undef __
557 563
558 564
559 } } // namespace v8::internal 565 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698