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

Side by Side Diff: src/hydrogen.cc

Issue 5699002: RFC: Switch to ast ids (instead of positions) for type feedback. (Closed)
Patch Set: Cleanup Created 10 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
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 HInstruction* HBasicBlock::GetLastInstruction() { 115 HInstruction* HBasicBlock::GetLastInstruction() {
116 if (end_ != NULL) return end_->previous(); 116 if (end_ != NULL) return end_->previous();
117 if (first_ == NULL) return NULL; 117 if (first_ == NULL) return NULL;
118 if (last_ == NULL) last_ = first_; 118 if (last_ == NULL) last_ = first_;
119 while (last_->next() != NULL) last_ = last_->next(); 119 while (last_->next() != NULL) last_ = last_->next();
120 return last_; 120 return last_;
121 } 121 }
122 122
123 123
124 HSimulate* HBasicBlock::CreateSimulate(int id) { 124 HSimulate* HBasicBlock::CreateSimulate(AstId id) {
125 ASSERT(HasEnvironment()); 125 ASSERT(HasEnvironment());
126 HEnvironment* environment = last_environment(); 126 HEnvironment* environment = last_environment();
127 ASSERT(id == AstNode::kNoNumber || 127 ASSERT(id == kNoAstId ||
128 environment->closure()->shared()->VerifyBailoutId(id)); 128 environment->closure()->shared()->VerifyBailoutId(id));
129 129
130 int push_count = environment->push_count(); 130 int push_count = environment->push_count();
131 int pop_count = environment->pop_count(); 131 int pop_count = environment->pop_count();
132 132
133 int length = environment->values()->length(); 133 int length = environment->values()->length();
134 HSimulate* instr = new HSimulate(id, pop_count, length); 134 HSimulate* instr = new HSimulate(id, pop_count, length);
135 for (int i = push_count - 1; i >= 0; --i) { 135 for (int i = push_count - 1; i >= 0; --i) {
136 instr->AddPushedValue(environment->ExpressionStackAt(i)); 136 instr->AddPushedValue(environment->ExpressionStackAt(i));
137 } 137 }
(...skipping 13 matching lines...) Expand all
151 if (end->FirstSuccessor() != NULL) { 151 if (end->FirstSuccessor() != NULL) {
152 end->FirstSuccessor()->RegisterPredecessor(this); 152 end->FirstSuccessor()->RegisterPredecessor(this);
153 if (end->SecondSuccessor() != NULL) { 153 if (end->SecondSuccessor() != NULL) {
154 end->SecondSuccessor()->RegisterPredecessor(this); 154 end->SecondSuccessor()->RegisterPredecessor(this);
155 } 155 }
156 } 156 }
157 } 157 }
158 158
159 159
160 void HBasicBlock::Goto(HBasicBlock* block, bool include_stack_check) { 160 void HBasicBlock::Goto(HBasicBlock* block, bool include_stack_check) {
161 AddSimulate(AstNode::kNoNumber); 161 AddSimulate(kNoAstId);
162 HGoto* instr = new HGoto(block); 162 HGoto* instr = new HGoto(block);
163 instr->set_include_stack_check(include_stack_check); 163 instr->set_include_stack_check(include_stack_check);
164 Finish(instr); 164 Finish(instr);
165 } 165 }
166 166
167 167
168 void HBasicBlock::SetInitialEnvironment(HEnvironment* env) { 168 void HBasicBlock::SetInitialEnvironment(HEnvironment* env) {
169 ASSERT(!HasEnvironment()); 169 ASSERT(!HasEnvironment());
170 ASSERT(first() == NULL); 170 ASSERT(first() == NULL);
171 UpdateEnvironment(env); 171 UpdateEnvironment(env);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 427
428 // Check that phis have correct arguments. 428 // Check that phis have correct arguments.
429 for (int j = 0; j < block->phis()->length(); j++) { 429 for (int j = 0; j < block->phis()->length(); j++) {
430 HPhi* phi = block->phis()->at(j); 430 HPhi* phi = block->phis()->at(j);
431 phi->Verify(); 431 phi->Verify();
432 } 432 }
433 433
434 // Check that all join blocks have predecessors that end with an 434 // Check that all join blocks have predecessors that end with an
435 // unconditional goto and agree on their environment node id. 435 // unconditional goto and agree on their environment node id.
436 if (block->predecessors()->length() >= 2) { 436 if (block->predecessors()->length() >= 2) {
437 int id = block->predecessors()->first()->last_environment()->ast_id(); 437 AstId id = block->predecessors()->first()->last_environment()->ast_id();
438 for (int k = 0; k < block->predecessors()->length(); k++) { 438 for (int k = 0; k < block->predecessors()->length(); k++) {
439 HBasicBlock* predecessor = block->predecessors()->at(k); 439 HBasicBlock* predecessor = block->predecessors()->at(k);
440 ASSERT(predecessor->end()->IsGoto()); 440 ASSERT(predecessor->end()->IsGoto());
441 ASSERT(predecessor->last_environment()->ast_id() == id); 441 ASSERT(predecessor->last_environment()->ast_id() == id);
442 } 442 }
443 } 443 }
444 } 444 }
445 445
446 // Check special property of first block to have no predecessors. 446 // Check special property of first block to have no predecessors.
447 ASSERT(blocks_.at(0)->predecessors()->is_empty()); 447 ASSERT(blocks_.at(0)->predecessors()->is_empty());
(...skipping 3498 matching lines...) Expand 10 before | Expand all | Expand 10 after
3946 invert_true, invert_false); 3946 invert_true, invert_false);
3947 function_return_ = NULL; 3947 function_return_ = NULL;
3948 } else { 3948 } else {
3949 // Inlined body is treated as if it occurs in the original call context. 3949 // Inlined body is treated as if it occurs in the original call context.
3950 function_return_ = graph()->CreateBasicBlock(); 3950 function_return_ = graph()->CreateBasicBlock();
3951 function_return_->MarkAsInlineReturnTarget(); 3951 function_return_->MarkAsInlineReturnTarget();
3952 } 3952 }
3953 call_context_ = ast_context(); 3953 call_context_ = ast_context();
3954 TypeFeedbackOracle new_oracle(Handle<Code>(shared->code())); 3954 TypeFeedbackOracle new_oracle(Handle<Code>(shared->code()));
3955 oracle_ = &new_oracle; 3955 oracle_ = &new_oracle;
3956 graph()->info()->SetOsrAstId(AstNode::kNoNumber); 3956 graph()->info()->SetOsrAstId(kNoAstId);
3957 3957
3958 HSubgraph* body = CreateInlinedSubgraph(env, target, function); 3958 HSubgraph* body = CreateInlinedSubgraph(env, target, function);
3959 body->exit_block()->AddInstruction(new HEnterInlined(target, function)); 3959 body->exit_block()->AddInstruction(new HEnterInlined(target, function));
3960 AddToSubgraph(body, function->body()); 3960 AddToSubgraph(body, function->body());
3961 if (HasStackOverflow()) { 3961 if (HasStackOverflow()) {
3962 // Bail out if the inline function did, as we cannot residualize a call 3962 // Bail out if the inline function did, as we cannot residualize a call
3963 // instead. 3963 // instead.
3964 delete test_context; 3964 delete test_context;
3965 call_context_ = saved_call_context; 3965 call_context_ = saved_call_context;
3966 function_return_ = saved_function_return; 3966 function_return_ = saved_function_return;
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 // occurs as a subexpression of CountOperation. 4450 // occurs as a subexpression of CountOperation.
4451 UNREACHABLE(); 4451 UNREACHABLE();
4452 } 4452 }
4453 4453
4454 4454
4455 HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment) { 4455 HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment) {
4456 HConstant* delta = increment 4456 HConstant* delta = increment
4457 ? graph_->GetConstant1() 4457 ? graph_->GetConstant1()
4458 : graph_->GetConstantMinus1(); 4458 : graph_->GetConstantMinus1();
4459 HInstruction* instr = new HAdd(value, delta); 4459 HInstruction* instr = new HAdd(value, delta);
4460 AssumeRepresentation(instr, Representation::Integer32()); 4460 AssumeRepresentation(instr, Representation::Integer32());
4461 return instr; 4461 return instr;
4462 } 4462 }
4463 4463
4464 4464
4465 void HGraphBuilder::VisitCountOperation(CountOperation* expr) { 4465 void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
4466 IncrementOperation* increment = expr->increment(); 4466 IncrementOperation* increment = expr->increment();
4467 Expression* target = increment->expression(); 4467 Expression* target = increment->expression();
4468 VariableProxy* proxy = target->AsVariableProxy(); 4468 VariableProxy* proxy = target->AsVariableProxy();
4469 Variable* var = proxy->AsVariable(); 4469 Variable* var = proxy->AsVariable();
4470 Property* prop = target->AsProperty(); 4470 Property* prop = target->AsProperty();
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
5124 Scope* scope, 5124 Scope* scope,
5125 Handle<JSFunction> closure) 5125 Handle<JSFunction> closure)
5126 : closure_(closure), 5126 : closure_(closure),
5127 values_(0), 5127 values_(0),
5128 assigned_variables_(4), 5128 assigned_variables_(4),
5129 parameter_count_(0), 5129 parameter_count_(0),
5130 local_count_(0), 5130 local_count_(0),
5131 outer_(outer), 5131 outer_(outer),
5132 pop_count_(0), 5132 pop_count_(0),
5133 push_count_(0), 5133 push_count_(0),
5134 ast_id_(AstNode::kNoNumber) { 5134 ast_id_(kNoAstId) {
5135 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0); 5135 Initialize(scope->num_parameters() + 1, scope->num_stack_slots(), 0);
5136 } 5136 }
5137 5137
5138 5138
5139 HEnvironment::HEnvironment(const HEnvironment* other) 5139 HEnvironment::HEnvironment(const HEnvironment* other)
5140 : values_(0), 5140 : values_(0),
5141 assigned_variables_(0), 5141 assigned_variables_(0),
5142 parameter_count_(0), 5142 parameter_count_(0),
5143 local_count_(0), 5143 local_count_(0),
5144 outer_(NULL), 5144 outer_(NULL),
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
5577 } 5577 }
5578 5578
5579 #ifdef DEBUG 5579 #ifdef DEBUG
5580 if (graph_ != NULL) graph_->Verify(); 5580 if (graph_ != NULL) graph_->Verify();
5581 if (chunk_ != NULL) chunk_->Verify(); 5581 if (chunk_ != NULL) chunk_->Verify();
5582 if (allocator_ != NULL) allocator_->Verify(); 5582 if (allocator_ != NULL) allocator_->Verify();
5583 #endif 5583 #endif
5584 } 5584 }
5585 5585
5586 } } // namespace v8::internal 5586 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698