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

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

Issue 2852943003: Move the Kernel string offsets into the VM's heap. (Closed)
Patch Set: Incorporate review comments. Created 3 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
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | runtime/vm/object.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 <set> 5 #include <set>
6 #include <string>
7 6
8 #include "vm/kernel_to_il.h" 7 #include "vm/kernel_to_il.h"
9 8
10 #include "vm/compiler.h" 9 #include "vm/compiler.h"
11 #include "vm/intermediate_language.h" 10 #include "vm/intermediate_language.h"
12 #include "vm/kernel_reader.h" 11 #include "vm/kernel_reader.h"
13 #include "vm/kernel_binary_flowgraph.h" 12 #include "vm/kernel_binary_flowgraph.h"
14 #include "vm/longjump.h" 13 #include "vm/longjump.h"
15 #include "vm/method_recognizer.h" 14 #include "vm/method_recognizer.h"
16 #include "vm/object_store.h" 15 #include "vm/object_store.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 node_(node), 63 node_(node),
65 translation_helper_(Thread::Current()), 64 translation_helper_(Thread::Current()),
66 zone_(translation_helper_.zone()), 65 zone_(translation_helper_.zone()),
67 type_translator_(&translation_helper_, &active_class_, /*finalize=*/true), 66 type_translator_(&translation_helper_, &active_class_, /*finalize=*/true),
68 current_function_scope_(NULL), 67 current_function_scope_(NULL),
69 scope_(NULL), 68 scope_(NULL),
70 depth_(0), 69 depth_(0),
71 name_index_(0), 70 name_index_(0),
72 needs_expr_temp_(false) { 71 needs_expr_temp_(false) {
73 Script& script = Script::Handle(Z, parsed_function->function().script()); 72 Script& script = Script::Handle(Z, parsed_function->function().script());
74 H.SetStringData(TypedData::Handle(Z, script.kernel_strings())); 73 H.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
74 H.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
75 } 75 }
76 76
77 77
78 void ScopeBuilder::EnterScope(TreeNode* node, TokenPosition start_position) { 78 void ScopeBuilder::EnterScope(TreeNode* node, TokenPosition start_position) {
79 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); 79 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_);
80 scope_->set_begin_token_pos(start_position); 80 scope_->set_begin_token_pos(start_position);
81 ASSERT(node->kernel_offset() >= 0); 81 ASSERT(node->kernel_offset() >= 0);
82 result_->scopes.Insert(node->kernel_offset(), scope_); 82 result_->scopes.Insert(node->kernel_offset(), scope_);
83 } 83 }
84 84
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 char name[64]; 254 char name[64];
255 OS::SNPrint(name, 64, "%s%" Pd "", prefix, suffix); 255 OS::SNPrint(name, 64, "%s%" Pd "", prefix, suffix);
256 return H.DartSymbol(name); 256 return H.DartSymbol(name);
257 } 257 }
258 258
259 259
260 void ScopeBuilder::AddVariable(VariableDeclaration* declaration) { 260 void ScopeBuilder::AddVariable(VariableDeclaration* declaration) {
261 // In case `declaration->IsConst()` the flow graph building will take care of 261 // In case `declaration->IsConst()` the flow graph building will take care of
262 // evaluating the constant and setting it via 262 // evaluating the constant and setting it via
263 // `declaration->SetConstantValue()`. 263 // `declaration->SetConstantValue()`.
264 const dart::String& name = declaration->name()->is_empty() 264 const dart::String& name = (H.StringSize(declaration->name()) == 0)
265 ? GenerateName(":var", name_index_++) 265 ? GenerateName(":var", name_index_++)
266 : H.DartSymbol(declaration->name()); 266 : H.DartSymbol(declaration->name());
267 LocalVariable* variable = 267 LocalVariable* variable =
268 MakeVariable(declaration->position(), declaration->end_position(), name, 268 MakeVariable(declaration->position(), declaration->end_position(), name,
269 T.TranslateVariableType(declaration)); 269 T.TranslateVariableType(declaration));
270 if (declaration->IsFinal()) { 270 if (declaration->IsFinal()) {
271 variable->set_is_final(); 271 variable->set_is_final();
272 } 272 }
273 scope_->AddVariable(variable); 273 scope_->AddVariable(variable);
274 result_->locals.Insert(declaration->kernel_offset(), variable); 274 result_->locals.Insert(declaration->kernel_offset(), variable);
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 result <<= next; 1036 result <<= next;
1037 return result; 1037 return result;
1038 } 1038 }
1039 1039
1040 1040
1041 TranslationHelper::TranslationHelper(dart::Thread* thread) 1041 TranslationHelper::TranslationHelper(dart::Thread* thread)
1042 : thread_(thread), 1042 : thread_(thread),
1043 zone_(thread->zone()), 1043 zone_(thread->zone()),
1044 isolate_(thread->isolate()), 1044 isolate_(thread->isolate()),
1045 allocation_space_(thread->IsMutatorThread() ? Heap::kNew : Heap::kOld), 1045 allocation_space_(thread->IsMutatorThread() ? Heap::kNew : Heap::kOld),
1046 string_data_(TypedData::Handle(zone_)) {} 1046 string_offsets_(TypedData::Handle(Z)),
1047 string_data_(TypedData::Handle(Z)) {}
1048
1049
1050 void TranslationHelper::SetStringOffsets(const TypedData& string_offsets) {
1051 ASSERT(string_offsets_.IsNull());
1052 string_offsets_ = string_offsets.raw();
1053 }
1047 1054
1048 1055
1049 void TranslationHelper::SetStringData(const TypedData& string_data) { 1056 void TranslationHelper::SetStringData(const TypedData& string_data) {
1050 ASSERT(string_data_.IsNull()); 1057 ASSERT(string_data_.IsNull());
1051 string_data_ = string_data.raw(); 1058 string_data_ = string_data.raw();
1052 } 1059 }
1053 1060
1054 1061
1055 uint8_t TranslationHelper::CharacterAt(String* string, intptr_t index) { 1062 intptr_t TranslationHelper::StringOffset(intptr_t string_index) const {
1056 ASSERT(index < string->size()); 1063 return string_offsets_.GetUint32(string_index << 2);
1057 return string_data_.GetUint8(string->offset() + index);
1058 } 1064 }
1059 1065
1060 1066
1061 bool TranslationHelper::StringEquals(String* string, const char* other) { 1067 intptr_t TranslationHelper::StringSize(intptr_t string_index) const {
1068 return StringOffset(string_index + 1) - StringOffset(string_index);
1069 }
1070
1071
1072 uint8_t TranslationHelper::CharacterAt(intptr_t string_index, intptr_t index) {
1073 ASSERT(index < StringSize(string_index));
1074 return string_data_.GetUint8(StringOffset(string_index) + index);
1075 }
1076
1077
1078 bool TranslationHelper::StringEquals(intptr_t string_index, const char* other) {
1062 NoSafepointScope no_safepoint; 1079 NoSafepointScope no_safepoint;
1063 intptr_t length = strlen(other); 1080 intptr_t length = strlen(other);
1064 return (length == string->size()) && 1081 return (length == StringSize(string_index)) &&
1065 memcmp(string_data_.DataAddr(string->offset()), other, length) == 0; 1082 (memcmp(string_data_.DataAddr(StringOffset(string_index)), other,
1083 length) == 0);
1066 } 1084 }
1067 1085
1068 1086
1069 bool TranslationHelper::IsAdministrative(CanonicalName* name) { 1087 bool TranslationHelper::IsAdministrative(CanonicalName* name) {
1070 // Administrative names start with '@'. 1088 // Administrative names start with '@'.
1071 return (name->name()->size() > 0) && (CharacterAt(name->name(), 0) == '@'); 1089 return (StringSize(name->name()) > 0) &&
1090 (CharacterAt(name->name(), 0) == '@');
1072 } 1091 }
1073 1092
1074 1093
1075 bool TranslationHelper::IsPrivate(CanonicalName* name) { 1094 bool TranslationHelper::IsPrivate(CanonicalName* name) {
1076 // Private names start with '_'. 1095 // Private names start with '_'.
1077 return (name->name()->size() > 0) && (CharacterAt(name->name(), 0) == '_'); 1096 return (StringSize(name->name()) > 0) &&
1097 (CharacterAt(name->name(), 0) == '_');
1078 } 1098 }
1079 1099
1080 1100
1081 bool TranslationHelper::IsRoot(CanonicalName* name) { 1101 bool TranslationHelper::IsRoot(CanonicalName* name) {
1082 // The root is the only canonical name with no parent. 1102 // The root is the only canonical name with no parent.
1083 return name->parent() == NULL; 1103 return name->parent() == NULL;
1084 } 1104 }
1085 1105
1086 1106
1087 bool TranslationHelper::IsLibrary(CanonicalName* name) { 1107 bool TranslationHelper::IsLibrary(CanonicalName* name) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 return result; 1241 return result;
1222 } 1242 }
1223 1243
1224 1244
1225 const dart::String& TranslationHelper::DartString(const char* content, 1245 const dart::String& TranslationHelper::DartString(const char* content,
1226 Heap::Space space) { 1246 Heap::Space space) {
1227 return dart::String::ZoneHandle(Z, dart::String::New(content, space)); 1247 return dart::String::ZoneHandle(Z, dart::String::New(content, space));
1228 } 1248 }
1229 1249
1230 1250
1231 dart::String& TranslationHelper::DartString(String* content, 1251 dart::String& TranslationHelper::DartString(intptr_t string_index,
1232 Heap::Space space) { 1252 Heap::Space space) {
1233 intptr_t length = content->size(); 1253 intptr_t length = StringSize(string_index);
1234 uint8_t* buffer = Z->Alloc<uint8_t>(length); 1254 uint8_t* buffer = Z->Alloc<uint8_t>(length);
1235 { 1255 {
1236 NoSafepointScope no_safepoint; 1256 NoSafepointScope no_safepoint;
1237 memmove(buffer, string_data_.DataAddr(content->offset()), length); 1257 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length);
1238 } 1258 }
1239 return dart::String::ZoneHandle( 1259 return dart::String::ZoneHandle(
1240 Z, dart::String::FromUTF8(buffer, length, space)); 1260 Z, dart::String::FromUTF8(buffer, length, space));
1241 } 1261 }
1242 1262
1243 1263
1244 dart::String& TranslationHelper::DartString(const uint8_t* utf8_array, 1264 dart::String& TranslationHelper::DartString(const uint8_t* utf8_array,
1245 intptr_t len, 1265 intptr_t len,
1246 Heap::Space space) { 1266 Heap::Space space) {
1247 return dart::String::ZoneHandle( 1267 return dart::String::ZoneHandle(
1248 Z, dart::String::FromUTF8(utf8_array, len, space)); 1268 Z, dart::String::FromUTF8(utf8_array, len, space));
1249 } 1269 }
1250 1270
1251 1271
1252 const dart::String& TranslationHelper::DartSymbol(const char* content) const { 1272 const dart::String& TranslationHelper::DartSymbol(const char* content) const {
1253 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content)); 1273 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content));
1254 } 1274 }
1255 1275
1256 1276
1257 dart::String& TranslationHelper::DartSymbol(String* content) const { 1277 dart::String& TranslationHelper::DartSymbol(intptr_t string_index) const {
1258 intptr_t length = content->size(); 1278 intptr_t length = StringSize(string_index);
1259 uint8_t* buffer = Z->Alloc<uint8_t>(length); 1279 uint8_t* buffer = Z->Alloc<uint8_t>(length);
1260 { 1280 {
1261 NoSafepointScope no_safepoint; 1281 NoSafepointScope no_safepoint;
1262 memmove(buffer, string_data_.DataAddr(content->offset()), length); 1282 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length);
1263 } 1283 }
1264 return dart::String::ZoneHandle( 1284 return dart::String::ZoneHandle(
1265 Z, dart::Symbols::FromUTF8(thread_, buffer, length)); 1285 Z, dart::Symbols::FromUTF8(thread_, buffer, length));
1266 } 1286 }
1267 1287
1268 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array, 1288 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array,
1269 intptr_t len) const { 1289 intptr_t len) const {
1270 return dart::String::ZoneHandle( 1290 return dart::String::ZoneHandle(
1271 Z, dart::Symbols::FromUTF8(thread_, utf8_array, len)); 1291 Z, dart::Symbols::FromUTF8(thread_, utf8_array, len));
1272 } 1292 }
(...skipping 27 matching lines...) Expand all
1300 } 1320 }
1301 } 1321 }
1302 1322
1303 1323
1304 const dart::String& TranslationHelper::DartSetterName(CanonicalName* setter) { 1324 const dart::String& TranslationHelper::DartSetterName(CanonicalName* setter) {
1305 return DartSetterName(setter->parent(), setter->name()); 1325 return DartSetterName(setter->parent(), setter->name());
1306 } 1326 }
1307 1327
1308 1328
1309 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) { 1329 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) {
1310 return DartSetterName(setter_name->library(), setter_name->string()); 1330 return DartSetterName(setter_name->library(), setter_name->string_index());
1311 } 1331 }
1312 1332
1313 1333
1314 const dart::String& TranslationHelper::DartSetterName(CanonicalName* parent, 1334 const dart::String& TranslationHelper::DartSetterName(CanonicalName* parent,
1315 String* setter) { 1335 intptr_t setter) {
1316 // The names flowing into [setter] are coming from the Kernel file: 1336 // The names flowing into [setter] are coming from the Kernel file:
1317 // * user-defined setters: `fieldname=` 1337 // * user-defined setters: `fieldname=`
1318 // * property-set expressions: `fieldname` 1338 // * property-set expressions: `fieldname`
1319 // 1339 //
1320 // The VM uses `get:fieldname` and `set:fieldname`. 1340 // The VM uses `get:fieldname` and `set:fieldname`.
1321 // 1341 //
1322 // => In order to be consistent, we remove the `=` always and adopt the VM 1342 // => In order to be consistent, we remove the `=` always and adopt the VM
1323 // conventions. 1343 // conventions.
1324 ASSERT(setter->size() > 0); 1344 intptr_t size = StringSize(setter);
1325 intptr_t skip = 0; 1345 ASSERT(size > 0);
1326 if (CharacterAt(setter, setter->size() - 1) == '=') { 1346 if (CharacterAt(setter, size - 1) == '=') {
1327 skip = 1; 1347 --size;
1328 } 1348 }
1329 intptr_t length = setter->size() - skip; 1349 uint8_t* buffer = Z->Alloc<uint8_t>(size);
1330 uint8_t* buffer = Z->Alloc<uint8_t>(length);
1331 { 1350 {
1332 NoSafepointScope no_safepoint; 1351 NoSafepointScope no_safepoint;
1333 memmove(buffer, string_data_.DataAddr(setter->offset()), length); 1352 memmove(buffer, string_data_.DataAddr(StringOffset(setter)), size);
1334 } 1353 }
1335 dart::String& name = dart::String::ZoneHandle( 1354 dart::String& name = dart::String::ZoneHandle(
1336 Z, dart::String::FromUTF8(buffer, length, allocation_space_)); 1355 Z, dart::String::FromUTF8(buffer, size, allocation_space_));
1337 ManglePrivateName(parent, &name, false); 1356 ManglePrivateName(parent, &name, false);
1338 name = dart::Field::SetterSymbol(name); 1357 name = dart::Field::SetterSymbol(name);
1339 return name; 1358 return name;
1340 } 1359 }
1341 1360
1342 1361
1343 const dart::String& TranslationHelper::DartGetterName(CanonicalName* getter) { 1362 const dart::String& TranslationHelper::DartGetterName(CanonicalName* getter) {
1344 return DartGetterName(getter->parent(), getter->name()); 1363 return DartGetterName(getter->parent(), getter->name());
1345 } 1364 }
1346 1365
1347 1366
1348 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) { 1367 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) {
1349 return DartGetterName(getter_name->library(), getter_name->string()); 1368 return DartGetterName(getter_name->library(), getter_name->string_index());
1350 } 1369 }
1351 1370
1352 1371
1353 const dart::String& TranslationHelper::DartGetterName(CanonicalName* parent, 1372 const dart::String& TranslationHelper::DartGetterName(CanonicalName* parent,
1354 String* getter) { 1373 intptr_t getter) {
1355 dart::String& name = DartString(getter); 1374 dart::String& name = DartString(getter);
1356 ManglePrivateName(parent, &name, false); 1375 ManglePrivateName(parent, &name, false);
1357 name = dart::Field::GetterSymbol(name); 1376 name = dart::Field::GetterSymbol(name);
1358 return name; 1377 return name;
1359 } 1378 }
1360 1379
1361 1380
1362 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) { 1381 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) {
1363 dart::String& name = DartString(kernel_name->string()); 1382 dart::String& name = DartString(kernel_name->string_index());
1364 return ManglePrivateName(kernel_name->library(), &name); 1383 return ManglePrivateName(kernel_name->library(), &name);
1365 } 1384 }
1366 1385
1367 1386
1368 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) { 1387 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) {
1369 // The [DartFieldName] will take care of mangling the name. 1388 // The [DartFieldName] will take care of mangling the name.
1370 dart::String& name = 1389 dart::String& name =
1371 dart::String::Handle(Z, DartFieldName(kernel_name).raw()); 1390 dart::String::Handle(Z, DartFieldName(kernel_name).raw());
1372 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name); 1391 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name);
1373 return name; 1392 return name;
1374 } 1393 }
1375 1394
1376 1395
1377 const dart::String& TranslationHelper::DartMethodName(CanonicalName* method) { 1396 const dart::String& TranslationHelper::DartMethodName(CanonicalName* method) {
1378 return DartMethodName(method->parent(), method->name()); 1397 return DartMethodName(method->parent(), method->name());
1379 } 1398 }
1380 1399
1381 1400
1382 const dart::String& TranslationHelper::DartMethodName(Name* method_name) { 1401 const dart::String& TranslationHelper::DartMethodName(Name* method_name) {
1383 return DartMethodName(method_name->library(), method_name->string()); 1402 return DartMethodName(method_name->library(), method_name->string_index());
1384 } 1403 }
1385 1404
1386 1405
1387 const dart::String& TranslationHelper::DartMethodName(CanonicalName* parent, 1406 const dart::String& TranslationHelper::DartMethodName(CanonicalName* parent,
1388 String* method) { 1407 intptr_t method) {
1389 dart::String& name = DartString(method); 1408 dart::String& name = DartString(method);
1390 return ManglePrivateName(parent, &name); 1409 return ManglePrivateName(parent, &name);
1391 } 1410 }
1392 1411
1393 1412
1394 const dart::String& TranslationHelper::DartFactoryName(CanonicalName* factory) { 1413 const dart::String& TranslationHelper::DartFactoryName(CanonicalName* factory) {
1395 ASSERT(IsConstructor(factory) || IsFactory(factory)); 1414 ASSERT(IsConstructor(factory) || IsFactory(factory));
1396 GrowableHandlePtrArray<const dart::String> pieces(Z, 3); 1415 GrowableHandlePtrArray<const dart::String> pieces(Z, 3);
1397 pieces.Add(DartClassName(EnclosingName(factory))); 1416 pieces.Add(DartClassName(EnclosingName(factory)));
1398 pieces.Add(Symbols::Dot()); 1417 pieces.Add(Symbols::Dot());
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 } 2069 }
2051 } 2070 }
2052 2071
2053 2072
2054 void ConstantEvaluator::VisitNot(Not* node) { 2073 void ConstantEvaluator::VisitNot(Not* node) {
2055 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw(); 2074 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw();
2056 } 2075 }
2057 2076
2058 2077
2059 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { 2078 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) {
2060 const intptr_t kLengthLen = sizeof("length") - 1; 2079 intptr_t string_index = node->name()->string_index();
2061 2080 if (H.StringEquals(string_index, "length")) {
2062 String* string = node->name()->string();
2063 if ((string->size() == kLengthLen) && H.StringEquals(string, "length")) {
2064 node->receiver()->AcceptExpressionVisitor(this); 2081 node->receiver()->AcceptExpressionVisitor(this);
2065 if (result_.IsString()) { 2082 if (result_.IsString()) {
2066 const dart::String& str = 2083 const dart::String& str =
2067 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); 2084 dart::String::Handle(Z, dart::String::RawCast(result_.raw()));
2068 result_ = Integer::New(str.Length()); 2085 result_ = Integer::New(str.Length());
2069 } else { 2086 } else {
2070 H.ReportError( 2087 H.ReportError(
2071 "Constant expressions can only call " 2088 "Constant expressions can only call "
2072 "'length' on string constants."); 2089 "'length' on string constants.");
2073 } 2090 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 try_finally_block_(NULL), 2197 try_finally_block_(NULL),
2181 try_catch_block_(NULL), 2198 try_catch_block_(NULL),
2182 next_used_try_index_(0), 2199 next_used_try_index_(0),
2183 catch_block_(NULL), 2200 catch_block_(NULL),
2184 type_translator_(&translation_helper_, 2201 type_translator_(&translation_helper_,
2185 &active_class_, 2202 &active_class_,
2186 /* finalize= */ true), 2203 /* finalize= */ true),
2187 constant_evaluator_(this, zone_, &translation_helper_, &type_translator_), 2204 constant_evaluator_(this, zone_, &translation_helper_, &type_translator_),
2188 streaming_flow_graph_builder_(NULL) { 2205 streaming_flow_graph_builder_(NULL) {
2189 Script& script = Script::Handle(Z, parsed_function->function().script()); 2206 Script& script = Script::Handle(Z, parsed_function->function().script());
2190 H.SetStringData(TypedData::Handle(Z, script.kernel_strings())); 2207 H.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
2208 H.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
2191 } 2209 }
2192 2210
2193 2211
2194 FlowGraphBuilder::~FlowGraphBuilder() { 2212 FlowGraphBuilder::~FlowGraphBuilder() {
2195 if (streaming_flow_graph_builder_ != NULL) { 2213 if (streaming_flow_graph_builder_ != NULL) {
2196 delete streaming_flow_graph_builder_; 2214 delete streaming_flow_graph_builder_;
2197 } 2215 }
2198 } 2216 }
2199 2217
2200 2218
(...skipping 2474 matching lines...) Expand 10 before | Expand all | Expand 10 after
4675 pos++; 4693 pos++;
4676 for (intptr_t i = 0; i < positional_count; i++, pos++) { 4694 for (intptr_t i = 0; i < positional_count; i++, pos++) {
4677 node->positional_parameters()[i]->AcceptDartTypeVisitor(this); 4695 node->positional_parameters()[i]->AcceptDartTypeVisitor(this);
4678 if (result_.IsMalformed()) { 4696 if (result_.IsMalformed()) {
4679 result_ = AbstractType::dynamic_type().raw(); 4697 result_ = AbstractType::dynamic_type().raw();
4680 } 4698 }
4681 parameter_types.SetAt(pos, result_); 4699 parameter_types.SetAt(pos, result_);
4682 parameter_names.SetAt(pos, H.DartSymbol("noname")); 4700 parameter_names.SetAt(pos, H.DartSymbol("noname"));
4683 } 4701 }
4684 for (intptr_t i = 0; i < named_count; i++, pos++) { 4702 for (intptr_t i = 0; i < named_count; i++, pos++) {
4685 Tuple<String, DartType>* tuple = node->named_parameters()[i]; 4703 NamedParameter* parameter = node->named_parameters()[i];
4686 tuple->second()->AcceptDartTypeVisitor(this); 4704 parameter->type()->AcceptDartTypeVisitor(this);
4687 if (result_.IsMalformed()) { 4705 if (result_.IsMalformed()) {
4688 result_ = AbstractType::dynamic_type().raw(); 4706 result_ = AbstractType::dynamic_type().raw();
4689 } 4707 }
4690 parameter_types.SetAt(pos, result_); 4708 parameter_types.SetAt(pos, result_);
4691 parameter_names.SetAt(pos, H.DartSymbol(tuple->first())); 4709 parameter_names.SetAt(pos, H.DartSymbol(parameter->name()));
4692 } 4710 }
4693 4711
4694 Type& signature_type = 4712 Type& signature_type =
4695 Type::ZoneHandle(Z, signature_function.SignatureType()); 4713 Type::ZoneHandle(Z, signature_function.SignatureType());
4696 4714
4697 if (finalize_) { 4715 if (finalize_) {
4698 signature_type ^= 4716 signature_type ^=
4699 ClassFinalizer::FinalizeType(*active_class_->klass, signature_type); 4717 ClassFinalizer::FinalizeType(*active_class_->klass, signature_type);
4700 // Do not refer to signature_function anymore, since it may have been 4718 // Do not refer to signature_function anymore, since it may have been
4701 // replaced during canonicalization. 4719 // replaced during canonicalization.
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
6726 metadata_expressions = &Field::Cast(kernel_node)->annotations(); 6744 metadata_expressions = &Field::Cast(kernel_node)->annotations();
6727 } else if (kernel_node->IsConstructor()) { 6745 } else if (kernel_node->IsConstructor()) {
6728 metadata_expressions = &Constructor::Cast(kernel_node)->annotations(); 6746 metadata_expressions = &Constructor::Cast(kernel_node)->annotations();
6729 } else { 6747 } else {
6730 FATAL1("No support for metadata on this type of kernel node %p\n", 6748 FATAL1("No support for metadata on this type of kernel node %p\n",
6731 kernel_node); 6749 kernel_node);
6732 } 6750 }
6733 6751
6734 TranslationHelper helper(thread); 6752 TranslationHelper helper(thread);
6735 Script& script = Script::Handle(Z, metadata_field.Script()); 6753 Script& script = Script::Handle(Z, metadata_field.Script());
6736 helper.SetStringData(TypedData::Handle(Z, script.kernel_strings())); 6754 helper.SetStringOffsets(
6755 TypedData::Handle(Z, script.kernel_string_offsets()));
6756 helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
6737 DartTypeTranslator type_translator(&helper, NULL, true); 6757 DartTypeTranslator type_translator(&helper, NULL, true);
6738 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z, 6758 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z,
6739 &helper, &type_translator); 6759 &helper, &type_translator);
6740 6760
6741 const Array& metadata_values = 6761 const Array& metadata_values =
6742 Array::Handle(Z, Array::New(metadata_expressions->length())); 6762 Array::Handle(Z, Array::New(metadata_expressions->length()));
6743 6763
6744 for (intptr_t i = 0; i < metadata_expressions->length(); i++) { 6764 for (intptr_t i = 0; i < metadata_expressions->length(); i++) {
6745 const Instance& value = 6765 const Instance& value =
6746 constant_evaluator.EvaluateExpression((*metadata_expressions)[i]); 6766 constant_evaluator.EvaluateExpression((*metadata_expressions)[i]);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
6823 thread->clear_sticky_error(); 6843 thread->clear_sticky_error();
6824 return error.raw(); 6844 return error.raw();
6825 } 6845 }
6826 } 6846 }
6827 6847
6828 6848
6829 } // namespace kernel 6849 } // namespace kernel
6830 } // namespace dart 6850 } // namespace dart
6831 6851
6832 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6852 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_to_il.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698