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 | |
7444 static bool CompileLazyHelper(CompilationInfo* info, | 7438 static bool CompileLazyHelper(CompilationInfo* info, |
7445 ClearExceptionFlag flag) { | 7439 ClearExceptionFlag flag) { |
7446 // Compile the source information to a code object. | 7440 // Compile the source information to a code object. |
7447 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); | 7441 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); |
7448 ASSERT(!info->isolate()->has_pending_exception()); | 7442 ASSERT(!info->isolate()->has_pending_exception()); |
7449 bool result = Compiler::CompileLazy(info); | 7443 bool result = Compiler::CompileLazy(info); |
7450 ASSERT(result != Isolate::Current()->has_pending_exception()); | 7444 ASSERT(result != Isolate::Current()->has_pending_exception()); |
7451 if (!result && flag == CLEAR_EXCEPTION) { | 7445 if (!result && flag == CLEAR_EXCEPTION) { |
7452 info->isolate()->clear_pending_exception(); | 7446 info->isolate()->clear_pending_exception(); |
7453 } | 7447 } |
7454 return result; | 7448 return result; |
7455 } | 7449 } |
7456 | 7450 |
7457 | 7451 |
7458 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, | 7452 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, |
7459 ClearExceptionFlag flag) { | 7453 ClearExceptionFlag flag) { |
| 7454 ASSERT(shared->allows_lazy_compilation_without_context()); |
7460 CompilationInfo info(shared); | 7455 CompilationInfo info(shared); |
7461 return CompileLazyHelper(&info, flag); | 7456 return CompileLazyHelper(&info, flag); |
7462 } | 7457 } |
7463 | 7458 |
7464 | 7459 |
7465 bool JSFunction::CompileLazy(Handle<JSFunction> function, | 7460 bool JSFunction::CompileLazy(Handle<JSFunction> function, |
7466 ClearExceptionFlag flag) { | 7461 ClearExceptionFlag flag) { |
7467 bool result = true; | 7462 bool result = true; |
7468 if (function->shared()->is_compiled()) { | 7463 if (function->shared()->is_compiled()) { |
7469 function->ReplaceCode(function->shared()->code()); | 7464 function->ReplaceCode(function->shared()->code()); |
7470 function->shared()->set_code_age(0); | 7465 function->shared()->set_code_age(0); |
7471 } else { | 7466 } else { |
| 7467 ASSERT(function->shared()->allows_lazy_compilation()); |
7472 CompilationInfo info(function); | 7468 CompilationInfo info(function); |
7473 result = CompileLazyHelper(&info, flag); | 7469 result = CompileLazyHelper(&info, flag); |
7474 ASSERT(!result || function->is_compiled()); | 7470 ASSERT(!result || function->is_compiled()); |
7475 } | 7471 } |
7476 return result; | 7472 return result; |
7477 } | 7473 } |
7478 | 7474 |
7479 | 7475 |
7480 bool JSFunction::CompileOptimized(Handle<JSFunction> function, | 7476 bool JSFunction::CompileOptimized(Handle<JSFunction> function, |
7481 int osr_ast_id, | 7477 int osr_ast_id, |
7482 ClearExceptionFlag flag) { | 7478 ClearExceptionFlag flag) { |
7483 CompilationInfo info(function); | 7479 CompilationInfo info(function); |
7484 info.SetOptimizing(osr_ast_id); | 7480 info.SetOptimizing(osr_ast_id); |
7485 return CompileLazyHelper(&info, flag); | 7481 return CompileLazyHelper(&info, flag); |
7486 } | 7482 } |
7487 | 7483 |
7488 | 7484 |
| 7485 bool JSFunction::EnsureCompiled(Handle<JSFunction> function, |
| 7486 ClearExceptionFlag flag) { |
| 7487 return function->is_compiled() || CompileLazy(function, flag); |
| 7488 } |
| 7489 |
| 7490 |
7489 bool JSFunction::IsInlineable() { | 7491 bool JSFunction::IsInlineable() { |
7490 if (IsBuiltin()) return false; | 7492 if (IsBuiltin()) return false; |
7491 SharedFunctionInfo* shared_info = shared(); | 7493 SharedFunctionInfo* shared_info = shared(); |
7492 // Check that the function has a script associated with it. | 7494 // Check that the function has a script associated with it. |
7493 if (!shared_info->script()->IsScript()) return false; | 7495 if (!shared_info->script()->IsScript()) return false; |
7494 if (shared_info->optimization_disabled()) return false; | 7496 if (shared_info->optimization_disabled()) return false; |
7495 Code* code = shared_info->code(); | 7497 Code* code = shared_info->code(); |
7496 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; | 7498 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; |
7497 // If we never ran this (unlikely) then lets try to optimize it. | 7499 // If we never ran this (unlikely) then lets try to optimize it. |
7498 if (code->kind() != Code::FUNCTION) return true; | 7500 if (code->kind() != Code::FUNCTION) return true; |
(...skipping 5685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13184 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13186 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13185 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13187 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13186 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13188 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13187 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13189 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13188 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13190 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13189 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13191 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13190 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13192 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13191 } | 13193 } |
13192 | 13194 |
13193 } } // namespace v8::internal | 13195 } } // namespace v8::internal |
OLD | NEW |