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

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

Issue 2853423002: Move the Kernel canonical name table into the VM's heap (Closed)
Patch Set: Merge a bugfix 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
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 6
7 #include "vm/kernel_to_il.h" 7 #include "vm/kernel_to_il.h"
8 8
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/intermediate_language.h" 10 #include "vm/intermediate_language.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 zone_(translation_helper_.zone()), 65 zone_(translation_helper_.zone()),
66 type_translator_(&translation_helper_, &active_class_, /*finalize=*/true), 66 type_translator_(&translation_helper_, &active_class_, /*finalize=*/true),
67 current_function_scope_(NULL), 67 current_function_scope_(NULL),
68 scope_(NULL), 68 scope_(NULL),
69 depth_(0), 69 depth_(0),
70 name_index_(0), 70 name_index_(0),
71 needs_expr_temp_(false) { 71 needs_expr_temp_(false) {
72 Script& script = Script::Handle(Z, parsed_function->function().script()); 72 Script& script = Script::Handle(Z, parsed_function->function().script());
73 H.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets())); 73 H.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
74 H.SetStringData(TypedData::Handle(Z, script.kernel_string_data())); 74 H.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
75 H.SetCanonicalNames(TypedData::Handle(Z, script.kernel_canonical_names()));
75 } 76 }
76 77
77 78
78 void ScopeBuilder::EnterScope(TreeNode* node, TokenPosition start_position) { 79 void ScopeBuilder::EnterScope(TreeNode* node, TokenPosition start_position) {
79 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_); 80 scope_ = new (Z) LocalScope(scope_, depth_.function_, depth_.loop_);
80 scope_->set_begin_token_pos(start_position); 81 scope_->set_begin_token_pos(start_position);
81 ASSERT(node->kernel_offset() >= 0); 82 ASSERT(node->kernel_offset() >= 0);
82 result_->scopes.Insert(node->kernel_offset(), scope_); 83 result_->scopes.Insert(node->kernel_offset(), scope_);
83 } 84 }
84 85
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 283 }
283 284
284 285
285 ScopeBuildingResult* ScopeBuilder::BuildScopes() { 286 ScopeBuildingResult* ScopeBuilder::BuildScopes() {
286 if (result_ != NULL) return result_; 287 if (result_ != NULL) return result_;
287 288
288 ASSERT(scope_ == NULL && depth_.loop_ == 0 && depth_.function_ == 0); 289 ASSERT(scope_ == NULL && depth_.loop_ == 0 && depth_.function_ == 0);
289 result_ = new (Z) ScopeBuildingResult(); 290 result_ = new (Z) ScopeBuildingResult();
290 291
291 ParsedFunction* parsed_function = parsed_function_; 292 ParsedFunction* parsed_function = parsed_function_;
292 const dart::Function& function = parsed_function->function(); 293 const Function& function = parsed_function->function();
293 294
294 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used 295 // Setup a [ActiveClassScope] and a [ActiveMemberScope] which will be used
295 // e.g. for type translation. 296 // e.g. for type translation.
296 const dart::Class& klass = 297 const dart::Class& klass =
297 dart::Class::Handle(zone_, parsed_function_->function().Owner()); 298 dart::Class::Handle(zone_, parsed_function_->function().Owner());
298 Function& outermost_function = Function::Handle(Z); 299 Function& outermost_function = Function::Handle(Z);
299 TreeNode* outermost_node = NULL; 300 TreeNode* outermost_node = NULL;
300 Class* kernel_class = NULL; 301 Class* kernel_class = NULL;
301 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node, 302 DiscoverEnclosingElements(Z, function, &outermost_function, &outermost_node,
302 &kernel_class); 303 &kernel_class);
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 } 1032 }
1032 1033
1033 1034
1034 Fragment operator<<(const Fragment& fragment, Instruction* next) { 1035 Fragment operator<<(const Fragment& fragment, Instruction* next) {
1035 Fragment result = fragment; 1036 Fragment result = fragment;
1036 result <<= next; 1037 result <<= next;
1037 return result; 1038 return result;
1038 } 1039 }
1039 1040
1040 1041
1041 TranslationHelper::TranslationHelper(dart::Thread* thread) 1042 TranslationHelper::TranslationHelper(Thread* thread)
1042 : thread_(thread), 1043 : thread_(thread),
1043 zone_(thread->zone()), 1044 zone_(thread->zone()),
1044 isolate_(thread->isolate()), 1045 isolate_(thread->isolate()),
1045 allocation_space_(thread->IsMutatorThread() ? Heap::kNew : Heap::kOld), 1046 allocation_space_(thread->IsMutatorThread() ? Heap::kNew : Heap::kOld),
1046 string_offsets_(TypedData::Handle(Z)), 1047 string_offsets_(TypedData::Handle(Z)),
1047 string_data_(TypedData::Handle(Z)) {} 1048 string_data_(TypedData::Handle(Z)),
1049 canonical_names_(TypedData::Handle(Z)) {}
1048 1050
1049 1051
1050 void TranslationHelper::SetStringOffsets(const TypedData& string_offsets) { 1052 void TranslationHelper::SetStringOffsets(const TypedData& string_offsets) {
1051 ASSERT(string_offsets_.IsNull()); 1053 ASSERT(string_offsets_.IsNull());
1052 string_offsets_ = string_offsets.raw(); 1054 string_offsets_ = string_offsets.raw();
1053 } 1055 }
1054 1056
1055 1057
1056 void TranslationHelper::SetStringData(const TypedData& string_data) { 1058 void TranslationHelper::SetStringData(const TypedData& string_data) {
1057 ASSERT(string_data_.IsNull()); 1059 ASSERT(string_data_.IsNull());
1058 string_data_ = string_data.raw(); 1060 string_data_ = string_data.raw();
1059 } 1061 }
1060 1062
1061 1063
1064 void TranslationHelper::SetCanonicalNames(const TypedData& canonical_names) {
1065 ASSERT(canonical_names_.IsNull());
1066 canonical_names_ = canonical_names.raw();
1067 }
1068
1069
1062 intptr_t TranslationHelper::StringOffset(intptr_t string_index) const { 1070 intptr_t TranslationHelper::StringOffset(intptr_t string_index) const {
1063 return string_offsets_.GetUint32(string_index << 2); 1071 return string_offsets_.GetUint32(string_index << 2);
1064 } 1072 }
1065 1073
1066 1074
1067 intptr_t TranslationHelper::StringSize(intptr_t string_index) const { 1075 intptr_t TranslationHelper::StringSize(intptr_t string_index) const {
1068 return StringOffset(string_index + 1) - StringOffset(string_index); 1076 return StringOffset(string_index + 1) - StringOffset(string_index);
1069 } 1077 }
1070 1078
1071 1079
1072 uint8_t TranslationHelper::CharacterAt(intptr_t string_index, intptr_t index) { 1080 uint8_t TranslationHelper::CharacterAt(intptr_t string_index, intptr_t index) {
1073 ASSERT(index < StringSize(string_index)); 1081 ASSERT(index < StringSize(string_index));
1074 return string_data_.GetUint8(StringOffset(string_index) + index); 1082 return string_data_.GetUint8(StringOffset(string_index) + index);
1075 } 1083 }
1076 1084
1077 1085
1078 bool TranslationHelper::StringEquals(intptr_t string_index, const char* other) { 1086 bool TranslationHelper::StringEquals(intptr_t string_index, const char* other) {
1079 NoSafepointScope no_safepoint; 1087 NoSafepointScope no_safepoint;
1080 intptr_t length = strlen(other); 1088 intptr_t length = strlen(other);
1081 return (length == StringSize(string_index)) && 1089 return (length == StringSize(string_index)) &&
1082 (memcmp(string_data_.DataAddr(StringOffset(string_index)), other, 1090 (memcmp(string_data_.DataAddr(StringOffset(string_index)), other,
1083 length) == 0); 1091 length) == 0);
1084 } 1092 }
1085 1093
1086 1094
1087 bool TranslationHelper::IsAdministrative(CanonicalName* name) { 1095 intptr_t TranslationHelper::CanonicalNameParent(intptr_t name) {
1088 // Administrative names start with '@'. 1096 // Canonical names are pairs of 4-byte parent and string indexes, so the size
1089 return (StringSize(name->name()) > 0) && 1097 // of an entry is 8 bytes. The parent is biased: 0 represents the root name
1090 (CharacterAt(name->name(), 0) == '@'); 1098 // and N+1 represents the name with index N.
1099 return static_cast<intptr_t>(canonical_names_.GetUint32(8 * name)) - 1;
1091 } 1100 }
1092 1101
1093 1102
1094 bool TranslationHelper::IsPrivate(CanonicalName* name) { 1103 intptr_t TranslationHelper::CanonicalNameString(intptr_t name) {
1095 // Private names start with '_'. 1104 return canonical_names_.GetUint32((8 * name) + 4);
1096 return (StringSize(name->name()) > 0) &&
1097 (CharacterAt(name->name(), 0) == '_');
1098 } 1105 }
1099 1106
1100 1107
1101 bool TranslationHelper::IsRoot(CanonicalName* name) { 1108 bool TranslationHelper::IsAdministrative(intptr_t name) {
1102 // The root is the only canonical name with no parent. 1109 // Administrative names start with '@'.
1103 return name->parent() == NULL; 1110 intptr_t name_string = CanonicalNameString(name);
1111 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '@');
1104 } 1112 }
1105 1113
1106 1114
1107 bool TranslationHelper::IsLibrary(CanonicalName* name) { 1115 bool TranslationHelper::IsPrivate(intptr_t name) {
1108 // Libraries are the only canonical names with the root as their parent. 1116 // Private names start with '_'.
1109 return !IsRoot(name) && IsRoot(name->parent()); 1117 intptr_t name_string = CanonicalNameString(name);
1118 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '_');
1110 } 1119 }
1111 1120
1112 1121
1113 bool TranslationHelper::IsClass(CanonicalName* name) { 1122 bool TranslationHelper::IsRoot(intptr_t name) {
1114 // Classes have the library as their parent and are not an administrative 1123 return name == -1;
1115 // name starting with @.
1116 return !IsAdministrative(name) && !IsRoot(name) && IsLibrary(name->parent());
1117 } 1124 }
1118 1125
1119 1126
1120 bool TranslationHelper::IsMember(CanonicalName* name) { 1127 bool TranslationHelper::IsLibrary(intptr_t name) {
1128 // Libraries are the only canonical names with the root as their parent.
1129 return !IsRoot(name) && IsRoot(CanonicalNameParent(name));
1130 }
1131
1132
1133 bool TranslationHelper::IsClass(intptr_t name) {
1134 // Classes have the library as their parent and are not an administrative
1135 // name starting with @.
1136 return !IsAdministrative(name) && !IsRoot(name) &&
1137 IsLibrary(CanonicalNameParent(name));
1138 }
1139
1140
1141 bool TranslationHelper::IsMember(intptr_t name) {
1121 return IsConstructor(name) || IsField(name) || IsProcedure(name); 1142 return IsConstructor(name) || IsField(name) || IsProcedure(name);
1122 } 1143 }
1123 1144
1124 1145
1125 bool TranslationHelper::IsField(CanonicalName* name) { 1146 bool TranslationHelper::IsField(intptr_t name) {
1126 // Fields with private names have the import URI of the library where they are 1147 // Fields with private names have the import URI of the library where they are
1127 // visible as the parent and the string "@fields" as the parent's parent. 1148 // visible as the parent and the string "@fields" as the parent's parent.
1128 // Fields with non-private names have the string "@fields' as the parent. 1149 // Fields with non-private names have the string "@fields' as the parent.
1129 if (IsRoot(name)) { 1150 if (IsRoot(name)) {
1130 return false; 1151 return false;
1131 } 1152 }
1132 CanonicalName* kind = name->parent(); 1153 intptr_t kind = CanonicalNameParent(name);
1133 if (IsPrivate(name)) { 1154 if (IsPrivate(name)) {
1134 kind = kind->parent(); 1155 kind = CanonicalNameParent(kind);
1135 } 1156 }
1136 return StringEquals(kind->name(), "@fields"); 1157 return StringEquals(CanonicalNameString(kind), "@fields");
1137 } 1158 }
1138 1159
1139 1160
1140 bool TranslationHelper::IsConstructor(CanonicalName* name) { 1161 bool TranslationHelper::IsConstructor(intptr_t name) {
1141 // Constructors with private names have the import URI of the library where 1162 // Constructors with private names have the import URI of the library where
1142 // they are visible as the parent and the string "@constructors" as the 1163 // they are visible as the parent and the string "@constructors" as the
1143 // parent's parent. Constructors with non-private names have the string 1164 // parent's parent. Constructors with non-private names have the string
1144 // "@constructors" as the parent. 1165 // "@constructors" as the parent.
1145 if (IsRoot(name)) { 1166 if (IsRoot(name)) {
1146 return false; 1167 return false;
1147 } 1168 }
1148 CanonicalName* kind = name->parent(); 1169 intptr_t kind = CanonicalNameParent(name);
1149 if (IsPrivate(name)) { 1170 if (IsPrivate(name)) {
1150 kind = kind->parent(); 1171 kind = CanonicalNameParent(kind);
1151 } 1172 }
1152 return StringEquals(kind->name(), "@constructors"); 1173 return StringEquals(CanonicalNameString(kind), "@constructors");
1153 } 1174 }
1154 1175
1155 1176
1156 bool TranslationHelper::IsProcedure(CanonicalName* name) { 1177 bool TranslationHelper::IsProcedure(intptr_t name) {
1157 return IsMethod(name) || IsGetter(name) || IsSetter(name) || IsFactory(name); 1178 return IsMethod(name) || IsGetter(name) || IsSetter(name) || IsFactory(name);
1158 } 1179 }
1159 1180
1160 1181
1161 bool TranslationHelper::IsMethod(CanonicalName* name) { 1182 bool TranslationHelper::IsMethod(intptr_t name) {
1162 // Methods with private names have the import URI of the library where they 1183 // Methods with private names have the import URI of the library where they
1163 // are visible as the parent and the string "@methods" as the parent's parent. 1184 // are visible as the parent and the string "@methods" as the parent's parent.
1164 // Methods with non-private names have the string "@methods" as the parent. 1185 // Methods with non-private names have the string "@methods" as the parent.
1165 if (IsRoot(name)) { 1186 if (IsRoot(name)) {
1166 return false; 1187 return false;
1167 } 1188 }
1168 CanonicalName* kind = name->parent(); 1189 intptr_t kind = CanonicalNameParent(name);
1169 if (IsPrivate(name)) { 1190 if (IsPrivate(name)) {
1170 kind = kind->parent(); 1191 kind = CanonicalNameParent(kind);
1171 } 1192 }
1172 return StringEquals(kind->name(), "@methods"); 1193 return StringEquals(CanonicalNameString(kind), "@methods");
1173 } 1194 }
1174 1195
1175 1196
1176 bool TranslationHelper::IsGetter(CanonicalName* name) { 1197 bool TranslationHelper::IsGetter(intptr_t name) {
1177 // Getters with private names have the import URI of the library where they 1198 // Getters with private names have the import URI of the library where they
1178 // are visible as the parent and the string "@getters" as the parent's parent. 1199 // are visible as the parent and the string "@getters" as the parent's parent.
1179 // Getters with non-private names have the string "@getters" as the parent. 1200 // Getters with non-private names have the string "@getters" as the parent.
1180 if (IsRoot(name)) { 1201 if (IsRoot(name)) {
1181 return false; 1202 return false;
1182 } 1203 }
1183 CanonicalName* kind = name->parent(); 1204 intptr_t kind = CanonicalNameParent(name);
1184 if (IsPrivate(name)) { 1205 if (IsPrivate(name)) {
1185 kind = kind->parent(); 1206 kind = CanonicalNameParent(kind);
1186 } 1207 }
1187 return StringEquals(kind->name(), "@getters"); 1208 return StringEquals(CanonicalNameString(kind), "@getters");
1188 } 1209 }
1189 1210
1190 1211
1191 bool TranslationHelper::IsSetter(CanonicalName* name) { 1212 bool TranslationHelper::IsSetter(intptr_t name) {
1192 // Setters with private names have the import URI of the library where they 1213 // Setters with private names have the import URI of the library where they
1193 // are visible as the parent and the string "@setters" as the parent's parent. 1214 // are visible as the parent and the string "@setters" as the parent's parent.
1194 // Setters with non-private names have the string "@setters" as the parent. 1215 // Setters with non-private names have the string "@setters" as the parent.
1195 if (IsRoot(name)) { 1216 if (IsRoot(name)) {
1196 return false; 1217 return false;
1197 } 1218 }
1198 CanonicalName* kind = name->parent(); 1219 intptr_t kind = CanonicalNameParent(name);
1199 if (IsPrivate(name)) { 1220 if (IsPrivate(name)) {
1200 kind = kind->parent(); 1221 kind = CanonicalNameParent(kind);
1201 } 1222 }
1202 return StringEquals(kind->name(), "@setters"); 1223 return StringEquals(CanonicalNameString(kind), "@setters");
1203 } 1224 }
1204 1225
1205 1226
1206 bool TranslationHelper::IsFactory(CanonicalName* name) { 1227 bool TranslationHelper::IsFactory(intptr_t name) {
1207 // Factories with private names have the import URI of the library where they 1228 // Factories with private names have the import URI of the library where they
1208 // are visible as the parent and the string "@factories" as the parent's 1229 // are visible as the parent and the string "@factories" as the parent's
1209 // parent. Factories with non-private names have the string "@factories" as 1230 // parent. Factories with non-private names have the string "@factories" as
1210 // the parent. 1231 // the parent.
1211 if (IsRoot(name)) { 1232 if (IsRoot(name)) {
1212 return false; 1233 return false;
1213 } 1234 }
1214 CanonicalName* kind = name->parent(); 1235 intptr_t kind = CanonicalNameParent(name);
1215 if (IsPrivate(name)) { 1236 if (IsPrivate(name)) {
1216 kind = kind->parent(); 1237 kind = CanonicalNameParent(kind);
1217 } 1238 }
1218 return StringEquals(kind->name(), "@factories"); 1239 return StringEquals(CanonicalNameString(kind), "@factories");
1219 } 1240 }
1220 1241
1221 1242
1222 CanonicalName* TranslationHelper::EnclosingName(CanonicalName* name) { 1243 intptr_t TranslationHelper::EnclosingName(intptr_t name) {
1223 ASSERT(IsField(name) || IsConstructor(name) || IsProcedure(name)); 1244 ASSERT(IsField(name) || IsConstructor(name) || IsProcedure(name));
1224 CanonicalName* enclosing = name->parent()->parent(); 1245 intptr_t enclosing = CanonicalNameParent(CanonicalNameParent(name));
1225 if (IsPrivate(name)) { 1246 if (IsPrivate(name)) {
1226 enclosing = enclosing->parent(); 1247 enclosing = CanonicalNameParent(enclosing);
1227 } 1248 }
1228 ASSERT(IsLibrary(enclosing) || IsClass(enclosing)); 1249 ASSERT(IsLibrary(enclosing) || IsClass(enclosing));
1229 return enclosing; 1250 return enclosing;
1230 } 1251 }
1231 1252
1232 1253
1233 RawInstance* TranslationHelper::Canonicalize(const Instance& instance) { 1254 RawInstance* TranslationHelper::Canonicalize(const Instance& instance) {
1234 if (instance.IsNull()) return instance.raw(); 1255 if (instance.IsNull()) return instance.raw();
1235 1256
1236 const char* error_str = NULL; 1257 const char* error_str = NULL;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 } 1295 }
1275 1296
1276 1297
1277 dart::String& TranslationHelper::DartSymbol(intptr_t string_index) const { 1298 dart::String& TranslationHelper::DartSymbol(intptr_t string_index) const {
1278 intptr_t length = StringSize(string_index); 1299 intptr_t length = StringSize(string_index);
1279 uint8_t* buffer = Z->Alloc<uint8_t>(length); 1300 uint8_t* buffer = Z->Alloc<uint8_t>(length);
1280 { 1301 {
1281 NoSafepointScope no_safepoint; 1302 NoSafepointScope no_safepoint;
1282 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length); 1303 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length);
1283 } 1304 }
1284 return dart::String::ZoneHandle( 1305 return dart::String::ZoneHandle(Z,
1285 Z, dart::Symbols::FromUTF8(thread_, buffer, length)); 1306 Symbols::FromUTF8(thread_, buffer, length));
1286 } 1307 }
1287 1308
1288 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array, 1309 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array,
1289 intptr_t len) const { 1310 intptr_t len) const {
1290 return dart::String::ZoneHandle( 1311 return dart::String::ZoneHandle(Z,
1291 Z, dart::Symbols::FromUTF8(thread_, utf8_array, len)); 1312 Symbols::FromUTF8(thread_, utf8_array, len));
1292 } 1313 }
1293 1314
1294 const dart::String& TranslationHelper::DartClassName( 1315 const dart::String& TranslationHelper::DartClassName(intptr_t kernel_class) {
1295 CanonicalName* kernel_class) {
1296 ASSERT(IsClass(kernel_class)); 1316 ASSERT(IsClass(kernel_class));
1297 dart::String& name = DartString(kernel_class->name()); 1317 dart::String& name = DartString(CanonicalNameString(kernel_class));
1298 return ManglePrivateName(kernel_class->parent(), &name); 1318 return ManglePrivateName(CanonicalNameParent(kernel_class), &name);
1299 } 1319 }
1300 1320
1301 1321
1302 const dart::String& TranslationHelper::DartConstructorName( 1322 const dart::String& TranslationHelper::DartConstructorName(
1303 CanonicalName* constructor) { 1323 intptr_t constructor) {
1304 ASSERT(IsConstructor(constructor)); 1324 ASSERT(IsConstructor(constructor));
1305 return DartFactoryName(constructor); 1325 return DartFactoryName(constructor);
1306 } 1326 }
1307 1327
1308 1328
1309 const dart::String& TranslationHelper::DartProcedureName( 1329 const dart::String& TranslationHelper::DartProcedureName(intptr_t procedure) {
1310 CanonicalName* procedure) {
1311 ASSERT(IsProcedure(procedure)); 1330 ASSERT(IsProcedure(procedure));
1312 if (IsSetter(procedure)) { 1331 if (IsSetter(procedure)) {
1313 return DartSetterName(procedure); 1332 return DartSetterName(procedure);
1314 } else if (IsGetter(procedure)) { 1333 } else if (IsGetter(procedure)) {
1315 return DartGetterName(procedure); 1334 return DartGetterName(procedure);
1316 } else if (IsFactory(procedure)) { 1335 } else if (IsFactory(procedure)) {
1317 return DartFactoryName(procedure); 1336 return DartFactoryName(procedure);
1318 } else { 1337 } else {
1319 return DartMethodName(procedure); 1338 return DartMethodName(procedure);
1320 } 1339 }
1321 } 1340 }
1322 1341
1323 1342
1324 const dart::String& TranslationHelper::DartSetterName(CanonicalName* setter) { 1343 const dart::String& TranslationHelper::DartSetterName(intptr_t setter) {
1325 return DartSetterName(setter->parent(), setter->name()); 1344 return DartSetterName(CanonicalNameParent(setter),
1345 CanonicalNameString(setter));
1326 } 1346 }
1327 1347
1328 1348
1329 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) { 1349 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) {
1330 return DartSetterName(setter_name->library(), setter_name->string_index()); 1350 return DartSetterName(setter_name->library(), setter_name->string_index());
1331 } 1351 }
1332 1352
1333 1353
1334 const dart::String& TranslationHelper::DartSetterName(CanonicalName* parent, 1354 const dart::String& TranslationHelper::DartSetterName(intptr_t parent,
1335 intptr_t setter) { 1355 intptr_t setter) {
1336 // The names flowing into [setter] are coming from the Kernel file: 1356 // The names flowing into [setter] are coming from the Kernel file:
1337 // * user-defined setters: `fieldname=` 1357 // * user-defined setters: `fieldname=`
1338 // * property-set expressions: `fieldname` 1358 // * property-set expressions: `fieldname`
1339 // 1359 //
1340 // The VM uses `get:fieldname` and `set:fieldname`. 1360 // The VM uses `get:fieldname` and `set:fieldname`.
1341 // 1361 //
1342 // => In order to be consistent, we remove the `=` always and adopt the VM 1362 // => In order to be consistent, we remove the `=` always and adopt the VM
1343 // conventions. 1363 // conventions.
1344 intptr_t size = StringSize(setter); 1364 intptr_t size = StringSize(setter);
1345 ASSERT(size > 0); 1365 ASSERT(size > 0);
1346 if (CharacterAt(setter, size - 1) == '=') { 1366 if (CharacterAt(setter, size - 1) == '=') {
1347 --size; 1367 --size;
1348 } 1368 }
1349 uint8_t* buffer = Z->Alloc<uint8_t>(size); 1369 uint8_t* buffer = Z->Alloc<uint8_t>(size);
1350 { 1370 {
1351 NoSafepointScope no_safepoint; 1371 NoSafepointScope no_safepoint;
1352 memmove(buffer, string_data_.DataAddr(StringOffset(setter)), size); 1372 memmove(buffer, string_data_.DataAddr(StringOffset(setter)), size);
1353 } 1373 }
1354 dart::String& name = dart::String::ZoneHandle( 1374 dart::String& name = dart::String::ZoneHandle(
1355 Z, dart::String::FromUTF8(buffer, size, allocation_space_)); 1375 Z, dart::String::FromUTF8(buffer, size, allocation_space_));
1356 ManglePrivateName(parent, &name, false); 1376 ManglePrivateName(parent, &name, false);
1357 name = dart::Field::SetterSymbol(name); 1377 name = dart::Field::SetterSymbol(name);
1358 return name; 1378 return name;
1359 } 1379 }
1360 1380
1361 1381
1362 const dart::String& TranslationHelper::DartGetterName(CanonicalName* getter) { 1382 const dart::String& TranslationHelper::DartGetterName(intptr_t getter) {
1363 return DartGetterName(getter->parent(), getter->name()); 1383 return DartGetterName(CanonicalNameParent(getter),
1384 CanonicalNameString(getter));
1364 } 1385 }
1365 1386
1366 1387
1367 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) { 1388 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) {
1368 return DartGetterName(getter_name->library(), getter_name->string_index()); 1389 return DartGetterName(getter_name->library(), getter_name->string_index());
1369 } 1390 }
1370 1391
1371 1392
1372 const dart::String& TranslationHelper::DartGetterName(CanonicalName* parent, 1393 const dart::String& TranslationHelper::DartGetterName(intptr_t parent,
1373 intptr_t getter) { 1394 intptr_t getter) {
1374 dart::String& name = DartString(getter); 1395 dart::String& name = DartString(getter);
1375 ManglePrivateName(parent, &name, false); 1396 ManglePrivateName(parent, &name, false);
1376 name = dart::Field::GetterSymbol(name); 1397 name = dart::Field::GetterSymbol(name);
1377 return name; 1398 return name;
1378 } 1399 }
1379 1400
1380 1401
1381 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) { 1402 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) {
1382 dart::String& name = DartString(kernel_name->string_index()); 1403 dart::String& name = DartString(kernel_name->string_index());
1383 return ManglePrivateName(kernel_name->library(), &name); 1404 return ManglePrivateName(kernel_name->library(), &name);
1384 } 1405 }
1385 1406
1386 1407
1387 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) { 1408 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) {
1388 // The [DartFieldName] will take care of mangling the name. 1409 // The [DartFieldName] will take care of mangling the name.
1389 dart::String& name = 1410 dart::String& name =
1390 dart::String::Handle(Z, DartFieldName(kernel_name).raw()); 1411 dart::String::Handle(Z, DartFieldName(kernel_name).raw());
1391 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name); 1412 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name);
1392 return name; 1413 return name;
1393 } 1414 }
1394 1415
1395 1416
1396 const dart::String& TranslationHelper::DartMethodName(CanonicalName* method) { 1417 const dart::String& TranslationHelper::DartMethodName(intptr_t method) {
1397 return DartMethodName(method->parent(), method->name()); 1418 return DartMethodName(CanonicalNameParent(method),
1419 CanonicalNameString(method));
1398 } 1420 }
1399 1421
1400 1422
1401 const dart::String& TranslationHelper::DartMethodName(Name* method_name) { 1423 const dart::String& TranslationHelper::DartMethodName(Name* method_name) {
1402 return DartMethodName(method_name->library(), method_name->string_index()); 1424 return DartMethodName(method_name->library(), method_name->string_index());
1403 } 1425 }
1404 1426
1405 1427
1406 const dart::String& TranslationHelper::DartMethodName(CanonicalName* parent, 1428 const dart::String& TranslationHelper::DartMethodName(intptr_t parent,
1407 intptr_t method) { 1429 intptr_t method) {
1408 dart::String& name = DartString(method); 1430 dart::String& name = DartString(method);
1409 return ManglePrivateName(parent, &name); 1431 return ManglePrivateName(parent, &name);
1410 } 1432 }
1411 1433
1412 1434
1413 const dart::String& TranslationHelper::DartFactoryName(CanonicalName* factory) { 1435 const dart::String& TranslationHelper::DartFactoryName(intptr_t factory) {
1414 ASSERT(IsConstructor(factory) || IsFactory(factory)); 1436 ASSERT(IsConstructor(factory) || IsFactory(factory));
1415 GrowableHandlePtrArray<const dart::String> pieces(Z, 3); 1437 GrowableHandlePtrArray<const dart::String> pieces(Z, 3);
1416 pieces.Add(DartClassName(EnclosingName(factory))); 1438 pieces.Add(DartClassName(EnclosingName(factory)));
1417 pieces.Add(Symbols::Dot()); 1439 pieces.Add(Symbols::Dot());
1418 // [DartMethodName] will mangle the name. 1440 // [DartMethodName] will mangle the name.
1419 pieces.Add(DartMethodName(factory)); 1441 pieces.Add(DartMethodName(factory));
1420 return dart::String::ZoneHandle( 1442 return dart::String::ZoneHandle(Z, Symbols::FromConcatAll(thread_, pieces));
1421 Z, dart::Symbols::FromConcatAll(thread_, pieces));
1422 } 1443 }
1423 1444
1424 1445
1425 dart::RawLibrary* TranslationHelper::LookupLibraryByKernelLibrary( 1446 RawLibrary* TranslationHelper::LookupLibraryByKernelLibrary(
1426 CanonicalName* kernel_library) { 1447 intptr_t kernel_library) {
1427 // We only use the string and don't rely on having any particular parent. 1448 // We only use the string and don't rely on having any particular parent.
1428 // This ASSERT is just a sanity check. 1449 // This ASSERT is just a sanity check.
1429 ASSERT(IsLibrary(kernel_library) || 1450 ASSERT(IsLibrary(kernel_library) ||
1430 IsAdministrative(kernel_library->parent())); 1451 IsAdministrative(CanonicalNameParent(kernel_library)));
1431 const dart::String& library_name = DartSymbol(kernel_library->name()); 1452 const dart::String& library_name =
1453 DartSymbol(CanonicalNameString(kernel_library));
1432 ASSERT(!library_name.IsNull()); 1454 ASSERT(!library_name.IsNull());
1433 dart::RawLibrary* library = 1455 RawLibrary* library = dart::Library::LookupLibrary(thread_, library_name);
1434 dart::Library::LookupLibrary(thread_, library_name);
1435 ASSERT(library != Object::null()); 1456 ASSERT(library != Object::null());
1436 return library; 1457 return library;
1437 } 1458 }
1438 1459
1439 1460
1440 dart::RawClass* TranslationHelper::LookupClassByKernelClass( 1461 RawClass* TranslationHelper::LookupClassByKernelClass(intptr_t kernel_class) {
1441 CanonicalName* kernel_class) {
1442 ASSERT(IsClass(kernel_class)); 1462 ASSERT(IsClass(kernel_class));
1443 dart::RawClass* klass = NULL;
1444 const dart::String& class_name = DartClassName(kernel_class); 1463 const dart::String& class_name = DartClassName(kernel_class);
1445 CanonicalName* kernel_library = kernel_class->parent(); 1464 intptr_t kernel_library = CanonicalNameParent(kernel_class);
1446 dart::Library& library = 1465 dart::Library& library =
1447 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); 1466 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library));
1448 klass = library.LookupClassAllowPrivate(class_name); 1467 RawClass* klass = library.LookupClassAllowPrivate(class_name);
1449 1468
1450 ASSERT(klass != Object::null()); 1469 ASSERT(klass != Object::null());
1451 return klass; 1470 return klass;
1452 } 1471 }
1453 1472
1454 1473
1455 dart::RawField* TranslationHelper::LookupFieldByKernelField( 1474 RawField* TranslationHelper::LookupFieldByKernelField(intptr_t kernel_field) {
1456 CanonicalName* kernel_field) {
1457 ASSERT(IsField(kernel_field)); 1475 ASSERT(IsField(kernel_field));
1458 CanonicalName* enclosing = EnclosingName(kernel_field); 1476 intptr_t enclosing = EnclosingName(kernel_field);
1459 1477
1460 dart::Class& klass = dart::Class::Handle(Z); 1478 dart::Class& klass = dart::Class::Handle(Z);
1461 if (IsLibrary(enclosing)) { 1479 if (IsLibrary(enclosing)) {
1462 dart::Library& library = 1480 dart::Library& library =
1463 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing)); 1481 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing));
1464 klass = library.toplevel_class(); 1482 klass = library.toplevel_class();
1465 } else { 1483 } else {
1466 ASSERT(IsClass(enclosing)); 1484 ASSERT(IsClass(enclosing));
1467 klass = LookupClassByKernelClass(enclosing); 1485 klass = LookupClassByKernelClass(enclosing);
1468 } 1486 }
1469 dart::RawField* field = 1487 RawField* field = klass.LookupFieldAllowPrivate(
1470 klass.LookupFieldAllowPrivate(DartSymbol(kernel_field->name())); 1488 DartSymbol(CanonicalNameString(kernel_field)));
1471 ASSERT(field != Object::null()); 1489 ASSERT(field != Object::null());
1472 return field; 1490 return field;
1473 } 1491 }
1474 1492
1475 1493
1476 dart::RawFunction* TranslationHelper::LookupStaticMethodByKernelProcedure( 1494 RawFunction* TranslationHelper::LookupStaticMethodByKernelProcedure(
1477 CanonicalName* procedure) { 1495 intptr_t procedure) {
1478 const dart::String& procedure_name = DartProcedureName(procedure); 1496 const dart::String& procedure_name = DartProcedureName(procedure);
1479 1497
1480 // The parent is either a library or a class (in which case the procedure is a 1498 // The parent is either a library or a class (in which case the procedure is a
1481 // static method). 1499 // static method).
1482 CanonicalName* enclosing = EnclosingName(procedure); 1500 intptr_t enclosing = EnclosingName(procedure);
1483 if (IsLibrary(enclosing)) { 1501 if (IsLibrary(enclosing)) {
1484 dart::Library& library = 1502 dart::Library& library =
1485 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing)); 1503 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing));
1486 dart::RawFunction* function = 1504 RawFunction* function = library.LookupFunctionAllowPrivate(procedure_name);
1487 library.LookupFunctionAllowPrivate(procedure_name);
1488 ASSERT(function != Object::null()); 1505 ASSERT(function != Object::null());
1489 return function; 1506 return function;
1490 } else { 1507 } else {
1491 ASSERT(IsClass(enclosing)); 1508 ASSERT(IsClass(enclosing));
1492 dart::Class& klass = 1509 dart::Class& klass =
1493 dart::Class::Handle(Z, LookupClassByKernelClass(enclosing)); 1510 dart::Class::Handle(Z, LookupClassByKernelClass(enclosing));
1494 dart::RawFunction* raw_function = 1511 Function& function = Function::ZoneHandle(
1495 klass.LookupFunctionAllowPrivate(procedure_name); 1512 Z, klass.LookupFunctionAllowPrivate(procedure_name));
1496 ASSERT(raw_function != Object::null()); 1513 ASSERT(!function.IsNull());
1497 1514
1498 // TODO(27590): We can probably get rid of this after no longer using 1515 // TODO(27590): We can probably get rid of this after no longer using
1499 // core libraries from the source. 1516 // core libraries from the source.
1500 dart::Function& function = dart::Function::ZoneHandle(Z, raw_function);
1501 if (function.IsRedirectingFactory()) { 1517 if (function.IsRedirectingFactory()) {
1502 ClassFinalizer::ResolveRedirectingFactory(klass, function); 1518 ClassFinalizer::ResolveRedirectingFactory(klass, function);
1503 function = function.RedirectionTarget(); 1519 function = function.RedirectionTarget();
1504 } 1520 }
1505 return function.raw(); 1521 return function.raw();
1506 } 1522 }
1507 } 1523 }
1508 1524
1509 1525
1510 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( 1526 RawFunction* TranslationHelper::LookupConstructorByKernelConstructor(
1511 CanonicalName* constructor) { 1527 intptr_t constructor) {
1512 ASSERT(IsConstructor(constructor)); 1528 ASSERT(IsConstructor(constructor));
1513 dart::Class& klass = dart::Class::Handle( 1529 dart::Class& klass = dart::Class::Handle(
1514 Z, LookupClassByKernelClass(EnclosingName(constructor))); 1530 Z, LookupClassByKernelClass(EnclosingName(constructor)));
1515 return LookupConstructorByKernelConstructor(klass, constructor); 1531 return LookupConstructorByKernelConstructor(klass, constructor);
1516 } 1532 }
1517 1533
1518 1534
1519 dart::RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( 1535 RawFunction* TranslationHelper::LookupConstructorByKernelConstructor(
1520 const dart::Class& owner, 1536 const dart::Class& owner,
1521 CanonicalName* constructor) { 1537 intptr_t constructor) {
1522 ASSERT(IsConstructor(constructor)); 1538 ASSERT(IsConstructor(constructor));
1523 dart::RawFunction* function = 1539 RawFunction* function =
1524 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor)); 1540 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor));
1525 ASSERT(function != Object::null()); 1541 ASSERT(function != Object::null());
1526 return function; 1542 return function;
1527 } 1543 }
1528 1544
1529 1545
1530 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) { 1546 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) {
1531 ASSERT(!klass.IsNull()); 1547 ASSERT(!klass.IsNull());
1532 // Note that if cls is _Closure, the returned type will be _Closure, 1548 // Note that if cls is _Closure, the returned type will be _Closure,
1533 // and not the signature type. 1549 // and not the signature type.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 1581
1566 va_list args; 1582 va_list args;
1567 va_start(args, format); 1583 va_start(args, format);
1568 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format, 1584 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format,
1569 args); 1585 args);
1570 va_end(args); 1586 va_end(args);
1571 UNREACHABLE(); 1587 UNREACHABLE();
1572 } 1588 }
1573 1589
1574 1590
1575 dart::String& TranslationHelper::ManglePrivateName(CanonicalName* parent, 1591 dart::String& TranslationHelper::ManglePrivateName(intptr_t parent,
1576 dart::String* name_to_modify, 1592 dart::String* name_to_modify,
1577 bool symbolize) { 1593 bool symbolize) {
1578 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') { 1594 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') {
1579 const dart::Library& library = 1595 const dart::Library& library =
1580 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(parent)); 1596 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(parent));
1581 *name_to_modify = library.PrivateName(*name_to_modify); 1597 *name_to_modify = library.PrivateName(*name_to_modify);
1582 } else if (symbolize) { 1598 } else if (symbolize) {
1583 *name_to_modify = Symbols::New(thread_, *name_to_modify); 1599 *name_to_modify = Symbols::New(thread_, *name_to_modify);
1584 } 1600 }
1585 return *name_to_modify; 1601 return *name_to_modify;
(...skipping 27 matching lines...) Expand all
1613 result_(Instance::Handle(zone)) {} 1629 result_(Instance::Handle(zone)) {}
1614 1630
1615 1631
1616 Instance& ConstantEvaluator::EvaluateExpression(Expression* expression) { 1632 Instance& ConstantEvaluator::EvaluateExpression(Expression* expression) {
1617 if (!GetCachedConstant(expression, &result_)) { 1633 if (!GetCachedConstant(expression, &result_)) {
1618 expression->AcceptExpressionVisitor(this); 1634 expression->AcceptExpressionVisitor(this);
1619 CacheConstantValue(expression, result_); 1635 CacheConstantValue(expression, result_);
1620 } 1636 }
1621 // We return a new `ZoneHandle` here on purpose: The intermediate language 1637 // We return a new `ZoneHandle` here on purpose: The intermediate language
1622 // instructions do not make a copy of the handle, so we do it. 1638 // instructions do not make a copy of the handle, so we do it.
1623 return dart::Instance::ZoneHandle(Z, result_.raw()); 1639 return Instance::ZoneHandle(Z, result_.raw());
1624 } 1640 }
1625 1641
1626 1642
1627 Object& ConstantEvaluator::EvaluateExpressionSafe(Expression* expression) { 1643 Object& ConstantEvaluator::EvaluateExpressionSafe(Expression* expression) {
1628 LongJumpScope jump; 1644 LongJumpScope jump;
1629 if (setjmp(*jump.Set()) == 0) { 1645 if (setjmp(*jump.Set()) == 0) {
1630 return EvaluateExpression(expression); 1646 return EvaluateExpression(expression);
1631 } else { 1647 } else {
1632 Thread* thread = H.thread(); 1648 Thread* thread = H.thread();
1633 Error& error = Error::Handle(Z); 1649 Error& error = Error::Handle(Z);
1634 error = thread->sticky_error(); 1650 error = thread->sticky_error();
1635 thread->clear_sticky_error(); 1651 thread->clear_sticky_error();
1636 return error; 1652 return error;
1637 } 1653 }
1638 } 1654 }
1639 1655
1640 1656
1641 Instance& ConstantEvaluator::EvaluateConstructorInvocation( 1657 Instance& ConstantEvaluator::EvaluateConstructorInvocation(
1642 ConstructorInvocation* node) { 1658 ConstructorInvocation* node) {
1643 if (!GetCachedConstant(node, &result_)) { 1659 if (!GetCachedConstant(node, &result_)) {
1644 VisitConstructorInvocation(node); 1660 VisitConstructorInvocation(node);
1645 CacheConstantValue(node, result_); 1661 CacheConstantValue(node, result_);
1646 } 1662 }
1647 // We return a new `ZoneHandle` here on purpose: The intermediate language 1663 // We return a new `ZoneHandle` here on purpose: The intermediate language
1648 // instructions do not make a copy of the handle, so we do it. 1664 // instructions do not make a copy of the handle, so we do it.
1649 return dart::Instance::ZoneHandle(Z, result_.raw()); 1665 return Instance::ZoneHandle(Z, result_.raw());
1650 } 1666 }
1651 1667
1652 1668
1653 Instance& ConstantEvaluator::EvaluateListLiteral(ListLiteral* node) { 1669 Instance& ConstantEvaluator::EvaluateListLiteral(ListLiteral* node) {
1654 if (!GetCachedConstant(node, &result_)) { 1670 if (!GetCachedConstant(node, &result_)) {
1655 VisitListLiteral(node); 1671 VisitListLiteral(node);
1656 CacheConstantValue(node, result_); 1672 CacheConstantValue(node, result_);
1657 } 1673 }
1658 // We return a new `ZoneHandle` here on purpose: The intermediate language 1674 // We return a new `ZoneHandle` here on purpose: The intermediate language
1659 // instructions do not make a copy of the handle, so we do it. 1675 // instructions do not make a copy of the handle, so we do it.
1660 return dart::Instance::ZoneHandle(Z, result_.raw()); 1676 return Instance::ZoneHandle(Z, result_.raw());
1661 } 1677 }
1662 1678
1663 1679
1664 Instance& ConstantEvaluator::EvaluateMapLiteral(MapLiteral* node) { 1680 Instance& ConstantEvaluator::EvaluateMapLiteral(MapLiteral* node) {
1665 if (!GetCachedConstant(node, &result_)) { 1681 if (!GetCachedConstant(node, &result_)) {
1666 VisitMapLiteral(node); 1682 VisitMapLiteral(node);
1667 CacheConstantValue(node, result_); 1683 CacheConstantValue(node, result_);
1668 } 1684 }
1669 // We return a new `ZoneHandle` here on purpose: The intermediate language 1685 // We return a new `ZoneHandle` here on purpose: The intermediate language
1670 // instructions do not make a copy of the handle, so we do it. 1686 // instructions do not make a copy of the handle, so we do it.
1671 return dart::Instance::ZoneHandle(Z, result_.raw()); 1687 return Instance::ZoneHandle(Z, result_.raw());
1672 } 1688 }
1673 1689
1674 1690
1675 void ConstantEvaluator::VisitBigintLiteral(BigintLiteral* node) { 1691 void ConstantEvaluator::VisitBigintLiteral(BigintLiteral* node) {
1676 const dart::String& value = H.DartString(node->value()); 1692 const dart::String& value = H.DartString(node->value());
1677 result_ = Integer::New(value, Heap::kOld); 1693 result_ = Integer::New(value, Heap::kOld);
1678 result_ = H.Canonicalize(result_); 1694 result_ = H.Canonicalize(result_);
1679 } 1695 }
1680 1696
1681 1697
1682 void ConstantEvaluator::VisitBoolLiteral(BoolLiteral* node) { 1698 void ConstantEvaluator::VisitBoolLiteral(BoolLiteral* node) {
1683 result_ = dart::Bool::Get(node->value()).raw(); 1699 result_ = Bool::Get(node->value()).raw();
1684 } 1700 }
1685 1701
1686 1702
1687 void ConstantEvaluator::VisitDoubleLiteral(DoubleLiteral* node) { 1703 void ConstantEvaluator::VisitDoubleLiteral(DoubleLiteral* node) {
1688 result_ = dart::Double::New(H.DartString(node->value()), Heap::kOld); 1704 result_ = Double::New(H.DartString(node->value()), Heap::kOld);
1689 result_ = H.Canonicalize(result_); 1705 result_ = H.Canonicalize(result_);
1690 } 1706 }
1691 1707
1692 1708
1693 void ConstantEvaluator::VisitIntLiteral(IntLiteral* node) { 1709 void ConstantEvaluator::VisitIntLiteral(IntLiteral* node) {
1694 result_ = dart::Integer::New(node->value(), Heap::kOld); 1710 result_ = Integer::New(node->value(), Heap::kOld);
1695 result_ = H.Canonicalize(result_); 1711 result_ = H.Canonicalize(result_);
1696 } 1712 }
1697 1713
1698 1714
1699 void ConstantEvaluator::VisitNullLiteral(NullLiteral* node) { 1715 void ConstantEvaluator::VisitNullLiteral(NullLiteral* node) {
1700 result_ = dart::Instance::null(); 1716 result_ = Instance::null();
1701 } 1717 }
1702 1718
1703 1719
1704 void ConstantEvaluator::VisitStringLiteral(StringLiteral* node) { 1720 void ConstantEvaluator::VisitStringLiteral(StringLiteral* node) {
1705 result_ = H.DartSymbol(node->value()).raw(); 1721 result_ = H.DartSymbol(node->value()).raw();
1706 } 1722 }
1707 1723
1708 1724
1709 void ConstantEvaluator::VisitTypeLiteral(TypeLiteral* node) { 1725 void ConstantEvaluator::VisitTypeLiteral(TypeLiteral* node) {
1710 const AbstractType& type = T.TranslateType(node->type()); 1726 const AbstractType& type = T.TranslateType(node->type());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 script_.set_compile_time_constants(constants.Release()); 1823 script_.set_compile_time_constants(constants.Release());
1808 } 1824 }
1809 1825
1810 1826
1811 void ConstantEvaluator::VisitSymbolLiteral(SymbolLiteral* node) { 1827 void ConstantEvaluator::VisitSymbolLiteral(SymbolLiteral* node) {
1812 const dart::String& symbol_value = H.DartSymbol(node->value()); 1828 const dart::String& symbol_value = H.DartSymbol(node->value());
1813 1829
1814 const dart::Class& symbol_class = 1830 const dart::Class& symbol_class =
1815 dart::Class::ZoneHandle(Z, I->object_store()->symbol_class()); 1831 dart::Class::ZoneHandle(Z, I->object_store()->symbol_class());
1816 ASSERT(!symbol_class.IsNull()); 1832 ASSERT(!symbol_class.IsNull());
1817 const dart::Function& symbol_constructor = Function::ZoneHandle( 1833 const Function& symbol_constructor = Function::ZoneHandle(
1818 Z, symbol_class.LookupConstructor(Symbols::SymbolCtor())); 1834 Z, symbol_class.LookupConstructor(Symbols::SymbolCtor()));
1819 ASSERT(!symbol_constructor.IsNull()); 1835 ASSERT(!symbol_constructor.IsNull());
1820 result_ ^= EvaluateConstConstructorCall( 1836 result_ ^= EvaluateConstConstructorCall(
1821 symbol_class, TypeArguments::Handle(Z), symbol_constructor, symbol_value); 1837 symbol_class, TypeArguments::Handle(Z), symbol_constructor, symbol_value);
1822 } 1838 }
1823 1839
1824 1840
1825 void ConstantEvaluator::VisitListLiteral(ListLiteral* node) { 1841 void ConstantEvaluator::VisitListLiteral(ListLiteral* node) {
1826 DartType* types[] = {node->type()}; 1842 DartType* types[] = {node->type()};
1827 const TypeArguments& type_arguments = T.TranslateTypeArguments(types, 1); 1843 const TypeArguments& type_arguments = T.TranslateTypeArguments(types, 1);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1912 } 1928 }
1913 } 1929 }
1914 1930
1915 1931
1916 void ConstantEvaluator::VisitMethodInvocation(MethodInvocation* node) { 1932 void ConstantEvaluator::VisitMethodInvocation(MethodInvocation* node) {
1917 Arguments* kernel_arguments = node->arguments(); 1933 Arguments* kernel_arguments = node->arguments();
1918 1934
1919 // Dart does not support generic methods yet. 1935 // Dart does not support generic methods yet.
1920 ASSERT(kernel_arguments->types().length() == 0); 1936 ASSERT(kernel_arguments->types().length() == 0);
1921 1937
1922 const dart::Instance& receiver = EvaluateExpression(node->receiver()); 1938 const Instance& receiver = EvaluateExpression(node->receiver());
1923 dart::Class& klass = dart::Class::Handle( 1939 dart::Class& klass = dart::Class::Handle(
1924 Z, isolate_->class_table()->At(receiver.GetClassId())); 1940 Z, isolate_->class_table()->At(receiver.GetClassId()));
1925 ASSERT(!klass.IsNull()); 1941 ASSERT(!klass.IsNull());
1926 1942
1927 // Search the superclass chain for the selector. 1943 // Search the superclass chain for the selector.
1928 dart::Function& function = dart::Function::Handle(Z); 1944 Function& function = Function::Handle(Z);
1929 const dart::String& method_name = H.DartMethodName(node->name()); 1945 const dart::String& method_name = H.DartMethodName(node->name());
1930 while (!klass.IsNull()) { 1946 while (!klass.IsNull()) {
1931 function = klass.LookupDynamicFunctionAllowPrivate(method_name); 1947 function = klass.LookupDynamicFunctionAllowPrivate(method_name);
1932 if (!function.IsNull()) break; 1948 if (!function.IsNull()) break;
1933 klass = klass.SuperClass(); 1949 klass = klass.SuperClass();
1934 } 1950 }
1935 1951
1936 // The frontend should guarantee that [MethodInvocation]s inside constant 1952 // The frontend should guarantee that [MethodInvocation]s inside constant
1937 // expressions are always valid. 1953 // expressions are always valid.
1938 ASSERT(!function.IsNull()); 1954 ASSERT(!function.IsNull());
1939 1955
1940 // Run the method and canonicalize the result. 1956 // Run the method and canonicalize the result.
1941 const Object& result = RunFunction(function, kernel_arguments, &receiver); 1957 const Object& result = RunFunction(function, kernel_arguments, &receiver);
1942 result_ ^= result.raw(); 1958 result_ ^= result.raw();
1943 result_ = H.Canonicalize(result_); 1959 result_ = H.Canonicalize(result_);
1944 } 1960 }
1945 1961
1946 1962
1947 void ConstantEvaluator::VisitStaticGet(StaticGet* node) { 1963 void ConstantEvaluator::VisitStaticGet(StaticGet* node) {
1948 CanonicalName* target = node->target(); 1964 intptr_t target = node->target();
1949 if (H.IsField(target)) { 1965 if (H.IsField(target)) {
1950 const dart::Field& field = 1966 const dart::Field& field =
1951 dart::Field::Handle(Z, H.LookupFieldByKernelField(target)); 1967 dart::Field::Handle(Z, H.LookupFieldByKernelField(target));
1952 if (field.StaticValue() == Object::sentinel().raw() || 1968 if (field.StaticValue() == Object::sentinel().raw() ||
1953 field.StaticValue() == Object::transition_sentinel().raw()) { 1969 field.StaticValue() == Object::transition_sentinel().raw()) {
1954 field.EvaluateInitializer(); 1970 field.EvaluateInitializer();
1955 result_ = field.StaticValue(); 1971 result_ = field.StaticValue();
1956 result_ = H.Canonicalize(result_); 1972 result_ = H.Canonicalize(result_);
1957 field.SetStaticValue(result_, true); 1973 field.SetStaticValue(result_, true);
1958 } else { 1974 } else {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 next_used_try_index_(0), 2215 next_used_try_index_(0),
2200 catch_block_(NULL), 2216 catch_block_(NULL),
2201 type_translator_(&translation_helper_, 2217 type_translator_(&translation_helper_,
2202 &active_class_, 2218 &active_class_,
2203 /* finalize= */ true), 2219 /* finalize= */ true),
2204 constant_evaluator_(this, zone_, &translation_helper_, &type_translator_), 2220 constant_evaluator_(this, zone_, &translation_helper_, &type_translator_),
2205 streaming_flow_graph_builder_(NULL) { 2221 streaming_flow_graph_builder_(NULL) {
2206 Script& script = Script::Handle(Z, parsed_function->function().script()); 2222 Script& script = Script::Handle(Z, parsed_function->function().script());
2207 H.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets())); 2223 H.SetStringOffsets(TypedData::Handle(Z, script.kernel_string_offsets()));
2208 H.SetStringData(TypedData::Handle(Z, script.kernel_string_data())); 2224 H.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
2225 H.SetCanonicalNames(TypedData::Handle(Z, script.kernel_canonical_names()));
2209 } 2226 }
2210 2227
2211 2228
2212 FlowGraphBuilder::~FlowGraphBuilder() { 2229 FlowGraphBuilder::~FlowGraphBuilder() {
2213 if (streaming_flow_graph_builder_ != NULL) { 2230 if (streaming_flow_graph_builder_ != NULL) {
2214 delete streaming_flow_graph_builder_; 2231 delete streaming_flow_graph_builder_;
2215 } 2232 }
2216 } 2233 }
2217 2234
2218 2235
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
3021 return Fragment(interpolate); 3038 return Fragment(interpolate);
3022 } 3039 }
3023 3040
3024 3041
3025 Fragment FlowGraphBuilder::StringInterpolateSingle(TokenPosition position) { 3042 Fragment FlowGraphBuilder::StringInterpolateSingle(TokenPosition position) {
3026 const int kNumberOfArguments = 1; 3043 const int kNumberOfArguments = 1;
3027 const Array& kNoArgumentNames = Object::null_array(); 3044 const Array& kNoArgumentNames = Object::null_array();
3028 const dart::Class& cls = dart::Class::Handle( 3045 const dart::Class& cls = dart::Class::Handle(
3029 dart::Library::LookupCoreClass(Symbols::StringBase())); 3046 dart::Library::LookupCoreClass(Symbols::StringBase()));
3030 ASSERT(!cls.IsNull()); 3047 ASSERT(!cls.IsNull());
3031 const Function& function = dart::Function::ZoneHandle( 3048 const Function& function = Function::ZoneHandle(
3032 Z, dart::Resolver::ResolveStatic(cls, dart::Library::PrivateCoreLibName( 3049 Z, Resolver::ResolveStatic(cls, dart::Library::PrivateCoreLibName(
3033 Symbols::InterpolateSingle()), 3050 Symbols::InterpolateSingle()),
3034 kNumberOfArguments, kNoArgumentNames)); 3051 kNumberOfArguments, kNoArgumentNames));
3035 Fragment instructions; 3052 Fragment instructions;
3036 instructions += PushArgument(); 3053 instructions += PushArgument();
3037 instructions += StaticCall(position, function, 1); 3054 instructions += StaticCall(position, function, 1);
3038 return instructions; 3055 return instructions;
3039 } 3056 }
3040 3057
3041 3058
3042 Fragment FlowGraphBuilder::ThrowTypeError() { 3059 Fragment FlowGraphBuilder::ThrowTypeError() {
3043 const dart::Class& klass = dart::Class::ZoneHandle( 3060 const dart::Class& klass = dart::Class::ZoneHandle(
3044 Z, dart::Library::LookupCoreClass(Symbols::TypeError())); 3061 Z, dart::Library::LookupCoreClass(Symbols::TypeError()));
3045 ASSERT(!klass.IsNull()); 3062 ASSERT(!klass.IsNull());
3046 const dart::Function& constructor = dart::Function::ZoneHandle( 3063 const Function& constructor = Function::ZoneHandle(
3047 Z, 3064 Z,
3048 klass.LookupConstructorAllowPrivate(H.DartSymbol("_TypeError._create"))); 3065 klass.LookupConstructorAllowPrivate(H.DartSymbol("_TypeError._create")));
3049 ASSERT(!constructor.IsNull()); 3066 ASSERT(!constructor.IsNull());
3050 3067
3051 const dart::String& url = H.DartString( 3068 const dart::String& url = H.DartString(
3052 parsed_function_->function().ToLibNamePrefixedQualifiedCString(), 3069 parsed_function_->function().ToLibNamePrefixedQualifiedCString(),
3053 Heap::kOld); 3070 Heap::kOld);
3054 3071
3055 Fragment instructions; 3072 Fragment instructions;
3056 3073
(...skipping 25 matching lines...) Expand all
3082 instructions += ThrowException(TokenPosition::kNoSource); 3099 instructions += ThrowException(TokenPosition::kNoSource);
3083 3100
3084 return instructions; 3101 return instructions;
3085 } 3102 }
3086 3103
3087 3104
3088 Fragment FlowGraphBuilder::ThrowNoSuchMethodError() { 3105 Fragment FlowGraphBuilder::ThrowNoSuchMethodError() {
3089 const dart::Class& klass = dart::Class::ZoneHandle( 3106 const dart::Class& klass = dart::Class::ZoneHandle(
3090 Z, dart::Library::LookupCoreClass(Symbols::NoSuchMethodError())); 3107 Z, dart::Library::LookupCoreClass(Symbols::NoSuchMethodError()));
3091 ASSERT(!klass.IsNull()); 3108 ASSERT(!klass.IsNull());
3092 const dart::Function& throw_function = dart::Function::ZoneHandle( 3109 const Function& throw_function = Function::ZoneHandle(
3093 Z, klass.LookupStaticFunctionAllowPrivate(Symbols::ThrowNew())); 3110 Z, klass.LookupStaticFunctionAllowPrivate(Symbols::ThrowNew()));
3094 ASSERT(!throw_function.IsNull()); 3111 ASSERT(!throw_function.IsNull());
3095 3112
3096 Fragment instructions; 3113 Fragment instructions;
3097 3114
3098 // Call NoSuchMethodError._throwNew static function. 3115 // Call NoSuchMethodError._throwNew static function.
3099 instructions += NullConstant(); 3116 instructions += NullConstant();
3100 instructions += PushArgument(); // receiver 3117 instructions += PushArgument(); // receiver
3101 3118
3102 instructions += Constant(H.DartString("<unknown>", Heap::kOld)); 3119 instructions += Constant(H.DartString("<unknown>", Heap::kOld));
(...skipping 12 matching lines...) Expand all
3115 instructions += PushArgument(); // existingArgumentNames 3132 instructions += PushArgument(); // existingArgumentNames
3116 3133
3117 instructions += StaticCall(TokenPosition::kNoSource, throw_function, 6); 3134 instructions += StaticCall(TokenPosition::kNoSource, throw_function, 6);
3118 // Leave "result" on the stack since callers expect it to be there (even 3135 // Leave "result" on the stack since callers expect it to be there (even
3119 // though the function will result in an exception). 3136 // though the function will result in an exception).
3120 3137
3121 return instructions; 3138 return instructions;
3122 } 3139 }
3123 3140
3124 3141
3125 dart::RawFunction* FlowGraphBuilder::LookupMethodByMember( 3142 RawFunction* FlowGraphBuilder::LookupMethodByMember(
3126 CanonicalName* target, 3143 intptr_t target,
3127 const dart::String& method_name) { 3144 const dart::String& method_name) {
3128 CanonicalName* kernel_class = H.EnclosingName(target); 3145 intptr_t kernel_class = H.EnclosingName(target);
3129 dart::Class& klass = 3146 dart::Class& klass =
3130 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_class)); 3147 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_class));
3131 3148
3132 dart::RawFunction* function = klass.LookupFunctionAllowPrivate(method_name); 3149 RawFunction* function = klass.LookupFunctionAllowPrivate(method_name);
3133 ASSERT(function != Object::null()); 3150 ASSERT(function != Object::null());
3134 return function; 3151 return function;
3135 } 3152 }
3136 3153
3137 3154
3138 LocalVariable* FlowGraphBuilder::MakeTemporary() { 3155 LocalVariable* FlowGraphBuilder::MakeTemporary() {
3139 char name[64]; 3156 char name[64];
3140 intptr_t index = stack_->definition()->temp_index(); 3157 intptr_t index = stack_->definition()->temp_index();
3141 OS::SNPrint(name, 64, ":temp%" Pd, index); 3158 OS::SNPrint(name, 64, ":temp%" Pd, index);
3142 LocalVariable* variable = 3159 LocalVariable* variable =
(...skipping 16 matching lines...) Expand all
3159 3176
3160 intptr_t FlowGraphBuilder::CurrentTryIndex() { 3177 intptr_t FlowGraphBuilder::CurrentTryIndex() {
3161 if (try_catch_block_ == NULL) { 3178 if (try_catch_block_ == NULL) {
3162 return CatchClauseNode::kInvalidTryIndex; 3179 return CatchClauseNode::kInvalidTryIndex;
3163 } else { 3180 } else {
3164 return try_catch_block_->try_index(); 3181 return try_catch_block_->try_index();
3165 } 3182 }
3166 } 3183 }
3167 3184
3168 3185
3169 dart::LocalVariable* FlowGraphBuilder::LookupVariable( 3186 LocalVariable* FlowGraphBuilder::LookupVariable(VariableDeclaration* var) {
3170 VariableDeclaration* var) {
3171 LocalVariable* local = scopes_->locals.Lookup(var->kernel_offset()); 3187 LocalVariable* local = scopes_->locals.Lookup(var->kernel_offset());
3172 ASSERT(local != NULL); 3188 ASSERT(local != NULL);
3173 return local; 3189 return local;
3174 } 3190 }
3175 3191
3176 3192
3177 void FlowGraphBuilder::SetTempIndex(Definition* definition) { 3193 void FlowGraphBuilder::SetTempIndex(Definition* definition) {
3178 definition->set_temp_index( 3194 definition->set_temp_index(
3179 stack_ == NULL ? 0 : stack_->definition()->temp_index() + 1); 3195 stack_ == NULL ? 0 : stack_->definition()->temp_index() + 1);
3180 } 3196 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3270 void FlowGraphBuilder::InlineBailout(const char* reason) { 3286 void FlowGraphBuilder::InlineBailout(const char* reason) {
3271 bool is_inlining = exit_collector_ != NULL; 3287 bool is_inlining = exit_collector_ != NULL;
3272 if (is_inlining) { 3288 if (is_inlining) {
3273 parsed_function_->function().set_is_inlinable(false); 3289 parsed_function_->function().set_is_inlinable(false);
3274 parsed_function_->Bailout("kernel::FlowGraphBuilder", reason); 3290 parsed_function_->Bailout("kernel::FlowGraphBuilder", reason);
3275 } 3291 }
3276 } 3292 }
3277 3293
3278 3294
3279 FlowGraph* FlowGraphBuilder::BuildGraph() { 3295 FlowGraph* FlowGraphBuilder::BuildGraph() {
3280 const dart::Function& function = parsed_function_->function(); 3296 const Function& function = parsed_function_->function();
3281 3297
3282 if (function.IsConstructorClosureFunction()) return NULL; 3298 if (function.IsConstructorClosureFunction()) return NULL;
3283 3299
3284 TreeNode* library_node = node_; 3300 TreeNode* library_node = node_;
3285 if (node_ != NULL) { 3301 if (node_ != NULL) {
3286 const dart::Function* parent = &function; 3302 const Function* parent = &function;
3287 while (true) { 3303 while (true) {
3288 library_node = static_cast<kernel::TreeNode*>(parent->kernel_function()); 3304 library_node = static_cast<kernel::TreeNode*>(parent->kernel_function());
3289 while (library_node != NULL && !library_node->IsLibrary()) { 3305 while (library_node != NULL && !library_node->IsLibrary()) {
3290 if (library_node->IsMember()) { 3306 if (library_node->IsMember()) {
3291 library_node = Member::Cast(library_node)->parent(); 3307 library_node = Member::Cast(library_node)->parent();
3292 } else if (library_node->IsClass()) { 3308 } else if (library_node->IsClass()) {
3293 library_node = Class::Cast(library_node)->parent(); 3309 library_node = Class::Cast(library_node)->parent();
3294 break; 3310 break;
3295 } else { 3311 } else {
3296 library_node = NULL; 3312 library_node = NULL;
3297 break; 3313 break;
3298 } 3314 }
3299 } 3315 }
3300 if (library_node != NULL) break; 3316 if (library_node != NULL) break;
3301 parent = &dart::Function::Handle(parent->parent_function()); 3317 parent = &Function::Handle(parent->parent_function());
3302 } 3318 }
3303 } 3319 }
3304 if (streaming_flow_graph_builder_ != NULL) { 3320 if (streaming_flow_graph_builder_ != NULL) {
3305 delete streaming_flow_graph_builder_; 3321 delete streaming_flow_graph_builder_;
3306 streaming_flow_graph_builder_ = NULL; 3322 streaming_flow_graph_builder_ = NULL;
3307 } 3323 }
3308 if (library_node != NULL && library_node->IsLibrary()) { 3324 if (library_node != NULL && library_node->IsLibrary()) {
3309 Library* library = Library::Cast(library_node); 3325 Library* library = Library::Cast(library_node);
3310 streaming_flow_graph_builder_ = new StreamingFlowGraphBuilder( 3326 streaming_flow_graph_builder_ = new StreamingFlowGraphBuilder(
3311 this, library->kernel_data(), library->kernel_data_size()); 3327 this, library->kernel_data(), library->kernel_data_size());
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
3830 break; 3846 break;
3831 } 3847 }
3832 } 3848 }
3833 return body + Return(TokenPosition::kNoSource); 3849 return body + Return(TokenPosition::kNoSource);
3834 } 3850 }
3835 3851
3836 3852
3837 FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor( 3853 FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor(
3838 Field* kernel_field, 3854 Field* kernel_field,
3839 LocalVariable* setter_value) { 3855 LocalVariable* setter_value) {
3840 const dart::Function& function = parsed_function_->function(); 3856 const Function& function = parsed_function_->function();
3841 3857
3842 bool is_setter = function.IsImplicitSetterFunction(); 3858 bool is_setter = function.IsImplicitSetterFunction();
3843 bool is_method = !function.IsStaticFunction(); 3859 bool is_method = !function.IsStaticFunction();
3844 dart::Field& field = dart::Field::ZoneHandle( 3860 dart::Field& field = dart::Field::ZoneHandle(
3845 Z, H.LookupFieldByKernelField(kernel_field->canonical_name())); 3861 Z, H.LookupFieldByKernelField(kernel_field->canonical_name()));
3846 3862
3847 TargetEntryInstr* normal_entry = BuildTargetEntry(); 3863 TargetEntryInstr* normal_entry = BuildTargetEntry();
3848 graph_entry_ = new (Z) 3864 graph_entry_ = new (Z)
3849 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); 3865 GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId);
3850 3866
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 Fragment FlowGraphBuilder::DebugStepCheck(TokenPosition position) { 4008 Fragment FlowGraphBuilder::DebugStepCheck(TokenPosition position) {
3993 return Fragment( 4009 return Fragment(
3994 new (Z) DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall)); 4010 new (Z) DebugStepCheckInstr(position, RawPcDescriptors::kRuntimeCall));
3995 } 4011 }
3996 4012
3997 4013
3998 Fragment FlowGraphBuilder::EvaluateAssertion() { 4014 Fragment FlowGraphBuilder::EvaluateAssertion() {
3999 const dart::Class& klass = dart::Class::ZoneHandle( 4015 const dart::Class& klass = dart::Class::ZoneHandle(
4000 Z, dart::Library::LookupCoreClass(Symbols::AssertionError())); 4016 Z, dart::Library::LookupCoreClass(Symbols::AssertionError()));
4001 ASSERT(!klass.IsNull()); 4017 ASSERT(!klass.IsNull());
4002 const dart::Function& target = 4018 const Function& target =
4003 dart::Function::ZoneHandle(Z, klass.LookupStaticFunctionAllowPrivate( 4019 Function::ZoneHandle(Z, klass.LookupStaticFunctionAllowPrivate(
4004 H.DartSymbol("_evaluateAssertion"))); 4020 H.DartSymbol("_evaluateAssertion")));
4005 ASSERT(!target.IsNull()); 4021 ASSERT(!target.IsNull());
4006 return StaticCall(TokenPosition::kNoSource, target, 1); 4022 return StaticCall(TokenPosition::kNoSource, target, 1);
4007 } 4023 }
4008 4024
4009 4025
4010 Fragment FlowGraphBuilder::CheckReturnTypeInCheckedMode() { 4026 Fragment FlowGraphBuilder::CheckReturnTypeInCheckedMode() {
4011 if (I->type_checks()) { 4027 if (I->type_checks()) {
4012 const AbstractType& return_type = 4028 const AbstractType& return_type =
4013 AbstractType::Handle(Z, parsed_function_->function().result_type()); 4029 AbstractType::Handle(Z, parsed_function_->function().result_type());
4014 return CheckAssignableInCheckedMode(return_type, Symbols::FunctionResult()); 4030 return CheckAssignableInCheckedMode(return_type, Symbols::FunctionResult());
4015 } 4031 }
4016 return Fragment(); 4032 return Fragment();
4017 } 4033 }
4018 4034
4019 4035
4020 Fragment FlowGraphBuilder::CheckBooleanInCheckedMode() { 4036 Fragment FlowGraphBuilder::CheckBooleanInCheckedMode() {
4021 Fragment instructions; 4037 Fragment instructions;
4022 if (I->type_checks()) { 4038 if (I->type_checks()) {
4023 LocalVariable* top_of_stack = MakeTemporary(); 4039 LocalVariable* top_of_stack = MakeTemporary();
4024 instructions += LoadLocal(top_of_stack); 4040 instructions += LoadLocal(top_of_stack);
4025 instructions += AssertBool(); 4041 instructions += AssertBool();
4026 instructions += Drop(); 4042 instructions += Drop();
4027 } 4043 }
4028 return instructions; 4044 return instructions;
4029 } 4045 }
4030 4046
4031 4047
4032 Fragment FlowGraphBuilder::CheckAssignableInCheckedMode( 4048 Fragment FlowGraphBuilder::CheckAssignableInCheckedMode(
4033 const dart::AbstractType& dst_type, 4049 const AbstractType& dst_type,
4034 const dart::String& dst_name) { 4050 const dart::String& dst_name) {
4035 Fragment instructions; 4051 Fragment instructions;
4036 if (I->type_checks() && !dst_type.IsDynamicType() && 4052 if (I->type_checks() && !dst_type.IsDynamicType() &&
4037 !dst_type.IsObjectType()) { 4053 !dst_type.IsObjectType()) {
4038 LocalVariable* top_of_stack = MakeTemporary(); 4054 LocalVariable* top_of_stack = MakeTemporary();
4039 instructions += LoadLocal(top_of_stack); 4055 instructions += LoadLocal(top_of_stack);
4040 instructions += AssertAssignable(dst_type, dst_name); 4056 instructions += AssertAssignable(dst_type, dst_name);
4041 instructions += Drop(); 4057 instructions += Drop();
4042 } 4058 }
4043 return instructions; 4059 return instructions;
4044 } 4060 }
4045 4061
4046 4062
4047 Fragment FlowGraphBuilder::AssertBool() { 4063 Fragment FlowGraphBuilder::AssertBool() {
4048 Value* value = Pop(); 4064 Value* value = Pop();
4049 AssertBooleanInstr* instr = 4065 AssertBooleanInstr* instr =
4050 new (Z) AssertBooleanInstr(TokenPosition::kNoSource, value); 4066 new (Z) AssertBooleanInstr(TokenPosition::kNoSource, value);
4051 Push(instr); 4067 Push(instr);
4052 return Fragment(instr); 4068 return Fragment(instr);
4053 } 4069 }
4054 4070
4055 4071
4056 Fragment FlowGraphBuilder::AssertAssignable(const dart::AbstractType& dst_type, 4072 Fragment FlowGraphBuilder::AssertAssignable(const AbstractType& dst_type,
4057 const dart::String& dst_name) { 4073 const dart::String& dst_name) {
4058 Fragment instructions; 4074 Fragment instructions;
4059 Value* value = Pop(); 4075 Value* value = Pop();
4060 4076
4061 if (!dst_type.IsInstantiated(kCurrentClass)) { 4077 if (!dst_type.IsInstantiated(kCurrentClass)) {
4062 instructions += LoadInstantiatorTypeArguments(); 4078 instructions += LoadInstantiatorTypeArguments();
4063 } else { 4079 } else {
4064 instructions += NullConstant(); 4080 instructions += NullConstant();
4065 } 4081 }
4066 Value* instantiator_type_args = Pop(); 4082 Value* instantiator_type_args = Pop();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
4204 body += LoadLocal(array); 4220 body += LoadLocal(array);
4205 body += IntConstant(i); 4221 body += IntConstant(i);
4206 body += LoadLocal(scope->VariableAt(i)); 4222 body += LoadLocal(scope->VariableAt(i));
4207 body += StoreIndexed(kArrayCid); 4223 body += StoreIndexed(kArrayCid);
4208 body += Drop(); 4224 body += Drop();
4209 } 4225 }
4210 dart::String& name = dart::String::Handle(Z); 4226 dart::String& name = dart::String::Handle(Z);
4211 for (intptr_t i = 0; i < descriptor.NamedCount(); ++i) { 4227 for (intptr_t i = 0; i < descriptor.NamedCount(); ++i) {
4212 intptr_t parameter_index = descriptor.PositionalCount() + i; 4228 intptr_t parameter_index = descriptor.PositionalCount() + i;
4213 name = descriptor.NameAt(i); 4229 name = descriptor.NameAt(i);
4214 name = dart::Symbols::New(H.thread(), name); 4230 name = Symbols::New(H.thread(), name);
4215 body += LoadLocal(array); 4231 body += LoadLocal(array);
4216 body += IntConstant(descriptor.PositionAt(i)); 4232 body += IntConstant(descriptor.PositionAt(i));
4217 body += LoadLocal(scope->VariableAt(parameter_index)); 4233 body += LoadLocal(scope->VariableAt(parameter_index));
4218 body += StoreIndexed(kArrayCid); 4234 body += StoreIndexed(kArrayCid);
4219 body += Drop(); 4235 body += Drop();
4220 } 4236 }
4221 body += PushArgument(); 4237 body += PushArgument();
4222 4238
4223 // Fourth, false indicating this is not a super NoSuchMethod. 4239 // Fourth, false indicating this is not a super NoSuchMethod.
4224 body += Constant(Bool::False()); 4240 body += Constant(Bool::False());
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
4390 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry(intptr_t try_index) { 4406 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry(intptr_t try_index) {
4391 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index); 4407 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index);
4392 } 4408 }
4393 4409
4394 4410
4395 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { 4411 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() {
4396 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex()); 4412 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex());
4397 } 4413 }
4398 4414
4399 4415
4400 Fragment FlowGraphBuilder::TranslateFieldInitializer( 4416 Fragment FlowGraphBuilder::TranslateFieldInitializer(intptr_t canonical_name,
4401 CanonicalName* canonical_name, 4417 Expression* init) {
4402 Expression* init) {
4403 dart::Field& field = 4418 dart::Field& field =
4404 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name)); 4419 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name));
4405 if (init->IsNullLiteral()) { 4420 if (init->IsNullLiteral()) {
4406 field.RecordStore(Object::null_object()); 4421 field.RecordStore(Object::null_object());
4407 return Fragment(); 4422 return Fragment();
4408 } 4423 }
4409 Fragment instructions; 4424 Fragment instructions;
4410 instructions += LoadLocal(scopes_->this_variable); 4425 instructions += LoadLocal(scopes_->this_variable);
4411 instructions += TranslateExpression(init); 4426 instructions += TranslateExpression(init);
4412 instructions += StoreInstanceFieldGuarded(field, true); 4427 instructions += StoreInstanceFieldGuarded(field, true);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 void FlowGraphBuilder::VisitSymbolLiteral(SymbolLiteral* node) { 4618 void FlowGraphBuilder::VisitSymbolLiteral(SymbolLiteral* node) {
4604 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset()); 4619 fragment_ = streaming_flow_graph_builder_->BuildAt(node->kernel_offset());
4605 } 4620 }
4606 4621
4607 4622
4608 AbstractType& DartTypeTranslator::TranslateType(DartType* node) { 4623 AbstractType& DartTypeTranslator::TranslateType(DartType* node) {
4609 node->AcceptDartTypeVisitor(this); 4624 node->AcceptDartTypeVisitor(this);
4610 4625
4611 // We return a new `ZoneHandle` here on purpose: The intermediate language 4626 // We return a new `ZoneHandle` here on purpose: The intermediate language
4612 // instructions do not make a copy of the handle, so we do it. 4627 // instructions do not make a copy of the handle, so we do it.
4613 return dart::AbstractType::ZoneHandle(Z, result_.raw()); 4628 return AbstractType::ZoneHandle(Z, result_.raw());
4614 } 4629 }
4615 4630
4616 4631
4617 AbstractType& DartTypeTranslator::TranslateTypeWithoutFinalization( 4632 AbstractType& DartTypeTranslator::TranslateTypeWithoutFinalization(
4618 DartType* node) { 4633 DartType* node) {
4619 bool saved_finalize = finalize_; 4634 bool saved_finalize = finalize_;
4620 finalize_ = false; 4635 finalize_ = false;
4621 AbstractType& result = TranslateType(node); 4636 AbstractType& result = TranslateType(node);
4622 finalize_ = saved_finalize; 4637 finalize_ = saved_finalize;
4623 return result; 4638 return result;
(...skipping 14 matching lines...) Expand all
4638 type = result_.raw(); 4653 type = result_.raw();
4639 } 4654 }
4640 4655
4641 return type; 4656 return type;
4642 } 4657 }
4643 4658
4644 4659
4645 void DartTypeTranslator::VisitInvalidType(InvalidType* node) { 4660 void DartTypeTranslator::VisitInvalidType(InvalidType* node) {
4646 result_ = ClassFinalizer::NewFinalizedMalformedType( 4661 result_ = ClassFinalizer::NewFinalizedMalformedType(
4647 Error::Handle(Z), // No previous error. 4662 Error::Handle(Z), // No previous error.
4648 dart::Script::Handle(Z, dart::Script::null()), TokenPosition::kNoSource, 4663 Script::Handle(Z, Script::null()), TokenPosition::kNoSource,
4649 "[InvalidType] in Kernel IR."); 4664 "[InvalidType] in Kernel IR.");
4650 } 4665 }
4651 4666
4652 4667
4653 void DartTypeTranslator::VisitFunctionType(FunctionType* node) { 4668 void DartTypeTranslator::VisitFunctionType(FunctionType* node) {
4654 // The spec describes in section "19.1 Static Types": 4669 // The spec describes in section "19.1 Static Types":
4655 // 4670 //
4656 // Any use of a malformed type gives rise to a static warning. A 4671 // Any use of a malformed type gives rise to a static warning. A
4657 // malformed type is then interpreted as dynamic by the static type 4672 // malformed type is then interpreted as dynamic by the static type
4658 // checker and the runtime unless explicitly specified otherwise. 4673 // checker and the runtime unless explicitly specified otherwise.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4767 // class A<T> { 4782 // class A<T> {
4768 // static A.x<T'>() { return new B<T'>(); } 4783 // static A.x<T'>() { return new B<T'>(); }
4769 // } 4784 // }
4770 // 4785 //
4771 const intptr_t index = FindTypeParameterIndex( 4786 const intptr_t index = FindTypeParameterIndex(
4772 &procedure->function()->type_parameters(), node->parameter()); 4787 &procedure->function()->type_parameters(), node->parameter());
4773 if (index >= 0) { 4788 if (index >= 0) {
4774 if (procedure->kind() == Procedure::kFactory) { 4789 if (procedure->kind() == Procedure::kFactory) {
4775 // The index of the type parameter in [parameters] is 4790 // The index of the type parameter in [parameters] is
4776 // the same index into the `klass->type_parameters()` array. 4791 // the same index into the `klass->type_parameters()` array.
4777 result_ ^= dart::TypeArguments::Handle( 4792 result_ ^=
4778 Z, active_class_->klass->type_parameters()) 4793 TypeArguments::Handle(Z, active_class_->klass->type_parameters())
4779 .TypeAt(index); 4794 .TypeAt(index);
4780 } else { 4795 } else {
4781 result_ ^= dart::Type::DynamicType(); 4796 result_ ^= dart::Type::DynamicType();
4782 } 4797 }
4783 return; 4798 return;
4784 } 4799 }
4785 } 4800 }
4786 } 4801 }
4787 4802
4788 ASSERT(active_class_->kernel_class != NULL); 4803 ASSERT(active_class_->kernel_class != NULL);
4789 List<TypeParameter>* parameters = 4804 List<TypeParameter>* parameters =
4790 &active_class_->kernel_class->type_parameters(); 4805 &active_class_->kernel_class->type_parameters();
4791 const intptr_t index = FindTypeParameterIndex(parameters, node->parameter()); 4806 const intptr_t index = FindTypeParameterIndex(parameters, node->parameter());
4792 if (index >= 0) { 4807 if (index >= 0) {
4793 // The index of the type parameter in [parameters] is 4808 // The index of the type parameter in [parameters] is
4794 // the same index into the `klass->type_parameters()` array. 4809 // the same index into the `klass->type_parameters()` array.
4795 result_ ^= 4810 result_ ^= TypeArguments::Handle(Z, active_class_->klass->type_parameters())
4796 dart::TypeArguments::Handle(Z, active_class_->klass->type_parameters()) 4811 .TypeAt(index);
4797 .TypeAt(index);
4798 return; 4812 return;
4799 } 4813 }
4800 4814
4801 UNREACHABLE(); 4815 UNREACHABLE();
4802 } 4816 }
4803 4817
4804 4818
4805 void DartTypeTranslator::VisitInterfaceType(InterfaceType* node) { 4819 void DartTypeTranslator::VisitInterfaceType(InterfaceType* node) {
4806 // NOTE: That an interface type like `T<A, B>` is considered to be 4820 // NOTE: That an interface type like `T<A, B>` is considered to be
4807 // malformed iff `T` is malformed. 4821 // malformed iff `T` is malformed.
4808 // => We therefore ignore errors in `A` or `B`. 4822 // => We therefore ignore errors in `A` or `B`.
4809 const TypeArguments& type_arguments = TranslateTypeArguments( 4823 const TypeArguments& type_arguments = TranslateTypeArguments(
4810 node->type_arguments().raw_array(), node->type_arguments().length()); 4824 node->type_arguments().raw_array(), node->type_arguments().length());
4811 4825
4812 4826
4813 dart::Object& klass = 4827 Object& klass = Object::Handle(Z, H.LookupClassByKernelClass(node->klass()));
4814 dart::Object::Handle(Z, H.LookupClassByKernelClass(node->klass()));
4815 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource); 4828 result_ = Type::New(klass, type_arguments, TokenPosition::kNoSource);
4816 if (finalize_) { 4829 if (finalize_) {
4817 ASSERT(active_class_->klass != NULL); 4830 ASSERT(active_class_->klass != NULL);
4818 result_ = ClassFinalizer::FinalizeType(*active_class_->klass, result_); 4831 result_ = ClassFinalizer::FinalizeType(*active_class_->klass, result_);
4819 } 4832 }
4820 } 4833 }
4821 4834
4822 4835
4823 void DartTypeTranslator::VisitDynamicType(DynamicType* node) { 4836 void DartTypeTranslator::VisitDynamicType(DynamicType* node) {
4824 result_ = Object::dynamic_type().raw(); 4837 result_ = Object::dynamic_type().raw();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 } else { 4982 } else {
4970 UNIMPLEMENTED(); 4983 UNIMPLEMENTED();
4971 } 4984 }
4972 } else { 4985 } else {
4973 UNIMPLEMENTED(); 4986 UNIMPLEMENTED();
4974 } 4987 }
4975 } 4988 }
4976 4989
4977 4990
4978 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) { 4991 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) {
4979 CanonicalName* target = node->target(); 4992 intptr_t target = node->target();
4980 if (H.IsField(target)) { 4993 if (H.IsField(target)) {
4981 const dart::Field& field = 4994 const dart::Field& field =
4982 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target)); 4995 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target));
4983 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type()); 4996 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type());
4984 Fragment instructions = TranslateExpression(node->expression()); 4997 Fragment instructions = TranslateExpression(node->expression());
4985 if (NeedsDebugStepCheck(stack_, node->position())) { 4998 if (NeedsDebugStepCheck(stack_, node->position())) {
4986 instructions = DebugStepCheck(node->position()) + instructions; 4999 instructions = DebugStepCheck(node->position()) + instructions;
4987 } 5000 }
4988 instructions += CheckAssignableInCheckedMode( 5001 instructions += CheckAssignableInCheckedMode(
4989 dst_type, dart::String::ZoneHandle(Z, field.name())); 5002 dst_type, dart::String::ZoneHandle(Z, field.name()));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 instructions += PushArgument(); 5044 instructions += PushArgument();
5032 5045
5033 const dart::String& setter_name = H.DartSetterName(node->name()); 5046 const dart::String& setter_name = H.DartSetterName(node->name());
5034 instructions += InstanceCall(node->position(), setter_name, Token::kSET, 2); 5047 instructions += InstanceCall(node->position(), setter_name, Token::kSET, 2);
5035 fragment_ = instructions + Drop(); 5048 fragment_ = instructions + Drop();
5036 } 5049 }
5037 5050
5038 5051
5039 void FlowGraphBuilder::VisitDirectPropertyGet(DirectPropertyGet* node) { 5052 void FlowGraphBuilder::VisitDirectPropertyGet(DirectPropertyGet* node) {
5040 Function& target = Function::ZoneHandle(Z); 5053 Function& target = Function::ZoneHandle(Z);
5041 CanonicalName* kernel_name = node->target(); 5054 intptr_t kernel_name = node->target();
5042 if (H.IsProcedure(kernel_name)) { 5055 if (H.IsProcedure(kernel_name)) {
5043 if (H.IsGetter(kernel_name)) { 5056 if (H.IsGetter(kernel_name)) {
5044 target = LookupMethodByMember(kernel_name, H.DartGetterName(kernel_name)); 5057 target = LookupMethodByMember(kernel_name, H.DartGetterName(kernel_name));
5045 } else { 5058 } else {
5046 target = LookupMethodByMember(kernel_name, H.DartMethodName(kernel_name)); 5059 target = LookupMethodByMember(kernel_name, H.DartMethodName(kernel_name));
5047 target = target.ImplicitClosureFunction(); 5060 target = target.ImplicitClosureFunction();
5048 ASSERT(!target.IsNull()); 5061 ASSERT(!target.IsNull());
5049 fragment_ = BuildImplicitClosureCreation(target); 5062 fragment_ = BuildImplicitClosureCreation(target);
5050 return; 5063 return;
5051 } 5064 }
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
6106 body_fragment += Drop(); 6119 body_fragment += Drop();
6107 } 6120 }
6108 6121
6109 // The Dart language specification mandates fall-throughs in [SwitchCase]es 6122 // The Dart language specification mandates fall-throughs in [SwitchCase]es
6110 // to be runtime errors. 6123 // to be runtime errors.
6111 if (!switch_case->is_default() && body_fragment.is_open() && 6124 if (!switch_case->is_default() && body_fragment.is_open() &&
6112 (i < (node->cases().length() - 1))) { 6125 (i < (node->cases().length() - 1))) {
6113 const dart::Class& klass = dart::Class::ZoneHandle( 6126 const dart::Class& klass = dart::Class::ZoneHandle(
6114 Z, dart::Library::LookupCoreClass(Symbols::FallThroughError())); 6127 Z, dart::Library::LookupCoreClass(Symbols::FallThroughError()));
6115 ASSERT(!klass.IsNull()); 6128 ASSERT(!klass.IsNull());
6116 const dart::Function& constructor = dart::Function::ZoneHandle( 6129 const Function& constructor = Function::ZoneHandle(
6117 Z, klass.LookupConstructorAllowPrivate( 6130 Z, klass.LookupConstructorAllowPrivate(
6118 H.DartSymbol("FallThroughError._create"))); 6131 H.DartSymbol("FallThroughError._create")));
6119 ASSERT(!constructor.IsNull()); 6132 ASSERT(!constructor.IsNull());
6120 const dart::String& url = H.DartString( 6133 const dart::String& url = H.DartString(
6121 parsed_function_->function().ToLibNamePrefixedQualifiedCString(), 6134 parsed_function_->function().ToLibNamePrefixedQualifiedCString(),
6122 Heap::kOld); 6135 Heap::kOld);
6123 6136
6124 // Create instance of _FallThroughError 6137 // Create instance of _FallThroughError
6125 body_fragment += AllocateObject(klass, 0); 6138 body_fragment += AllocateObject(klass, 0);
6126 LocalVariable* instance = MakeTemporary(); 6139 LocalVariable* instance = MakeTemporary();
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
6298 instructions += TranslateExpression(node->condition()); 6311 instructions += TranslateExpression(node->condition());
6299 instructions += PushArgument(); 6312 instructions += PushArgument();
6300 instructions += EvaluateAssertion(); 6313 instructions += EvaluateAssertion();
6301 instructions += CheckBooleanInCheckedMode(); 6314 instructions += CheckBooleanInCheckedMode();
6302 instructions += Constant(Bool::True()); 6315 instructions += Constant(Bool::True());
6303 instructions += BranchIfEqual(&then, &otherwise, false); 6316 instructions += BranchIfEqual(&then, &otherwise, false);
6304 6317
6305 const dart::Class& klass = dart::Class::ZoneHandle( 6318 const dart::Class& klass = dart::Class::ZoneHandle(
6306 Z, dart::Library::LookupCoreClass(Symbols::AssertionError())); 6319 Z, dart::Library::LookupCoreClass(Symbols::AssertionError()));
6307 ASSERT(!klass.IsNull()); 6320 ASSERT(!klass.IsNull());
6308 const dart::Function& constructor = dart::Function::ZoneHandle( 6321 const Function& constructor =
6309 Z, klass.LookupConstructorAllowPrivate( 6322 Function::ZoneHandle(Z, klass.LookupConstructorAllowPrivate(
6310 H.DartSymbol("_AssertionError._create"))); 6323 H.DartSymbol("_AssertionError._create")));
6311 ASSERT(!constructor.IsNull()); 6324 ASSERT(!constructor.IsNull());
6312 6325
6313 const dart::String& url = H.DartString( 6326 const dart::String& url = H.DartString(
6314 parsed_function_->function().ToLibNamePrefixedQualifiedCString(), 6327 parsed_function_->function().ToLibNamePrefixedQualifiedCString(),
6315 Heap::kOld); 6328 Heap::kOld);
6316 6329
6317 // Create instance of _AssertionError 6330 // Create instance of _AssertionError
6318 Fragment otherwise_fragment(otherwise); 6331 Fragment otherwise_fragment(otherwise);
6319 otherwise_fragment += AllocateObject(klass, 0); 6332 otherwise_fragment += AllocateObject(klass, 0);
6320 LocalVariable* instance = MakeTemporary(); 6333 LocalVariable* instance = MakeTemporary();
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
6747 } else { 6760 } else {
6748 FATAL1("No support for metadata on this type of kernel node %p\n", 6761 FATAL1("No support for metadata on this type of kernel node %p\n",
6749 kernel_node); 6762 kernel_node);
6750 } 6763 }
6751 6764
6752 TranslationHelper helper(thread); 6765 TranslationHelper helper(thread);
6753 Script& script = Script::Handle(Z, metadata_field.Script()); 6766 Script& script = Script::Handle(Z, metadata_field.Script());
6754 helper.SetStringOffsets( 6767 helper.SetStringOffsets(
6755 TypedData::Handle(Z, script.kernel_string_offsets())); 6768 TypedData::Handle(Z, script.kernel_string_offsets()));
6756 helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data())); 6769 helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
6770 helper.SetCanonicalNames(
6771 TypedData::Handle(Z, script.kernel_canonical_names()));
6757 DartTypeTranslator type_translator(&helper, NULL, true); 6772 DartTypeTranslator type_translator(&helper, NULL, true);
6758 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z, 6773 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z,
6759 &helper, &type_translator); 6774 &helper, &type_translator);
6760 6775
6761 const Array& metadata_values = 6776 const Array& metadata_values =
6762 Array::Handle(Z, Array::New(metadata_expressions->length())); 6777 Array::Handle(Z, Array::New(metadata_expressions->length()));
6763 6778
6764 for (intptr_t i = 0; i < metadata_expressions->length(); i++) { 6779 for (intptr_t i = 0; i < metadata_expressions->length(); i++) {
6765 const Instance& value = 6780 const Instance& value =
6766 constant_evaluator.EvaluateExpression((*metadata_expressions)[i]); 6781 constant_evaluator.EvaluateExpression((*metadata_expressions)[i]);
(...skipping 28 matching lines...) Expand all
6795 return NULL; 6810 return NULL;
6796 } 6811 }
6797 6812
6798 Thread* thread = Thread::Current(); 6813 Thread* thread = Thread::Current();
6799 Zone* zone_ = thread->zone(); 6814 Zone* zone_ = thread->zone();
6800 TranslationHelper helper(thread); 6815 TranslationHelper helper(thread);
6801 Script& script = Script::Handle(Z, function.script()); 6816 Script& script = Script::Handle(Z, function.script());
6802 helper.SetStringOffsets( 6817 helper.SetStringOffsets(
6803 TypedData::Handle(Z, script.kernel_string_offsets())); 6818 TypedData::Handle(Z, script.kernel_string_offsets()));
6804 helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data())); 6819 helper.SetStringData(TypedData::Handle(Z, script.kernel_string_data()));
6820 helper.SetCanonicalNames(
6821 TypedData::Handle(Z, script.kernel_canonical_names()));
6805 DartTypeTranslator type_translator(&helper, NULL, true); 6822 DartTypeTranslator type_translator(&helper, NULL, true);
6806 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z, 6823 ConstantEvaluator constant_evaluator(/* flow_graph_builder = */ NULL, Z,
6807 &helper, &type_translator); 6824 &helper, &type_translator);
6808 6825
6809 const intptr_t positional_count = 6826 const intptr_t positional_count =
6810 function_node->positional_parameters().length(); 6827 function_node->positional_parameters().length();
6811 const intptr_t param_count = 6828 const intptr_t param_count =
6812 positional_count + function_node->named_parameters().length(); 6829 positional_count + function_node->named_parameters().length();
6813 const Array& param_descriptor = Array::Handle( 6830 const Array& param_descriptor = Array::Handle(
6814 Array::New(param_count * Parser::kParameterEntrySize, Heap::kOld)); 6831 Array::New(param_count * Parser::kParameterEntrySize, Heap::kOld));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
6848 thread->clear_sticky_error(); 6865 thread->clear_sticky_error();
6849 return error.raw(); 6866 return error.raw();
6850 } 6867 }
6851 } 6868 }
6852 6869
6853 6870
6854 } // namespace kernel 6871 } // namespace kernel
6855 } // namespace dart 6872 } // namespace dart
6856 6873
6857 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6874 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698