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

Side by Side Diff: runtime/vm/compiler.cc

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 if (osr_id != kNoOSRDeoptId) { 1445 if (osr_id != kNoOSRDeoptId) {
1446 event_name = "CompileFunctionOptimizedOSR"; 1446 event_name = "CompileFunctionOptimizedOSR";
1447 } else if (IsBackgroundCompilation()) { 1447 } else if (IsBackgroundCompilation()) {
1448 event_name = "CompileFunctionOptimizedBackground"; 1448 event_name = "CompileFunctionOptimizedBackground";
1449 } else { 1449 } else {
1450 event_name = "CompileFunctionOptimized"; 1450 event_name = "CompileFunctionOptimized";
1451 } 1451 }
1452 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, event_name, function); 1452 TIMELINE_FUNCTION_COMPILATION_DURATION(thread, event_name, function);
1453 ) // !PRODUCT 1453 ) // !PRODUCT
1454 1454
1455 // Optimization must happen in non-mutator/Dart thread if background 1455 // If we are in the optimizing in the mutator/Dart thread, then
1456 // compilation is on. OSR compilation still occurs in the main thread. 1456 // this is either an OSR compilation or background compilation is
1457 ASSERT((osr_id != kNoOSRDeoptId) || !FLAG_background_compilation || 1457 // not currently allowed.
1458 !thread->IsMutatorThread()); 1458 ASSERT(!thread->IsMutatorThread() ||
1459 (osr_id != kNoOSRDeoptId) ||
1460 !FLAG_background_compilation || BackgroundCompiler::IsDisabled());
1459 CompilationPipeline* pipeline = 1461 CompilationPipeline* pipeline =
1460 CompilationPipeline::New(thread->zone(), function); 1462 CompilationPipeline::New(thread->zone(), function);
1461 return CompileFunctionHelper(pipeline, 1463 return CompileFunctionHelper(pipeline,
1462 function, 1464 function,
1463 true, /* optimized */ 1465 true, /* optimized */
1464 osr_id); 1466 osr_id);
1465 } 1467 }
1466 1468
1467 1469
1468 // This is only used from unit tests. 1470 // This is only used from unit tests.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 #ifdef DART_PRECOMPILER 1558 #ifdef DART_PRECOMPILER
1557 if (FLAG_precompiled_mode) { 1559 if (FLAG_precompiled_mode) {
1558 return Precompiler::EvaluateStaticInitializer(field); 1560 return Precompiler::EvaluateStaticInitializer(field);
1559 } 1561 }
1560 #endif 1562 #endif
1561 ASSERT(field.is_static()); 1563 ASSERT(field.is_static());
1562 // The VM sets the field's value to transiton_sentinel prior to 1564 // The VM sets the field's value to transiton_sentinel prior to
1563 // evaluating the initializer value. 1565 // evaluating the initializer value.
1564 ASSERT(field.StaticValue() == Object::transition_sentinel().raw()); 1566 ASSERT(field.StaticValue() == Object::transition_sentinel().raw());
1565 LongJumpScope jump; 1567 LongJumpScope jump;
1568 Thread* thread = Thread::Current();
1566 if (setjmp(*jump.Set()) == 0) { 1569 if (setjmp(*jump.Set()) == 0) {
1570 NoOOBMessageScope no_msg_scope(thread);
1571 NoReloadScope no_reload_scope(thread->isolate(), thread);
1567 // Under lazy compilation initializer has not yet been created, so create 1572 // Under lazy compilation initializer has not yet been created, so create
1568 // it now, but don't bother remembering it because it won't be used again. 1573 // it now, but don't bother remembering it because it won't be used again.
1569 ASSERT(!field.HasPrecompiledInitializer()); 1574 ASSERT(!field.HasPrecompiledInitializer());
1570 Thread* const thread = Thread::Current(); 1575 Thread* const thread = Thread::Current();
1571 StackZone zone(thread); 1576 StackZone zone(thread);
1572 ParsedFunction* parsed_function = 1577 ParsedFunction* parsed_function =
1573 Parser::ParseStaticFieldInitializer(field); 1578 Parser::ParseStaticFieldInitializer(field);
1574 1579
1575 parsed_function->AllocateVariables(); 1580 parsed_function->AllocateVariables();
1576 // Non-optimized code generator. 1581 // Non-optimized code generator.
(...skipping 25 matching lines...) Expand all
1602 return Precompiler::ExecuteOnce(fragment); 1607 return Precompiler::ExecuteOnce(fragment);
1603 } 1608 }
1604 #endif 1609 #endif
1605 LongJumpScope jump; 1610 LongJumpScope jump;
1606 if (setjmp(*jump.Set()) == 0) { 1611 if (setjmp(*jump.Set()) == 0) {
1607 Thread* const thread = Thread::Current(); 1612 Thread* const thread = Thread::Current();
1608 1613
1609 // Don't allow message interrupts while executing constant 1614 // Don't allow message interrupts while executing constant
1610 // expressions. They can cause bogus recursive compilation. 1615 // expressions. They can cause bogus recursive compilation.
1611 NoOOBMessageScope no_msg_scope(thread); 1616 NoOOBMessageScope no_msg_scope(thread);
1617
1618 // Don't allow reload requests to come in.
1619 NoReloadScope no_reload_scope(thread->isolate(), thread);
1620
1612 if (FLAG_trace_compiler) { 1621 if (FLAG_trace_compiler) {
1613 THR_Print("compiling expression: "); 1622 THR_Print("compiling expression: ");
1614 if (FLAG_support_ast_printer) { 1623 if (FLAG_support_ast_printer) {
1615 AstPrinter::PrintNode(fragment); 1624 AstPrinter::PrintNode(fragment);
1616 } 1625 }
1617 } 1626 }
1618 1627
1619 // Create a dummy function object for the code generator. 1628 // Create a dummy function object for the code generator.
1620 // The function needs to be associated with a named Class: the interface 1629 // The function needs to be associated with a named Class: the interface
1621 // Function fits the bill. 1630 // Function fits the bill.
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 } 1965 }
1957 } 1966 }
1958 delete task_done; 1967 delete task_done;
1959 delete done_monitor; 1968 delete done_monitor;
1960 delete queue_monitor; 1969 delete queue_monitor;
1961 delete function_queue; 1970 delete function_queue;
1962 isolate->set_background_compiler(NULL); 1971 isolate->set_background_compiler(NULL);
1963 } 1972 }
1964 1973
1965 1974
1975 void BackgroundCompiler::Disable() {
1976 Thread* thread = Thread::Current();
1977 ASSERT(thread != NULL);
1978 Isolate* isolate = thread->isolate();
1979 MutexLocker ml(isolate->mutex());
1980 BackgroundCompiler* task = isolate->background_compiler();
1981 if (task != NULL) {
1982 // We should only ever have to stop the task if this is the first call to
1983 // Disable.
1984 ASSERT(!isolate->is_background_compiler_disabled());
1985 BackgroundCompiler::Stop(isolate);
1986 }
1987 ASSERT(isolate->background_compiler() == NULL);
1988 isolate->disable_background_compiler();
1989 }
1990
1991
1992 bool BackgroundCompiler::IsDisabled() {
1993 Thread* thread = Thread::Current();
1994 ASSERT(thread != NULL);
1995 Isolate* isolate = thread->isolate();
1996 MutexLocker ml(isolate->mutex());
1997 return isolate->is_background_compiler_disabled();
1998 }
1999
2000
2001 void BackgroundCompiler::Enable() {
2002 Thread* thread = Thread::Current();
2003 ASSERT(thread != NULL);
2004 Isolate* isolate = thread->isolate();
2005 MutexLocker ml(isolate->mutex());
2006 isolate->enable_background_compiler();
2007 }
2008
2009
1966 void BackgroundCompiler::EnsureInit(Thread* thread) { 2010 void BackgroundCompiler::EnsureInit(Thread* thread) {
1967 ASSERT(thread->IsMutatorThread()); 2011 ASSERT(thread->IsMutatorThread());
1968 // Finalize NoSuchMethodError, _Mint; occasionally needed in optimized 2012 // Finalize NoSuchMethodError, _Mint; occasionally needed in optimized
1969 // compilation. 2013 // compilation.
1970 Class& cls = Class::Handle(thread->zone(), 2014 Class& cls = Class::Handle(thread->zone(),
1971 Library::LookupCoreClass(Symbols::NoSuchMethodError())); 2015 Library::LookupCoreClass(Symbols::NoSuchMethodError()));
1972 ASSERT(!cls.IsNull()); 2016 ASSERT(!cls.IsNull());
1973 Error& error = Error::Handle(thread->zone(), 2017 Error& error = Error::Handle(thread->zone(),
1974 cls.EnsureIsFinalized(thread)); 2018 cls.EnsureIsFinalized(thread));
1975 ASSERT(error.IsNull()); 2019 ASSERT(error.IsNull());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 2151
2108 void BackgroundCompiler::Stop(Isolate* isolate) { 2152 void BackgroundCompiler::Stop(Isolate* isolate) {
2109 UNREACHABLE(); 2153 UNREACHABLE();
2110 } 2154 }
2111 2155
2112 2156
2113 void BackgroundCompiler::EnsureInit(Thread* thread) { 2157 void BackgroundCompiler::EnsureInit(Thread* thread) {
2114 UNREACHABLE(); 2158 UNREACHABLE();
2115 } 2159 }
2116 2160
2161
2162 void BackgroundCompiler::Disable() {
2163 UNREACHABLE();
2164 }
2165
2166
2167 void BackgroundCompiler::Enable() {
2168 UNREACHABLE();
2169 }
2170
2171
2172 bool BackgroundCompiler::IsDisabled() {
2173 UNREACHABLE();
2174 return true;
2175 }
2176
2117 #endif // DART_PRECOMPILED_RUNTIME 2177 #endif // DART_PRECOMPILED_RUNTIME
2118 2178
2119 } // namespace dart 2179 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698