| 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 4521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4532 TraceInline(target, caller, "target text too big"); | 4532 TraceInline(target, caller, "target text too big"); |
| 4533 return false; | 4533 return false; |
| 4534 } | 4534 } |
| 4535 | 4535 |
| 4536 // Target must be inlineable. | 4536 // Target must be inlineable. |
| 4537 if (!target->IsInlineable()) { | 4537 if (!target->IsInlineable()) { |
| 4538 TraceInline(target, caller, "target not inlineable"); | 4538 TraceInline(target, caller, "target not inlineable"); |
| 4539 return false; | 4539 return false; |
| 4540 } | 4540 } |
| 4541 | 4541 |
| 4542 CompilationInfo* outer_info = info(); | |
| 4543 #if !defined(V8_TARGET_ARCH_IA32) | 4542 #if !defined(V8_TARGET_ARCH_IA32) |
| 4544 // Target must be able to use caller's context. | 4543 // Target must be able to use caller's context. |
| 4544 CompilationInfo* outer_info = info(); |
| 4545 if (target->context() != outer_info->closure()->context() || | 4545 if (target->context() != outer_info->closure()->context() || |
| 4546 outer_info->scope()->contains_with() || | 4546 outer_info->scope()->contains_with() || |
| 4547 outer_info->scope()->num_heap_slots() > 0) { | 4547 outer_info->scope()->num_heap_slots() > 0) { |
| 4548 TraceInline(target, caller, "target requires context change"); | 4548 TraceInline(target, caller, "target requires context change"); |
| 4549 return false; | 4549 return false; |
| 4550 } | 4550 } |
| 4551 #endif | 4551 #endif |
| 4552 | 4552 |
| 4553 | 4553 |
| 4554 // Don't inline deeper than kMaxInliningLevels calls. | 4554 // Don't inline deeper than kMaxInliningLevels calls. |
| 4555 HEnvironment* env = environment(); | 4555 HEnvironment* env = environment(); |
| 4556 int current_level = 1; | 4556 int current_level = 1; |
| 4557 while (env->outer() != NULL) { | 4557 while (env->outer() != NULL) { |
| 4558 if (current_level == Compiler::kMaxInliningLevels) { | 4558 if (current_level == Compiler::kMaxInliningLevels) { |
| 4559 TraceInline(target, caller, "inline depth limit reached"); | 4559 TraceInline(target, caller, "inline depth limit reached"); |
| 4560 return false; | 4560 return false; |
| 4561 } | 4561 } |
| 4562 current_level++; | 4562 current_level++; |
| 4563 env = env->outer(); | 4563 env = env->outer(); |
| 4564 } | 4564 } |
| 4565 | 4565 |
| 4566 // Don't inline recursive functions. | 4566 // Don't inline recursive functions. |
| 4567 if (*target_shared == outer_info->closure()->shared()) { | 4567 for (FunctionState* state = function_state(); |
| 4568 TraceInline(target, caller, "target is recursive"); | 4568 state != NULL; |
| 4569 return false; | 4569 state = state->outer()) { |
| 4570 if (state->compilation_info()->closure()->shared() == *target_shared) { |
| 4571 TraceInline(target, caller, "target is recursive"); |
| 4572 return false; |
| 4573 } |
| 4570 } | 4574 } |
| 4571 | 4575 |
| 4572 // We don't want to add more than a certain number of nodes from inlining. | 4576 // We don't want to add more than a certain number of nodes from inlining. |
| 4573 if (FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) { | 4577 if (FLAG_limit_inlining && inlined_count_ > kMaxInlinedNodes) { |
| 4574 TraceInline(target, caller, "cumulative AST node limit reached"); | 4578 TraceInline(target, caller, "cumulative AST node limit reached"); |
| 4575 return false; | 4579 return false; |
| 4576 } | 4580 } |
| 4577 | 4581 |
| 4578 int count_before = AstNode::Count(); | 4582 int count_before = AstNode::Count(); |
| 4579 | 4583 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5064 HGlobalObject* global = new(zone()) HGlobalObject(context); | 5068 HGlobalObject* global = new(zone()) HGlobalObject(context); |
| 5065 HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global); | 5069 HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global); |
| 5066 AddInstruction(global); | 5070 AddInstruction(global); |
| 5067 PushAndAdd(receiver); | 5071 PushAndAdd(receiver); |
| 5068 CHECK_ALIVE(VisitExpressions(expr->arguments())); | 5072 CHECK_ALIVE(VisitExpressions(expr->arguments())); |
| 5069 AddInstruction(new(zone()) HCheckFunction(function, expr->target())); | 5073 AddInstruction(new(zone()) HCheckFunction(function, expr->target())); |
| 5070 if (TryInline(expr)) { | 5074 if (TryInline(expr)) { |
| 5071 // The function is lingering in the deoptimization environment. | 5075 // The function is lingering in the deoptimization environment. |
| 5072 // Handle it by case analysis on the AST context. | 5076 // Handle it by case analysis on the AST context. |
| 5073 if (ast_context()->IsEffect()) { | 5077 if (ast_context()->IsEffect()) { |
| 5078 if (current_block() == NULL) return; |
| 5079 ASSERT(Top() == function); |
| 5074 Drop(1); | 5080 Drop(1); |
| 5075 } else if (ast_context()->IsValue()) { | 5081 } else if (ast_context()->IsValue()) { |
| 5082 if (current_block() == NULL) return; |
| 5076 HValue* result = Pop(); | 5083 HValue* result = Pop(); |
| 5084 ASSERT(Top() == function); |
| 5077 Drop(1); | 5085 Drop(1); |
| 5078 Push(result); | 5086 Push(result); |
| 5079 } else if (ast_context()->IsTest()) { | 5087 } else if (ast_context()->IsTest()) { |
| 5088 ASSERT(current_block() == NULL); |
| 5080 TestContext* context = TestContext::cast(ast_context()); | 5089 TestContext* context = TestContext::cast(ast_context()); |
| 5081 if (context->if_true()->HasPredecessor()) { | 5090 if (context->if_true()->HasPredecessor() && |
| 5091 context->if_true()->last_environment()->Top() == function) { |
| 5082 context->if_true()->last_environment()->Drop(1); | 5092 context->if_true()->last_environment()->Drop(1); |
| 5083 } | 5093 } |
| 5084 if (context->if_false()->HasPredecessor()) { | 5094 if (context->if_false()->HasPredecessor() && |
| 5085 context->if_true()->last_environment()->Drop(1); | 5095 context->if_false()->last_environment()->Top() == function) { |
| 5096 context->if_false()->last_environment()->Drop(1); |
| 5086 } | 5097 } |
| 5087 } else { | 5098 } else { |
| 5088 UNREACHABLE(); | 5099 UNREACHABLE(); |
| 5089 } | 5100 } |
| 5090 return; | 5101 return; |
| 5091 } else { | 5102 } else { |
| 5092 call = PreProcessCall(new(zone()) HInvokeFunction(context, | 5103 call = PreProcessCall(new(zone()) HInvokeFunction(context, |
| 5093 function, | 5104 function, |
| 5094 argument_count)); | 5105 argument_count)); |
| 5095 Drop(1); // The function. | 5106 Drop(1); // The function. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5295 if (info.IsUninitialized()) { | 5306 if (info.IsUninitialized()) { |
| 5296 AddInstruction(new(zone()) HSoftDeoptimize); | 5307 AddInstruction(new(zone()) HSoftDeoptimize); |
| 5297 current_block()->MarkAsDeoptimizing(); | 5308 current_block()->MarkAsDeoptimizing(); |
| 5298 } | 5309 } |
| 5299 HInstruction* instr = new(zone()) HBitNot(value); | 5310 HInstruction* instr = new(zone()) HBitNot(value); |
| 5300 return ast_context()->ReturnInstruction(instr, expr->id()); | 5311 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5301 } | 5312 } |
| 5302 | 5313 |
| 5303 | 5314 |
| 5304 void HGraphBuilder::VisitNot(UnaryOperation* expr) { | 5315 void HGraphBuilder::VisitNot(UnaryOperation* expr) { |
| 5305 // TODO(svenpanne) Perhaps a switch/virtual function is nicer here. | |
| 5306 if (ast_context()->IsTest()) { | 5316 if (ast_context()->IsTest()) { |
| 5307 TestContext* context = TestContext::cast(ast_context()); | 5317 TestContext* context = TestContext::cast(ast_context()); |
| 5308 VisitForControl(expr->expression(), | 5318 VisitForControl(expr->expression(), |
| 5309 context->if_false(), | 5319 context->if_false(), |
| 5310 context->if_true()); | 5320 context->if_true()); |
| 5311 return; | 5321 return; |
| 5312 } | 5322 } |
| 5313 | 5323 |
| 5314 if (ast_context()->IsEffect()) { | 5324 if (ast_context()->IsEffect()) { |
| 5315 VisitForEffect(expr->expression()); | 5325 VisitForEffect(expr->expression()); |
| (...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6977 } | 6987 } |
| 6978 } | 6988 } |
| 6979 | 6989 |
| 6980 #ifdef DEBUG | 6990 #ifdef DEBUG |
| 6981 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 6991 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 6982 if (allocator_ != NULL) allocator_->Verify(); | 6992 if (allocator_ != NULL) allocator_->Verify(); |
| 6983 #endif | 6993 #endif |
| 6984 } | 6994 } |
| 6985 | 6995 |
| 6986 } } // namespace v8::internal | 6996 } } // namespace v8::internal |
| OLD | NEW |