| Index: src/handles.cc
|
| diff --git a/src/handles.cc b/src/handles.cc
|
| index 1cec5f616c50ef1c6ee42d936c57f3f29d7d1943..b61a675bdb25000487398446bd49ceb1abcf9020 100644
|
| --- a/src/handles.cc
|
| +++ b/src/handles.cc
|
| @@ -39,6 +39,7 @@
|
| #include "runtime.h"
|
| #include "string-search.h"
|
| #include "stub-cache.h"
|
| +#include "vm-state-inl.h"
|
|
|
| namespace v8 {
|
| namespace internal {
|
| @@ -867,7 +868,7 @@ bool EnsureCompiled(Handle<SharedFunctionInfo> shared,
|
| static bool CompileLazyHelper(CompilationInfo* info,
|
| ClearExceptionFlag flag) {
|
| // Compile the source information to a code object.
|
| - ASSERT(!info->shared_info()->is_compiled());
|
| + ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled());
|
| bool result = Compiler::CompileLazy(info);
|
| ASSERT(result != Isolate::Current()->has_pending_exception());
|
| if (!result && flag == CLEAR_EXCEPTION) {
|
| @@ -886,36 +887,47 @@ bool CompileLazyShared(Handle<SharedFunctionInfo> shared,
|
|
|
| bool CompileLazy(Handle<JSFunction> function,
|
| ClearExceptionFlag flag) {
|
| + bool result = true;
|
| if (function->shared()->is_compiled()) {
|
| - function->set_code(function->shared()->code());
|
| - PROFILE(FunctionCreateEvent(*function));
|
| + function->ReplaceCode(function->shared()->code());
|
| function->shared()->set_code_age(0);
|
| - return true;
|
| } else {
|
| CompilationInfo info(function);
|
| - bool result = CompileLazyHelper(&info, flag);
|
| + result = CompileLazyHelper(&info, flag);
|
| ASSERT(!result || function->is_compiled());
|
| + }
|
| + if (result && function->is_compiled()) {
|
| PROFILE(FunctionCreateEvent(*function));
|
| - return result;
|
| }
|
| + return result;
|
| }
|
|
|
|
|
| bool CompileLazyInLoop(Handle<JSFunction> function,
|
| ClearExceptionFlag flag) {
|
| + bool result = true;
|
| if (function->shared()->is_compiled()) {
|
| - function->set_code(function->shared()->code());
|
| - PROFILE(FunctionCreateEvent(*function));
|
| + function->ReplaceCode(function->shared()->code());
|
| function->shared()->set_code_age(0);
|
| - return true;
|
| } else {
|
| CompilationInfo info(function);
|
| info.MarkAsInLoop();
|
| - bool result = CompileLazyHelper(&info, flag);
|
| + result = CompileLazyHelper(&info, flag);
|
| ASSERT(!result || function->is_compiled());
|
| + }
|
| + if (result && function->is_compiled()) {
|
| PROFILE(FunctionCreateEvent(*function));
|
| - return result;
|
| }
|
| + return result;
|
| +}
|
| +
|
| +
|
| +bool CompileOptimized(Handle<JSFunction> function, int osr_ast_id) {
|
| + CompilationInfo info(function);
|
| + info.SetOptimizing(osr_ast_id);
|
| + bool result = CompileLazyHelper(&info, KEEP_EXCEPTION);
|
| + if (result) PROFILE(FunctionCreateEvent(*function));
|
| + return result;
|
| }
|
|
|
|
|
|
|