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

Side by Side Diff: src/hydrogen.cc

Issue 23903017: Wrap PushLoad and BuildStoreInEffect in CHECK_ALIVE. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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/hydrogen.h ('k') | no next file » | 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 4893 matching lines...) Expand 10 before | Expand all | Expand 10 after
4904 if (prop->key()->IsPropertyName()) { 4904 if (prop->key()->IsPropertyName()) {
4905 // Named store. 4905 // Named store.
4906 CHECK_ALIVE(VisitForValue(expr->value())); 4906 CHECK_ALIVE(VisitForValue(expr->value()));
4907 HValue* value = environment()->ExpressionStackAt(0); 4907 HValue* value = environment()->ExpressionStackAt(0);
4908 HValue* object = environment()->ExpressionStackAt(1); 4908 HValue* object = environment()->ExpressionStackAt(1);
4909 4909
4910 if (expr->IsUninitialized()) { 4910 if (expr->IsUninitialized()) {
4911 Add<HDeoptimize>("Insufficient type feedback for property assignment", 4911 Add<HDeoptimize>("Insufficient type feedback for property assignment",
4912 Deoptimizer::SOFT); 4912 Deoptimizer::SOFT);
4913 } 4913 }
4914 return BuildStoreNamed(expr, expr->id(), expr->position(), 4914 return BuildStoreNamed(
4915 expr->AssignmentId(), prop, object, value); 4915 expr, expr->id(), expr->AssignmentId(), prop, object, value);
4916 } else { 4916 } else {
4917 // Keyed store. 4917 // Keyed store.
4918 CHECK_ALIVE(VisitForValue(prop->key())); 4918 CHECK_ALIVE(VisitForValue(prop->key()));
4919 CHECK_ALIVE(VisitForValue(expr->value())); 4919 CHECK_ALIVE(VisitForValue(expr->value()));
4920 HValue* value = environment()->ExpressionStackAt(0); 4920 HValue* value = environment()->ExpressionStackAt(0);
4921 HValue* key = environment()->ExpressionStackAt(1); 4921 HValue* key = environment()->ExpressionStackAt(1);
4922 HValue* object = environment()->ExpressionStackAt(2); 4922 HValue* object = environment()->ExpressionStackAt(2);
4923 bool has_side_effects = false; 4923 bool has_side_effects = false;
4924 HandleKeyedElementAccess(object, key, value, expr, expr->AssignmentId(), 4924 HandleKeyedElementAccess(object, key, value, expr, expr->AssignmentId(),
4925 expr->position(), 4925 expr->position(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4973 value, function_strict_mode_flag()); 4973 value, function_strict_mode_flag());
4974 instr->set_position(position); 4974 instr->set_position(position);
4975 ASSERT(instr->HasObservableSideEffects()); 4975 ASSERT(instr->HasObservableSideEffects());
4976 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 4976 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
4977 } 4977 }
4978 } 4978 }
4979 4979
4980 4980
4981 void HOptimizedGraphBuilder::BuildStoreNamed(Expression* expr, 4981 void HOptimizedGraphBuilder::BuildStoreNamed(Expression* expr,
4982 BailoutId id, 4982 BailoutId id,
4983 int position,
4984 BailoutId assignment_id, 4983 BailoutId assignment_id,
4985 Property* prop, 4984 Property* prop,
4986 HValue* object, 4985 HValue* object,
4987 HValue* value) { 4986 HValue* value) {
4988 Literal* key = prop->key()->AsLiteral(); 4987 Literal* key = prop->key()->AsLiteral();
4989 Handle<String> name = Handle<String>::cast(key->value()); 4988 Handle<String> name = Handle<String>::cast(key->value());
4990 ASSERT(!name.is_null()); 4989 ASSERT(!name.is_null());
4991 4990
4992 HInstruction* instr = NULL; 4991 HInstruction* instr = NULL;
4993 SmallMapList* types = expr->GetReceiverTypes(); 4992 SmallMapList* types = expr->GetReceiverTypes();
(...skipping 19 matching lines...) Expand all
5013 } else { 5012 } else {
5014 Drop(2); 5013 Drop(2);
5015 CHECK_ALIVE(instr = BuildStoreNamedMonomorphic(object, 5014 CHECK_ALIVE(instr = BuildStoreNamedMonomorphic(object,
5016 name, 5015 name,
5017 value, 5016 value,
5018 map)); 5017 map));
5019 } 5018 }
5020 } else if (types != NULL && types->length() > 1) { 5019 } else if (types != NULL && types->length() > 1) {
5021 Drop(2); 5020 Drop(2);
5022 return HandlePolymorphicStoreNamedField( 5021 return HandlePolymorphicStoreNamedField(
5023 position, id, object, value, types, name); 5022 expr->position(), id, object, value, types, name);
5024 } else { 5023 } else {
5025 Drop(2); 5024 Drop(2);
5026 instr = BuildStoreNamedGeneric(object, name, value); 5025 instr = BuildStoreNamedGeneric(object, name, value);
5027 } 5026 }
5028 5027
5029 if (!ast_context()->IsEffect()) Push(value); 5028 if (!ast_context()->IsEffect()) Push(value);
5030 instr->set_position(position); 5029 instr->set_position(expr->position());
5031 AddInstruction(instr); 5030 AddInstruction(instr);
5032 if (instr->HasObservableSideEffects()) { 5031 if (instr->HasObservableSideEffects()) {
5033 Add<HSimulate>(id, REMOVABLE_SIMULATE); 5032 Add<HSimulate>(id, REMOVABLE_SIMULATE);
5034 } 5033 }
5035 if (!ast_context()->IsEffect()) Drop(1); 5034 if (!ast_context()->IsEffect()) Drop(1);
5036 return ast_context()->ReturnValue(value); 5035 return ast_context()->ReturnValue(value);
5037 } 5036 }
5038 5037
5039 5038
5040 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { 5039 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
5115 case Variable::LOOKUP: 5114 case Variable::LOOKUP:
5116 return Bailout(kCompoundAssignmentToLookupSlot); 5115 return Bailout(kCompoundAssignmentToLookupSlot);
5117 } 5116 }
5118 return ast_context()->ReturnValue(Pop()); 5117 return ast_context()->ReturnValue(Pop());
5119 5118
5120 } else if (prop != NULL) { 5119 } else if (prop != NULL) {
5121 if (prop->key()->IsPropertyName()) { 5120 if (prop->key()->IsPropertyName()) {
5122 // Named property. 5121 // Named property.
5123 CHECK_ALIVE(VisitForValue(prop->obj())); 5122 CHECK_ALIVE(VisitForValue(prop->obj()));
5124 HValue* object = Top(); 5123 HValue* object = Top();
5125 PushLoad(prop, object, expr->position()); 5124 CHECK_ALIVE(PushLoad(prop, object, expr->position()));
5126 5125
5127 CHECK_ALIVE(VisitForValue(expr->value())); 5126 CHECK_ALIVE(VisitForValue(expr->value()));
5128 HValue* right = Pop(); 5127 HValue* right = Pop();
5129 HValue* left = Pop(); 5128 HValue* left = Pop();
5130 5129
5131 HInstruction* instr = BuildBinaryOperation(operation, left, right); 5130 HInstruction* instr = BuildBinaryOperation(operation, left, right);
5132 PushAndAdd(instr); 5131 PushAndAdd(instr);
5133 if (instr->HasObservableSideEffects()) { 5132 if (instr->HasObservableSideEffects()) {
5134 Add<HSimulate>(operation->id(), REMOVABLE_SIMULATE); 5133 Add<HSimulate>(operation->id(), REMOVABLE_SIMULATE);
5135 } 5134 }
5136 5135
5137 return BuildStoreNamed(expr, expr->id(), expr->position(), 5136 return BuildStoreNamed(
5138 expr->AssignmentId(), prop, object, instr); 5137 expr, expr->id(), expr->AssignmentId(), prop, object, instr);
5139 } else { 5138 } else {
5140 // Keyed property. 5139 // Keyed property.
5141 CHECK_ALIVE(VisitForValue(prop->obj())); 5140 CHECK_ALIVE(VisitForValue(prop->obj()));
5142 CHECK_ALIVE(VisitForValue(prop->key())); 5141 CHECK_ALIVE(VisitForValue(prop->key()));
5143 HValue* obj = environment()->ExpressionStackAt(1); 5142 HValue* obj = environment()->ExpressionStackAt(1);
5144 HValue* key = environment()->ExpressionStackAt(0); 5143 HValue* key = environment()->ExpressionStackAt(0);
5145 5144
5146 bool has_side_effects = false; 5145 bool has_side_effects = false;
5147 HValue* load = HandleKeyedElementAccess( 5146 HValue* load = HandleKeyedElementAccess(
5148 obj, key, NULL, prop, prop->LoadId(), RelocInfo::kNoPosition, 5147 obj, key, NULL, prop, prop->LoadId(), RelocInfo::kNoPosition,
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
7468 HAdd* add = HAdd::cast(instr); 7467 HAdd* add = HAdd::cast(instr);
7469 add->set_observed_input_representation(1, rep); 7468 add->set_observed_input_representation(1, rep);
7470 add->set_observed_input_representation(2, Representation::Smi()); 7469 add->set_observed_input_representation(2, Representation::Smi());
7471 } 7470 }
7472 instr->SetFlag(HInstruction::kCannotBeTagged); 7471 instr->SetFlag(HInstruction::kCannotBeTagged);
7473 instr->ClearAllSideEffects(); 7472 instr->ClearAllSideEffects();
7474 return instr; 7473 return instr;
7475 } 7474 }
7476 7475
7477 7476
7477 void HOptimizedGraphBuilder::BuildStoreInEffect(Expression* expr,
7478 Property* prop,
7479 BailoutId ast_id,
7480 BailoutId return_id,
7481 HValue* object,
7482 HValue* value) {
7483 EffectContext for_effect(this);
7484 Push(object);
7485 Push(value);
7486 BuildStoreNamed(expr, ast_id, return_id, prop, object, value);
7487 }
7488
7489
7478 void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { 7490 void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) {
7479 ASSERT(!HasStackOverflow()); 7491 ASSERT(!HasStackOverflow());
7480 ASSERT(current_block() != NULL); 7492 ASSERT(current_block() != NULL);
7481 ASSERT(current_block()->HasPredecessor()); 7493 ASSERT(current_block()->HasPredecessor());
7482 Expression* target = expr->expression(); 7494 Expression* target = expr->expression();
7483 VariableProxy* proxy = target->AsVariableProxy(); 7495 VariableProxy* proxy = target->AsVariableProxy();
7484 Property* prop = target->AsProperty(); 7496 Property* prop = target->AsProperty();
7485 if (proxy == NULL && prop == NULL) { 7497 if (proxy == NULL && prop == NULL) {
7486 return Bailout(kInvalidLhsInCountOperation); 7498 return Bailout(kInvalidLhsInCountOperation);
7487 } 7499 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
7554 } else { 7566 } else {
7555 // Argument of the count operation is a property. 7567 // Argument of the count operation is a property.
7556 ASSERT(prop != NULL); 7568 ASSERT(prop != NULL);
7557 7569
7558 if (prop->key()->IsPropertyName()) { 7570 if (prop->key()->IsPropertyName()) {
7559 // Named property. 7571 // Named property.
7560 if (returns_original_input) Push(graph()->GetConstantUndefined()); 7572 if (returns_original_input) Push(graph()->GetConstantUndefined());
7561 7573
7562 CHECK_ALIVE(VisitForValue(prop->obj())); 7574 CHECK_ALIVE(VisitForValue(prop->obj()));
7563 HValue* object = Top(); 7575 HValue* object = Top();
7564 PushLoad(prop, object, expr->position()); 7576 CHECK_ALIVE(PushLoad(prop, object, expr->position()));
7565 7577
7566 after = BuildIncrement(returns_original_input, expr); 7578 after = BuildIncrement(returns_original_input, expr);
7567 7579
7568 if (returns_original_input) { 7580 if (returns_original_input) {
7569 HValue* result = Pop(); 7581 HValue* result = Pop();
7570 HValue* object = Pop(); 7582 HValue* object = Pop();
7571 environment()->SetExpressionStackAt(0, result); 7583 environment()->SetExpressionStackAt(0, result);
7572 { 7584 CHECK_ALIVE(BuildStoreInEffect(
7573 EffectContext for_effect(this); 7585 expr, prop, expr->id(), expr->AssignmentId(), object, after));
7574 Push(object);
7575 Push(after);
7576 BuildStoreNamed(expr, expr->id(), expr->position(),
7577 expr->AssignmentId(), prop, object, after);
7578 }
7579 return ast_context()->ReturnValue(Pop()); 7586 return ast_context()->ReturnValue(Pop());
7580 } 7587 }
7581 7588
7582 return BuildStoreNamed(expr, expr->id(), expr->position(), 7589 return BuildStoreNamed(
7583 expr->AssignmentId(), prop, object, after); 7590 expr, expr->id(), expr->AssignmentId(), prop, object, after);
7584 } else { 7591 } else {
7585 // Keyed property. 7592 // Keyed property.
7586 if (returns_original_input) Push(graph()->GetConstantUndefined()); 7593 if (returns_original_input) Push(graph()->GetConstantUndefined());
7587 7594
7588 CHECK_ALIVE(VisitForValue(prop->obj())); 7595 CHECK_ALIVE(VisitForValue(prop->obj()));
7589 CHECK_ALIVE(VisitForValue(prop->key())); 7596 CHECK_ALIVE(VisitForValue(prop->key()));
7590 HValue* obj = environment()->ExpressionStackAt(1); 7597 HValue* obj = environment()->ExpressionStackAt(1);
7591 HValue* key = environment()->ExpressionStackAt(0); 7598 HValue* key = environment()->ExpressionStackAt(0);
7592 7599
7593 bool has_side_effects = false; 7600 bool has_side_effects = false;
(...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after
9715 if (ShouldProduceTraceOutput()) { 9722 if (ShouldProduceTraceOutput()) {
9716 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9723 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9717 } 9724 }
9718 9725
9719 #ifdef DEBUG 9726 #ifdef DEBUG
9720 graph_->Verify(false); // No full verify. 9727 graph_->Verify(false); // No full verify.
9721 #endif 9728 #endif
9722 } 9729 }
9723 9730
9724 } } // namespace v8::internal 9731 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698