OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 7417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7428 | 7428 |
7429 void JSFunction::MarkForLazyRecompilation() { | 7429 void JSFunction::MarkForLazyRecompilation() { |
7430 ASSERT(is_compiled() && !IsOptimized()); | 7430 ASSERT(is_compiled() && !IsOptimized()); |
7431 ASSERT(shared()->allows_lazy_compilation() || | 7431 ASSERT(shared()->allows_lazy_compilation() || |
7432 code()->optimizable()); | 7432 code()->optimizable()); |
7433 Builtins* builtins = GetIsolate()->builtins(); | 7433 Builtins* builtins = GetIsolate()->builtins(); |
7434 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile)); | 7434 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile)); |
7435 } | 7435 } |
7436 | 7436 |
7437 | 7437 |
| 7438 bool SharedFunctionInfo::EnsureCompiled(Handle<SharedFunctionInfo> shared, |
| 7439 ClearExceptionFlag flag) { |
| 7440 return shared->is_compiled() || CompileLazy(shared, flag); |
| 7441 } |
| 7442 |
| 7443 |
7438 static bool CompileLazyHelper(CompilationInfo* info, | 7444 static bool CompileLazyHelper(CompilationInfo* info, |
7439 ClearExceptionFlag flag) { | 7445 ClearExceptionFlag flag) { |
7440 // Compile the source information to a code object. | 7446 // Compile the source information to a code object. |
7441 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); | 7447 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); |
7442 ASSERT(!info->isolate()->has_pending_exception()); | 7448 ASSERT(!info->isolate()->has_pending_exception()); |
7443 bool result = Compiler::CompileLazy(info); | 7449 bool result = Compiler::CompileLazy(info); |
7444 ASSERT(result != Isolate::Current()->has_pending_exception()); | 7450 ASSERT(result != Isolate::Current()->has_pending_exception()); |
7445 if (!result && flag == CLEAR_EXCEPTION) { | 7451 if (!result && flag == CLEAR_EXCEPTION) { |
7446 info->isolate()->clear_pending_exception(); | 7452 info->isolate()->clear_pending_exception(); |
7447 } | 7453 } |
7448 return result; | 7454 return result; |
7449 } | 7455 } |
7450 | 7456 |
7451 | 7457 |
7452 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, | 7458 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, |
7453 ClearExceptionFlag flag) { | 7459 ClearExceptionFlag flag) { |
7454 ASSERT(shared->allows_lazy_compilation_without_context()); | |
7455 CompilationInfo info(shared); | 7460 CompilationInfo info(shared); |
7456 return CompileLazyHelper(&info, flag); | 7461 return CompileLazyHelper(&info, flag); |
7457 } | 7462 } |
7458 | 7463 |
7459 | 7464 |
7460 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 7465 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
7461 ClearExceptionFlag flag) { | 7466 ClearExceptionFlag flag) { |
7462 bool result = true; | 7467 bool result = true; |
7463 if (function->shared()->is_compiled()) { | 7468 if (function->shared()->is_compiled()) { |
7464 function->ReplaceCode(function->shared()->code()); | 7469 function->ReplaceCode(function->shared()->code()); |
7465 function->shared()->set_code_age(0); | 7470 function->shared()->set_code_age(0); |
7466 } else { | 7471 } else { |
7467 ASSERT(function->shared()->allows_lazy_compilation()); | |
7468 CompilationInfo info(function); | 7472 CompilationInfo info(function); |
7469 result = CompileLazyHelper(&info, flag); | 7473 result = CompileLazyHelper(&info, flag); |
7470 ASSERT(!result || function->is_compiled()); | 7474 ASSERT(!result || function->is_compiled()); |
7471 } | 7475 } |
7472 return result; | 7476 return result; |
7473 } | 7477 } |
7474 | 7478 |
7475 | 7479 |
7476 bool JSFunction::CompileOptimized(Handle<JSFunction> function, | 7480 bool JSFunction::CompileOptimized(Handle<JSFunction> function, |
7477 int osr_ast_id, | 7481 int osr_ast_id, |
7478 ClearExceptionFlag flag) { | 7482 ClearExceptionFlag flag) { |
7479 CompilationInfo info(function); | 7483 CompilationInfo info(function); |
7480 info.SetOptimizing(osr_ast_id); | 7484 info.SetOptimizing(osr_ast_id); |
7481 return CompileLazyHelper(&info, flag); | 7485 return CompileLazyHelper(&info, flag); |
7482 } | 7486 } |
7483 | 7487 |
7484 | 7488 |
7485 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, | |
7486 ClearExceptionFlag flag) { | |
7487 return function->is_compiled() || CompileLazy(function, flag); | |
7488 } | |
7489 | |
7490 | |
7491 bool JSFunction::IsInlineable() { | 7489 bool JSFunction::IsInlineable() { |
7492 if (IsBuiltin()) return false; | 7490 if (IsBuiltin()) return false; |
7493 SharedFunctionInfo* shared_info = shared(); | 7491 SharedFunctionInfo* shared_info = shared(); |
7494 // Check that the function has a script associated with it. | 7492 // Check that the function has a script associated with it. |
7495 if (!shared_info->script()->IsScript()) return false; | 7493 if (!shared_info->script()->IsScript()) return false; |
7496 if (shared_info->optimization_disabled()) return false; | 7494 if (shared_info->optimization_disabled()) return false; |
7497 Code* code = shared_info->code(); | 7495 Code* code = shared_info->code(); |
7498 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; | 7496 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; |
7499 // If we never ran this (unlikely) then lets try to optimize it. | 7497 // If we never ran this (unlikely) then lets try to optimize it. |
7500 if (code->kind() != Code::FUNCTION) return true; | 7498 if (code->kind() != Code::FUNCTION) return true; |
(...skipping 5697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13198 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13196 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13199 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13197 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13200 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13198 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13201 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13199 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13202 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13200 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13203 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13201 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13204 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13202 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13205 } | 13203 } |
13206 | 13204 |
13207 } } // namespace v8::internal | 13205 } } // namespace v8::internal |
OLD | NEW |