Commit 6ce4b106 authored by ager@chromium.org's avatar ager@chromium.org

Re-enable all declarations in fast top-level compiler.

Disable fast top-level compiler for now because of issues 525 and 526.

Add regression test for issue 525.

Review URL: http://codereview.chromium.org/438017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3348 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f6a5d422
...@@ -646,9 +646,8 @@ void CodeGenSelector::VisitStatements(ZoneList<Statement*>* stmts) { ...@@ -646,9 +646,8 @@ void CodeGenSelector::VisitStatements(ZoneList<Statement*>* stmts) {
void CodeGenSelector::VisitDeclaration(Declaration* decl) { void CodeGenSelector::VisitDeclaration(Declaration* decl) {
Variable* var = decl->proxy()->var(); if (decl->fun() != NULL) {
if (!var->is_global() || var->mode() == Variable::CONST) { ProcessExpression(decl->fun(), Expression::kValue);
BAILOUT("Non-global declaration");
} }
} }
......
...@@ -143,7 +143,7 @@ DEFINE_bool(debug_info, true, "add debug information to compiled functions") ...@@ -143,7 +143,7 @@ DEFINE_bool(debug_info, true, "add debug information to compiled functions")
DEFINE_bool(strict, false, "strict error checking") DEFINE_bool(strict, false, "strict error checking")
DEFINE_int(min_preparse_length, 1024, DEFINE_int(min_preparse_length, 1024,
"minimum length for automatic enable preparsing") "minimum length for automatic enable preparsing")
DEFINE_bool(fast_compiler, true, DEFINE_bool(fast_compiler, false,
"use the fast-mode compiler for some top-level code") "use the fast-mode compiler for some top-level code")
DEFINE_bool(trace_bailout, false, DEFINE_bool(trace_bailout, false,
"print reasons for failing to use fast compilation") "print reasons for failing to use fast compilation")
......
...@@ -82,14 +82,30 @@ v8::Handle<v8::Value> DoLoop(const v8::Arguments& args) { ...@@ -82,14 +82,30 @@ v8::Handle<v8::Value> DoLoop(const v8::Arguments& args) {
} }
v8::Handle<v8::Value> DoLoopNoCall(const v8::Arguments& args) {
v8::TryCatch try_catch;
v8::Script::Compile(v8::String::New("var term = true;"
"while(true) {"
" if (term) terminate();"
" term = false;"
"}"))->Run();
CHECK(try_catch.HasCaught());
CHECK(try_catch.Exception()->IsNull());
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
return v8::Undefined();
}
v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate( v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
v8::InvocationCallback terminate) { v8::InvocationCallback terminate,
v8::InvocationCallback doloop) {
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::New("terminate"), global->Set(v8::String::New("terminate"),
v8::FunctionTemplate::New(terminate)); v8::FunctionTemplate::New(terminate));
global->Set(v8::String::New("fail"), v8::FunctionTemplate::New(Fail)); global->Set(v8::String::New("fail"), v8::FunctionTemplate::New(Fail));
global->Set(v8::String::New("loop"), v8::FunctionTemplate::New(Loop)); global->Set(v8::String::New("loop"), v8::FunctionTemplate::New(Loop));
global->Set(v8::String::New("doloop"), v8::FunctionTemplate::New(DoLoop)); global->Set(v8::String::New("doloop"), v8::FunctionTemplate::New(doloop));
return global; return global;
} }
...@@ -99,7 +115,25 @@ v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate( ...@@ -99,7 +115,25 @@ v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
TEST(TerminateOnlyV8ThreadFromThreadItself) { TEST(TerminateOnlyV8ThreadFromThreadItself) {
v8::HandleScope scope; v8::HandleScope scope;
v8::Handle<v8::ObjectTemplate> global = v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(TerminateCurrentThread); CreateGlobalTemplate(TerminateCurrentThread, DoLoop);
v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
v8::Context::Scope context_scope(context);
// Run a loop that will be infinite if thread termination does not work.
v8::Handle<v8::String> source =
v8::String::New("try { loop(); fail(); } catch(e) { fail(); }");
v8::Script::Compile(source)->Run();
// Test that we can run the code again after thread termination.
v8::Script::Compile(source)->Run();
context.Dispose();
}
// Test that a single thread of JavaScript execution can terminate
// itself in a loop that performs no calls.
TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) {
v8::HandleScope scope;
v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(TerminateCurrentThread, DoLoopNoCall);
v8::Persistent<v8::Context> context = v8::Context::New(NULL, global); v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
// Run a loop that will be infinite if thread termination does not work. // Run a loop that will be infinite if thread termination does not work.
...@@ -128,7 +162,7 @@ TEST(TerminateOnlyV8ThreadFromOtherThread) { ...@@ -128,7 +162,7 @@ TEST(TerminateOnlyV8ThreadFromOtherThread) {
thread.Start(); thread.Start();
v8::HandleScope scope; v8::HandleScope scope;
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(Signal); v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(Signal, DoLoop);
v8::Persistent<v8::Context> context = v8::Context::New(NULL, global); v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
// Run a loop that will be infinite if thread termination does not work. // Run a loop that will be infinite if thread termination does not work.
...@@ -149,7 +183,8 @@ class LoopingThread : public v8::internal::Thread { ...@@ -149,7 +183,8 @@ class LoopingThread : public v8::internal::Thread {
v8::Locker locker; v8::Locker locker;
v8::HandleScope scope; v8::HandleScope scope;
v8_thread_id_ = v8::V8::GetCurrentThreadId(); v8_thread_id_ = v8::V8::GetCurrentThreadId();
v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(Signal); v8::Handle<v8::ObjectTemplate> global =
CreateGlobalTemplate(Signal, DoLoop);
v8::Persistent<v8::Context> context = v8::Context::New(NULL, global); v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
v8::Context::Scope context_scope(context); v8::Context::Scope context_scope(context);
// Run a loop that will be infinite if thread termination does not work. // Run a loop that will be infinite if thread termination does not work.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment