| OLD | NEW |
| 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 6982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6993 if (FLAG_trace_opt) { | 6993 if (FLAG_trace_opt) { |
| 6994 PrintF("[failed to optimize "); | 6994 PrintF("[failed to optimize "); |
| 6995 function->PrintName(); | 6995 function->PrintName(); |
| 6996 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", | 6996 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", |
| 6997 function->shared()->code()->optimizable() ? "T" : "F", | 6997 function->shared()->code()->optimizable() ? "T" : "F", |
| 6998 Debug::has_break_points() ? "T" : "F"); | 6998 Debug::has_break_points() ? "T" : "F"); |
| 6999 } | 6999 } |
| 7000 function->ReplaceCode(function->shared()->code()); | 7000 function->ReplaceCode(function->shared()->code()); |
| 7001 return function->code(); | 7001 return function->code(); |
| 7002 } | 7002 } |
| 7003 if (CompileOptimized(function, AstNode::kNoNumber, KEEP_EXCEPTION)) { | 7003 if (CompileOptimized(function, AstNode::kNoNumber)) { |
| 7004 return function->code(); | 7004 return function->code(); |
| 7005 } | 7005 } |
| 7006 if (FLAG_trace_opt) { | 7006 if (FLAG_trace_opt) { |
| 7007 PrintF("[failed to optimize "); | 7007 PrintF("[failed to optimize "); |
| 7008 function->PrintName(); | 7008 function->PrintName(); |
| 7009 PrintF(": optimized compilation failed]\n"); | 7009 PrintF(": optimized compilation failed]\n"); |
| 7010 } | 7010 } |
| 7011 function->ReplaceCode(function->shared()->code()); | 7011 function->ReplaceCode(function->shared()->code()); |
| 7012 return Failure::Exception(); | 7012 return Failure::Exception(); |
| 7013 } | 7013 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7162 ASSERT(ast_id != AstNode::kNoNumber); | 7162 ASSERT(ast_id != AstNode::kNoNumber); |
| 7163 if (FLAG_trace_osr) { | 7163 if (FLAG_trace_osr) { |
| 7164 PrintF("[replacing on-stack at AST id %d in ", ast_id); | 7164 PrintF("[replacing on-stack at AST id %d in ", ast_id); |
| 7165 function->PrintName(); | 7165 function->PrintName(); |
| 7166 PrintF("]\n"); | 7166 PrintF("]\n"); |
| 7167 } | 7167 } |
| 7168 | 7168 |
| 7169 // Try to compile the optimized code. A true return value from | 7169 // Try to compile the optimized code. A true return value from |
| 7170 // CompileOptimized means that compilation succeeded, not necessarily | 7170 // CompileOptimized means that compilation succeeded, not necessarily |
| 7171 // that optimization succeeded. | 7171 // that optimization succeeded. |
| 7172 if (CompileOptimized(function, ast_id, CLEAR_EXCEPTION) && | 7172 if (CompileOptimized(function, ast_id) && function->IsOptimized()) { |
| 7173 function->IsOptimized()) { | |
| 7174 DeoptimizationInputData* data = DeoptimizationInputData::cast( | 7173 DeoptimizationInputData* data = DeoptimizationInputData::cast( |
| 7175 function->code()->deoptimization_data()); | 7174 function->code()->deoptimization_data()); |
| 7176 if (data->OsrPcOffset()->value() >= 0) { | 7175 if (data->OsrPcOffset()->value() >= 0) { |
| 7177 if (FLAG_trace_osr) { | 7176 if (FLAG_trace_osr) { |
| 7178 PrintF("[on-stack replacement offset %d in optimized code]\n", | 7177 PrintF("[on-stack replacement offset %d in optimized code]\n", |
| 7179 data->OsrPcOffset()->value()); | 7178 data->OsrPcOffset()->value()); |
| 7180 } | 7179 } |
| 7181 ASSERT(data->OsrAstId()->value() == ast_id); | 7180 ASSERT(data->OsrAstId()->value() == ast_id); |
| 7182 } else { | 7181 } else { |
| 7183 // We may never generate the desired OSR entry if we emit an | 7182 // We may never generate the desired OSR entry if we emit an |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7206 // Allow OSR only at nesting level zero again. | 7205 // Allow OSR only at nesting level zero again. |
| 7207 unoptimized->set_allow_osr_at_loop_nesting_level(0); | 7206 unoptimized->set_allow_osr_at_loop_nesting_level(0); |
| 7208 | 7207 |
| 7209 // If the optimization attempt succeeded, return the AST id tagged as a | 7208 // If the optimization attempt succeeded, return the AST id tagged as a |
| 7210 // smi. This tells the builtin that we need to translate the unoptimized | 7209 // smi. This tells the builtin that we need to translate the unoptimized |
| 7211 // frame to an optimized one. | 7210 // frame to an optimized one. |
| 7212 if (succeeded) { | 7211 if (succeeded) { |
| 7213 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); | 7212 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); |
| 7214 return Smi::FromInt(ast_id); | 7213 return Smi::FromInt(ast_id); |
| 7215 } else { | 7214 } else { |
| 7216 if (function->IsMarkedForLazyRecompilation()) { | |
| 7217 function->ReplaceCode(function->shared()->code()); | |
| 7218 } | |
| 7219 return Smi::FromInt(-1); | 7215 return Smi::FromInt(-1); |
| 7220 } | 7216 } |
| 7221 } | 7217 } |
| 7222 | 7218 |
| 7223 | 7219 |
| 7224 static MaybeObject* Runtime_GetFunctionDelegate(Arguments args) { | 7220 static MaybeObject* Runtime_GetFunctionDelegate(Arguments args) { |
| 7225 HandleScope scope; | 7221 HandleScope scope; |
| 7226 ASSERT(args.length() == 1); | 7222 ASSERT(args.length() == 1); |
| 7227 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 7223 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
| 7228 return *Execution::GetFunctionDelegate(args.at<Object>(0)); | 7224 return *Execution::GetFunctionDelegate(args.at<Object>(0)); |
| (...skipping 3976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11205 } else { | 11201 } else { |
| 11206 // Handle last resort GC and make sure to allow future allocations | 11202 // Handle last resort GC and make sure to allow future allocations |
| 11207 // to grow the heap without causing GCs (if possible). | 11203 // to grow the heap without causing GCs (if possible). |
| 11208 Counters::gc_last_resort_from_js.Increment(); | 11204 Counters::gc_last_resort_from_js.Increment(); |
| 11209 Heap::CollectAllGarbage(false); | 11205 Heap::CollectAllGarbage(false); |
| 11210 } | 11206 } |
| 11211 } | 11207 } |
| 11212 | 11208 |
| 11213 | 11209 |
| 11214 } } // namespace v8::internal | 11210 } } // namespace v8::internal |
| OLD | NEW |