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 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2291 // not replayed by the Lithium translation. | 2291 // not replayed by the Lithium translation. |
| 2292 HEnvironment* initial_env = environment()->CopyWithoutHistory(); | 2292 HEnvironment* initial_env = environment()->CopyWithoutHistory(); |
| 2293 HBasicBlock* body_entry = CreateBasicBlock(initial_env); | 2293 HBasicBlock* body_entry = CreateBasicBlock(initial_env); |
| 2294 current_block()->Goto(body_entry); | 2294 current_block()->Goto(body_entry); |
| 2295 body_entry->SetJoinId(AstNode::kFunctionEntryId); | 2295 body_entry->SetJoinId(AstNode::kFunctionEntryId); |
| 2296 set_current_block(body_entry); | 2296 set_current_block(body_entry); |
| 2297 | 2297 |
| 2298 // Handle implicit declaration of the function name in named function | 2298 // Handle implicit declaration of the function name in named function |
| 2299 // expressions before other declarations. | 2299 // expressions before other declarations. |
| 2300 if (scope->is_function_scope() && scope->function() != NULL) { | 2300 if (scope->is_function_scope() && scope->function() != NULL) { |
| 2301 if (!scope->function()->IsStackAllocated()) { | 2301 EmitDeclaration(scope->function(), Variable::CONST, NULL); |
| 2302 Bailout("unsupported declaration"); | |
| 2303 return NULL; | |
| 2304 } | |
| 2305 environment()->Bind(scope->function(), graph()->GetConstantHole()); | |
| 2306 } | 2302 } |
| 2307 VisitDeclarations(scope->declarations()); | 2303 VisitDeclarations(scope->declarations()); |
| 2308 AddSimulate(AstNode::kDeclarationsId); | 2304 AddSimulate(AstNode::kDeclarationsId); |
| 2309 | 2305 |
| 2310 HValue* context = environment()->LookupContext(); | 2306 HValue* context = environment()->LookupContext(); |
| 2311 AddInstruction( | 2307 AddInstruction( |
| 2312 new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry)); | 2308 new(zone()) HStackCheck(context, HStackCheck::kFunctionEntry)); |
| 2313 | 2309 |
| 2314 VisitStatements(info()->function()->body()); | 2310 VisitStatements(info()->function()->body()); |
| 2315 if (HasStackOverflow()) return NULL; | 2311 if (HasStackOverflow()) return NULL; |
| (...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5815 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 5811 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
| 5816 ASSERT(!HasStackOverflow()); | 5812 ASSERT(!HasStackOverflow()); |
| 5817 ASSERT(current_block() != NULL); | 5813 ASSERT(current_block() != NULL); |
| 5818 ASSERT(current_block()->HasPredecessor()); | 5814 ASSERT(current_block()->HasPredecessor()); |
| 5819 HThisFunction* self = new(zone()) HThisFunction; | 5815 HThisFunction* self = new(zone()) HThisFunction; |
| 5820 return ast_context()->ReturnInstruction(self, expr->id()); | 5816 return ast_context()->ReturnInstruction(self, expr->id()); |
| 5821 } | 5817 } |
| 5822 | 5818 |
| 5823 | 5819 |
| 5824 void HGraphBuilder::VisitDeclaration(Declaration* decl) { | 5820 void HGraphBuilder::VisitDeclaration(Declaration* decl) { |
| 5825 // We support only declarations that do not require code generation. | 5821 EmitDeclaration(decl->proxy(), decl->mode(), decl->fun()); |
| 5826 Variable* var = decl->proxy()->var(); | 5822 } |
| 5827 if (!var->IsStackAllocated() || | |
| 5828 decl->mode() == Variable::LET) { | |
| 5829 return Bailout("unsupported declaration"); | |
| 5830 } | |
| 5831 | 5823 |
| 5832 if (decl->mode() == Variable::CONST) { | 5824 |
| 5833 ASSERT(var->IsStackAllocated()); | 5825 void HGraphBuilder::EmitDeclaration(VariableProxy* proxy, |
| 5834 environment()->Bind(var, graph()->GetConstantHole()); | 5826 Variable::Mode mode, |
| 5835 } else if (decl->fun() != NULL) { | 5827 FunctionLiteral* function) { |
| 5836 VisitForValue(decl->fun()); | 5828 if (mode == Variable::LET) return Bailout("unsupported let declaration"); |
| 5837 HValue* function = Pop(); | 5829 Variable* var = proxy->var(); |
| 5838 environment()->Bind(var, function); | 5830 Slot* slot = var->AsSlot(); |
| 5831 ASSERT(slot != NULL); | |
| 5832 switch (slot->type()) { | |
| 5833 case Slot::PARAMETER: | |
| 5834 case Slot::LOCAL: | |
| 5835 if (mode == Variable::CONST) { | |
| 5836 ASSERT(var->IsStackAllocated()); | |
|
Kevin Millikin (Chromium)
2011/09/01 15:40:58
This ASSERT is trivially true, because it's in the
fschneider
2011/09/01 16:28:21
Done.
| |
| 5837 environment()->Bind(var, graph()->GetConstantHole()); | |
| 5838 } else if (function != NULL) { | |
| 5839 VisitForValue(function); | |
| 5840 HValue* function_value = Pop(); | |
| 5841 environment()->Bind(var, function_value); | |
| 5842 } | |
| 5843 break; | |
| 5844 case Slot::CONTEXT: { | |
| 5845 HValue* context = environment()->LookupContext(); | |
| 5846 if (mode == Variable::CONST) { | |
| 5847 HStoreContextSlot* store = | |
| 5848 new HStoreContextSlot(context, | |
| 5849 slot->index(), | |
| 5850 graph()->GetConstantHole()); | |
| 5851 AddInstruction(store); | |
| 5852 if (store->HasSideEffects()) AddSimulate(proxy->id()); | |
| 5853 } else if (function != NULL) { | |
| 5854 VisitForValue(function); | |
| 5855 HValue* function_value = Pop(); | |
| 5856 HStoreContextSlot* store = | |
| 5857 new HStoreContextSlot(context, | |
| 5858 slot->index(), | |
| 5859 function_value); | |
| 5860 AddInstruction(store); | |
| 5861 if (store->HasSideEffects()) AddSimulate(proxy->id()); | |
| 5862 } | |
| 5863 break; | |
| 5864 } | |
| 5865 case Slot::LOOKUP: | |
| 5866 return Bailout("unsupported lookup slot in declaration"); | |
| 5839 } | 5867 } |
| 5840 } | 5868 } |
| 5841 | 5869 |
| 5842 | 5870 |
| 5843 // Generators for inline runtime functions. | 5871 // Generators for inline runtime functions. |
| 5844 // Support for types. | 5872 // Support for types. |
| 5845 void HGraphBuilder::GenerateIsSmi(CallRuntime* call) { | 5873 void HGraphBuilder::GenerateIsSmi(CallRuntime* call) { |
| 5846 ASSERT(call->arguments()->length() == 1); | 5874 ASSERT(call->arguments()->length() == 1); |
| 5847 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 5875 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 5848 HValue* value = Pop(); | 5876 HValue* value = Pop(); |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6765 } | 6793 } |
| 6766 } | 6794 } |
| 6767 | 6795 |
| 6768 #ifdef DEBUG | 6796 #ifdef DEBUG |
| 6769 if (graph_ != NULL) graph_->Verify(); | 6797 if (graph_ != NULL) graph_->Verify(); |
| 6770 if (allocator_ != NULL) allocator_->Verify(); | 6798 if (allocator_ != NULL) allocator_->Verify(); |
| 6771 #endif | 6799 #endif |
| 6772 } | 6800 } |
| 6773 | 6801 |
| 6774 } } // namespace v8::internal | 6802 } } // namespace v8::internal |
| OLD | NEW |