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

Side by Side Diff: src/cfg.cc

Issue 165129: Added support for property loads to the CFG builder and fast-mode (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void MoveInstr::FastAllocate(TempLocation* temp) { 203 void MoveInstr::FastAllocate(TempLocation* temp) {
204 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); 204 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
205 if (temp == value()) { 205 if (temp == value()) {
206 temp->set_where(TempLocation::ACCUMULATOR); 206 temp->set_where(TempLocation::ACCUMULATOR);
207 } else { 207 } else {
208 temp->set_where(TempLocation::STACK); 208 temp->set_where(TempLocation::STACK);
209 } 209 }
210 } 210 }
211 211
212 212
213 void PropRefInstr::FastAllocate(TempLocation* temp) {
214 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
215 if (temp == object() || temp == key()) {
216 temp->set_where(TempLocation::ACCUMULATOR);
217 } else {
218 temp->set_where(TempLocation::STACK);
219 }
220 }
221
222
213 void BinaryOpInstr::FastAllocate(TempLocation* temp) { 223 void BinaryOpInstr::FastAllocate(TempLocation* temp) {
214 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); 224 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
215 if (temp == value0() || temp == value1()) { 225 if (temp == left() || temp == right()) {
216 temp->set_where(TempLocation::ACCUMULATOR); 226 temp->set_where(TempLocation::ACCUMULATOR);
217 } else { 227 } else {
218 temp->set_where(TempLocation::STACK); 228 temp->set_where(TempLocation::STACK);
219 } 229 }
220 } 230 }
221 231
222 232
223 void ReturnInstr::FastAllocate(TempLocation* temp) { 233 void ReturnInstr::FastAllocate(TempLocation* temp) {
224 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED); 234 ASSERT(temp->where() == TempLocation::NOT_ALLOCATED);
225 if (temp == value_) { 235 if (temp == value()) {
226 temp->set_where(TempLocation::ACCUMULATOR); 236 temp->set_where(TempLocation::ACCUMULATOR);
227 } else { 237 } else {
228 temp->set_where(TempLocation::STACK); 238 temp->set_where(TempLocation::STACK);
229 } 239 }
230 } 240 }
231 241
232 242
233 void PositionInstr::Compile(MacroAssembler* masm) { 243 void PositionInstr::Compile(MacroAssembler* masm) {
234 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) { 244 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) {
235 masm->RecordStatementPosition(pos_); 245 masm->RecordStatementPosition(pos_);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 value_ = loc; 372 value_ = loc;
363 } 373 }
364 374
365 375
366 void ExpressionCfgBuilder::VisitThrow(Throw* expr) { 376 void ExpressionCfgBuilder::VisitThrow(Throw* expr) {
367 BAILOUT("Throw"); 377 BAILOUT("Throw");
368 } 378 }
369 379
370 380
371 void ExpressionCfgBuilder::VisitProperty(Property* expr) { 381 void ExpressionCfgBuilder::VisitProperty(Property* expr) {
372 BAILOUT("Property"); 382 ExpressionCfgBuilder object, key;
383 object.Build(expr->obj(), NULL);
384 if (object.graph() == NULL) {
385 BAILOUT("unsupported object subexpression in propref");
386 }
387 key.Build(expr->key(), NULL);
388 if (key.graph() == NULL) {
389 BAILOUT("unsupported key subexpression in propref");
390 }
391
392 if (destination_ == NULL) destination_ = new TempLocation();
393
394 graph_ = object.graph();
395 // Insert a move to a fresh temporary if the object value is in a slot
396 // that's assigned in the key.
397 Location* temp = NULL;
398 if (object.value()->is_slot() &&
399 key.assigned_vars()->Contains(SlotLocation::cast(object.value()))) {
400 temp = new TempLocation();
401 graph()->Append(new MoveInstr(temp, object.value()));
402 }
403 graph()->Concatenate(key.graph());
404 graph()->Append(new PropRefInstr(destination_,
405 temp == NULL ? object.value() : temp,
406 key.value()));
407
408 assigned_vars_ = *object.assigned_vars();
409 assigned_vars()->Union(key.assigned_vars());
410
411 value_ = destination_;
373 } 412 }
374 413
375 414
376 void ExpressionCfgBuilder::VisitCall(Call* expr) { 415 void ExpressionCfgBuilder::VisitCall(Call* expr) {
377 BAILOUT("Call"); 416 BAILOUT("Call");
378 } 417 }
379 418
380 419
381 void ExpressionCfgBuilder::VisitCallEval(CallEval* expr) { 420 void ExpressionCfgBuilder::VisitCallEval(CallEval* expr) {
382 BAILOUT("CallEval"); 421 BAILOUT("CallEval");
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 672
634 void MoveInstr::Print() { 673 void MoveInstr::Print() {
635 PrintF("Move("); 674 PrintF("Move(");
636 location()->Print(); 675 location()->Print();
637 PrintF(", "); 676 PrintF(", ");
638 value_->Print(); 677 value_->Print();
639 PrintF(")\n"); 678 PrintF(")\n");
640 } 679 }
641 680
642 681
682 void PropRefInstr::Print() {
683 PrintF("PropRef(");
684 location()->Print();
685 PrintF(", ");
686 object()->Print();
687 PrintF(", ");
688 key()->Print();
689 PrintF(")\n");
690 }
691
692
643 void BinaryOpInstr::Print() { 693 void BinaryOpInstr::Print() {
644 PrintF("BinaryOp("); 694 PrintF("BinaryOp(");
645 location()->Print(); 695 location()->Print();
646 PrintF(", %s, ", Token::Name(op())); 696 PrintF(", %s, ", Token::Name(op()));
647 value0()->Print(); 697 left()->Print();
648 PrintF(", "); 698 PrintF(", ");
649 value1()->Print(); 699 right()->Print();
650 PrintF(")\n"); 700 PrintF(")\n");
651 } 701 }
652 702
653 703
654 void ReturnInstr::Print() { 704 void ReturnInstr::Print() {
655 PrintF("Return("); 705 PrintF("Return(");
656 value_->Print(); 706 value_->Print();
657 PrintF(")\n"); 707 PrintF(")\n");
658 } 708 }
659 709
(...skipping 22 matching lines...) Expand all
682 void ExitNode::Print() { 732 void ExitNode::Print() {
683 if (!is_marked_) { 733 if (!is_marked_) {
684 is_marked_ = true; 734 is_marked_ = true;
685 PrintF("L%d:\nExit\n\n", number()); 735 PrintF("L%d:\nExit\n\n", number());
686 } 736 }
687 } 737 }
688 738
689 #endif // DEBUG 739 #endif // DEBUG
690 740
691 } } // namespace v8::internal 741 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698