| Index: src/compiler.cc
|
| ===================================================================
|
| --- src/compiler.cc (revision 12582)
|
| +++ src/compiler.cc (working copy)
|
| @@ -425,6 +425,17 @@
|
| #endif
|
|
|
|
|
| +static bool IsCacheableJSONEval(FunctionLiteral* function) {
|
| + if (!FLAG_json_eval_cache ||
|
| + function->body()->length() != 1)
|
| + return false;
|
| + ExpressionStatement* body = function->body()->at(0)->AsExpressionStatement();
|
| + if (body == NULL) return false;
|
| + bool is_json = CompileTimeValue::IsCompileTimeValue(body->expression());
|
| + return is_json;
|
| +}
|
| +
|
| +
|
| static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
|
| Isolate* isolate = info->isolate();
|
| ZoneScope zone_scope(info->zone(), DELETE_ON_EXIT);
|
| @@ -467,6 +478,7 @@
|
| if (!ParserApi::Parse(info, flags)) {
|
| return Handle<SharedFunctionInfo>::null();
|
| }
|
| + bool is_json_eval = info->is_eval() && IsCacheableJSONEval(info->function());
|
|
|
| // Measure how long it takes to do the compilation; only take the
|
| // rest of the function into account to avoid overlap with the
|
| @@ -492,6 +504,9 @@
|
| lit->materialized_literal_count(),
|
| info->code(),
|
| ScopeInfo::Create(info->scope(), info->zone()));
|
| + if (is_json_eval) {
|
| + result->set_is_json_eval(true);
|
| + }
|
|
|
| ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
|
| Compiler::SetFunctionInfo(result, lit, true, script);
|
|
|