| OLD | NEW |
| 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 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 string_data_ = string_data.raw(); | 1060 string_data_ = string_data.raw(); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 | 1063 |
| 1064 void TranslationHelper::SetCanonicalNames(const TypedData& canonical_names) { | 1064 void TranslationHelper::SetCanonicalNames(const TypedData& canonical_names) { |
| 1065 ASSERT(canonical_names_.IsNull()); | 1065 ASSERT(canonical_names_.IsNull()); |
| 1066 canonical_names_ = canonical_names.raw(); | 1066 canonical_names_ = canonical_names.raw(); |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 | 1069 |
| 1070 intptr_t TranslationHelper::StringOffset(intptr_t string_index) const { | 1070 intptr_t TranslationHelper::StringOffset(StringIndex index) const { |
| 1071 return string_offsets_.GetUint32(string_index << 2); | 1071 return string_offsets_.GetUint32(index << 2); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 | 1074 |
| 1075 intptr_t TranslationHelper::StringSize(intptr_t string_index) const { | 1075 intptr_t TranslationHelper::StringSize(StringIndex index) const { |
| 1076 return StringOffset(string_index + 1) - StringOffset(string_index); | 1076 return StringOffset(StringIndex(index + 1)) - StringOffset(index); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 | 1079 |
| 1080 uint8_t TranslationHelper::CharacterAt(intptr_t string_index, intptr_t index) { | 1080 uint8_t TranslationHelper::CharacterAt(StringIndex string_index, |
| 1081 intptr_t index) { |
| 1081 ASSERT(index < StringSize(string_index)); | 1082 ASSERT(index < StringSize(string_index)); |
| 1082 return string_data_.GetUint8(StringOffset(string_index) + index); | 1083 return string_data_.GetUint8(StringOffset(string_index) + index); |
| 1083 } | 1084 } |
| 1084 | 1085 |
| 1085 | 1086 |
| 1086 bool TranslationHelper::StringEquals(intptr_t string_index, const char* other) { | 1087 bool TranslationHelper::StringEquals(StringIndex string_index, |
| 1088 const char* other) { |
| 1087 NoSafepointScope no_safepoint; | 1089 NoSafepointScope no_safepoint; |
| 1088 intptr_t length = strlen(other); | 1090 intptr_t length = strlen(other); |
| 1089 return (length == StringSize(string_index)) && | 1091 return (length == StringSize(string_index)) && |
| 1090 (memcmp(string_data_.DataAddr(StringOffset(string_index)), other, | 1092 (memcmp(string_data_.DataAddr(StringOffset(string_index)), other, |
| 1091 length) == 0); | 1093 length) == 0); |
| 1092 } | 1094 } |
| 1093 | 1095 |
| 1094 | 1096 |
| 1095 intptr_t TranslationHelper::CanonicalNameParent(intptr_t name) { | 1097 NameIndex TranslationHelper::CanonicalNameParent(NameIndex name) { |
| 1096 // Canonical names are pairs of 4-byte parent and string indexes, so the size | 1098 // Canonical names are pairs of 4-byte parent and string indexes, so the size |
| 1097 // of an entry is 8 bytes. The parent is biased: 0 represents the root name | 1099 // of an entry is 8 bytes. The parent is biased: 0 represents the root name |
| 1098 // and N+1 represents the name with index N. | 1100 // and N+1 represents the name with index N. |
| 1099 return static_cast<intptr_t>(canonical_names_.GetUint32(8 * name)) - 1; | 1101 return NameIndex(static_cast<intptr_t>(canonical_names_.GetUint32(8 * name)) - |
| 1102 1); |
| 1100 } | 1103 } |
| 1101 | 1104 |
| 1102 | 1105 |
| 1103 intptr_t TranslationHelper::CanonicalNameString(intptr_t name) { | 1106 StringIndex TranslationHelper::CanonicalNameString(NameIndex name) { |
| 1104 return canonical_names_.GetUint32((8 * name) + 4); | 1107 return StringIndex(canonical_names_.GetUint32((8 * name) + 4)); |
| 1105 } | 1108 } |
| 1106 | 1109 |
| 1107 | 1110 |
| 1108 bool TranslationHelper::IsAdministrative(intptr_t name) { | 1111 bool TranslationHelper::IsAdministrative(NameIndex name) { |
| 1109 // Administrative names start with '@'. | 1112 // Administrative names start with '@'. |
| 1110 intptr_t name_string = CanonicalNameString(name); | 1113 StringIndex name_string = CanonicalNameString(name); |
| 1111 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '@'); | 1114 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '@'); |
| 1112 } | 1115 } |
| 1113 | 1116 |
| 1114 | 1117 |
| 1115 bool TranslationHelper::IsPrivate(intptr_t name) { | 1118 bool TranslationHelper::IsPrivate(NameIndex name) { |
| 1116 // Private names start with '_'. | 1119 // Private names start with '_'. |
| 1117 intptr_t name_string = CanonicalNameString(name); | 1120 StringIndex name_string = CanonicalNameString(name); |
| 1118 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '_'); | 1121 return (StringSize(name_string) > 0) && (CharacterAt(name_string, 0) == '_'); |
| 1119 } | 1122 } |
| 1120 | 1123 |
| 1121 | 1124 |
| 1122 bool TranslationHelper::IsRoot(intptr_t name) { | 1125 bool TranslationHelper::IsRoot(NameIndex name) { |
| 1123 return name == -1; | 1126 return name == -1; |
| 1124 } | 1127 } |
| 1125 | 1128 |
| 1126 | 1129 |
| 1127 bool TranslationHelper::IsLibrary(intptr_t name) { | 1130 bool TranslationHelper::IsLibrary(NameIndex name) { |
| 1128 // Libraries are the only canonical names with the root as their parent. | 1131 // Libraries are the only canonical names with the root as their parent. |
| 1129 return !IsRoot(name) && IsRoot(CanonicalNameParent(name)); | 1132 return !IsRoot(name) && IsRoot(CanonicalNameParent(name)); |
| 1130 } | 1133 } |
| 1131 | 1134 |
| 1132 | 1135 |
| 1133 bool TranslationHelper::IsClass(intptr_t name) { | 1136 bool TranslationHelper::IsClass(NameIndex name) { |
| 1134 // Classes have the library as their parent and are not an administrative | 1137 // Classes have the library as their parent and are not an administrative |
| 1135 // name starting with @. | 1138 // name starting with @. |
| 1136 return !IsAdministrative(name) && !IsRoot(name) && | 1139 return !IsAdministrative(name) && !IsRoot(name) && |
| 1137 IsLibrary(CanonicalNameParent(name)); | 1140 IsLibrary(CanonicalNameParent(name)); |
| 1138 } | 1141 } |
| 1139 | 1142 |
| 1140 | 1143 |
| 1141 bool TranslationHelper::IsMember(intptr_t name) { | 1144 bool TranslationHelper::IsMember(NameIndex name) { |
| 1142 return IsConstructor(name) || IsField(name) || IsProcedure(name); | 1145 return IsConstructor(name) || IsField(name) || IsProcedure(name); |
| 1143 } | 1146 } |
| 1144 | 1147 |
| 1145 | 1148 |
| 1146 bool TranslationHelper::IsField(intptr_t name) { | 1149 bool TranslationHelper::IsField(NameIndex name) { |
| 1147 // Fields with private names have the import URI of the library where they are | 1150 // Fields with private names have the import URI of the library where they are |
| 1148 // visible as the parent and the string "@fields" as the parent's parent. | 1151 // visible as the parent and the string "@fields" as the parent's parent. |
| 1149 // Fields with non-private names have the string "@fields' as the parent. | 1152 // Fields with non-private names have the string "@fields' as the parent. |
| 1150 if (IsRoot(name)) { | 1153 if (IsRoot(name)) { |
| 1151 return false; | 1154 return false; |
| 1152 } | 1155 } |
| 1153 intptr_t kind = CanonicalNameParent(name); | 1156 NameIndex kind = CanonicalNameParent(name); |
| 1154 if (IsPrivate(name)) { | 1157 if (IsPrivate(name)) { |
| 1155 kind = CanonicalNameParent(kind); | 1158 kind = CanonicalNameParent(kind); |
| 1156 } | 1159 } |
| 1157 return StringEquals(CanonicalNameString(kind), "@fields"); | 1160 return StringEquals(CanonicalNameString(kind), "@fields"); |
| 1158 } | 1161 } |
| 1159 | 1162 |
| 1160 | 1163 |
| 1161 bool TranslationHelper::IsConstructor(intptr_t name) { | 1164 bool TranslationHelper::IsConstructor(NameIndex name) { |
| 1162 // Constructors with private names have the import URI of the library where | 1165 // Constructors with private names have the import URI of the library where |
| 1163 // they are visible as the parent and the string "@constructors" as the | 1166 // they are visible as the parent and the string "@constructors" as the |
| 1164 // parent's parent. Constructors with non-private names have the string | 1167 // parent's parent. Constructors with non-private names have the string |
| 1165 // "@constructors" as the parent. | 1168 // "@constructors" as the parent. |
| 1166 if (IsRoot(name)) { | 1169 if (IsRoot(name)) { |
| 1167 return false; | 1170 return false; |
| 1168 } | 1171 } |
| 1169 intptr_t kind = CanonicalNameParent(name); | 1172 NameIndex kind = CanonicalNameParent(name); |
| 1170 if (IsPrivate(name)) { | 1173 if (IsPrivate(name)) { |
| 1171 kind = CanonicalNameParent(kind); | 1174 kind = CanonicalNameParent(kind); |
| 1172 } | 1175 } |
| 1173 return StringEquals(CanonicalNameString(kind), "@constructors"); | 1176 return StringEquals(CanonicalNameString(kind), "@constructors"); |
| 1174 } | 1177 } |
| 1175 | 1178 |
| 1176 | 1179 |
| 1177 bool TranslationHelper::IsProcedure(intptr_t name) { | 1180 bool TranslationHelper::IsProcedure(NameIndex name) { |
| 1178 return IsMethod(name) || IsGetter(name) || IsSetter(name) || IsFactory(name); | 1181 return IsMethod(name) || IsGetter(name) || IsSetter(name) || IsFactory(name); |
| 1179 } | 1182 } |
| 1180 | 1183 |
| 1181 | 1184 |
| 1182 bool TranslationHelper::IsMethod(intptr_t name) { | 1185 bool TranslationHelper::IsMethod(NameIndex name) { |
| 1183 // Methods with private names have the import URI of the library where they | 1186 // Methods with private names have the import URI of the library where they |
| 1184 // are visible as the parent and the string "@methods" as the parent's parent. | 1187 // are visible as the parent and the string "@methods" as the parent's parent. |
| 1185 // Methods with non-private names have the string "@methods" as the parent. | 1188 // Methods with non-private names have the string "@methods" as the parent. |
| 1186 if (IsRoot(name)) { | 1189 if (IsRoot(name)) { |
| 1187 return false; | 1190 return false; |
| 1188 } | 1191 } |
| 1189 intptr_t kind = CanonicalNameParent(name); | 1192 NameIndex kind = CanonicalNameParent(name); |
| 1190 if (IsPrivate(name)) { | 1193 if (IsPrivate(name)) { |
| 1191 kind = CanonicalNameParent(kind); | 1194 kind = CanonicalNameParent(kind); |
| 1192 } | 1195 } |
| 1193 return StringEquals(CanonicalNameString(kind), "@methods"); | 1196 return StringEquals(CanonicalNameString(kind), "@methods"); |
| 1194 } | 1197 } |
| 1195 | 1198 |
| 1196 | 1199 |
| 1197 bool TranslationHelper::IsGetter(intptr_t name) { | 1200 bool TranslationHelper::IsGetter(NameIndex name) { |
| 1198 // Getters with private names have the import URI of the library where they | 1201 // Getters with private names have the import URI of the library where they |
| 1199 // are visible as the parent and the string "@getters" as the parent's parent. | 1202 // are visible as the parent and the string "@getters" as the parent's parent. |
| 1200 // Getters with non-private names have the string "@getters" as the parent. | 1203 // Getters with non-private names have the string "@getters" as the parent. |
| 1201 if (IsRoot(name)) { | 1204 if (IsRoot(name)) { |
| 1202 return false; | 1205 return false; |
| 1203 } | 1206 } |
| 1204 intptr_t kind = CanonicalNameParent(name); | 1207 NameIndex kind = CanonicalNameParent(name); |
| 1205 if (IsPrivate(name)) { | 1208 if (IsPrivate(name)) { |
| 1206 kind = CanonicalNameParent(kind); | 1209 kind = CanonicalNameParent(kind); |
| 1207 } | 1210 } |
| 1208 return StringEquals(CanonicalNameString(kind), "@getters"); | 1211 return StringEquals(CanonicalNameString(kind), "@getters"); |
| 1209 } | 1212 } |
| 1210 | 1213 |
| 1211 | 1214 |
| 1212 bool TranslationHelper::IsSetter(intptr_t name) { | 1215 bool TranslationHelper::IsSetter(NameIndex name) { |
| 1213 // Setters with private names have the import URI of the library where they | 1216 // Setters with private names have the import URI of the library where they |
| 1214 // are visible as the parent and the string "@setters" as the parent's parent. | 1217 // are visible as the parent and the string "@setters" as the parent's parent. |
| 1215 // Setters with non-private names have the string "@setters" as the parent. | 1218 // Setters with non-private names have the string "@setters" as the parent. |
| 1216 if (IsRoot(name)) { | 1219 if (IsRoot(name)) { |
| 1217 return false; | 1220 return false; |
| 1218 } | 1221 } |
| 1219 intptr_t kind = CanonicalNameParent(name); | 1222 NameIndex kind = CanonicalNameParent(name); |
| 1220 if (IsPrivate(name)) { | 1223 if (IsPrivate(name)) { |
| 1221 kind = CanonicalNameParent(kind); | 1224 kind = CanonicalNameParent(kind); |
| 1222 } | 1225 } |
| 1223 return StringEquals(CanonicalNameString(kind), "@setters"); | 1226 return StringEquals(CanonicalNameString(kind), "@setters"); |
| 1224 } | 1227 } |
| 1225 | 1228 |
| 1226 | 1229 |
| 1227 bool TranslationHelper::IsFactory(intptr_t name) { | 1230 bool TranslationHelper::IsFactory(NameIndex name) { |
| 1228 // Factories with private names have the import URI of the library where they | 1231 // Factories with private names have the import URI of the library where they |
| 1229 // are visible as the parent and the string "@factories" as the parent's | 1232 // are visible as the parent and the string "@factories" as the parent's |
| 1230 // parent. Factories with non-private names have the string "@factories" as | 1233 // parent. Factories with non-private names have the string "@factories" as |
| 1231 // the parent. | 1234 // the parent. |
| 1232 if (IsRoot(name)) { | 1235 if (IsRoot(name)) { |
| 1233 return false; | 1236 return false; |
| 1234 } | 1237 } |
| 1235 intptr_t kind = CanonicalNameParent(name); | 1238 NameIndex kind = CanonicalNameParent(name); |
| 1236 if (IsPrivate(name)) { | 1239 if (IsPrivate(name)) { |
| 1237 kind = CanonicalNameParent(kind); | 1240 kind = CanonicalNameParent(kind); |
| 1238 } | 1241 } |
| 1239 return StringEquals(CanonicalNameString(kind), "@factories"); | 1242 return StringEquals(CanonicalNameString(kind), "@factories"); |
| 1240 } | 1243 } |
| 1241 | 1244 |
| 1242 | 1245 |
| 1243 intptr_t TranslationHelper::EnclosingName(intptr_t name) { | 1246 NameIndex TranslationHelper::EnclosingName(NameIndex name) { |
| 1244 ASSERT(IsField(name) || IsConstructor(name) || IsProcedure(name)); | 1247 ASSERT(IsField(name) || IsConstructor(name) || IsProcedure(name)); |
| 1245 intptr_t enclosing = CanonicalNameParent(CanonicalNameParent(name)); | 1248 NameIndex enclosing = CanonicalNameParent(CanonicalNameParent(name)); |
| 1246 if (IsPrivate(name)) { | 1249 if (IsPrivate(name)) { |
| 1247 enclosing = CanonicalNameParent(enclosing); | 1250 enclosing = CanonicalNameParent(enclosing); |
| 1248 } | 1251 } |
| 1249 ASSERT(IsLibrary(enclosing) || IsClass(enclosing)); | 1252 ASSERT(IsLibrary(enclosing) || IsClass(enclosing)); |
| 1250 return enclosing; | 1253 return enclosing; |
| 1251 } | 1254 } |
| 1252 | 1255 |
| 1253 | 1256 |
| 1254 RawInstance* TranslationHelper::Canonicalize(const Instance& instance) { | 1257 RawInstance* TranslationHelper::Canonicalize(const Instance& instance) { |
| 1255 if (instance.IsNull()) return instance.raw(); | 1258 if (instance.IsNull()) return instance.raw(); |
| 1256 | 1259 |
| 1257 const char* error_str = NULL; | 1260 const char* error_str = NULL; |
| 1258 RawInstance* result = instance.CheckAndCanonicalize(thread(), &error_str); | 1261 RawInstance* result = instance.CheckAndCanonicalize(thread(), &error_str); |
| 1259 if (result == Object::null()) { | 1262 if (result == Object::null()) { |
| 1260 ReportError("Invalid const object %s", error_str); | 1263 ReportError("Invalid const object %s", error_str); |
| 1261 } | 1264 } |
| 1262 return result; | 1265 return result; |
| 1263 } | 1266 } |
| 1264 | 1267 |
| 1265 | 1268 |
| 1266 const dart::String& TranslationHelper::DartString(const char* content, | 1269 const dart::String& TranslationHelper::DartString(const char* content, |
| 1267 Heap::Space space) { | 1270 Heap::Space space) { |
| 1268 return dart::String::ZoneHandle(Z, dart::String::New(content, space)); | 1271 return dart::String::ZoneHandle(Z, dart::String::New(content, space)); |
| 1269 } | 1272 } |
| 1270 | 1273 |
| 1271 | 1274 |
| 1272 dart::String& TranslationHelper::DartString(intptr_t string_index, | 1275 dart::String& TranslationHelper::DartString(StringIndex string_index, |
| 1273 Heap::Space space) { | 1276 Heap::Space space) { |
| 1274 intptr_t length = StringSize(string_index); | 1277 intptr_t length = StringSize(string_index); |
| 1275 uint8_t* buffer = Z->Alloc<uint8_t>(length); | 1278 uint8_t* buffer = Z->Alloc<uint8_t>(length); |
| 1276 { | 1279 { |
| 1277 NoSafepointScope no_safepoint; | 1280 NoSafepointScope no_safepoint; |
| 1278 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length); | 1281 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length); |
| 1279 } | 1282 } |
| 1280 return dart::String::ZoneHandle( | 1283 return dart::String::ZoneHandle( |
| 1281 Z, dart::String::FromUTF8(buffer, length, space)); | 1284 Z, dart::String::FromUTF8(buffer, length, space)); |
| 1282 } | 1285 } |
| 1283 | 1286 |
| 1284 | 1287 |
| 1285 dart::String& TranslationHelper::DartString(const uint8_t* utf8_array, | 1288 dart::String& TranslationHelper::DartString(const uint8_t* utf8_array, |
| 1286 intptr_t len, | 1289 intptr_t len, |
| 1287 Heap::Space space) { | 1290 Heap::Space space) { |
| 1288 return dart::String::ZoneHandle( | 1291 return dart::String::ZoneHandle( |
| 1289 Z, dart::String::FromUTF8(utf8_array, len, space)); | 1292 Z, dart::String::FromUTF8(utf8_array, len, space)); |
| 1290 } | 1293 } |
| 1291 | 1294 |
| 1292 | 1295 |
| 1293 const dart::String& TranslationHelper::DartSymbol(const char* content) const { | 1296 const dart::String& TranslationHelper::DartSymbol(const char* content) const { |
| 1294 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content)); | 1297 return dart::String::ZoneHandle(Z, Symbols::New(thread_, content)); |
| 1295 } | 1298 } |
| 1296 | 1299 |
| 1297 | 1300 |
| 1298 dart::String& TranslationHelper::DartSymbol(intptr_t string_index) const { | 1301 dart::String& TranslationHelper::DartSymbol(StringIndex string_index) const { |
| 1299 intptr_t length = StringSize(string_index); | 1302 intptr_t length = StringSize(string_index); |
| 1300 uint8_t* buffer = Z->Alloc<uint8_t>(length); | 1303 uint8_t* buffer = Z->Alloc<uint8_t>(length); |
| 1301 { | 1304 { |
| 1302 NoSafepointScope no_safepoint; | 1305 NoSafepointScope no_safepoint; |
| 1303 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length); | 1306 memmove(buffer, string_data_.DataAddr(StringOffset(string_index)), length); |
| 1304 } | 1307 } |
| 1305 return dart::String::ZoneHandle(Z, | 1308 return dart::String::ZoneHandle(Z, |
| 1306 Symbols::FromUTF8(thread_, buffer, length)); | 1309 Symbols::FromUTF8(thread_, buffer, length)); |
| 1307 } | 1310 } |
| 1308 | 1311 |
| 1309 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array, | 1312 dart::String& TranslationHelper::DartSymbol(const uint8_t* utf8_array, |
| 1310 intptr_t len) const { | 1313 intptr_t len) const { |
| 1311 return dart::String::ZoneHandle(Z, | 1314 return dart::String::ZoneHandle(Z, |
| 1312 Symbols::FromUTF8(thread_, utf8_array, len)); | 1315 Symbols::FromUTF8(thread_, utf8_array, len)); |
| 1313 } | 1316 } |
| 1314 | 1317 |
| 1315 const dart::String& TranslationHelper::DartClassName(intptr_t kernel_class) { | 1318 const dart::String& TranslationHelper::DartClassName(NameIndex kernel_class) { |
| 1316 ASSERT(IsClass(kernel_class)); | 1319 ASSERT(IsClass(kernel_class)); |
| 1317 dart::String& name = DartString(CanonicalNameString(kernel_class)); | 1320 dart::String& name = DartString(CanonicalNameString(kernel_class)); |
| 1318 return ManglePrivateName(CanonicalNameParent(kernel_class), &name); | 1321 return ManglePrivateName(CanonicalNameParent(kernel_class), &name); |
| 1319 } | 1322 } |
| 1320 | 1323 |
| 1321 | 1324 |
| 1322 const dart::String& TranslationHelper::DartConstructorName( | 1325 const dart::String& TranslationHelper::DartConstructorName( |
| 1323 intptr_t constructor) { | 1326 NameIndex constructor) { |
| 1324 ASSERT(IsConstructor(constructor)); | 1327 ASSERT(IsConstructor(constructor)); |
| 1325 return DartFactoryName(constructor); | 1328 return DartFactoryName(constructor); |
| 1326 } | 1329 } |
| 1327 | 1330 |
| 1328 | 1331 |
| 1329 const dart::String& TranslationHelper::DartProcedureName(intptr_t procedure) { | 1332 const dart::String& TranslationHelper::DartProcedureName(NameIndex procedure) { |
| 1330 ASSERT(IsProcedure(procedure)); | 1333 ASSERT(IsProcedure(procedure)); |
| 1331 if (IsSetter(procedure)) { | 1334 if (IsSetter(procedure)) { |
| 1332 return DartSetterName(procedure); | 1335 return DartSetterName(procedure); |
| 1333 } else if (IsGetter(procedure)) { | 1336 } else if (IsGetter(procedure)) { |
| 1334 return DartGetterName(procedure); | 1337 return DartGetterName(procedure); |
| 1335 } else if (IsFactory(procedure)) { | 1338 } else if (IsFactory(procedure)) { |
| 1336 return DartFactoryName(procedure); | 1339 return DartFactoryName(procedure); |
| 1337 } else { | 1340 } else { |
| 1338 return DartMethodName(procedure); | 1341 return DartMethodName(procedure); |
| 1339 } | 1342 } |
| 1340 } | 1343 } |
| 1341 | 1344 |
| 1342 | 1345 |
| 1343 const dart::String& TranslationHelper::DartSetterName(intptr_t setter) { | 1346 const dart::String& TranslationHelper::DartSetterName(NameIndex setter) { |
| 1344 return DartSetterName(CanonicalNameParent(setter), | 1347 return DartSetterName(CanonicalNameParent(setter), |
| 1345 CanonicalNameString(setter)); | 1348 CanonicalNameString(setter)); |
| 1346 } | 1349 } |
| 1347 | 1350 |
| 1348 | 1351 |
| 1349 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) { | 1352 const dart::String& TranslationHelper::DartSetterName(Name* setter_name) { |
| 1350 return DartSetterName(setter_name->library(), setter_name->string_index()); | 1353 return DartSetterName(setter_name->library(), setter_name->string_index()); |
| 1351 } | 1354 } |
| 1352 | 1355 |
| 1353 | 1356 |
| 1354 const dart::String& TranslationHelper::DartSetterName(intptr_t parent, | 1357 const dart::String& TranslationHelper::DartSetterName(NameIndex parent, |
| 1355 intptr_t setter) { | 1358 StringIndex setter) { |
| 1356 // The names flowing into [setter] are coming from the Kernel file: | 1359 // The names flowing into [setter] are coming from the Kernel file: |
| 1357 // * user-defined setters: `fieldname=` | 1360 // * user-defined setters: `fieldname=` |
| 1358 // * property-set expressions: `fieldname` | 1361 // * property-set expressions: `fieldname` |
| 1359 // | 1362 // |
| 1360 // The VM uses `get:fieldname` and `set:fieldname`. | 1363 // The VM uses `get:fieldname` and `set:fieldname`. |
| 1361 // | 1364 // |
| 1362 // => In order to be consistent, we remove the `=` always and adopt the VM | 1365 // => In order to be consistent, we remove the `=` always and adopt the VM |
| 1363 // conventions. | 1366 // conventions. |
| 1364 intptr_t size = StringSize(setter); | 1367 intptr_t size = StringSize(setter); |
| 1365 ASSERT(size > 0); | 1368 ASSERT(size > 0); |
| 1366 if (CharacterAt(setter, size - 1) == '=') { | 1369 if (CharacterAt(setter, size - 1) == '=') { |
| 1367 --size; | 1370 --size; |
| 1368 } | 1371 } |
| 1369 uint8_t* buffer = Z->Alloc<uint8_t>(size); | 1372 uint8_t* buffer = Z->Alloc<uint8_t>(size); |
| 1370 { | 1373 { |
| 1371 NoSafepointScope no_safepoint; | 1374 NoSafepointScope no_safepoint; |
| 1372 memmove(buffer, string_data_.DataAddr(StringOffset(setter)), size); | 1375 memmove(buffer, string_data_.DataAddr(StringOffset(setter)), size); |
| 1373 } | 1376 } |
| 1374 dart::String& name = dart::String::ZoneHandle( | 1377 dart::String& name = dart::String::ZoneHandle( |
| 1375 Z, dart::String::FromUTF8(buffer, size, allocation_space_)); | 1378 Z, dart::String::FromUTF8(buffer, size, allocation_space_)); |
| 1376 ManglePrivateName(parent, &name, false); | 1379 ManglePrivateName(parent, &name, false); |
| 1377 name = dart::Field::SetterSymbol(name); | 1380 name = dart::Field::SetterSymbol(name); |
| 1378 return name; | 1381 return name; |
| 1379 } | 1382 } |
| 1380 | 1383 |
| 1381 | 1384 |
| 1382 const dart::String& TranslationHelper::DartGetterName(intptr_t getter) { | 1385 const dart::String& TranslationHelper::DartGetterName(NameIndex getter) { |
| 1383 return DartGetterName(CanonicalNameParent(getter), | 1386 return DartGetterName(CanonicalNameParent(getter), |
| 1384 CanonicalNameString(getter)); | 1387 CanonicalNameString(getter)); |
| 1385 } | 1388 } |
| 1386 | 1389 |
| 1387 | 1390 |
| 1388 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) { | 1391 const dart::String& TranslationHelper::DartGetterName(Name* getter_name) { |
| 1389 return DartGetterName(getter_name->library(), getter_name->string_index()); | 1392 return DartGetterName(getter_name->library(), getter_name->string_index()); |
| 1390 } | 1393 } |
| 1391 | 1394 |
| 1392 | 1395 |
| 1393 const dart::String& TranslationHelper::DartGetterName(intptr_t parent, | 1396 const dart::String& TranslationHelper::DartGetterName(NameIndex parent, |
| 1394 intptr_t getter) { | 1397 StringIndex getter) { |
| 1395 dart::String& name = DartString(getter); | 1398 dart::String& name = DartString(getter); |
| 1396 ManglePrivateName(parent, &name, false); | 1399 ManglePrivateName(parent, &name, false); |
| 1397 name = dart::Field::GetterSymbol(name); | 1400 name = dart::Field::GetterSymbol(name); |
| 1398 return name; | 1401 return name; |
| 1399 } | 1402 } |
| 1400 | 1403 |
| 1401 | 1404 |
| 1402 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) { | 1405 const dart::String& TranslationHelper::DartFieldName(Name* kernel_name) { |
| 1403 dart::String& name = DartString(kernel_name->string_index()); | 1406 dart::String& name = DartString(kernel_name->string_index()); |
| 1404 return ManglePrivateName(kernel_name->library(), &name); | 1407 return ManglePrivateName(kernel_name->library(), &name); |
| 1405 } | 1408 } |
| 1406 | 1409 |
| 1407 | 1410 |
| 1408 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) { | 1411 const dart::String& TranslationHelper::DartInitializerName(Name* kernel_name) { |
| 1409 // The [DartFieldName] will take care of mangling the name. | 1412 // The [DartFieldName] will take care of mangling the name. |
| 1410 dart::String& name = | 1413 dart::String& name = |
| 1411 dart::String::Handle(Z, DartFieldName(kernel_name).raw()); | 1414 dart::String::Handle(Z, DartFieldName(kernel_name).raw()); |
| 1412 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name); | 1415 name = Symbols::FromConcat(thread_, Symbols::InitPrefix(), name); |
| 1413 return name; | 1416 return name; |
| 1414 } | 1417 } |
| 1415 | 1418 |
| 1416 | 1419 |
| 1417 const dart::String& TranslationHelper::DartMethodName(intptr_t method) { | 1420 const dart::String& TranslationHelper::DartMethodName(NameIndex method) { |
| 1418 return DartMethodName(CanonicalNameParent(method), | 1421 return DartMethodName(CanonicalNameParent(method), |
| 1419 CanonicalNameString(method)); | 1422 CanonicalNameString(method)); |
| 1420 } | 1423 } |
| 1421 | 1424 |
| 1422 | 1425 |
| 1423 const dart::String& TranslationHelper::DartMethodName(Name* method_name) { | 1426 const dart::String& TranslationHelper::DartMethodName(Name* method_name) { |
| 1424 return DartMethodName(method_name->library(), method_name->string_index()); | 1427 return DartMethodName(method_name->library(), method_name->string_index()); |
| 1425 } | 1428 } |
| 1426 | 1429 |
| 1427 | 1430 |
| 1428 const dart::String& TranslationHelper::DartMethodName(intptr_t parent, | 1431 const dart::String& TranslationHelper::DartMethodName(NameIndex parent, |
| 1429 intptr_t method) { | 1432 StringIndex method) { |
| 1430 dart::String& name = DartString(method); | 1433 dart::String& name = DartString(method); |
| 1431 return ManglePrivateName(parent, &name); | 1434 return ManglePrivateName(parent, &name); |
| 1432 } | 1435 } |
| 1433 | 1436 |
| 1434 | 1437 |
| 1435 const dart::String& TranslationHelper::DartFactoryName(intptr_t factory) { | 1438 const dart::String& TranslationHelper::DartFactoryName(NameIndex factory) { |
| 1436 ASSERT(IsConstructor(factory) || IsFactory(factory)); | 1439 ASSERT(IsConstructor(factory) || IsFactory(factory)); |
| 1437 GrowableHandlePtrArray<const dart::String> pieces(Z, 3); | 1440 GrowableHandlePtrArray<const dart::String> pieces(Z, 3); |
| 1438 pieces.Add(DartClassName(EnclosingName(factory))); | 1441 pieces.Add(DartClassName(EnclosingName(factory))); |
| 1439 pieces.Add(Symbols::Dot()); | 1442 pieces.Add(Symbols::Dot()); |
| 1440 // [DartMethodName] will mangle the name. | 1443 // [DartMethodName] will mangle the name. |
| 1441 pieces.Add(DartMethodName(factory)); | 1444 pieces.Add(DartMethodName(factory)); |
| 1442 return dart::String::ZoneHandle(Z, Symbols::FromConcatAll(thread_, pieces)); | 1445 return dart::String::ZoneHandle(Z, Symbols::FromConcatAll(thread_, pieces)); |
| 1443 } | 1446 } |
| 1444 | 1447 |
| 1445 | 1448 |
| 1446 RawLibrary* TranslationHelper::LookupLibraryByKernelLibrary( | 1449 RawLibrary* TranslationHelper::LookupLibraryByKernelLibrary( |
| 1447 intptr_t kernel_library) { | 1450 NameIndex kernel_library) { |
| 1448 // We only use the string and don't rely on having any particular parent. | 1451 // We only use the string and don't rely on having any particular parent. |
| 1449 // This ASSERT is just a sanity check. | 1452 // This ASSERT is just a sanity check. |
| 1450 ASSERT(IsLibrary(kernel_library) || | 1453 ASSERT(IsLibrary(kernel_library) || |
| 1451 IsAdministrative(CanonicalNameParent(kernel_library))); | 1454 IsAdministrative(CanonicalNameParent(kernel_library))); |
| 1452 const dart::String& library_name = | 1455 const dart::String& library_name = |
| 1453 DartSymbol(CanonicalNameString(kernel_library)); | 1456 DartSymbol(CanonicalNameString(kernel_library)); |
| 1454 ASSERT(!library_name.IsNull()); | 1457 ASSERT(!library_name.IsNull()); |
| 1455 RawLibrary* library = dart::Library::LookupLibrary(thread_, library_name); | 1458 RawLibrary* library = dart::Library::LookupLibrary(thread_, library_name); |
| 1456 ASSERT(library != Object::null()); | 1459 ASSERT(library != Object::null()); |
| 1457 return library; | 1460 return library; |
| 1458 } | 1461 } |
| 1459 | 1462 |
| 1460 | 1463 |
| 1461 RawClass* TranslationHelper::LookupClassByKernelClass(intptr_t kernel_class) { | 1464 RawClass* TranslationHelper::LookupClassByKernelClass(NameIndex kernel_class) { |
| 1462 ASSERT(IsClass(kernel_class)); | 1465 ASSERT(IsClass(kernel_class)); |
| 1463 const dart::String& class_name = DartClassName(kernel_class); | 1466 const dart::String& class_name = DartClassName(kernel_class); |
| 1464 intptr_t kernel_library = CanonicalNameParent(kernel_class); | 1467 NameIndex kernel_library = CanonicalNameParent(kernel_class); |
| 1465 dart::Library& library = | 1468 dart::Library& library = |
| 1466 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); | 1469 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(kernel_library)); |
| 1467 RawClass* klass = library.LookupClassAllowPrivate(class_name); | 1470 RawClass* klass = library.LookupClassAllowPrivate(class_name); |
| 1468 | 1471 |
| 1469 ASSERT(klass != Object::null()); | 1472 ASSERT(klass != Object::null()); |
| 1470 return klass; | 1473 return klass; |
| 1471 } | 1474 } |
| 1472 | 1475 |
| 1473 | 1476 |
| 1474 RawField* TranslationHelper::LookupFieldByKernelField(intptr_t kernel_field) { | 1477 RawField* TranslationHelper::LookupFieldByKernelField(NameIndex kernel_field) { |
| 1475 ASSERT(IsField(kernel_field)); | 1478 ASSERT(IsField(kernel_field)); |
| 1476 intptr_t enclosing = EnclosingName(kernel_field); | 1479 NameIndex enclosing = EnclosingName(kernel_field); |
| 1477 | 1480 |
| 1478 dart::Class& klass = dart::Class::Handle(Z); | 1481 dart::Class& klass = dart::Class::Handle(Z); |
| 1479 if (IsLibrary(enclosing)) { | 1482 if (IsLibrary(enclosing)) { |
| 1480 dart::Library& library = | 1483 dart::Library& library = |
| 1481 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing)); | 1484 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing)); |
| 1482 klass = library.toplevel_class(); | 1485 klass = library.toplevel_class(); |
| 1483 } else { | 1486 } else { |
| 1484 ASSERT(IsClass(enclosing)); | 1487 ASSERT(IsClass(enclosing)); |
| 1485 klass = LookupClassByKernelClass(enclosing); | 1488 klass = LookupClassByKernelClass(enclosing); |
| 1486 } | 1489 } |
| 1487 RawField* field = klass.LookupFieldAllowPrivate( | 1490 RawField* field = klass.LookupFieldAllowPrivate( |
| 1488 DartSymbol(CanonicalNameString(kernel_field))); | 1491 DartSymbol(CanonicalNameString(kernel_field))); |
| 1489 ASSERT(field != Object::null()); | 1492 ASSERT(field != Object::null()); |
| 1490 return field; | 1493 return field; |
| 1491 } | 1494 } |
| 1492 | 1495 |
| 1493 | 1496 |
| 1494 RawFunction* TranslationHelper::LookupStaticMethodByKernelProcedure( | 1497 RawFunction* TranslationHelper::LookupStaticMethodByKernelProcedure( |
| 1495 intptr_t procedure) { | 1498 NameIndex procedure) { |
| 1496 const dart::String& procedure_name = DartProcedureName(procedure); | 1499 const dart::String& procedure_name = DartProcedureName(procedure); |
| 1497 | 1500 |
| 1498 // The parent is either a library or a class (in which case the procedure is a | 1501 // The parent is either a library or a class (in which case the procedure is a |
| 1499 // static method). | 1502 // static method). |
| 1500 intptr_t enclosing = EnclosingName(procedure); | 1503 NameIndex enclosing = EnclosingName(procedure); |
| 1501 if (IsLibrary(enclosing)) { | 1504 if (IsLibrary(enclosing)) { |
| 1502 dart::Library& library = | 1505 dart::Library& library = |
| 1503 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing)); | 1506 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(enclosing)); |
| 1504 RawFunction* function = library.LookupFunctionAllowPrivate(procedure_name); | 1507 RawFunction* function = library.LookupFunctionAllowPrivate(procedure_name); |
| 1505 ASSERT(function != Object::null()); | 1508 ASSERT(function != Object::null()); |
| 1506 return function; | 1509 return function; |
| 1507 } else { | 1510 } else { |
| 1508 ASSERT(IsClass(enclosing)); | 1511 ASSERT(IsClass(enclosing)); |
| 1509 dart::Class& klass = | 1512 dart::Class& klass = |
| 1510 dart::Class::Handle(Z, LookupClassByKernelClass(enclosing)); | 1513 dart::Class::Handle(Z, LookupClassByKernelClass(enclosing)); |
| 1511 Function& function = Function::ZoneHandle( | 1514 Function& function = Function::ZoneHandle( |
| 1512 Z, klass.LookupFunctionAllowPrivate(procedure_name)); | 1515 Z, klass.LookupFunctionAllowPrivate(procedure_name)); |
| 1513 ASSERT(!function.IsNull()); | 1516 ASSERT(!function.IsNull()); |
| 1514 | 1517 |
| 1515 // TODO(27590): We can probably get rid of this after no longer using | 1518 // TODO(27590): We can probably get rid of this after no longer using |
| 1516 // core libraries from the source. | 1519 // core libraries from the source. |
| 1517 if (function.IsRedirectingFactory()) { | 1520 if (function.IsRedirectingFactory()) { |
| 1518 ClassFinalizer::ResolveRedirectingFactory(klass, function); | 1521 ClassFinalizer::ResolveRedirectingFactory(klass, function); |
| 1519 function = function.RedirectionTarget(); | 1522 function = function.RedirectionTarget(); |
| 1520 } | 1523 } |
| 1521 return function.raw(); | 1524 return function.raw(); |
| 1522 } | 1525 } |
| 1523 } | 1526 } |
| 1524 | 1527 |
| 1525 | 1528 |
| 1526 RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( | 1529 RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( |
| 1527 intptr_t constructor) { | 1530 NameIndex constructor) { |
| 1528 ASSERT(IsConstructor(constructor)); | 1531 ASSERT(IsConstructor(constructor)); |
| 1529 dart::Class& klass = dart::Class::Handle( | 1532 dart::Class& klass = dart::Class::Handle( |
| 1530 Z, LookupClassByKernelClass(EnclosingName(constructor))); | 1533 Z, LookupClassByKernelClass(EnclosingName(constructor))); |
| 1531 return LookupConstructorByKernelConstructor(klass, constructor); | 1534 return LookupConstructorByKernelConstructor(klass, constructor); |
| 1532 } | 1535 } |
| 1533 | 1536 |
| 1534 | 1537 |
| 1535 RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( | 1538 RawFunction* TranslationHelper::LookupConstructorByKernelConstructor( |
| 1536 const dart::Class& owner, | 1539 const dart::Class& owner, |
| 1537 intptr_t constructor) { | 1540 NameIndex constructor) { |
| 1538 ASSERT(IsConstructor(constructor)); | 1541 ASSERT(IsConstructor(constructor)); |
| 1539 RawFunction* function = | 1542 RawFunction* function = |
| 1540 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor)); | 1543 owner.LookupConstructorAllowPrivate(DartConstructorName(constructor)); |
| 1541 ASSERT(function != Object::null()); | 1544 ASSERT(function != Object::null()); |
| 1542 return function; | 1545 return function; |
| 1543 } | 1546 } |
| 1544 | 1547 |
| 1545 | 1548 |
| 1546 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) { | 1549 dart::Type& TranslationHelper::GetCanonicalType(const dart::Class& klass) { |
| 1547 ASSERT(!klass.IsNull()); | 1550 ASSERT(!klass.IsNull()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 | 1584 |
| 1582 va_list args; | 1585 va_list args; |
| 1583 va_start(args, format); | 1586 va_start(args, format); |
| 1584 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format, | 1587 Report::LongJumpV(prev_error, null_script, TokenPosition::kNoSource, format, |
| 1585 args); | 1588 args); |
| 1586 va_end(args); | 1589 va_end(args); |
| 1587 UNREACHABLE(); | 1590 UNREACHABLE(); |
| 1588 } | 1591 } |
| 1589 | 1592 |
| 1590 | 1593 |
| 1591 dart::String& TranslationHelper::ManglePrivateName(intptr_t parent, | 1594 dart::String& TranslationHelper::ManglePrivateName(NameIndex parent, |
| 1592 dart::String* name_to_modify, | 1595 dart::String* name_to_modify, |
| 1593 bool symbolize) { | 1596 bool symbolize) { |
| 1594 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') { | 1597 if (name_to_modify->Length() >= 1 && name_to_modify->CharAt(0) == '_') { |
| 1595 const dart::Library& library = | 1598 const dart::Library& library = |
| 1596 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(parent)); | 1599 dart::Library::Handle(Z, LookupLibraryByKernelLibrary(parent)); |
| 1597 *name_to_modify = library.PrivateName(*name_to_modify); | 1600 *name_to_modify = library.PrivateName(*name_to_modify); |
| 1598 } else if (symbolize) { | 1601 } else if (symbolize) { |
| 1599 *name_to_modify = Symbols::New(thread_, *name_to_modify); | 1602 *name_to_modify = Symbols::New(thread_, *name_to_modify); |
| 1600 } | 1603 } |
| 1601 return *name_to_modify; | 1604 return *name_to_modify; |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 ASSERT(!function.IsNull()); | 1957 ASSERT(!function.IsNull()); |
| 1955 | 1958 |
| 1956 // Run the method and canonicalize the result. | 1959 // Run the method and canonicalize the result. |
| 1957 const Object& result = RunFunction(function, kernel_arguments, &receiver); | 1960 const Object& result = RunFunction(function, kernel_arguments, &receiver); |
| 1958 result_ ^= result.raw(); | 1961 result_ ^= result.raw(); |
| 1959 result_ = H.Canonicalize(result_); | 1962 result_ = H.Canonicalize(result_); |
| 1960 } | 1963 } |
| 1961 | 1964 |
| 1962 | 1965 |
| 1963 void ConstantEvaluator::VisitStaticGet(StaticGet* node) { | 1966 void ConstantEvaluator::VisitStaticGet(StaticGet* node) { |
| 1964 intptr_t target = node->target(); | 1967 NameIndex target = node->target(); |
| 1965 if (H.IsField(target)) { | 1968 if (H.IsField(target)) { |
| 1966 const dart::Field& field = | 1969 const dart::Field& field = |
| 1967 dart::Field::Handle(Z, H.LookupFieldByKernelField(target)); | 1970 dart::Field::Handle(Z, H.LookupFieldByKernelField(target)); |
| 1968 if (field.StaticValue() == Object::sentinel().raw() || | 1971 if (field.StaticValue() == Object::sentinel().raw() || |
| 1969 field.StaticValue() == Object::transition_sentinel().raw()) { | 1972 field.StaticValue() == Object::transition_sentinel().raw()) { |
| 1970 field.EvaluateInitializer(); | 1973 field.EvaluateInitializer(); |
| 1971 result_ = field.StaticValue(); | 1974 result_ = field.StaticValue(); |
| 1972 result_ = H.Canonicalize(result_); | 1975 result_ = H.Canonicalize(result_); |
| 1973 field.SetStaticValue(result_, true); | 1976 field.SetStaticValue(result_, true); |
| 1974 } else { | 1977 } else { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2085 } | 2088 } |
| 2086 } | 2089 } |
| 2087 | 2090 |
| 2088 | 2091 |
| 2089 void ConstantEvaluator::VisitNot(Not* node) { | 2092 void ConstantEvaluator::VisitNot(Not* node) { |
| 2090 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw(); | 2093 result_ ^= Bool::Get(!EvaluateBooleanExpression(node->expression())).raw(); |
| 2091 } | 2094 } |
| 2092 | 2095 |
| 2093 | 2096 |
| 2094 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { | 2097 void ConstantEvaluator::VisitPropertyGet(PropertyGet* node) { |
| 2095 intptr_t string_index = node->name()->string_index(); | 2098 StringIndex string_index = node->name()->string_index(); |
| 2096 if (H.StringEquals(string_index, "length")) { | 2099 if (H.StringEquals(string_index, "length")) { |
| 2097 node->receiver()->AcceptExpressionVisitor(this); | 2100 node->receiver()->AcceptExpressionVisitor(this); |
| 2098 if (result_.IsString()) { | 2101 if (result_.IsString()) { |
| 2099 const dart::String& str = | 2102 const dart::String& str = |
| 2100 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); | 2103 dart::String::Handle(Z, dart::String::RawCast(result_.raw())); |
| 2101 result_ = Integer::New(str.Length()); | 2104 result_ = Integer::New(str.Length()); |
| 2102 } else { | 2105 } else { |
| 2103 H.ReportError( | 2106 H.ReportError( |
| 2104 "Constant expressions can only call " | 2107 "Constant expressions can only call " |
| 2105 "'length' on string constants."); | 2108 "'length' on string constants."); |
| (...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3133 | 3136 |
| 3134 instructions += StaticCall(TokenPosition::kNoSource, throw_function, 6); | 3137 instructions += StaticCall(TokenPosition::kNoSource, throw_function, 6); |
| 3135 // Leave "result" on the stack since callers expect it to be there (even | 3138 // Leave "result" on the stack since callers expect it to be there (even |
| 3136 // though the function will result in an exception). | 3139 // though the function will result in an exception). |
| 3137 | 3140 |
| 3138 return instructions; | 3141 return instructions; |
| 3139 } | 3142 } |
| 3140 | 3143 |
| 3141 | 3144 |
| 3142 RawFunction* FlowGraphBuilder::LookupMethodByMember( | 3145 RawFunction* FlowGraphBuilder::LookupMethodByMember( |
| 3143 intptr_t target, | 3146 NameIndex target, |
| 3144 const dart::String& method_name) { | 3147 const dart::String& method_name) { |
| 3145 intptr_t kernel_class = H.EnclosingName(target); | 3148 NameIndex kernel_class = H.EnclosingName(target); |
| 3146 dart::Class& klass = | 3149 dart::Class& klass = |
| 3147 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_class)); | 3150 dart::Class::Handle(Z, H.LookupClassByKernelClass(kernel_class)); |
| 3148 | 3151 |
| 3149 RawFunction* function = klass.LookupFunctionAllowPrivate(method_name); | 3152 RawFunction* function = klass.LookupFunctionAllowPrivate(method_name); |
| 3150 ASSERT(function != Object::null()); | 3153 ASSERT(function != Object::null()); |
| 3151 return function; | 3154 return function; |
| 3152 } | 3155 } |
| 3153 | 3156 |
| 3154 | 3157 |
| 3155 LocalVariable* FlowGraphBuilder::MakeTemporary() { | 3158 LocalVariable* FlowGraphBuilder::MakeTemporary() { |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4406 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry(intptr_t try_index) { | 4409 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry(intptr_t try_index) { |
| 4407 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index); | 4410 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index); |
| 4408 } | 4411 } |
| 4409 | 4412 |
| 4410 | 4413 |
| 4411 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { | 4414 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { |
| 4412 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex()); | 4415 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex()); |
| 4413 } | 4416 } |
| 4414 | 4417 |
| 4415 | 4418 |
| 4416 Fragment FlowGraphBuilder::TranslateFieldInitializer(intptr_t canonical_name, | 4419 Fragment FlowGraphBuilder::TranslateFieldInitializer(NameIndex canonical_name, |
| 4417 Expression* init) { | 4420 Expression* init) { |
| 4418 dart::Field& field = | 4421 dart::Field& field = |
| 4419 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name)); | 4422 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name)); |
| 4420 if (init->IsNullLiteral()) { | 4423 if (init->IsNullLiteral()) { |
| 4421 field.RecordStore(Object::null_object()); | 4424 field.RecordStore(Object::null_object()); |
| 4422 return Fragment(); | 4425 return Fragment(); |
| 4423 } | 4426 } |
| 4424 Fragment instructions; | 4427 Fragment instructions; |
| 4425 instructions += LoadLocal(scopes_->this_variable); | 4428 instructions += LoadLocal(scopes_->this_variable); |
| 4426 instructions += TranslateExpression(init); | 4429 instructions += TranslateExpression(init); |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4982 } else { | 4985 } else { |
| 4983 UNIMPLEMENTED(); | 4986 UNIMPLEMENTED(); |
| 4984 } | 4987 } |
| 4985 } else { | 4988 } else { |
| 4986 UNIMPLEMENTED(); | 4989 UNIMPLEMENTED(); |
| 4987 } | 4990 } |
| 4988 } | 4991 } |
| 4989 | 4992 |
| 4990 | 4993 |
| 4991 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) { | 4994 void FlowGraphBuilder::VisitStaticSet(StaticSet* node) { |
| 4992 intptr_t target = node->target(); | 4995 NameIndex target = node->target(); |
| 4993 if (H.IsField(target)) { | 4996 if (H.IsField(target)) { |
| 4994 const dart::Field& field = | 4997 const dart::Field& field = |
| 4995 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target)); | 4998 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(target)); |
| 4996 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type()); | 4999 const AbstractType& dst_type = AbstractType::ZoneHandle(Z, field.type()); |
| 4997 Fragment instructions = TranslateExpression(node->expression()); | 5000 Fragment instructions = TranslateExpression(node->expression()); |
| 4998 if (NeedsDebugStepCheck(stack_, node->position())) { | 5001 if (NeedsDebugStepCheck(stack_, node->position())) { |
| 4999 instructions = DebugStepCheck(node->position()) + instructions; | 5002 instructions = DebugStepCheck(node->position()) + instructions; |
| 5000 } | 5003 } |
| 5001 instructions += CheckAssignableInCheckedMode( | 5004 instructions += CheckAssignableInCheckedMode( |
| 5002 dst_type, dart::String::ZoneHandle(Z, field.name())); | 5005 dst_type, dart::String::ZoneHandle(Z, field.name())); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5044 instructions += PushArgument(); | 5047 instructions += PushArgument(); |
| 5045 | 5048 |
| 5046 const dart::String& setter_name = H.DartSetterName(node->name()); | 5049 const dart::String& setter_name = H.DartSetterName(node->name()); |
| 5047 instructions += InstanceCall(node->position(), setter_name, Token::kSET, 2); | 5050 instructions += InstanceCall(node->position(), setter_name, Token::kSET, 2); |
| 5048 fragment_ = instructions + Drop(); | 5051 fragment_ = instructions + Drop(); |
| 5049 } | 5052 } |
| 5050 | 5053 |
| 5051 | 5054 |
| 5052 void FlowGraphBuilder::VisitDirectPropertyGet(DirectPropertyGet* node) { | 5055 void FlowGraphBuilder::VisitDirectPropertyGet(DirectPropertyGet* node) { |
| 5053 Function& target = Function::ZoneHandle(Z); | 5056 Function& target = Function::ZoneHandle(Z); |
| 5054 intptr_t kernel_name = node->target(); | 5057 NameIndex kernel_name = node->target(); |
| 5055 if (H.IsProcedure(kernel_name)) { | 5058 if (H.IsProcedure(kernel_name)) { |
| 5056 if (H.IsGetter(kernel_name)) { | 5059 if (H.IsGetter(kernel_name)) { |
| 5057 target = LookupMethodByMember(kernel_name, H.DartGetterName(kernel_name)); | 5060 target = LookupMethodByMember(kernel_name, H.DartGetterName(kernel_name)); |
| 5058 } else { | 5061 } else { |
| 5059 target = LookupMethodByMember(kernel_name, H.DartMethodName(kernel_name)); | 5062 target = LookupMethodByMember(kernel_name, H.DartMethodName(kernel_name)); |
| 5060 target = target.ImplicitClosureFunction(); | 5063 target = target.ImplicitClosureFunction(); |
| 5061 ASSERT(!target.IsNull()); | 5064 ASSERT(!target.IsNull()); |
| 5062 fragment_ = BuildImplicitClosureCreation(target); | 5065 fragment_ = BuildImplicitClosureCreation(target); |
| 5063 return; | 5066 return; |
| 5064 } | 5067 } |
| (...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6865 thread->clear_sticky_error(); | 6868 thread->clear_sticky_error(); |
| 6866 return error.raw(); | 6869 return error.raw(); |
| 6867 } | 6870 } |
| 6868 } | 6871 } |
| 6869 | 6872 |
| 6870 | 6873 |
| 6871 } // namespace kernel | 6874 } // namespace kernel |
| 6872 } // namespace dart | 6875 } // namespace dart |
| 6873 | 6876 |
| 6874 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6877 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |