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

Side by Side Diff: src/compiler.cc

Issue 10534006: Remove TLS access for current Zone. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review. 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/ast.cc ('k') | src/deoptimizer.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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 ASSERT(FLAG_always_opt || code->optimizable()); 287 ASSERT(FLAG_always_opt || code->optimizable());
288 ASSERT(info->shared_info()->has_deoptimization_support()); 288 ASSERT(info->shared_info()->has_deoptimization_support());
289 289
290 if (FLAG_trace_hydrogen) { 290 if (FLAG_trace_hydrogen) {
291 PrintF("-----------------------------------------------------------\n"); 291 PrintF("-----------------------------------------------------------\n");
292 PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); 292 PrintF("Compiling method %s using hydrogen\n", *name->ToCString());
293 HTracer::Instance()->TraceCompilation(info->function()); 293 HTracer::Instance()->TraceCompilation(info->function());
294 } 294 }
295 295
296 Handle<Context> global_context(info->closure()->context()->global_context()); 296 Handle<Context> global_context(info->closure()->context()->global_context());
297 TypeFeedbackOracle oracle(code, global_context, info->isolate()); 297 TypeFeedbackOracle oracle(code, global_context, info->isolate(),
298 HGraphBuilder builder(info, &oracle); 298 info->isolate()->zone());
299 HGraphBuilder builder(info, &oracle, info->isolate()->zone());
299 HPhase phase(HPhase::kTotal); 300 HPhase phase(HPhase::kTotal);
300 HGraph* graph = builder.CreateGraph(); 301 HGraph* graph = builder.CreateGraph();
301 if (info->isolate()->has_pending_exception()) { 302 if (info->isolate()->has_pending_exception()) {
302 info->SetCode(Handle<Code>::null()); 303 info->SetCode(Handle<Code>::null());
303 return false; 304 return false;
304 } 305 }
305 306
306 if (graph != NULL) { 307 if (graph != NULL) {
307 Handle<Code> optimized_code = graph->Compile(info, graph->zone()); 308 Handle<Code> optimized_code = graph->Compile(info, graph->zone());
308 if (!optimized_code.is_null()) { 309 if (!optimized_code.is_null()) {
(...skipping 30 matching lines...) Expand all
339 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info); 340 return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info);
340 } 341 }
341 342
342 343
343 #ifdef ENABLE_DEBUGGER_SUPPORT 344 #ifdef ENABLE_DEBUGGER_SUPPORT
344 bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) { 345 bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) {
345 // Precondition: code has been parsed. Postcondition: the code field in 346 // Precondition: code has been parsed. Postcondition: the code field in
346 // the compilation info is set if compilation succeeded. 347 // the compilation info is set if compilation succeeded.
347 bool succeeded = MakeCode(info); 348 bool succeeded = MakeCode(info);
348 if (!info->shared_info().is_null()) { 349 if (!info->shared_info().is_null()) {
349 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope()); 350 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(),
351 info->isolate()->zone());
350 info->shared_info()->set_scope_info(*scope_info); 352 info->shared_info()->set_scope_info(*scope_info);
351 } 353 }
352 return succeeded; 354 return succeeded;
353 } 355 }
354 #endif 356 #endif
355 357
356 358
357 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) { 359 static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
358 Isolate* isolate = info->isolate(); 360 Isolate* isolate = info->isolate();
359 ZoneScope zone_scope(isolate, DELETE_ON_EXIT); 361 ZoneScope zone_scope(isolate, DELETE_ON_EXIT);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return Handle<SharedFunctionInfo>::null(); 415 return Handle<SharedFunctionInfo>::null();
414 } 416 }
415 417
416 // Allocate function. 418 // Allocate function.
417 ASSERT(!info->code().is_null()); 419 ASSERT(!info->code().is_null());
418 Handle<SharedFunctionInfo> result = 420 Handle<SharedFunctionInfo> result =
419 isolate->factory()->NewSharedFunctionInfo( 421 isolate->factory()->NewSharedFunctionInfo(
420 lit->name(), 422 lit->name(),
421 lit->materialized_literal_count(), 423 lit->materialized_literal_count(),
422 info->code(), 424 info->code(),
423 ScopeInfo::Create(info->scope())); 425 ScopeInfo::Create(info->scope(), info->isolate()->zone()));
424 426
425 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 427 ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
426 Compiler::SetFunctionInfo(result, lit, true, script); 428 Compiler::SetFunctionInfo(result, lit, true, script);
427 429
428 if (script->name()->IsString()) { 430 if (script->name()->IsString()) {
429 PROFILE(isolate, CodeCreateEvent( 431 PROFILE(isolate, CodeCreateEvent(
430 info->is_eval() 432 info->is_eval()
431 ? Logger::EVAL_TAG 433 ? Logger::EVAL_TAG
432 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script), 434 : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
433 *info->code(), 435 *info->code(),
(...skipping 21 matching lines...) Expand all
455 457
456 script->set_compilation_state( 458 script->set_compilation_state(
457 Smi::FromInt(Script::COMPILATION_STATE_COMPILED)); 459 Smi::FromInt(Script::COMPILATION_STATE_COMPILED));
458 460
459 #ifdef ENABLE_DEBUGGER_SUPPORT 461 #ifdef ENABLE_DEBUGGER_SUPPORT
460 // Notify debugger 462 // Notify debugger
461 isolate->debugger()->OnAfterCompile( 463 isolate->debugger()->OnAfterCompile(
462 script, Debugger::NO_AFTER_COMPILE_FLAGS); 464 script, Debugger::NO_AFTER_COMPILE_FLAGS);
463 #endif 465 #endif
464 466
465 live_edit_tracker.RecordFunctionInfo(result, lit); 467 live_edit_tracker.RecordFunctionInfo(result, lit, isolate->zone());
466 468
467 return result; 469 return result;
468 } 470 }
469 471
470 472
471 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source, 473 Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
472 Handle<Object> script_name, 474 Handle<Object> script_name,
473 int line_offset, 475 int line_offset,
474 int column_offset, 476 int column_offset,
475 v8::Extension* extension, 477 v8::Extension* extension,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 646
645 if (info->IsOptimizing()) { 647 if (info->IsOptimizing()) {
646 ASSERT(shared->scope_info() != ScopeInfo::Empty()); 648 ASSERT(shared->scope_info() != ScopeInfo::Empty());
647 function->ReplaceCode(*code); 649 function->ReplaceCode(*code);
648 } else { 650 } else {
649 // Update the shared function info with the compiled code and the 651 // Update the shared function info with the compiled code and the
650 // scope info. Please note, that the order of the shared function 652 // scope info. Please note, that the order of the shared function
651 // info initialization is important since set_scope_info might 653 // info initialization is important since set_scope_info might
652 // trigger a GC, causing the ASSERT below to be invalid if the code 654 // trigger a GC, causing the ASSERT below to be invalid if the code
653 // was flushed. By setting the code object last we avoid this. 655 // was flushed. By setting the code object last we avoid this.
654 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope()); 656 Handle<ScopeInfo> scope_info =
657 ScopeInfo::Create(info->scope(), info->isolate()->zone());
655 shared->set_scope_info(*scope_info); 658 shared->set_scope_info(*scope_info);
656 shared->set_code(*code); 659 shared->set_code(*code);
657 if (!function.is_null()) { 660 if (!function.is_null()) {
658 function->ReplaceCode(*code); 661 function->ReplaceCode(*code);
659 ASSERT(!function->IsOptimized()); 662 ASSERT(!function->IsOptimized());
660 } 663 }
661 664
662 // Set the expected number of properties for instances. 665 // Set the expected number of properties for instances.
663 FunctionLiteral* lit = info->function(); 666 FunctionLiteral* lit = info->function();
664 int expected = lit->expected_property_count(); 667 int expected = lit->expected_property_count();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 724
722 Handle<ScopeInfo> scope_info(ScopeInfo::Empty()); 725 Handle<ScopeInfo> scope_info(ScopeInfo::Empty());
723 726
724 // Generate code 727 // Generate code
725 if (FLAG_lazy && allow_lazy) { 728 if (FLAG_lazy && allow_lazy) {
726 Handle<Code> code = info.isolate()->builtins()->LazyCompile(); 729 Handle<Code> code = info.isolate()->builtins()->LazyCompile();
727 info.SetCode(code); 730 info.SetCode(code);
728 } else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) || 731 } else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) ||
729 (!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) { 732 (!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) {
730 ASSERT(!info.code().is_null()); 733 ASSERT(!info.code().is_null());
731 scope_info = ScopeInfo::Create(info.scope()); 734 scope_info = ScopeInfo::Create(info.scope(), info.isolate()->zone());
732 } else { 735 } else {
733 return Handle<SharedFunctionInfo>::null(); 736 return Handle<SharedFunctionInfo>::null();
734 } 737 }
735 738
736 // Create a shared function info object. 739 // Create a shared function info object.
737 Handle<SharedFunctionInfo> result = 740 Handle<SharedFunctionInfo> result =
738 FACTORY->NewSharedFunctionInfo(literal->name(), 741 FACTORY->NewSharedFunctionInfo(literal->name(),
739 literal->materialized_literal_count(), 742 literal->materialized_literal_count(),
740 info.code(), 743 info.code(),
741 scope_info); 744 scope_info);
742 SetFunctionInfo(result, literal, false, script); 745 SetFunctionInfo(result, literal, false, script);
743 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result); 746 RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
744 result->set_allows_lazy_compilation(allow_lazy); 747 result->set_allows_lazy_compilation(allow_lazy);
745 748
746 // Set the expected number of properties for instances and return 749 // Set the expected number of properties for instances and return
747 // the resulting function. 750 // the resulting function.
748 SetExpectedNofPropertiesFromEstimate(result, 751 SetExpectedNofPropertiesFromEstimate(result,
749 literal->expected_property_count()); 752 literal->expected_property_count());
750 live_edit_tracker.RecordFunctionInfo(result, literal); 753 live_edit_tracker.RecordFunctionInfo(result, literal, info.isolate()->zone());
751 return result; 754 return result;
752 } 755 }
753 756
754 757
755 // Sets the function info on a function. 758 // Sets the function info on a function.
756 // The start_position points to the first '(' character after the function name 759 // The start_position points to the first '(' character after the function name
757 // in the full script source. When counting characters in the script source the 760 // in the full script source. When counting characters in the script source the
758 // the first character is number 0 (not 1). 761 // the first character is number 0 (not 1).
759 void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info, 762 void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
760 FunctionLiteral* lit, 763 FunctionLiteral* lit,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 820 }
818 } 821 }
819 822
820 GDBJIT(AddCode(Handle<String>(shared->DebugName()), 823 GDBJIT(AddCode(Handle<String>(shared->DebugName()),
821 Handle<Script>(info->script()), 824 Handle<Script>(info->script()),
822 Handle<Code>(info->code()), 825 Handle<Code>(info->code()),
823 info)); 826 info));
824 } 827 }
825 828
826 } } // namespace v8::internal 829 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/deoptimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698