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 6999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7010 if (FLAG_trace_opt) { | 7010 if (FLAG_trace_opt) { |
7011 PrintF("[failed to optimize "); | 7011 PrintF("[failed to optimize "); |
7012 function->PrintName(); | 7012 function->PrintName(); |
7013 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", | 7013 PrintF(": is code optimizable: %s, is debugger enabled: %s]\n", |
7014 function->shared()->code()->optimizable() ? "T" : "F", | 7014 function->shared()->code()->optimizable() ? "T" : "F", |
7015 Debug::has_break_points() ? "T" : "F"); | 7015 Debug::has_break_points() ? "T" : "F"); |
7016 } | 7016 } |
7017 function->ReplaceCode(function->shared()->code()); | 7017 function->ReplaceCode(function->shared()->code()); |
7018 return function->code(); | 7018 return function->code(); |
7019 } | 7019 } |
7020 if (CompileOptimized(function, AstNode::kNoNumber)) { | 7020 if (CompileOptimized(function, AstNode::kNoNumber, CLEAR_EXCEPTION)) { |
7021 return function->code(); | 7021 return function->code(); |
7022 } | 7022 } |
7023 if (FLAG_trace_opt) { | 7023 if (FLAG_trace_opt) { |
7024 PrintF("[failed to optimize "); | 7024 PrintF("[failed to optimize "); |
7025 function->PrintName(); | 7025 function->PrintName(); |
7026 PrintF(": optimized compilation failed]\n"); | 7026 PrintF(": optimized compilation failed]\n"); |
7027 } | 7027 } |
7028 function->ReplaceCode(function->shared()->code()); | 7028 function->ReplaceCode(function->shared()->code()); |
7029 return Failure::Exception(); | 7029 return function->code(); |
7030 } | 7030 } |
7031 | 7031 |
7032 | 7032 |
7033 static MaybeObject* Runtime_NotifyDeoptimized(Arguments args) { | 7033 static MaybeObject* Runtime_NotifyDeoptimized(Arguments args) { |
7034 HandleScope scope; | 7034 HandleScope scope; |
7035 ASSERT(args.length() == 1); | 7035 ASSERT(args.length() == 1); |
7036 RUNTIME_ASSERT(args[0]->IsSmi()); | 7036 RUNTIME_ASSERT(args[0]->IsSmi()); |
7037 Deoptimizer::BailoutType type = | 7037 Deoptimizer::BailoutType type = |
7038 static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value()); | 7038 static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value()); |
7039 Deoptimizer* deoptimizer = Deoptimizer::Grab(); | 7039 Deoptimizer* deoptimizer = Deoptimizer::Grab(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7179 ASSERT(ast_id != AstNode::kNoNumber); | 7179 ASSERT(ast_id != AstNode::kNoNumber); |
7180 if (FLAG_trace_osr) { | 7180 if (FLAG_trace_osr) { |
7181 PrintF("[replacing on-stack at AST id %d in ", ast_id); | 7181 PrintF("[replacing on-stack at AST id %d in ", ast_id); |
7182 function->PrintName(); | 7182 function->PrintName(); |
7183 PrintF("]\n"); | 7183 PrintF("]\n"); |
7184 } | 7184 } |
7185 | 7185 |
7186 // Try to compile the optimized code. A true return value from | 7186 // Try to compile the optimized code. A true return value from |
7187 // CompileOptimized means that compilation succeeded, not necessarily | 7187 // CompileOptimized means that compilation succeeded, not necessarily |
7188 // that optimization succeeded. | 7188 // that optimization succeeded. |
7189 if (CompileOptimized(function, ast_id) && function->IsOptimized()) { | 7189 if (CompileOptimized(function, ast_id, CLEAR_EXCEPTION) && |
| 7190 function->IsOptimized()) { |
7190 DeoptimizationInputData* data = DeoptimizationInputData::cast( | 7191 DeoptimizationInputData* data = DeoptimizationInputData::cast( |
7191 function->code()->deoptimization_data()); | 7192 function->code()->deoptimization_data()); |
7192 if (data->OsrPcOffset()->value() >= 0) { | 7193 if (data->OsrPcOffset()->value() >= 0) { |
7193 if (FLAG_trace_osr) { | 7194 if (FLAG_trace_osr) { |
7194 PrintF("[on-stack replacement offset %d in optimized code]\n", | 7195 PrintF("[on-stack replacement offset %d in optimized code]\n", |
7195 data->OsrPcOffset()->value()); | 7196 data->OsrPcOffset()->value()); |
7196 } | 7197 } |
7197 ASSERT(data->OsrAstId()->value() == ast_id); | 7198 ASSERT(data->OsrAstId()->value() == ast_id); |
7198 } else { | 7199 } else { |
7199 // We may never generate the desired OSR entry if we emit an | 7200 // We may never generate the desired OSR entry if we emit an |
(...skipping 22 matching lines...) Expand all Loading... |
7222 // Allow OSR only at nesting level zero again. | 7223 // Allow OSR only at nesting level zero again. |
7223 unoptimized->set_allow_osr_at_loop_nesting_level(0); | 7224 unoptimized->set_allow_osr_at_loop_nesting_level(0); |
7224 | 7225 |
7225 // If the optimization attempt succeeded, return the AST id tagged as a | 7226 // If the optimization attempt succeeded, return the AST id tagged as a |
7226 // smi. This tells the builtin that we need to translate the unoptimized | 7227 // smi. This tells the builtin that we need to translate the unoptimized |
7227 // frame to an optimized one. | 7228 // frame to an optimized one. |
7228 if (succeeded) { | 7229 if (succeeded) { |
7229 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); | 7230 ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); |
7230 return Smi::FromInt(ast_id); | 7231 return Smi::FromInt(ast_id); |
7231 } else { | 7232 } else { |
| 7233 if (function->IsMarkedForLazyRecompilation()) { |
| 7234 function->ReplaceCode(function->shared()->code()); |
| 7235 } |
7232 return Smi::FromInt(-1); | 7236 return Smi::FromInt(-1); |
7233 } | 7237 } |
7234 } | 7238 } |
7235 | 7239 |
7236 | 7240 |
7237 static MaybeObject* Runtime_GetFunctionDelegate(Arguments args) { | 7241 static MaybeObject* Runtime_GetFunctionDelegate(Arguments args) { |
7238 HandleScope scope; | 7242 HandleScope scope; |
7239 ASSERT(args.length() == 1); | 7243 ASSERT(args.length() == 1); |
7240 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 7244 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
7241 return *Execution::GetFunctionDelegate(args.at<Object>(0)); | 7245 return *Execution::GetFunctionDelegate(args.at<Object>(0)); |
(...skipping 3976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11218 } else { | 11222 } else { |
11219 // Handle last resort GC and make sure to allow future allocations | 11223 // Handle last resort GC and make sure to allow future allocations |
11220 // to grow the heap without causing GCs (if possible). | 11224 // to grow the heap without causing GCs (if possible). |
11221 Counters::gc_last_resort_from_js.Increment(); | 11225 Counters::gc_last_resort_from_js.Increment(); |
11222 Heap::CollectAllGarbage(false); | 11226 Heap::CollectAllGarbage(false); |
11223 } | 11227 } |
11224 } | 11228 } |
11225 | 11229 |
11226 | 11230 |
11227 } } // namespace v8::internal | 11231 } } // namespace v8::internal |
OLD | NEW |