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

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

Issue 1133633002: Eagerly create local var descriptors for artificially created methods (they cannot be regularly par… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('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 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 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 UNREACHABLE(); 1127 UNREACHABLE();
1128 return Error::null(); 1128 return Error::null();
1129 } 1129 }
1130 1130
1131 1131
1132 void Compiler::ComputeLocalVarDescriptors(const Code& code) { 1132 void Compiler::ComputeLocalVarDescriptors(const Code& code) {
1133 ASSERT(!code.is_optimized()); 1133 ASSERT(!code.is_optimized());
1134 const Function& function = Function::Handle(code.function()); 1134 const Function& function = Function::Handle(code.function());
1135 ParsedFunction* parsed_function = new ParsedFunction( 1135 ParsedFunction* parsed_function = new ParsedFunction(
1136 Thread::Current(), Function::ZoneHandle(function.raw())); 1136 Thread::Current(), Function::ZoneHandle(function.raw()));
1137 LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(); 1137 LocalVarDescriptors& var_descs =
1138 LocalVarDescriptors::Handle(code.var_descriptors());
1139 ASSERT(var_descs.IsNull());
hausner 2015/05/07 16:45:29 This would fail for regexp function, right? They h
srdjan 2015/05/07 18:57:55 This method should not be called if local var desc
1138 if (function.IsIrregexpFunction()) { 1140 if (function.IsIrregexpFunction()) {
1139 UNREACHABLE(); // Special parsing needed, not yet implemented. 1141 UNREACHABLE(); // Special parsing needed, not yet implemented.
1140 } else { 1142 } else {
1141 Parser::ParseFunction(parsed_function); 1143 LongJumpScope jump;
1142 parsed_function->AllocateVariables(); 1144 if (setjmp(*jump.Set()) == 0) {
1143 var_descs = 1145 Parser::ParseFunction(parsed_function);
1144 parsed_function->node_sequence()->scope()->GetVarDescriptors(function); 1146 parsed_function->AllocateVariables();
1147 var_descs = parsed_function->node_sequence()->scope()->
1148 GetVarDescriptors(function);
1149 } else {
1150 UNREACHABLE();
hausner 2015/05/07 16:45:29 Why is the setjmp needed if there is never an exce
srdjan 2015/05/07 18:57:55 Removed. Was useful for debugging as an error in P
1151 }
1145 } 1152 }
1146 code.set_var_descriptors(var_descs); 1153 code.set_var_descriptors(var_descs);
hausner 2015/05/07 16:45:29 ASSERT here that the computed var_descs are not nu
srdjan 2015/05/07 18:57:56 Done.
1147 } 1154 }
1148 1155
1149 1156
1150 RawError* Compiler::CompileAllFunctions(const Class& cls) { 1157 RawError* Compiler::CompileAllFunctions(const Class& cls) {
1151 Thread* thread = Thread::Current(); 1158 Thread* thread = Thread::Current();
1152 Zone* zone = thread->zone(); 1159 Zone* zone = thread->zone();
1153 Error& error = Error::Handle(zone); 1160 Error& error = Error::Handle(zone);
1154 Array& functions = Array::Handle(zone, cls.functions()); 1161 Array& functions = Array::Handle(zone, cls.functions());
1155 Function& func = Function::Handle(zone); 1162 Function& func = Function::Handle(zone);
1156 // Class dynamic lives in the vm isolate. Its array fields cannot be set to 1163 // Class dynamic lives in the vm isolate. Its array fields cannot be set to
(...skipping 30 matching lines...) Expand all
1187 return error.raw(); 1194 return error.raw();
1188 } 1195 }
1189 func.ClearCode(); 1196 func.ClearCode();
1190 } 1197 }
1191 } 1198 }
1192 } 1199 }
1193 return error.raw(); 1200 return error.raw();
1194 } 1201 }
1195 1202
1196 1203
1204 static void CreateLocalVarDescriptors(const ParsedFunction& parsed_function) {
1205 const Function& func = parsed_function.function();
1206 LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle();
1207 var_descs = parsed_function.node_sequence()->scope()->GetVarDescriptors(func);
1208 Code::Handle(func.unoptimized_code()).set_var_descriptors(var_descs);
1209 }
1210
1211
1197 RawObject* Compiler::EvaluateStaticInitializer(const Field& field) { 1212 RawObject* Compiler::EvaluateStaticInitializer(const Field& field) {
1198 ASSERT(field.is_static()); 1213 ASSERT(field.is_static());
1199 // The VM sets the field's value to transiton_sentinel prior to 1214 // The VM sets the field's value to transiton_sentinel prior to
1200 // evaluating the initializer value. 1215 // evaluating the initializer value.
1201 ASSERT(field.value() == Object::transition_sentinel().raw()); 1216 ASSERT(field.value() == Object::transition_sentinel().raw());
1202 LongJumpScope jump; 1217 LongJumpScope jump;
1203 if (setjmp(*jump.Set()) == 0) { 1218 if (setjmp(*jump.Set()) == 0) {
1204 Isolate* const isolate = Isolate::Current(); 1219 Isolate* const isolate = Isolate::Current();
1205 StackZone zone(isolate); 1220 StackZone zone(isolate);
1206 ParsedFunction* parsed_function = 1221 ParsedFunction* parsed_function =
1207 Parser::ParseStaticFieldInitializer(field); 1222 Parser::ParseStaticFieldInitializer(field);
1208 1223
1209 parsed_function->AllocateVariables(); 1224 parsed_function->AllocateVariables();
1210 // Non-optimized code generator. 1225 // Non-optimized code generator.
1211 DartCompilationPipeline pipeline; 1226 DartCompilationPipeline pipeline;
1212 CompileParsedFunctionHelper(&pipeline, 1227 CompileParsedFunctionHelper(&pipeline,
1213 parsed_function, 1228 parsed_function,
1214 false, 1229 false,
1215 Isolate::kNoDeoptId); 1230 Isolate::kNoDeoptId);
1231 // Eagerly create local var descriptors.
1232 CreateLocalVarDescriptors(*parsed_function);
1216 1233
1217 // Invoke the function to evaluate the expression. 1234 // Invoke the function to evaluate the expression.
1218 const Function& initializer = parsed_function->function(); 1235 const Function& initializer = parsed_function->function();
1219 const Object& result = PassiveObject::Handle( 1236 const Object& result = PassiveObject::Handle(
1220 DartEntry::InvokeFunction(initializer, Object::empty_array())); 1237 DartEntry::InvokeFunction(initializer, Object::empty_array()));
1221 return result.raw(); 1238 return result.raw();
1222 } else { 1239 } else {
1223 Isolate* const isolate = Isolate::Current(); 1240 Isolate* const isolate = Isolate::Current();
1224 StackZone zone(isolate); 1241 StackZone zone(isolate);
1225 const Error& error = 1242 const Error& error =
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 parsed_function->current_context_var()); 1292 parsed_function->current_context_var());
1276 parsed_function->AllocateVariables(); 1293 parsed_function->AllocateVariables();
1277 1294
1278 // Non-optimized code generator. 1295 // Non-optimized code generator.
1279 DartCompilationPipeline pipeline; 1296 DartCompilationPipeline pipeline;
1280 CompileParsedFunctionHelper(&pipeline, 1297 CompileParsedFunctionHelper(&pipeline,
1281 parsed_function, 1298 parsed_function,
1282 false, 1299 false,
1283 Isolate::kNoDeoptId); 1300 Isolate::kNoDeoptId);
1284 1301
1302 // Eagerly create local var descriptors.
1303 CreateLocalVarDescriptors(*parsed_function);
1285 const Object& result = PassiveObject::Handle( 1304 const Object& result = PassiveObject::Handle(
1286 DartEntry::InvokeFunction(func, Object::empty_array())); 1305 DartEntry::InvokeFunction(func, Object::empty_array()));
1287 return result.raw(); 1306 return result.raw();
1288 } else { 1307 } else {
1289 Thread* const thread = Thread::Current(); 1308 Thread* const thread = Thread::Current();
1290 Isolate* const isolate = thread->isolate(); 1309 Isolate* const isolate = thread->isolate();
1291 const Object& result = 1310 const Object& result =
1292 PassiveObject::Handle(isolate->object_store()->sticky_error()); 1311 PassiveObject::Handle(isolate->object_store()->sticky_error());
1293 isolate->object_store()->clear_sticky_error(); 1312 isolate->object_store()->clear_sticky_error();
1294 return result.raw(); 1313 return result.raw();
1295 } 1314 }
1296 UNREACHABLE(); 1315 UNREACHABLE();
1297 return Object::null(); 1316 return Object::null();
1298 } 1317 }
1299 1318
1300 } // namespace dart 1319 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698