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

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: 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 string_offsets_.GetUint32((string_index + 1) << 2) -
Vyacheslav Egorov (Google) 2017/05/02 12:48:34 StringOffset(string_index + 1) - StringOffset(stri
Kevin Millikin (Google) 2017/05/03 00:07:47 Thanks for spotting this.
1069 StringOffset(string_index);
1070 }
1071
1072
1073 uint8_t TranslationHelper::CharacterAt(intptr_t string_index, intptr_t index) {
1074 ASSERT(index < StringSize(string_index));
1075 return string_data_.GetUint8(StringOffset(string_index) + index);
1076 }
1077
1078
1079 bool TranslationHelper::StringEquals(intptr_t string_index, const char* other) {
1062 NoSafepointScope no_safepoint; 1080 NoSafepointScope no_safepoint;
1063 intptr_t length = strlen(other); 1081 intptr_t length = strlen(other);
1064 return (length == string->size()) && 1082 return (length == StringSize(string_index)) &&
1065 memcmp(string_data_.DataAddr(string->offset()), other, length) == 0; 1083 (memcmp(string_data_.DataAddr(StringOffset(string_index)), other,
1084 length) == 0);
1066 } 1085 }
1067 1086
1068 1087
1069 bool TranslationHelper::IsAdministrative(CanonicalName* name) { 1088 bool TranslationHelper::IsAdministrative(CanonicalName* name) {
1070 // Administrative names start with '@'. 1089 // Administrative names start with '@'.
1071 return (name->name()->size() > 0) && (CharacterAt(name->name(), 0) == '@'); 1090 return (StringSize(name->name()) > 0) &&
1091 (CharacterAt(name->name(), 0) == '@');
1072 } 1092 }
1073 1093
1074 1094
1075 bool TranslationHelper::IsPrivate(CanonicalName* name) { 1095 bool TranslationHelper::IsPrivate(CanonicalName* name) {
1076 // Private names start with '_'. 1096 // Private names start with '_'.
1077 return (name->name()->size() > 0) && (CharacterAt(name->name(), 0) == '_'); 1097 return (StringSize(name->name()) > 0) &&
1098 (CharacterAt(name->name(), 0) == '_');
1078 } 1099 }
1079 1100
1080 1101
1081 bool TranslationHelper::IsRoot(CanonicalName* name) { 1102 bool TranslationHelper::IsRoot(CanonicalName* name) {
1082 // The root is the only canonical name with no parent. 1103 // The root is the only canonical name with no parent.
1083 return name->parent() == NULL; 1104 return name->parent() == NULL;
1084 } 1105 }
1085 1106
1086 1107
1087 bool TranslationHelper::IsLibrary(CanonicalName* name) { 1108 bool TranslationHelper::IsLibrary(CanonicalName* name) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 return result; 1242 return result;
1222 } 1243 }
1223 1244
1224 1245
1225 const dart::String& TranslationHelper::DartString(const char* content, 1246 const dart::String& TranslationHelper::DartString(const char* content,
1226 Heap::Space space) { 1247 Heap::Space space) {
1227 return dart::String::ZoneHandle(Z, dart::String::New(content, space)); 1248 return dart::String::ZoneHandle(Z, dart::String::New(content, space));
1228 } 1249 }
1229 1250
1230 1251
1231 dart::String& TranslationHelper::DartString(String* content, 1252 dart::String& TranslationHelper::DartString(intptr_t string_index,
1232 Heap::Space space) { 1253 Heap::Space space) {
1233 intptr_t length = content->size(); 1254 intptr_t length = StringSize(string_index);
1234 uint8_t* buffer = Z->Alloc<uint8_t>(length); 1255 uint8_t* buffer = Z->Alloc<uint8_t>(length);
1235 { 1256 {
1236 NoSafepointScope no_safepoint; 1257 NoSafepointScope no_safepoint;
1237 memmove(buffer, string_data_.DataAddr(content->offset()), length); 1258 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length);
1238 } 1259 }
1239 return dart::String::ZoneHandle( 1260 return dart::String::ZoneHandle(
1240 Z, dart::String::FromUTF8(buffer, length, space)); 1261 Z, dart::String::FromUTF8(buffer, length, space));
1241 } 1262 }
1242 1263
1243 1264
1244 dart::String& TranslationHelper::DartString(const uint8_t* utf8_array, 1265 dart::String& TranslationHelper::DartString(const uint8_t* utf8_array,
1245 intptr_t len, 1266 intptr_t len,
1246 Heap::Space space) { 1267 Heap::Space space) {
1247 return dart::String::ZoneHandle( 1268 return dart::String::ZoneHandle(
1248 Z, dart::String::FromUTF8(utf8_array, len, space)); 1269 Z, dart::String::FromUTF8(utf8_array, len, space));
1249 } 1270 }
1250 1271
1251 1272
1252 const dart::String& TranslationHelper::DartSymbol(const char* content) const { 1273 const dart::String& TranslationHelper::DartSymbol(const char* content) const {
1253 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content)); 1274 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content));
1254 } 1275 }
1255 1276
1256 1277
1257 dart::String& TranslationHelper::DartSymbol(String* content) const { 1278 dart::String& TranslationHelper::DartSymbol(intptr_t string_index) const {
1258 intptr_t length = content->size(); 1279 intptr_t length = StringSize(string_index);
1259 uint8_t* buffer = Z->Alloc<uint8_t>(length); 1280 uint8_t* buffer = Z->Alloc<uint8_t>(length);
1260 { 1281 {
1261 NoSafepointScope no_safepoint; 1282 NoSafepointScope no_safepoint;
1262 memmove(buffer, string_data_.DataAddr(content->offset()), length); 1283 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length);
1263 } 1284 }
1264 return dart::String::ZoneHandle( 1285 return dart::String::ZoneHandle(
1265 Z, dart::Symbols::FromUTF8(thread_, buffer, length)); 1286 Z, dart::Symbols::FromUTF8(thread_, buffer, length));
1266 } 1287 }
1267 1288
1268 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array, 1289 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array,
1269 intptr_t len) const { 1290 intptr_t len) const {
1270 return dart::String::ZoneHandle( 1291 return dart::String::ZoneHandle(
1271 Z, dart::Symbols::FromUTF8(thread_, utf8_array, len)); 1292 Z, dart::Symbols::FromUTF8(thread_, utf8_array, len));
1272 } 1293 }
(...skipping 27 matching lines...) Expand all
1300 } 1321 }
1301 } 1322 }
1302 1323
1303 1324
1304 const dart::String& TranslationHelper::DartSetterName(CanonicalName* setter) { 1325 const dart::String& TranslationHelper::DartSetterName(CanonicalName* setter) {
1305 return DartSetterName(setter->parent(), setter->name()); 1326 return DartSetterName(setter->parent(), setter->name());
1306 } 1327 }
1307 1328
1308 1329
1309 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) { 1330 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) {
1310 return DartSetterName(setter_name->library(), setter_name->string()); 1331 return DartSetterName(setter_name->library(), setter_name->string_index());
1311 } 1332 }
1312 1333
1313 1334
1314 const dart::String& TranslationHelper::DartSetterName(CanonicalName* parent, 1335 const dart::String& TranslationHelper::DartSetterName(CanonicalName* parent,
1315 String* setter) { 1336 intptr_t setter) {
1316 // The names flowing into [setter] are coming from the Kernel file: 1337 // The names flowing into [setter] are coming from the Kernel file:
1317 // * user-defined setters: `fieldname=` 1338 // * user-defined setters: `fieldname=`
1318 // * property-set expressions: `fieldname` 1339 // * property-set expressions: `fieldname`
1319 // 1340 //
1320 // The VM uses `get:fieldname` and `set:fieldname`. 1341 // The VM uses `get:fieldname` and `set:fieldname`.
1321 // 1342 //
1322 // => In order to be consistent, we remove the `=` always and adopt the VM 1343 // => In order to be consistent, we remove the `=` always and adopt the VM
1323 // conventions. 1344 // conventions.
1324 ASSERT(setter->size() > 0); 1345 intptr_t size = StringSize(setter);
1325 intptr_t skip = 0; 1346 ASSERT(size > 0);
1326 if (CharacterAt(setter, setter->size() - 1) == '=') { 1347 if (CharacterAt(setter, size - 1) == '=') {
1327 skip = 1; 1348 --size;
1328 } 1349 }
1329 intptr_t length = setter->size() - skip; 1350 uint8_t* buffer = Z->Alloc<uint8_t>(size);
1330 uint8_t* buffer = Z->Alloc<uint8_t>(length);
1331 { 1351 {
1332 NoSafepointScope no_safepoint; 1352 NoSafepointScope no_safepoint;
1333 memmove(buffer, string_data_.DataAddr(setter->offset()), length); 1353 memmove(buffer, string_data_.DataAddr(StringOffset(setter)), size);
1334 } 1354 }
1335 dart::String& name = dart::String::ZoneHandle( 1355 dart::String& name = dart::String::ZoneHandle(
1336 Z, dart::String::FromUTF8(buffer, length, allocation_space_)); 1356 Z, dart::String::FromUTF8(buffer, size, allocation_space_));
1337 ManglePrivateName(parent, &name, false); 1357 ManglePrivateName(parent, &name, false);
1338 name = dart::Field::SetterSymbol(name); 1358 name = dart::Field::SetterSymbol(name);
1339 return name; 1359 return name;
1340 } 1360 }
1341 1361
1342 1362
1343 const dart::String& TranslationHelper::DartGetterName(CanonicalName* getter) { 1363 const dart::String& TranslationHelper::DartGetterName(CanonicalName* getter) {
1344 return DartGetterName(getter->parent(), getter->name()); 1364 return DartGetterName(getter->parent(), getter->name());
1345 } 1365 }
1346 1366
1347 1367
1348 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) { 1368 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) {
1349 return DartGetterName(getter_name->library(), getter_name->string()); 1369 return DartGetterName(getter_name->library(), getter_name->string_index());
1350 } 1370 }
1351 1371
1352 1372
1353 const dart::String& TranslationHelper::DartGetterName(CanonicalName* parent, 1373 const dart::String& TranslationHelper::DartGetterName(CanonicalName* parent,
1354 String* getter) { 1374 intptr_t getter) {
1355 dart::String& name = DartString(getter); 1375 dart::String& name = DartString(getter);
1356 ManglePrivateName(parent, &name, false); 1376 ManglePrivateName(parent, &name, false);
1357 name = dart::Field::GetterSymbol(name); 1377 name = dart::Field::GetterSymbol(name);
1358 return name; 1378 return name;
1359 } 1379 }
1360 1380
1361 1381
1362 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) { 1382 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) {
1363 dart::String& name = DartString(kernel_name->string()); 1383 dart::String& name = DartString(kernel_name->string_index());
1364 return ManglePrivateName(kernel_name->library(), &name); 1384 return ManglePrivateName(kernel_name->library(), &name);
1365 } 1385 }
1366 1386
1367 1387
1368 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) { 1388 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) {
1369 // The [DartFieldName] will take care of mangling the name. 1389 // The [DartFieldName] will take care of mangling the name.
1370 dart::String& name = 1390 dart::String& name =
1371 dart::String::Handle(Z, DartFieldName(kernel_name).raw()); 1391 dart::String::Handle(Z, DartFieldName(kernel_name).raw());
1372 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name); 1392 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name);
1373 return name; 1393 return name;
1374 } 1394 }
1375 1395
1376 1396
1377 const dart::String& TranslationHelper::DartMethodName(CanonicalName* method) { 1397 const dart::String& TranslationHelper::DartMethodName(CanonicalName* method) {
1378 return DartMethodName(method->parent(), method->name()); 1398 return DartMethodName(method->parent(), method->name());
1379 } 1399 }
1380 1400
1381 1401
1382 const dart::String& TranslationHelper::DartMethodName(Name* method_name) { 1402 const dart::String& TranslationHelper::DartMethodName(Name* method_name) {
1383 return DartMethodName(method_name->library(), method_name->string()); 1403 return DartMethodName(method_name->library(), method_name->string_index());
1384 } 1404 }
1385 1405
1386 1406
1387 const dart::String& TranslationHelper::DartMethodName(CanonicalName* parent, 1407 const dart::String& TranslationHelper::DartMethodName(CanonicalName* parent,
1388 String* method) { 1408 intptr_t method) {
1389 dart::String& name = DartString(method); 1409 dart::String& name = DartString(method);
1390 return ManglePrivateName(parent, &name); 1410 return ManglePrivateName(parent, &name);
1391 } 1411 }
1392 1412
1393 1413
1394 const dart::String& TranslationHelper::DartFactoryName(CanonicalName* factory) { 1414 const dart::String& TranslationHelper::DartFactoryName(CanonicalName* factory) {
1395 ASSERT(IsConstructor(factory) || IsFactory(factory)); 1415 ASSERT(IsConstructor(factory) || IsFactory(factory));
1396 GrowableHandlePtrArray<const dart::String> pieces(Z, 3); 1416 GrowableHandlePtrArray<const dart::String> pieces(Z, 3);
1397 pieces.Add(DartClassName(EnclosingName(factory))); 1417 pieces.Add(DartClassName(EnclosingName(factory)));
1398 pieces.Add(Symbols::Dot()); 1418 pieces.Add(Symbols::Dot());
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 } 2070 }
2051 } 2071 }
2052 2072
2053 2073
2054 void ConstantEvaluator::VisitNot(Not* node) { 2074 void ConstantEvaluator::VisitNot(Not* node) {
2055 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw(); 2075 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw();
2056 } 2076 }
2057 2077
2058 2078
2059 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { 2079 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) {
2060 const intptr_t kLengthLen = sizeof("length") - 1; 2080 intptr_t string_index = node->name()->string_index();
2061 2081 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); 2082 node->receiver()->AcceptExpressionVisitor(this);
2065 if (result_.IsString()) { 2083 if (result_.IsString()) {
2066 const dart::String& str = 2084 const dart::String& str =
2067 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); 2085 dart::String::Handle(Z, dart::String::RawCast(result_.raw()));
2068 result_ = Integer::New(str.Length()); 2086 result_ = Integer::New(str.Length());
2069 } else { 2087 } else {
2070 H.ReportError( 2088 H.ReportError(
2071 "Constant expressions can only call " 2089 "Constant expressions can only call "
2072 "'length' on string constants."); 2090 "'length' on string constants.");
2073 } 2091 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 try_finally_block_(NULL), 2198 try_finally_block_(NULL),
2181 try_catch_block_(NULL), 2199 try_catch_block_(NULL),
2182 next_used_try_index_(0), 2200 next_used_try_index_(0),
2183 catch_block_(NULL), 2201 catch_block_(NULL),
2184 type_translator_(&translation_helper_, 2202 type_translator_(&translation_helper_,
2185 &active_class_, 2203 &active_class_,
2186 /* finalize= */ true), 2204 /* finalize= */ true),
2187 constant_evaluator_(this, zone_, &translation_helper_, &type_translator_), 2205 constant_evaluator_(this, zone_, &translation_helper_, &type_translator_),
2188 streaming_flow_graph_builder_(NULL) { 2206 streaming_flow_graph_builder_(NULL) {
2189 Script& script = Script::Handle(Z, parsed_function->function().script()); 2207 Script& script = Script::Handle(Z, parsed_function->function().script());
2190 H.SetStringData(TypedData::Handle(Z, script.kernel_strings())); 2208 H.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
2209 H.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
2191 } 2210 }
2192 2211
2193 2212
2194 FlowGraphBuilder::~FlowGraphBuilder() { 2213 FlowGraphBuilder::~FlowGraphBuilder() {
2195 if (streaming_flow_graph_builder_ != NULL) { 2214 if (streaming_flow_graph_builder_ != NULL) {
2196 delete streaming_flow_graph_builder_; 2215 delete streaming_flow_graph_builder_;
2197 } 2216 }
2198 } 2217 }
2199 2218
2200 2219
(...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after
4684 pos++; 4703 pos++;
4685 for (intptr_t i = 0; i < positional_count; i++, pos++) { 4704 for (intptr_t i = 0; i < positional_count; i++, pos++) {
4686 node->positional_parameters()[i]->AcceptDartTypeVisitor(this); 4705 node->positional_parameters()[i]->AcceptDartTypeVisitor(this);
4687 if (result_.IsMalformed()) { 4706 if (result_.IsMalformed()) {
4688 result_ = AbstractType::dynamic_type().raw(); 4707 result_ = AbstractType::dynamic_type().raw();
4689 } 4708 }
4690 parameter_types.SetAt(pos, result_); 4709 parameter_types.SetAt(pos, result_);
4691 parameter_names.SetAt(pos, H.DartSymbol("noname")); 4710 parameter_names.SetAt(pos, H.DartSymbol("noname"));
4692 } 4711 }
4693 for (intptr_t i = 0; i < named_count; i++, pos++) { 4712 for (intptr_t i = 0; i < named_count; i++, pos++) {
4694 Tuple<String, DartType>* tuple = node->named_parameters()[i]; 4713 NamedParameter* parameter = node->named_parameters()[i];
4695 tuple->second()->AcceptDartTypeVisitor(this); 4714 parameter->type()->AcceptDartTypeVisitor(this);
4696 if (result_.IsMalformed()) { 4715 if (result_.IsMalformed()) {
4697 result_ = AbstractType::dynamic_type().raw(); 4716 result_ = AbstractType::dynamic_type().raw();
4698 } 4717 }
4699 parameter_types.SetAt(pos, result_); 4718 parameter_types.SetAt(pos, result_);
4700 parameter_names.SetAt(pos, H.DartSymbol(tuple->first())); 4719 parameter_names.SetAt(pos, H.DartSymbol(parameter->name()));
4701 } 4720 }
4702 4721
4703 Type& signature_type = 4722 Type& signature_type =
4704 Type::ZoneHandle(Z, signature_function.SignatureType()); 4723 Type::ZoneHandle(Z, signature_function.SignatureType());
4705 4724
4706 if (finalize_) { 4725 if (finalize_) {
4707 signature_type ^= 4726 signature_type ^=
4708 ClassFinalizer::FinalizeType(*active_class_->klass, signature_type); 4727 ClassFinalizer::FinalizeType(*active_class_->klass, signature_type);
4709 // Do not refer to signature_function anymore, since it may have been 4728 // Do not refer to signature_function anymore, since it may have been
4710 // replaced during canonicalization. 4729 // replaced during canonicalization.
(...skipping 2024 matching lines...) Expand 10 before | Expand all | Expand 10 after
6735 metadata_expressions = &Field::Cast(kernel_node)->annotations(); 6754 metadata_expressions = &Field::Cast(kernel_node)->annotations();
6736 } else if (kernel_node->IsConstructor()) { 6755 } else if (kernel_node->IsConstructor()) {
6737 metadata_expressions = &Constructor::Cast(kernel_node)->annotations(); 6756 metadata_expressions = &Constructor::Cast(kernel_node)->annotations();
6738 } else { 6757 } else {
6739 FATAL1("No support for metadata on this type of kernel node %p\n", 6758 FATAL1("No support for metadata on this type of kernel node %p\n",
6740 kernel_node); 6759 kernel_node);
6741 } 6760 }
6742 6761
6743 TranslationHelper helper(thread); 6762 TranslationHelper helper(thread);
6744 Script& script = Script::Handle(Z, metadata_field.Script()); 6763 Script& script = Script::Handle(Z, metadata_field.Script());
6745 helper.SetStringData(TypedData::Handle(Z, script.kernel_strings())); 6764 helper.SetStringOffsets(
6765 TypedData::Handle(Z, script.kernel_string_offsets()));
6766 helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
6746 DartTypeTranslator type_translator(&helper, NULL, true); 6767 DartTypeTranslator type_translator(&helper, NULL, true);
6747 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z, 6768 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z,
6748 &helper, &type_translator); 6769 &helper, &type_translator);
6749 6770
6750 const Array& metadata_values = 6771 const Array& metadata_values =
6751 Array::Handle(Z, Array::New(metadata_expressions->length())); 6772 Array::Handle(Z, Array::New(metadata_expressions->length()));
6752 6773
6753 for (intptr_t i = 0; i < metadata_expressions->length(); i++) { 6774 for (intptr_t i = 0; i < metadata_expressions->length(); i++) {
6754 const Instance& value = 6775 const Instance& value =
6755 constant_evaluator.EvaluateExpression((*metadata_expressions)[i]); 6776 constant_evaluator.EvaluateExpression((*metadata_expressions)[i]);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
6832 thread->clear_sticky_error(); 6853 thread->clear_sticky_error();
6833 return error.raw(); 6854 return error.raw();
6834 } 6855 }
6835 } 6856 }
6836 6857
6837 6858
6838 } // namespace kernel 6859 } // namespace kernel
6839 } // namespace dart 6860 } // namespace dart
6840 6861
6841 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6862 #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