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

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

Issue 9443002: Added LongJump for bailout. When trying to fix all crashes, CHECK_ALIVE did not scale well as bail… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 | « no previous file | runtime/vm/flow_graph_builder.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 (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 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_index_table.h" 10 #include "vm/code_index_table.h"
(...skipping 14 matching lines...) Expand all
25 25
26 namespace dart { 26 namespace dart {
27 27
28 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); 28 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code.");
29 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); 29 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations.");
30 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, 30 DEFINE_FLAG(int, deoptimization_counter_threshold, 5,
31 "How many times we allow deoptimization before we disallow" 31 "How many times we allow deoptimization before we disallow"
32 " certain optimizations"); 32 " certain optimizations");
33 DEFINE_FLAG(bool, use_new_compiler, false, 33 DEFINE_FLAG(bool, use_new_compiler, false,
34 "Try to use the new compiler backend."); 34 "Try to use the new compiler backend.");
35 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from new compiler.");
35 36
36 37
37 // Compile a function. Should call only if the function has not been compiled. 38 // Compile a function. Should call only if the function has not been compiled.
38 // Arg0: function object. 39 // Arg0: function object.
39 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { 40 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) {
40 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); 41 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count());
41 const Function& function = Function::CheckedHandle(arguments.At(0)); 42 const Function& function = Function::CheckedHandle(arguments.At(0));
42 ASSERT(!function.HasCode()); 43 ASSERT(!function.HasCode());
43 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 44 const Error& error = Error::Handle(Compiler::CompileFunction(function));
44 if (!error.IsNull()) { 45 if (!error.IsNull()) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 ParsedFunction parsed_function(function); 111 ParsedFunction parsed_function(function);
111 const char* function_fullname = function.ToFullyQualifiedCString(); 112 const char* function_fullname = function.ToFullyQualifiedCString();
112 if (FLAG_trace_compiler) { 113 if (FLAG_trace_compiler) {
113 OS::Print("Compiling %sfunction: '%s' @ token %d\n", 114 OS::Print("Compiling %sfunction: '%s' @ token %d\n",
114 (optimized ? "optimized " : ""), 115 (optimized ? "optimized " : ""),
115 function_fullname, 116 function_fullname,
116 function.token_index()); 117 function.token_index());
117 } 118 }
118 Parser::ParseFunction(&parsed_function); 119 Parser::ParseFunction(&parsed_function);
119 if (FLAG_use_new_compiler) { 120 if (FLAG_use_new_compiler) {
120 FlowGraphBuilder graph_builder(parsed_function); 121 LongJump* old_base = isolate->long_jump_base();
121 graph_builder.BuildGraph(); 122 LongJump bailout_jump;
123 isolate->set_long_jump_base(&bailout_jump);
124 if (setjmp(*bailout_jump.Set()) == 0) {
125 FlowGraphBuilder graph_builder(parsed_function);
126 graph_builder.BuildGraph();
127 } else {
128 // We bailed out.
129 Error& bailout_error = Error::Handle(
130 isolate->object_store()->sticky_error());
131 isolate->object_store()->clear_sticky_error();
132 if (FLAG_trace_bailout) {
133 OS::Print("%s\n", bailout_error.ToErrorCString());
134 }
135 }
136 isolate->set_long_jump_base(old_base);
122 // Currently, always fails and falls through to the old compiler. 137 // Currently, always fails and falls through to the old compiler.
123 } 138 }
124 CodeIndexTable* code_index_table = isolate->code_index_table(); 139 CodeIndexTable* code_index_table = isolate->code_index_table();
125 ASSERT(code_index_table != NULL); 140 ASSERT(code_index_table != NULL);
126 Assembler assembler; 141 Assembler assembler;
127 if (optimized) { 142 if (optimized) {
128 // Transition to optimized code only from unoptimized code ... for now. 143 // Transition to optimized code only from unoptimized code ... for now.
129 ASSERT(function.HasCode()); 144 ASSERT(function.HasCode());
130 ASSERT(!Code::Handle(function.code()).is_optimized()); 145 ASSERT(!Code::Handle(function.code()).is_optimized());
131 // Do not use type feedback to optimize a function that was deoptimized. 146 // Do not use type feedback to optimize a function that was deoptimized.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } else { 356 } else {
342 result = isolate->object_store()->sticky_error(); 357 result = isolate->object_store()->sticky_error();
343 isolate->object_store()->clear_sticky_error(); 358 isolate->object_store()->clear_sticky_error();
344 } 359 }
345 isolate->set_long_jump_base(base); 360 isolate->set_long_jump_base(base);
346 return result.raw(); 361 return result.raw();
347 } 362 }
348 363
349 364
350 } // namespace dart 365 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698