Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2266 { | 2266 { |
| 2267 HPhase phase("Block building"); | 2267 HPhase phase("Block building"); |
| 2268 current_block_ = graph()->entry_block(); | 2268 current_block_ = graph()->entry_block(); |
| 2269 | 2269 |
| 2270 Scope* scope = info()->scope(); | 2270 Scope* scope = info()->scope(); |
| 2271 if (scope->HasIllegalRedeclaration()) { | 2271 if (scope->HasIllegalRedeclaration()) { |
| 2272 Bailout("function with illegal redeclaration"); | 2272 Bailout("function with illegal redeclaration"); |
| 2273 return NULL; | 2273 return NULL; |
| 2274 } | 2274 } |
| 2275 SetupScope(scope); | 2275 SetupScope(scope); |
| 2276 VisitDeclarations(scope->declarations()); | |
| 2277 HValue* context = environment()->LookupContext(); | |
| 2278 AddInstruction( | |
| 2279 new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry)); | |
| 2280 | 2276 |
| 2281 // Add an edge to the body entry. This is warty: the graph's start | 2277 // Add an edge to the body entry. This is warty: the graph's start |
| 2282 // environment will be used by the Lithium translation as the initial | 2278 // environment will be used by the Lithium translation as the initial |
| 2283 // environment on graph entry, but it has now been mutated by the | 2279 // environment on graph entry, but it has now been mutated by the |
| 2284 // Hydrogen translation of the instructions in the start block. This | 2280 // Hydrogen translation of the instructions in the start block. This |
| 2285 // environment uses values which have not been defined yet. These | 2281 // environment uses values which have not been defined yet. These |
| 2286 // Hydrogen instructions will then be replayed by the Lithium | 2282 // Hydrogen instructions will then be replayed by the Lithium |
| 2287 // translation, so they cannot have an environment effect. The edge to | 2283 // translation, so they cannot have an environment effect. The edge to |
| 2288 // the body's entry block (along with some special logic for the start | 2284 // the body's entry block (along with some special logic for the start |
| 2289 // block in HInstruction::InsertAfter) seals the start block from | 2285 // block in HInstruction::InsertAfter) seals the start block from |
| 2290 // getting unwanted instructions inserted. | 2286 // getting unwanted instructions inserted. |
| 2291 // | 2287 // |
| 2292 // TODO(kmillikin): Fix this. Stop mutating the initial environment. | 2288 // TODO(kmillikin): Fix this. Stop mutating the initial environment. |
| 2293 // Make the Hydrogen instructions in the initial block into Hydrogen | 2289 // Make the Hydrogen instructions in the initial block into Hydrogen |
| 2294 // values (but not instructions), present in the initial environment and | 2290 // values (but not instructions), present in the initial environment and |
| 2295 // not replayed by the Lithium translation. | 2291 // not replayed by the Lithium translation. |
| 2296 HEnvironment* initial_env = environment()->CopyWithoutHistory(); | 2292 HEnvironment* initial_env = environment()->CopyWithoutHistory(); |
| 2297 HBasicBlock* body_entry = CreateBasicBlock(initial_env); | 2293 HBasicBlock* body_entry = CreateBasicBlock(initial_env); |
| 2298 current_block()->Goto(body_entry); | 2294 current_block()->Goto(body_entry); |
| 2299 body_entry->SetJoinId(AstNode::kFunctionEntryId); | 2295 body_entry->SetJoinId(AstNode::kFunctionEntryId); |
| 2300 set_current_block(body_entry); | 2296 set_current_block(body_entry); |
| 2297 | |
| 2298 VisitDeclarations(scope->declarations()); | |
|
Kevin Millikin (Chromium)
2011/08/31 11:44:27
There's an implicit declaration of the function na
fschneider
2011/08/31 12:09:40
Done.
| |
| 2299 AddSimulate(AstNode::kDeclarationsId); | |
| 2300 | |
| 2301 HValue* context = environment()->LookupContext(); | |
| 2302 AddInstruction( | |
| 2303 new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry)); | |
| 2304 | |
| 2301 VisitStatements(info()->function()->body()); | 2305 VisitStatements(info()->function()->body()); |
| 2302 if (HasStackOverflow()) return NULL; | 2306 if (HasStackOverflow()) return NULL; |
| 2303 | 2307 |
| 2304 if (current_block() != NULL) { | 2308 if (current_block() != NULL) { |
| 2305 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined()); | 2309 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined()); |
| 2306 current_block()->FinishExit(instr); | 2310 current_block()->FinishExit(instr); |
| 2307 set_current_block(NULL); | 2311 set_current_block(NULL); |
| 2308 } | 2312 } |
| 2309 } | 2313 } |
| 2310 | 2314 |
| (...skipping 3486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5797 ASSERT(current_block() != NULL); | 5801 ASSERT(current_block() != NULL); |
| 5798 ASSERT(current_block()->HasPredecessor()); | 5802 ASSERT(current_block()->HasPredecessor()); |
| 5799 HThisFunction* self = new(zone()) HThisFunction; | 5803 HThisFunction* self = new(zone()) HThisFunction; |
| 5800 return ast_context()->ReturnInstruction(self, expr->id()); | 5804 return ast_context()->ReturnInstruction(self, expr->id()); |
| 5801 } | 5805 } |
| 5802 | 5806 |
| 5803 | 5807 |
| 5804 void HGraphBuilder::VisitDeclaration(Declaration* decl) { | 5808 void HGraphBuilder::VisitDeclaration(Declaration* decl) { |
| 5805 // We support only declarations that do not require code generation. | 5809 // We support only declarations that do not require code generation. |
| 5806 Variable* var = decl->proxy()->var(); | 5810 Variable* var = decl->proxy()->var(); |
| 5807 if (!var->IsStackAllocated() || decl->fun() != NULL) { | 5811 if (!var->IsStackAllocated()) { |
| 5808 return Bailout("unsupported declaration"); | 5812 return Bailout("unsupported declaration"); |
| 5809 } | 5813 } |
| 5810 | 5814 |
| 5811 if (decl->mode() == Variable::CONST) { | 5815 if (decl->mode() == Variable::CONST) { |
| 5812 ASSERT(var->IsStackAllocated()); | 5816 ASSERT(var->IsStackAllocated()); |
| 5813 environment()->Bind(var, graph()->GetConstantHole()); | 5817 environment()->Bind(var, graph()->GetConstantHole()); |
| 5818 } else if (decl->fun() != NULL) { | |
| 5819 VisitForValue(decl->fun()); | |
| 5820 HValue* function = Pop(); | |
| 5821 environment()->Bind(var, function); | |
| 5814 } | 5822 } |
| 5815 } | 5823 } |
| 5816 | 5824 |
| 5817 | 5825 |
| 5818 // Generators for inline runtime functions. | 5826 // Generators for inline runtime functions. |
| 5819 // Support for types. | 5827 // Support for types. |
| 5820 void HGraphBuilder::GenerateIsSmi(CallRuntime* call) { | 5828 void HGraphBuilder::GenerateIsSmi(CallRuntime* call) { |
| 5821 ASSERT(call->arguments()->length() == 1); | 5829 ASSERT(call->arguments()->length() == 1); |
| 5822 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 5830 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 5823 HValue* value = Pop(); | 5831 HValue* value = Pop(); |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6740 } | 6748 } |
| 6741 } | 6749 } |
| 6742 | 6750 |
| 6743 #ifdef DEBUG | 6751 #ifdef DEBUG |
| 6744 if (graph_ != NULL) graph_->Verify(); | 6752 if (graph_ != NULL) graph_->Verify(); |
| 6745 if (allocator_ != NULL) allocator_->Verify(); | 6753 if (allocator_ != NULL) allocator_->Verify(); |
| 6746 #endif | 6754 #endif |
| 6747 } | 6755 } |
| 6748 | 6756 |
| 6749 } } // namespace v8::internal | 6757 } } // namespace v8::internal |
| OLD | NEW |