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

Side by Side Diff: src/compiler.cc

Issue 10990076: Short term JSON eval cache Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 2 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
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 if (!info->shared_info().is_null()) { 418 if (!info->shared_info().is_null()) {
419 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), 419 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(),
420 info->zone()); 420 info->zone());
421 info->shared_info()->set_scope_info(*scope_info); 421 info->shared_info()->set_scope_info(*scope_info);
422 } 422 }
423 return succeeded; 423 return succeeded;
424 } 424 }
425 #endif 425 #endif
426 426
427 427
428 static bool IsCacheableJSONEval(FunctionLiteral* function) {
429 if (!FLAG_json_eval_cache ||
430 function->body()->length() != 1)
431 return false;
432 ExpressionStatement* body = function->body()->at(0)->AsExpressionStatement();
433 if (body == NULL) return false;
434 bool is_json = CompileTimeValue::IsCompileTimeValue(body->expression());
435 return is_json;
436 }
437
438
428 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { 439 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
429 Isolate* isolate = info->isolate(); 440 Isolate* isolate = info->isolate();
430 ZoneScope zone_scope(info->zone(), DELETE_ON_EXIT); 441 ZoneScope zone_scope(info->zone(), DELETE_ON_EXIT);
431 PostponeInterruptsScope postpone(isolate); 442 PostponeInterruptsScope postpone(isolate);
432 443
433 ASSERT(!isolate->native_context().is_null()); 444 ASSERT(!isolate->native_context().is_null());
434 Handle<Script> script = info->script(); 445 Handle<Script> script = info->script();
435 script->set_context_data((*isolate->native_context())->data()); 446 script->set_context_data((*isolate->native_context())->data());
436 447
437 #ifdef ENABLE_DEBUGGER_SUPPORT 448 #ifdef ENABLE_DEBUGGER_SUPPORT
(...skipping 22 matching lines...) Expand all
460 // Only allow non-global compiles for eval. 471 // Only allow non-global compiles for eval.
461 ASSERT(info->is_eval() || info->is_global()); 472 ASSERT(info->is_eval() || info->is_global());
462 ParsingFlags flags = kNoParsingFlags; 473 ParsingFlags flags = kNoParsingFlags;
463 if (info->pre_parse_data() != NULL || 474 if (info->pre_parse_data() != NULL ||
464 String::cast(script->source())->length() > FLAG_min_preparse_length) { 475 String::cast(script->source())->length() > FLAG_min_preparse_length) {
465 flags = kAllowLazy; 476 flags = kAllowLazy;
466 } 477 }
467 if (!ParserApi::Parse(info, flags)) { 478 if (!ParserApi::Parse(info, flags)) {
468 return Handle<SharedFunctionInfo>::null(); 479 return Handle<SharedFunctionInfo>::null();
469 } 480 }
481 bool is_json_eval = info->is_eval() && IsCacheableJSONEval(info->function());
470 482
471 // Measure how long it takes to do the compilation; only take the 483 // Measure how long it takes to do the compilation; only take the
472 // rest of the function into account to avoid overlap with the 484 // rest of the function into account to avoid overlap with the
473 // parsing statistics. 485 // parsing statistics.
474 HistogramTimer* rate = info->is_eval() 486 HistogramTimer* rate = info->is_eval()
475 ? info->isolate()->counters()->compile_eval() 487 ? info->isolate()->counters()->compile_eval()
476 : info->isolate()->counters()->compile(); 488 : info->isolate()->counters()->compile();
477 HistogramTimerScope timer(rate); 489 HistogramTimerScope timer(rate);
478 490
479 // Compile the code. 491 // Compile the code.
480 FunctionLiteral* lit = info->function(); 492 FunctionLiteral* lit = info->function();
481 LiveEditFunctionTracker live_edit_tracker(isolate, lit); 493 LiveEditFunctionTracker live_edit_tracker(isolate, lit);
482 if (!MakeCode(info)) { 494 if (!MakeCode(info)) {
483 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 495 if (!isolate->has_pending_exception()) isolate->StackOverflow();
484 return Handle<SharedFunctionInfo>::null(); 496 return Handle<SharedFunctionInfo>::null();
485 } 497 }
486 498
487 // Allocate function. 499 // Allocate function.
488 ASSERT(!info->code().is_null()); 500 ASSERT(!info->code().is_null());
489 Handle<SharedFunctionInfo> result = 501 Handle<SharedFunctionInfo> result =
490 isolate->factory()->NewSharedFunctionInfo( 502 isolate->factory()->NewSharedFunctionInfo(
491 lit->name(), 503 lit->name(),
492 lit->materialized_literal_count(), 504 lit->materialized_literal_count(),
493 info->code(), 505 info->code(),
494 ScopeInfo::Create(info->scope(), info->zone())); 506 ScopeInfo::Create(info->scope(), info->zone()));
507 if (is_json_eval) {
508 result->set_is_json_eval(true);
509 }
495 510
496 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 511 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
497 Compiler::SetFunctionInfo(result, lit, true, script); 512 Compiler::SetFunctionInfo(result, lit, true, script);
498 513
499 if (script->name()->IsString()) { 514 if (script->name()->IsString()) {
500 PROFILE(isolate, CodeCreateEvent( 515 PROFILE(isolate, CodeCreateEvent(
501 info->is_eval() 516 info->is_eval()
502 ? Logger::EVAL_TAG 517 ? Logger::EVAL_TAG
503 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), 518 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
504 *info->code(), 519 *info->code(),
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 } 1062 }
1048 } 1063 }
1049 1064
1050 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 1065 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
1051 Handle<Script>(info->script()), 1066 Handle<Script>(info->script()),
1052 Handle<Code>(info->code()), 1067 Handle<Code>(info->code()),
1053 info)); 1068 info));
1054 } 1069 }
1055 1070
1056 } } // namespace v8::internal 1071 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compilation-cache.cc ('k') | src/flag-definitions.h » ('j') | src/v8.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698