Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/objects.cc

Issue 10543141: Enable lazy compilation for non-trivial outer contexts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Ulan Degenbaev. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7426 matching lines...) Expand 10 before | Expand all | Expand 10 after
7437 7437
7438 void JSFunction::MarkForLazyRecompilation() { 7438 void JSFunction::MarkForLazyRecompilation() {
7439 ASSERT(is_compiled() && !IsOptimized()); 7439 ASSERT(is_compiled() && !IsOptimized());
7440 ASSERT(shared()->allows_lazy_compilation() || 7440 ASSERT(shared()->allows_lazy_compilation() ||
7441 code()->optimizable()); 7441 code()->optimizable());
7442 Builtins* builtins = GetIsolate()->builtins(); 7442 Builtins* builtins = GetIsolate()->builtins();
7443 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile)); 7443 ReplaceCode(builtins->builtin(Builtins::kLazyRecompile));
7444 } 7444 }
7445 7445
7446 7446
7447 bool SharedFunctionInfo::EnsureCompiled(Handle<SharedFunctionInfo> shared,
7448 ClearExceptionFlag flag) {
7449 return shared->is_compiled() || CompileLazy(shared, flag);
7450 }
7451
7452
7453 static bool CompileLazyHelper(CompilationInfo* info, 7447 static bool CompileLazyHelper(CompilationInfo* info,
7454 ClearExceptionFlag flag) { 7448 ClearExceptionFlag flag) {
7455 // Compile the source information to a code object. 7449 // Compile the source information to a code object.
7456 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); 7450 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled());
7457 ASSERT(!info->isolate()->has_pending_exception()); 7451 ASSERT(!info->isolate()->has_pending_exception());
7458 bool result = Compiler::CompileLazy(info); 7452 bool result = Compiler::CompileLazy(info);
7459 ASSERT(result != Isolate::Current()->has_pending_exception()); 7453 ASSERT(result != Isolate::Current()->has_pending_exception());
7460 if (!result && flag == CLEAR_EXCEPTION) { 7454 if (!result && flag == CLEAR_EXCEPTION) {
7461 info->isolate()->clear_pending_exception(); 7455 info->isolate()->clear_pending_exception();
7462 } 7456 }
7463 return result; 7457 return result;
7464 } 7458 }
7465 7459
7466 7460
7467 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, 7461 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared,
7468 ClearExceptionFlag flag) { 7462 ClearExceptionFlag flag) {
7463 ASSERT(shared->allows_lazy_compilation_without_context());
7469 CompilationInfo info(shared); 7464 CompilationInfo info(shared);
7470 return CompileLazyHelper(&info, flag); 7465 return CompileLazyHelper(&info, flag);
7471 } 7466 }
7472 7467
7473 7468
7474 bool JSFunction::CompileLazy(Handle<JSFunction> function, 7469 bool JSFunction::CompileLazy(Handle<JSFunction> function,
7475 ClearExceptionFlag flag) { 7470 ClearExceptionFlag flag) {
7476 bool result = true; 7471 bool result = true;
7477 if (function->shared()->is_compiled()) { 7472 if (function->shared()->is_compiled()) {
7478 function->ReplaceCode(function->shared()->code()); 7473 function->ReplaceCode(function->shared()->code());
7479 function->shared()->set_code_age(0); 7474 function->shared()->set_code_age(0);
7480 } else { 7475 } else {
7476 ASSERT(function->shared()->allows_lazy_compilation());
7481 CompilationInfo info(function); 7477 CompilationInfo info(function);
7482 result = CompileLazyHelper(&info, flag); 7478 result = CompileLazyHelper(&info, flag);
7483 ASSERT(!result || function->is_compiled()); 7479 ASSERT(!result || function->is_compiled());
7484 } 7480 }
7485 return result; 7481 return result;
7486 } 7482 }
7487 7483
7488 7484
7489 bool JSFunction::CompileOptimized(Handle<JSFunction> function, 7485 bool JSFunction::CompileOptimized(Handle<JSFunction> function,
7490 int osr_ast_id, 7486 int osr_ast_id,
7491 ClearExceptionFlag flag) { 7487 ClearExceptionFlag flag) {
7492 CompilationInfo info(function); 7488 CompilationInfo info(function);
7493 info.SetOptimizing(osr_ast_id); 7489 info.SetOptimizing(osr_ast_id);
7494 return CompileLazyHelper(&info, flag); 7490 return CompileLazyHelper(&info, flag);
7495 } 7491 }
7496 7492
7497 7493
7494 bool JSFunction::EnsureCompiled(Handle<JSFunction> function,
7495 ClearExceptionFlag flag) {
7496 return function->is_compiled() || CompileLazy(function, flag);
7497 }
7498
7499
7498 bool JSFunction::IsInlineable() { 7500 bool JSFunction::IsInlineable() {
7499 if (IsBuiltin()) return false; 7501 if (IsBuiltin()) return false;
7500 SharedFunctionInfo* shared_info = shared(); 7502 SharedFunctionInfo* shared_info = shared();
7501 // Check that the function has a script associated with it. 7503 // Check that the function has a script associated with it.
7502 if (!shared_info->script()->IsScript()) return false; 7504 if (!shared_info->script()->IsScript()) return false;
7503 if (shared_info->optimization_disabled()) return false; 7505 if (shared_info->optimization_disabled()) return false;
7504 Code* code = shared_info->code(); 7506 Code* code = shared_info->code();
7505 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true; 7507 if (code->kind() == Code::OPTIMIZED_FUNCTION) return true;
7506 // If we never ran this (unlikely) then lets try to optimize it. 7508 // If we never ran this (unlikely) then lets try to optimize it.
7507 if (code->kind() != Code::FUNCTION) return true; 7509 if (code->kind() != Code::FUNCTION) return true;
(...skipping 5697 matching lines...) Expand 10 before | Expand all | Expand 10 after
13205 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13207 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13206 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13208 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13207 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13209 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13208 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13210 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13209 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13211 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13210 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13212 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13211 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13213 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13212 } 13214 }
13213 13215
13214 } } // namespace v8::internal 13216 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698