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

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

Issue 1128803002: Lazily generate local var descriptors. (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 | « runtime/vm/compiler.h ('k') | runtime/vm/debugger.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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 for (intptr_t i = 0; i < stackmap_table.Length(); ++i) { 883 for (intptr_t i = 0; i < stackmap_table.Length(); ++i) {
884 map ^= stackmap_table.At(i); 884 map ^= stackmap_table.At(i);
885 ISL_Print("%s\n", map.ToCString()); 885 ISL_Print("%s\n", map.ToCString());
886 } 886 }
887 } 887 }
888 ISL_Print("}\n"); 888 ISL_Print("}\n");
889 889
890 ISL_Print("Variable Descriptors for function '%s' {\n", 890 ISL_Print("Variable Descriptors for function '%s' {\n",
891 function_fullname); 891 function_fullname);
892 const LocalVarDescriptors& var_descriptors = 892 const LocalVarDescriptors& var_descriptors =
893 LocalVarDescriptors::Handle(code.var_descriptors()); 893 LocalVarDescriptors::Handle(code.GetLocalVarDescriptors());
894 intptr_t var_desc_length = 894 intptr_t var_desc_length =
895 var_descriptors.IsNull() ? 0 : var_descriptors.Length(); 895 var_descriptors.IsNull() ? 0 : var_descriptors.Length();
896 String& var_name = String::Handle(); 896 String& var_name = String::Handle();
897 for (intptr_t i = 0; i < var_desc_length; i++) { 897 for (intptr_t i = 0; i < var_desc_length; i++) {
898 var_name = var_descriptors.GetName(i); 898 var_name = var_descriptors.GetName(i);
899 RawLocalVarDescriptors::VarInfo var_info; 899 RawLocalVarDescriptors::VarInfo var_info;
900 var_descriptors.GetInfo(i, &var_info); 900 var_descriptors.GetInfo(i, &var_info);
901 const int8_t kind = var_info.kind(); 901 const int8_t kind = var_info.kind();
902 if (kind == RawLocalVarDescriptors::kSavedCurrentContext) { 902 if (kind == RawLocalVarDescriptors::kSavedCurrentContext) {
903 ISL_Print(" saved current CTX reg offset %d\n", var_info.index()); 903 ISL_Print(" saved current CTX reg offset %d\n", var_info.index());
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 // We got an error during compilation. 1122 // We got an error during compilation.
1123 error = isolate->object_store()->sticky_error(); 1123 error = isolate->object_store()->sticky_error();
1124 isolate->object_store()->clear_sticky_error(); 1124 isolate->object_store()->clear_sticky_error();
1125 return error.raw(); 1125 return error.raw();
1126 } 1126 }
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) {
1133 ASSERT(!code.is_optimized());
1134 const Function& function = Function::Handle(code.function());
1135 ParsedFunction* parsed_function = new ParsedFunction(
1136 Thread::Current(), Function::ZoneHandle(function.raw()));
1137 LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle();
1138 if (function.IsIrregexpFunction()) {
1139 UNREACHABLE(); // Special parsing needed, not yet implemented.
1140 } else {
1141 Parser::ParseFunction(parsed_function);
1142 parsed_function->AllocateVariables();
1143 var_descs =
1144 parsed_function->node_sequence()->scope()->GetVarDescriptors(function);
1145 }
1146 code.set_var_descriptors(var_descs);
1147 }
1148
1149
1132 RawError* Compiler::CompileAllFunctions(const Class& cls) { 1150 RawError* Compiler::CompileAllFunctions(const Class& cls) {
1133 Thread* thread = Thread::Current(); 1151 Thread* thread = Thread::Current();
1134 Zone* zone = thread->zone(); 1152 Zone* zone = thread->zone();
1135 Error& error = Error::Handle(zone); 1153 Error& error = Error::Handle(zone);
1136 Array& functions = Array::Handle(zone, cls.functions()); 1154 Array& functions = Array::Handle(zone, cls.functions());
1137 Function& func = Function::Handle(zone); 1155 Function& func = Function::Handle(zone);
1138 // Class dynamic lives in the vm isolate. Its array fields cannot be set to 1156 // Class dynamic lives in the vm isolate. Its array fields cannot be set to
1139 // an empty array. 1157 // an empty array.
1140 if (functions.IsNull()) { 1158 if (functions.IsNull()) {
1141 ASSERT(cls.IsDynamicClass()); 1159 ASSERT(cls.IsDynamicClass());
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 const Object& result = 1291 const Object& result =
1274 PassiveObject::Handle(isolate->object_store()->sticky_error()); 1292 PassiveObject::Handle(isolate->object_store()->sticky_error());
1275 isolate->object_store()->clear_sticky_error(); 1293 isolate->object_store()->clear_sticky_error();
1276 return result.raw(); 1294 return result.raw();
1277 } 1295 }
1278 UNREACHABLE(); 1296 UNREACHABLE();
1279 return Object::null(); 1297 return Object::null();
1280 } 1298 }
1281 1299
1282 } // namespace dart 1300 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698