| OLD | NEW |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return builder.BuildGraph(); | 103 return builder.BuildGraph(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual void FinalizeCompilation() { } | 106 virtual void FinalizeCompilation() { } |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 | 109 |
| 110 class IrregexpCompilationPipeline : public DefaultCompilationPipeline { | 110 class IrregexpCompilationPipeline : public DefaultCompilationPipeline { |
| 111 public: | 111 public: |
| 112 explicit IrregexpCompilationPipeline(Isolate* isolate) | 112 explicit IrregexpCompilationPipeline(Isolate* isolate) |
| 113 : macro_assembler_(NULL), | 113 : backtrack_goto_(NULL), |
| 114 isolate_(isolate) { } | 114 isolate_(isolate) { } |
| 115 | 115 |
| 116 virtual void ParseFunction(ParsedFunction* parsed_function) { | 116 virtual void ParseFunction(ParsedFunction* parsed_function) { |
| 117 RegExpParser::ParseFunction(parsed_function); | 117 RegExpParser::ParseFunction(parsed_function); |
| 118 // Variables are allocated after compilation. | 118 // Variables are allocated after compilation. |
| 119 } | 119 } |
| 120 | 120 |
| 121 virtual FlowGraph* BuildFlowGraph( | 121 virtual FlowGraph* BuildFlowGraph( |
| 122 ParsedFunction* parsed_function, | 122 ParsedFunction* parsed_function, |
| 123 const ZoneGrowableArray<const ICData*>& ic_data_array, | 123 const ZoneGrowableArray<const ICData*>& ic_data_array, |
| 124 intptr_t osr_id) { | 124 intptr_t osr_id) { |
| 125 // Compile to the dart IR. | 125 // Compile to the dart IR. |
| 126 RegExpEngine::CompilationResult result = | 126 RegExpEngine::CompilationResult result = |
| 127 RegExpEngine::Compile(parsed_function->regexp_compile_data(), | 127 RegExpEngine::Compile(parsed_function->regexp_compile_data(), |
| 128 parsed_function, | 128 parsed_function, |
| 129 ic_data_array); | 129 ic_data_array); |
| 130 macro_assembler_ = result.macro_assembler; | 130 backtrack_goto_ = result.backtrack_goto; |
| 131 | 131 |
| 132 // Allocate variables now that we know the number of locals. | 132 // Allocate variables now that we know the number of locals. |
| 133 parsed_function->AllocateIrregexpVariables(result.num_stack_locals); | 133 parsed_function->AllocateIrregexpVariables(result.num_stack_locals); |
| 134 | 134 |
| 135 // Build the flow graph. | 135 // Build the flow graph. |
| 136 FlowGraphBuilder builder(parsed_function, | 136 FlowGraphBuilder builder(parsed_function, |
| 137 ic_data_array, | 137 ic_data_array, |
| 138 NULL, // NULL = not inlining. | 138 NULL, // NULL = not inlining. |
| 139 osr_id); | 139 osr_id); |
| 140 | 140 |
| 141 return new(isolate_) FlowGraph(builder, | 141 return new(isolate_) FlowGraph(builder, |
| 142 result.graph_entry, | 142 result.graph_entry, |
| 143 result.num_blocks); | 143 result.num_blocks); |
| 144 } | 144 } |
| 145 | 145 |
| 146 virtual void FinalizeCompilation() { | 146 virtual void FinalizeCompilation() { |
| 147 macro_assembler_->FinalizeBlockOffsetTable(); | 147 backtrack_goto_->ComputeOffsetTable(isolate_); |
| 148 } | 148 } |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 IRRegExpMacroAssembler* macro_assembler_; | 151 IndirectGotoInstr* backtrack_goto_; |
| 152 Isolate* isolate_; | 152 Isolate* isolate_; |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 CompilationPipeline* CompilationPipeline::New(Isolate* isolate, | 155 CompilationPipeline* CompilationPipeline::New(Isolate* isolate, |
| 156 const Function& function) { | 156 const Function& function) { |
| 157 if (function.IsIrregexpFunction()) { | 157 if (function.IsIrregexpFunction()) { |
| 158 return new(isolate) IrregexpCompilationPipeline(isolate); | 158 return new(isolate) IrregexpCompilationPipeline(isolate); |
| 159 } else { | 159 } else { |
| 160 return new(isolate) DefaultCompilationPipeline(); | 160 return new(isolate) DefaultCompilationPipeline(); |
| 161 } | 161 } |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 const Object& result = | 1175 const Object& result = |
| 1176 PassiveObject::Handle(isolate->object_store()->sticky_error()); | 1176 PassiveObject::Handle(isolate->object_store()->sticky_error()); |
| 1177 isolate->object_store()->clear_sticky_error(); | 1177 isolate->object_store()->clear_sticky_error(); |
| 1178 return result.raw(); | 1178 return result.raw(); |
| 1179 } | 1179 } |
| 1180 UNREACHABLE(); | 1180 UNREACHABLE(); |
| 1181 return Object::null(); | 1181 return Object::null(); |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 } // namespace dart | 1184 } // namespace dart |
| OLD | NEW |