Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1180 cur += kWordSize; | 1180 cur += kWordSize; |
| 1181 } | 1181 } |
| 1182 uword tags = 0; | 1182 uword tags = 0; |
| 1183 ASSERT(class_id != kIllegalCid); | 1183 ASSERT(class_id != kIllegalCid); |
| 1184 tags = RawObject::ClassIdTag::update(class_id, tags); | 1184 tags = RawObject::ClassIdTag::update(class_id, tags); |
| 1185 tags = RawObject::SizeTag::update(size, tags); | 1185 tags = RawObject::SizeTag::update(size, tags); |
| 1186 reinterpret_cast<RawObject*>(address)->tags_ = tags; | 1186 reinterpret_cast<RawObject*>(address)->tags_ = tags; |
| 1187 } | 1187 } |
| 1188 | 1188 |
| 1189 | 1189 |
| 1190 void Object::CheckHandle() const { | |
| 1191 #if defined(DEBUG) | |
| 1192 if (raw_ != Object::null()) { | |
| 1193 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { | |
| 1194 ASSERT(vtable() == Smi::handle_vtable_); | |
| 1195 return; | |
| 1196 } | |
| 1197 intptr_t cid = raw_->GetClassId(); | |
| 1198 if (cid >= kNumPredefinedCids) { | |
| 1199 cid = kInstanceCid; | |
| 1200 } | |
| 1201 ASSERT(vtable() == builtin_vtables_[cid]); | |
| 1202 Isolate* isolate = Isolate::Current(); | |
| 1203 if (FLAG_verify_handles) { | |
| 1204 Heap* isolate_heap = isolate->heap(); | |
| 1205 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); | |
| 1206 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) || | |
| 1207 vm_isolate_heap->Contains(RawObject::ToAddr(raw_))); | |
| 1208 } | |
| 1209 ASSERT(builtin_vtables_[cid] == | |
| 1210 isolate->class_table()->At(cid)->ptr()->handle_vtable_); | |
|
Ivan Posva
2013/01/17 23:24:23
Do we really need to check this one-time assertion
siva
2013/01/18 00:08:38
True, this assertion can be pulled out into a one
| |
| 1211 } | |
| 1212 #endif | |
| 1213 } | |
| 1214 | |
| 1215 | |
| 1190 RawObject* Object::Allocate(intptr_t cls_id, | 1216 RawObject* Object::Allocate(intptr_t cls_id, |
| 1191 intptr_t size, | 1217 intptr_t size, |
| 1192 Heap::Space space) { | 1218 Heap::Space space) { |
| 1193 ASSERT(Utils::IsAligned(size, kObjectAlignment)); | 1219 ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
| 1194 Isolate* isolate = Isolate::Current(); | 1220 Isolate* isolate = Isolate::Current(); |
| 1195 Heap* heap = isolate->heap(); | 1221 Heap* heap = isolate->heap(); |
| 1196 | 1222 |
| 1197 uword address = heap->Allocate(size, space); | 1223 uword address = heap->Allocate(size, space); |
| 1198 if (address == 0) { | 1224 if (address == 0) { |
| 1199 // Use the preallocated out of memory exception to avoid calling | 1225 // Use the preallocated out of memory exception to avoid calling |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1408 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw()); | 1434 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw()); |
| 1409 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); | 1435 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); |
| 1410 StorePointer(&raw_ptr()->fields_, Object::empty_array().raw()); | 1436 StorePointer(&raw_ptr()->fields_, Object::empty_array().raw()); |
| 1411 } | 1437 } |
| 1412 | 1438 |
| 1413 | 1439 |
| 1414 bool Class::HasInstanceFields() const { | 1440 bool Class::HasInstanceFields() const { |
| 1415 const Array& field_array = Array::Handle(fields()); | 1441 const Array& field_array = Array::Handle(fields()); |
| 1416 Field& field = Field::Handle(); | 1442 Field& field = Field::Handle(); |
| 1417 for (intptr_t i = 0; i < field_array.Length(); ++i) { | 1443 for (intptr_t i = 0; i < field_array.Length(); ++i) { |
| 1418 field ^= field_array.At(i); | 1444 field |= field_array.At(i); |
| 1419 if (!field.is_static()) { | 1445 if (!field.is_static()) { |
| 1420 return true; | 1446 return true; |
| 1421 } | 1447 } |
| 1422 } | 1448 } |
| 1423 return false; | 1449 return false; |
| 1424 } | 1450 } |
| 1425 | 1451 |
| 1426 void Class::SetFunctions(const Array& value) const { | 1452 void Class::SetFunctions(const Array& value) const { |
| 1427 ASSERT(!value.IsNull()); | 1453 ASSERT(!value.IsNull()); |
| 1428 #if defined(DEBUG) | 1454 #if defined(DEBUG) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1455 if (raw_ptr()->closure_functions_ == GrowableObjectArray::null()) { | 1481 if (raw_ptr()->closure_functions_ == GrowableObjectArray::null()) { |
| 1456 return Function::null(); | 1482 return Function::null(); |
| 1457 } | 1483 } |
| 1458 const GrowableObjectArray& closures = | 1484 const GrowableObjectArray& closures = |
| 1459 GrowableObjectArray::Handle(raw_ptr()->closure_functions_); | 1485 GrowableObjectArray::Handle(raw_ptr()->closure_functions_); |
| 1460 Function& closure = Function::Handle(); | 1486 Function& closure = Function::Handle(); |
| 1461 intptr_t num_closures = closures.Length(); | 1487 intptr_t num_closures = closures.Length(); |
| 1462 intptr_t best_fit_token_pos = -1; | 1488 intptr_t best_fit_token_pos = -1; |
| 1463 intptr_t best_fit_index = -1; | 1489 intptr_t best_fit_index = -1; |
| 1464 for (intptr_t i = 0; i < num_closures; i++) { | 1490 for (intptr_t i = 0; i < num_closures; i++) { |
| 1465 closure ^= closures.At(i); | 1491 closure |= closures.At(i); |
| 1466 ASSERT(!closure.IsNull()); | 1492 ASSERT(!closure.IsNull()); |
| 1467 if ((closure.token_pos() <= token_pos) && | 1493 if ((closure.token_pos() <= token_pos) && |
| 1468 (token_pos < closure.end_token_pos()) && | 1494 (token_pos < closure.end_token_pos()) && |
| 1469 (best_fit_token_pos < closure.token_pos())) { | 1495 (best_fit_token_pos < closure.token_pos())) { |
| 1470 best_fit_index = i; | 1496 best_fit_index = i; |
| 1471 best_fit_token_pos = closure.token_pos(); | 1497 best_fit_token_pos = closure.token_pos(); |
| 1472 } | 1498 } |
| 1473 } | 1499 } |
| 1474 closure = Function::null(); | 1500 closure = Function::null(); |
| 1475 if (best_fit_index >= 0) { | 1501 if (best_fit_index >= 0) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1623 // The instance needs a type_arguments field. | 1649 // The instance needs a type_arguments field. |
| 1624 type_args_field_offset = offset; | 1650 type_args_field_offset = offset; |
| 1625 offset += kWordSize; | 1651 offset += kWordSize; |
| 1626 } | 1652 } |
| 1627 } | 1653 } |
| 1628 set_type_arguments_field_offset(type_args_field_offset); | 1654 set_type_arguments_field_offset(type_args_field_offset); |
| 1629 ASSERT(offset != 0); | 1655 ASSERT(offset != 0); |
| 1630 Field& field = Field::Handle(); | 1656 Field& field = Field::Handle(); |
| 1631 intptr_t len = flds.Length(); | 1657 intptr_t len = flds.Length(); |
| 1632 for (intptr_t i = 0; i < len; i++) { | 1658 for (intptr_t i = 0; i < len; i++) { |
| 1633 field ^= flds.At(i); | 1659 field |= flds.At(i); |
| 1634 // Offset is computed only for instance fields. | 1660 // Offset is computed only for instance fields. |
| 1635 if (!field.is_static()) { | 1661 if (!field.is_static()) { |
| 1636 ASSERT(field.Offset() == 0); | 1662 ASSERT(field.Offset() == 0); |
| 1637 field.SetOffset(offset); | 1663 field.SetOffset(offset); |
| 1638 offset += kWordSize; | 1664 offset += kWordSize; |
| 1639 } | 1665 } |
| 1640 } | 1666 } |
| 1641 set_instance_size(RoundedAllocationSize(offset)); | 1667 set_instance_size(RoundedAllocationSize(offset)); |
| 1642 set_next_field_offset(offset); | 1668 set_next_field_offset(offset); |
| 1643 } | 1669 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1679 Array& patch_list = Array::Handle(patch.functions()); | 1705 Array& patch_list = Array::Handle(patch.functions()); |
| 1680 intptr_t patch_len = patch_list.Length(); | 1706 intptr_t patch_len = patch_list.Length(); |
| 1681 | 1707 |
| 1682 // TODO(iposva): Verify that only patching existing methods and adding only | 1708 // TODO(iposva): Verify that only patching existing methods and adding only |
| 1683 // new private methods. | 1709 // new private methods. |
| 1684 Function& func = Function::Handle(); | 1710 Function& func = Function::Handle(); |
| 1685 Function& orig_func = Function::Handle(); | 1711 Function& orig_func = Function::Handle(); |
| 1686 const GrowableObjectArray& new_functions = GrowableObjectArray::Handle( | 1712 const GrowableObjectArray& new_functions = GrowableObjectArray::Handle( |
| 1687 GrowableObjectArray::New(orig_len)); | 1713 GrowableObjectArray::New(orig_len)); |
| 1688 for (intptr_t i = 0; i < orig_len; i++) { | 1714 for (intptr_t i = 0; i < orig_len; i++) { |
| 1689 orig_func ^= orig_list.At(i); | 1715 orig_func |= orig_list.At(i); |
| 1690 member_name = orig_func.name(); | 1716 member_name = orig_func.name(); |
| 1691 func = patch.LookupFunction(member_name); | 1717 func = patch.LookupFunction(member_name); |
| 1692 if (func.IsNull()) { | 1718 if (func.IsNull()) { |
| 1693 // Non-patched function is preserved, all patched functions are added in | 1719 // Non-patched function is preserved, all patched functions are added in |
| 1694 // the loop below. | 1720 // the loop below. |
| 1695 new_functions.Add(orig_func); | 1721 new_functions.Add(orig_func); |
| 1696 } else if (!func.HasCompatibleParametersWith(orig_func) && | 1722 } else if (!func.HasCompatibleParametersWith(orig_func) && |
| 1697 !(func.IsFactory() && orig_func.IsConstructor() && | 1723 !(func.IsFactory() && orig_func.IsConstructor() && |
| 1698 (func.num_fixed_parameters() + 1 == | 1724 (func.num_fixed_parameters() + 1 == |
| 1699 orig_func.num_fixed_parameters()))) { | 1725 orig_func.num_fixed_parameters()))) { |
| 1700 return FormatPatchError("mismatched parameters: %s", member_name); | 1726 return FormatPatchError("mismatched parameters: %s", member_name); |
| 1701 } | 1727 } |
| 1702 } | 1728 } |
| 1703 for (intptr_t i = 0; i < patch_len; i++) { | 1729 for (intptr_t i = 0; i < patch_len; i++) { |
| 1704 func ^= patch_list.At(i); | 1730 func |= patch_list.At(i); |
| 1705 func.set_owner(patch_class); | 1731 func.set_owner(patch_class); |
| 1706 new_functions.Add(func); | 1732 new_functions.Add(func); |
| 1707 } | 1733 } |
| 1708 Array& new_list = Array::Handle(Array::MakeArray(new_functions)); | 1734 Array& new_list = Array::Handle(Array::MakeArray(new_functions)); |
| 1709 SetFunctions(new_list); | 1735 SetFunctions(new_list); |
| 1710 | 1736 |
| 1711 // Merge the two list of fields. Raise an error when duplicates are found or | 1737 // Merge the two list of fields. Raise an error when duplicates are found or |
| 1712 // when a public field is being added. | 1738 // when a public field is being added. |
| 1713 orig_list = fields(); | 1739 orig_list = fields(); |
| 1714 orig_len = orig_list.Length(); | 1740 orig_len = orig_list.Length(); |
| 1715 patch_list = patch.fields(); | 1741 patch_list = patch.fields(); |
| 1716 patch_len = patch_list.Length(); | 1742 patch_len = patch_list.Length(); |
| 1717 | 1743 |
| 1718 Field& field = Field::Handle(); | 1744 Field& field = Field::Handle(); |
| 1719 Field& orig_field = Field::Handle(); | 1745 Field& orig_field = Field::Handle(); |
| 1720 new_list = Array::New(patch_len + orig_len); | 1746 new_list = Array::New(patch_len + orig_len); |
| 1721 for (intptr_t i = 0; i < patch_len; i++) { | 1747 for (intptr_t i = 0; i < patch_len; i++) { |
| 1722 field ^= patch_list.At(i); | 1748 field |= patch_list.At(i); |
| 1723 field.set_owner(*this); | 1749 field.set_owner(*this); |
| 1724 member_name = field.name(); | 1750 member_name = field.name(); |
| 1725 // TODO(iposva): Verify non-public fields only. | 1751 // TODO(iposva): Verify non-public fields only. |
| 1726 | 1752 |
| 1727 // Verify no duplicate additions. | 1753 // Verify no duplicate additions. |
| 1728 orig_field = LookupField(member_name); | 1754 orig_field = LookupField(member_name); |
| 1729 if (!orig_field.IsNull()) { | 1755 if (!orig_field.IsNull()) { |
| 1730 return FormatPatchError("duplicate field: %s", member_name); | 1756 return FormatPatchError("duplicate field: %s", member_name); |
| 1731 } | 1757 } |
| 1732 new_list.SetAt(i, field); | 1758 new_list.SetAt(i, field); |
| 1733 } | 1759 } |
| 1734 for (intptr_t i = 0; i < orig_len; i++) { | 1760 for (intptr_t i = 0; i < orig_len; i++) { |
| 1735 field ^= orig_list.At(i); | 1761 field |= orig_list.At(i); |
| 1736 new_list.SetAt(patch_len + i, field); | 1762 new_list.SetAt(patch_len + i, field); |
| 1737 } | 1763 } |
| 1738 SetFields(new_list); | 1764 SetFields(new_list); |
| 1739 return NULL; | 1765 return NULL; |
| 1740 } | 1766 } |
| 1741 | 1767 |
| 1742 | 1768 |
| 1743 void Class::SetFields(const Array& value) const { | 1769 void Class::SetFields(const Array& value) const { |
| 1744 ASSERT(!value.IsNull()); | 1770 ASSERT(!value.IsNull()); |
| 1745 #if defined(DEBUG) | 1771 #if defined(DEBUG) |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2264 | 2290 |
| 2265 | 2291 |
| 2266 RawFunction* Class::LookupFunction(const String& name) const { | 2292 RawFunction* Class::LookupFunction(const String& name) const { |
| 2267 Isolate* isolate = Isolate::Current(); | 2293 Isolate* isolate = Isolate::Current(); |
| 2268 ASSERT(name.IsOneByteString()); | 2294 ASSERT(name.IsOneByteString()); |
| 2269 Array& funcs = Array::Handle(isolate, functions()); | 2295 Array& funcs = Array::Handle(isolate, functions()); |
| 2270 if (funcs.IsNull()) { | 2296 if (funcs.IsNull()) { |
| 2271 // This can occur, e.g., for Null classes. | 2297 // This can occur, e.g., for Null classes. |
| 2272 return Function::null(); | 2298 return Function::null(); |
| 2273 } | 2299 } |
| 2300 Function& function = Function::Handle(isolate, Function::null()); | |
| 2274 const intptr_t len = funcs.Length(); | 2301 const intptr_t len = funcs.Length(); |
| 2275 if (name.IsSymbol()) { | 2302 if (name.IsSymbol()) { |
| 2276 // Quick Symbol compare. | 2303 // Quick Symbol compare. |
| 2277 NoGCScope no_gc; | 2304 NoGCScope no_gc; |
| 2278 for (intptr_t i = 0; i < len; i++) { | 2305 for (intptr_t i = 0; i < len; i++) { |
| 2279 RawFunction* raw_func = reinterpret_cast<RawFunction*>(funcs.At(i)); | 2306 function |= funcs.At(i); |
| 2280 if (raw_func->ptr()->name_ == name.raw()) { | 2307 if (function.name() == name.raw()) { |
| 2281 return raw_func; | 2308 return function.raw(); |
| 2282 } | 2309 } |
| 2283 } | 2310 } |
| 2284 } else { | 2311 } else { |
| 2285 Function& function = Function::Handle(isolate, Function::null()); | |
| 2286 String& function_name = String::Handle(isolate, String::null()); | 2312 String& function_name = String::Handle(isolate, String::null()); |
| 2287 for (intptr_t i = 0; i < len; i++) { | 2313 for (intptr_t i = 0; i < len; i++) { |
| 2288 function ^= funcs.At(i); | 2314 function |= funcs.At(i); |
| 2289 function_name ^= function.name(); | 2315 function_name |= function.name(); |
| 2290 if (function_name.Equals(name)) { | 2316 if (function_name.Equals(name)) { |
| 2291 return function.raw(); | 2317 return function.raw(); |
| 2292 } | 2318 } |
| 2293 } | 2319 } |
| 2294 } | 2320 } |
| 2295 // No function found. | 2321 // No function found. |
| 2296 return Function::null(); | 2322 return Function::null(); |
| 2297 } | 2323 } |
| 2298 | 2324 |
| 2299 | 2325 |
| 2300 RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const { | 2326 RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const { |
| 2301 Isolate* isolate = Isolate::Current(); | 2327 Isolate* isolate = Isolate::Current(); |
| 2302 ASSERT(name.IsOneByteString()); | 2328 ASSERT(name.IsOneByteString()); |
| 2303 Array& funcs = Array::Handle(isolate, functions()); | 2329 Array& funcs = Array::Handle(isolate, functions()); |
| 2304 if (funcs.IsNull()) { | 2330 if (funcs.IsNull()) { |
| 2305 // This can occur, e.g., for Null classes. | 2331 // This can occur, e.g., for Null classes. |
| 2306 return Function::null(); | 2332 return Function::null(); |
| 2307 } | 2333 } |
| 2308 Function& function = Function::Handle(isolate, Function::null()); | 2334 Function& function = Function::Handle(isolate, Function::null()); |
| 2309 String& function_name = String::Handle(isolate, String::null()); | 2335 String& function_name = String::Handle(isolate, String::null()); |
| 2310 intptr_t len = funcs.Length(); | 2336 intptr_t len = funcs.Length(); |
| 2311 for (intptr_t i = 0; i < len; i++) { | 2337 for (intptr_t i = 0; i < len; i++) { |
| 2312 function ^= funcs.At(i); | 2338 function |= funcs.At(i); |
| 2313 function_name ^= function.name(); | 2339 function_name |= function.name(); |
| 2314 if (OneByteString::EqualsIgnoringPrivateKey(function_name, name)) { | 2340 if (OneByteString::EqualsIgnoringPrivateKey(function_name, name)) { |
| 2315 return function.raw(); | 2341 return function.raw(); |
| 2316 } | 2342 } |
| 2317 } | 2343 } |
| 2318 // No function found. | 2344 // No function found. |
| 2319 return Function::null(); | 2345 return Function::null(); |
| 2320 } | 2346 } |
| 2321 | 2347 |
| 2322 | 2348 |
| 2323 RawFunction* Class::LookupGetterFunction(const String& name) const { | 2349 RawFunction* Class::LookupGetterFunction(const String& name) const { |
| 2324 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name); | 2350 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name); |
| 2325 } | 2351 } |
| 2326 | 2352 |
| 2327 | 2353 |
| 2328 RawFunction* Class::LookupSetterFunction(const String& name) const { | 2354 RawFunction* Class::LookupSetterFunction(const String& name) const { |
| 2329 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name); | 2355 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name); |
| 2330 } | 2356 } |
| 2331 | 2357 |
| 2332 | 2358 |
| 2333 RawFunction* Class::LookupAccessorFunction(const char* prefix, | 2359 RawFunction* Class::LookupAccessorFunction(const char* prefix, |
| 2334 intptr_t prefix_length, | 2360 intptr_t prefix_length, |
| 2335 const String& name) const { | 2361 const String& name) const { |
| 2336 Isolate* isolate = Isolate::Current(); | 2362 Isolate* isolate = Isolate::Current(); |
| 2337 Array& funcs = Array::Handle(isolate, functions()); | 2363 Array& funcs = Array::Handle(isolate, functions()); |
| 2338 Function& function = Function::Handle(isolate, Function::null()); | 2364 Function& function = Function::Handle(isolate, Function::null()); |
| 2339 String& function_name = String::Handle(isolate, String::null()); | 2365 String& function_name = String::Handle(isolate, String::null()); |
| 2340 intptr_t len = funcs.Length(); | 2366 intptr_t len = funcs.Length(); |
| 2341 for (intptr_t i = 0; i < len; i++) { | 2367 for (intptr_t i = 0; i < len; i++) { |
| 2342 function ^= funcs.At(i); | 2368 function |= funcs.At(i); |
| 2343 function_name ^= function.name(); | 2369 function_name |= function.name(); |
| 2344 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) { | 2370 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) { |
| 2345 return function.raw(); | 2371 return function.raw(); |
| 2346 } | 2372 } |
| 2347 } | 2373 } |
| 2348 | 2374 |
| 2349 // No function found. | 2375 // No function found. |
| 2350 return Function::null(); | 2376 return Function::null(); |
| 2351 } | 2377 } |
| 2352 | 2378 |
| 2353 | 2379 |
| 2354 RawFunction* Class::LookupFunctionAtToken(intptr_t token_pos) const { | 2380 RawFunction* Class::LookupFunctionAtToken(intptr_t token_pos) const { |
| 2355 // TODO(hausner): we can shortcut the negative case if we knew the | 2381 // TODO(hausner): we can shortcut the negative case if we knew the |
| 2356 // beginning and end token position of the class. | 2382 // beginning and end token position of the class. |
| 2357 Function& func = Function::Handle(); | 2383 Function& func = Function::Handle(); |
| 2358 func = LookupClosureFunction(token_pos); | 2384 func = LookupClosureFunction(token_pos); |
| 2359 if (!func.IsNull()) { | 2385 if (!func.IsNull()) { |
| 2360 return func.raw(); | 2386 return func.raw(); |
| 2361 } | 2387 } |
| 2362 Array& funcs = Array::Handle(functions()); | 2388 Array& funcs = Array::Handle(functions()); |
| 2363 intptr_t len = funcs.Length(); | 2389 intptr_t len = funcs.Length(); |
| 2364 for (intptr_t i = 0; i < len; i++) { | 2390 for (intptr_t i = 0; i < len; i++) { |
| 2365 func ^= funcs.At(i); | 2391 func |= funcs.At(i); |
| 2366 if ((func.token_pos() <= token_pos) && | 2392 if ((func.token_pos() <= token_pos) && |
| 2367 (token_pos <= func.end_token_pos())) { | 2393 (token_pos <= func.end_token_pos())) { |
| 2368 return func.raw(); | 2394 return func.raw(); |
| 2369 } | 2395 } |
| 2370 } | 2396 } |
| 2371 // No function found. | 2397 // No function found. |
| 2372 return Function::null(); | 2398 return Function::null(); |
| 2373 } | 2399 } |
| 2374 | 2400 |
| 2375 | 2401 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 2404 | 2430 |
| 2405 | 2431 |
| 2406 RawField* Class::LookupField(const String& name) const { | 2432 RawField* Class::LookupField(const String& name) const { |
| 2407 Isolate* isolate = Isolate::Current(); | 2433 Isolate* isolate = Isolate::Current(); |
| 2408 ASSERT(name.IsOneByteString()); | 2434 ASSERT(name.IsOneByteString()); |
| 2409 const Array& flds = Array::Handle(isolate, fields()); | 2435 const Array& flds = Array::Handle(isolate, fields()); |
| 2410 Field& field = Field::Handle(isolate, Field::null()); | 2436 Field& field = Field::Handle(isolate, Field::null()); |
| 2411 String& field_name = String::Handle(isolate, String::null()); | 2437 String& field_name = String::Handle(isolate, String::null()); |
| 2412 intptr_t len = flds.Length(); | 2438 intptr_t len = flds.Length(); |
| 2413 for (intptr_t i = 0; i < len; i++) { | 2439 for (intptr_t i = 0; i < len; i++) { |
| 2414 field ^= flds.At(i); | 2440 field |= flds.At(i); |
| 2415 field_name ^= field.name(); | 2441 field_name |= field.name(); |
| 2416 if (OneByteString::EqualsIgnoringPrivateKey(field_name, name)) { | 2442 if (OneByteString::EqualsIgnoringPrivateKey(field_name, name)) { |
| 2417 return field.raw(); | 2443 return field.raw(); |
| 2418 } | 2444 } |
| 2419 } | 2445 } |
| 2420 // No field found. | 2446 // No field found. |
| 2421 return Field::null(); | 2447 return Field::null(); |
| 2422 } | 2448 } |
| 2423 | 2449 |
| 2424 | 2450 |
| 2425 RawLibraryPrefix* Class::LookupLibraryPrefix(const String& name) const { | 2451 RawLibraryPrefix* Class::LookupLibraryPrefix(const String& name) const { |
| (...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5549 } | 5575 } |
| 5550 | 5576 |
| 5551 | 5577 |
| 5552 // Lookup a name in the library's export namespace. | 5578 // Lookup a name in the library's export namespace. |
| 5553 RawObject* Library::LookupExport(const String& name) const { | 5579 RawObject* Library::LookupExport(const String& name) const { |
| 5554 if (HasExports()) { | 5580 if (HasExports()) { |
| 5555 const Array& exports = Array::Handle(this->exports()); | 5581 const Array& exports = Array::Handle(this->exports()); |
| 5556 Namespace& ns = Namespace::Handle(); | 5582 Namespace& ns = Namespace::Handle(); |
| 5557 Object& obj = Object::Handle(); | 5583 Object& obj = Object::Handle(); |
| 5558 for (int i = 0; i < exports.Length(); i++) { | 5584 for (int i = 0; i < exports.Length(); i++) { |
| 5559 ns ^= exports.At(i); | 5585 ns |= exports.At(i); |
| 5560 obj = ns.Lookup(name); | 5586 obj = ns.Lookup(name); |
| 5561 if (!obj.IsNull()) { | 5587 if (!obj.IsNull()) { |
| 5562 return obj.raw(); | 5588 return obj.raw(); |
| 5563 } | 5589 } |
| 5564 } | 5590 } |
| 5565 } | 5591 } |
| 5566 return Object::null(); | 5592 return Object::null(); |
| 5567 } | 5593 } |
| 5568 | 5594 |
| 5569 | 5595 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5631 cls = Field::Cast(entry).owner(); | 5657 cls = Field::Cast(entry).owner(); |
| 5632 owner_script = cls.script(); | 5658 owner_script = cls.script(); |
| 5633 } else { | 5659 } else { |
| 5634 continue; | 5660 continue; |
| 5635 } | 5661 } |
| 5636 if (owner_script.IsNull()) { | 5662 if (owner_script.IsNull()) { |
| 5637 continue; | 5663 continue; |
| 5638 } | 5664 } |
| 5639 bool is_unique = true; | 5665 bool is_unique = true; |
| 5640 for (int i = 0; i < scripts.Length(); i++) { | 5666 for (int i = 0; i < scripts.Length(); i++) { |
| 5641 script_obj ^= scripts.At(i); | 5667 script_obj |= scripts.At(i); |
| 5642 if (script_obj.raw() == owner_script.raw()) { | 5668 if (script_obj.raw() == owner_script.raw()) { |
| 5643 // We already have a reference to this script. | 5669 // We already have a reference to this script. |
| 5644 is_unique = false; | 5670 is_unique = false; |
| 5645 break; | 5671 break; |
| 5646 } | 5672 } |
| 5647 } | 5673 } |
| 5648 if (is_unique) { | 5674 if (is_unique) { |
| 5649 // Add script to the list of scripts. | 5675 // Add script to the list of scripts. |
| 5650 scripts.Add(owner_script); | 5676 scripts.Add(owner_script); |
| 5651 } | 5677 } |
| 5652 } | 5678 } |
| 5653 | 5679 |
| 5654 // Create the array of scripts and cache it in loaded_scripts_. | 5680 // Create the array of scripts and cache it in loaded_scripts_. |
| 5655 StorePointer(&raw_ptr()->loaded_scripts_, Array::MakeArray(scripts)); | 5681 StorePointer(&raw_ptr()->loaded_scripts_, Array::MakeArray(scripts)); |
| 5656 } | 5682 } |
| 5657 return loaded_scripts(); | 5683 return loaded_scripts(); |
| 5658 } | 5684 } |
| 5659 | 5685 |
| 5660 | 5686 |
| 5661 // TODO(hausner): we might want to add a script dictionary to the | 5687 // TODO(hausner): we might want to add a script dictionary to the |
| 5662 // library class to make this lookup faster. | 5688 // library class to make this lookup faster. |
| 5663 RawScript* Library::LookupScript(const String& url) const { | 5689 RawScript* Library::LookupScript(const String& url) const { |
| 5664 const Array& scripts = Array::Handle(LoadedScripts()); | 5690 const Array& scripts = Array::Handle(LoadedScripts()); |
| 5665 Script& script = Script::Handle(); | 5691 Script& script = Script::Handle(); |
| 5666 String& script_url = String::Handle(); | 5692 String& script_url = String::Handle(); |
| 5667 intptr_t num_scripts = scripts.Length(); | 5693 intptr_t num_scripts = scripts.Length(); |
| 5668 for (int i = 0; i < num_scripts; i++) { | 5694 for (int i = 0; i < num_scripts; i++) { |
| 5669 script ^= scripts.At(i); | 5695 script |= scripts.At(i); |
| 5670 script_url = script.url(); | 5696 script_url = script.url(); |
| 5671 if (script_url.Equals(url)) { | 5697 if (script_url.Equals(url)) { |
| 5672 return script.raw(); | 5698 return script.raw(); |
| 5673 } | 5699 } |
| 5674 } | 5700 } |
| 5675 return Script::null(); | 5701 return Script::null(); |
| 5676 } | 5702 } |
| 5677 | 5703 |
| 5678 | 5704 |
| 5679 RawFunction* Library::LookupFunctionInSource(const String& script_url, | 5705 RawFunction* Library::LookupFunctionInSource(const String& script_url, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5713 func = cls.LookupFunctionAtToken(token_pos); | 5739 func = cls.LookupFunctionAtToken(token_pos); |
| 5714 if (!func.IsNull()) { | 5740 if (!func.IsNull()) { |
| 5715 return func.raw(); | 5741 return func.raw(); |
| 5716 } | 5742 } |
| 5717 } | 5743 } |
| 5718 } | 5744 } |
| 5719 // Look in anonymous classes for toplevel functions. | 5745 // Look in anonymous classes for toplevel functions. |
| 5720 Array& anon_classes = Array::Handle(this->raw_ptr()->anonymous_classes_); | 5746 Array& anon_classes = Array::Handle(this->raw_ptr()->anonymous_classes_); |
| 5721 intptr_t num_anonymous = raw_ptr()->num_anonymous_; | 5747 intptr_t num_anonymous = raw_ptr()->num_anonymous_; |
| 5722 for (int i = 0; i < num_anonymous; i++) { | 5748 for (int i = 0; i < num_anonymous; i++) { |
| 5723 cls ^= anon_classes.At(i); | 5749 cls |= anon_classes.At(i); |
| 5724 ASSERT(!cls.IsNull()); | 5750 ASSERT(!cls.IsNull()); |
| 5725 if (script.raw() == cls.script()) { | 5751 if (script.raw() == cls.script()) { |
| 5726 func = cls.LookupFunctionAtToken(token_pos); | 5752 func = cls.LookupFunctionAtToken(token_pos); |
| 5727 if (!func.IsNull()) { | 5753 if (!func.IsNull()) { |
| 5728 return func.raw(); | 5754 return func.raw(); |
| 5729 } | 5755 } |
| 5730 } | 5756 } |
| 5731 } | 5757 } |
| 5732 return Function::null(); | 5758 return Function::null(); |
| 5733 } | 5759 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 5762 // Do not look up private names in imported libraries. | 5788 // Do not look up private names in imported libraries. |
| 5763 if (ShouldBePrivate(name)) { | 5789 if (ShouldBePrivate(name)) { |
| 5764 return Field::null(); | 5790 return Field::null(); |
| 5765 } | 5791 } |
| 5766 | 5792 |
| 5767 // Now check if name is found in any imported libs. | 5793 // Now check if name is found in any imported libs. |
| 5768 const Array& imports = Array::Handle(this->imports()); | 5794 const Array& imports = Array::Handle(this->imports()); |
| 5769 Namespace& import = Namespace::Handle(); | 5795 Namespace& import = Namespace::Handle(); |
| 5770 Object& obj = Object::Handle(); | 5796 Object& obj = Object::Handle(); |
| 5771 for (intptr_t j = 0; j < this->num_imports(); j++) { | 5797 for (intptr_t j = 0; j < this->num_imports(); j++) { |
| 5772 import ^= imports.At(j); | 5798 import |= imports.At(j); |
| 5773 obj = import.Lookup(name); | 5799 obj = import.Lookup(name); |
| 5774 if (!obj.IsNull() && obj.IsField()) { | 5800 if (!obj.IsNull() && obj.IsField()) { |
| 5775 field ^= obj.raw(); | 5801 field |= obj.raw(); |
| 5776 return field.raw(); | 5802 return field.raw(); |
| 5777 } | 5803 } |
| 5778 } | 5804 } |
| 5779 return Field::null(); | 5805 return Field::null(); |
| 5780 } | 5806 } |
| 5781 | 5807 |
| 5782 | 5808 |
| 5783 RawField* Library::LookupLocalField(const String& name) const { | 5809 RawField* Library::LookupLocalField(const String& name) const { |
| 5784 Isolate* isolate = Isolate::Current(); | 5810 Isolate* isolate = Isolate::Current(); |
| 5785 Field& field = Field::Handle(isolate, Field::null()); | 5811 Field& field = Field::Handle(isolate, Field::null()); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 5811 // Do not look up private names in imported libraries. | 5837 // Do not look up private names in imported libraries. |
| 5812 if (ShouldBePrivate(name)) { | 5838 if (ShouldBePrivate(name)) { |
| 5813 return Function::null(); | 5839 return Function::null(); |
| 5814 } | 5840 } |
| 5815 | 5841 |
| 5816 // Now check if name is found in any imported libs. | 5842 // Now check if name is found in any imported libs. |
| 5817 const Array& imports = Array::Handle(this->imports()); | 5843 const Array& imports = Array::Handle(this->imports()); |
| 5818 Namespace& import = Namespace::Handle(); | 5844 Namespace& import = Namespace::Handle(); |
| 5819 Object& obj = Object::Handle(); | 5845 Object& obj = Object::Handle(); |
| 5820 for (intptr_t j = 0; j < this->num_imports(); j++) { | 5846 for (intptr_t j = 0; j < this->num_imports(); j++) { |
| 5821 import ^= imports.At(j); | 5847 import |= imports.At(j); |
| 5822 obj = import.Lookup(name); | 5848 obj = import.Lookup(name); |
| 5823 if (!obj.IsNull() && obj.IsFunction()) { | 5849 if (!obj.IsNull() && obj.IsFunction()) { |
| 5824 function ^= obj.raw(); | 5850 function |= obj.raw(); |
| 5825 return function.raw(); | 5851 return function.raw(); |
| 5826 } | 5852 } |
| 5827 } | 5853 } |
| 5828 return Function::null(); | 5854 return Function::null(); |
| 5829 } | 5855 } |
| 5830 | 5856 |
| 5831 | 5857 |
| 5832 RawFunction* Library::LookupLocalFunction(const String& name) const { | 5858 RawFunction* Library::LookupLocalFunction(const String& name) const { |
| 5833 Isolate* isolate = Isolate::Current(); | 5859 Isolate* isolate = Isolate::Current(); |
| 5834 Object& obj = Object::Handle(isolate, Object::null()); | 5860 Object& obj = Object::Handle(isolate, Object::null()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 5849 RawObject* Library::LookupObject(const String& name) const { | 5875 RawObject* Library::LookupObject(const String& name) const { |
| 5850 // First check if name is found in the local scope of the library. | 5876 // First check if name is found in the local scope of the library. |
| 5851 Object& obj = Object::Handle(LookupLocalObject(name)); | 5877 Object& obj = Object::Handle(LookupLocalObject(name)); |
| 5852 if (!obj.IsNull()) { | 5878 if (!obj.IsNull()) { |
| 5853 return obj.raw(); | 5879 return obj.raw(); |
| 5854 } | 5880 } |
| 5855 // Now check if name is found in any imported libs. | 5881 // Now check if name is found in any imported libs. |
| 5856 const Array& imports = Array::Handle(this->imports()); | 5882 const Array& imports = Array::Handle(this->imports()); |
| 5857 Namespace& import = Namespace::Handle(); | 5883 Namespace& import = Namespace::Handle(); |
| 5858 for (intptr_t j = 0; j < this->num_imports(); j++) { | 5884 for (intptr_t j = 0; j < this->num_imports(); j++) { |
| 5859 import ^= imports.At(j); | 5885 import |= imports.At(j); |
| 5860 obj = import.Lookup(name); | 5886 obj = import.Lookup(name); |
| 5861 if (!obj.IsNull()) { | 5887 if (!obj.IsNull()) { |
| 5862 return obj.raw(); | 5888 return obj.raw(); |
| 5863 } | 5889 } |
| 5864 } | 5890 } |
| 5865 return Object::null(); | 5891 return Object::null(); |
| 5866 } | 5892 } |
| 5867 | 5893 |
| 5868 | 5894 |
| 5869 RawClass* Library::LookupClass(const String& name) const { | 5895 RawClass* Library::LookupClass(const String& name) const { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6200 } | 6226 } |
| 6201 | 6227 |
| 6202 | 6228 |
| 6203 RawLibrary* Library::LookupLibrary(const String &url) { | 6229 RawLibrary* Library::LookupLibrary(const String &url) { |
| 6204 Isolate* isolate = Isolate::Current(); | 6230 Isolate* isolate = Isolate::Current(); |
| 6205 Library& lib = Library::Handle(isolate, Library::null()); | 6231 Library& lib = Library::Handle(isolate, Library::null()); |
| 6206 String& lib_url = String::Handle(isolate, String::null()); | 6232 String& lib_url = String::Handle(isolate, String::null()); |
| 6207 GrowableObjectArray& libs = GrowableObjectArray::Handle( | 6233 GrowableObjectArray& libs = GrowableObjectArray::Handle( |
| 6208 isolate, isolate->object_store()->libraries()); | 6234 isolate, isolate->object_store()->libraries()); |
| 6209 for (int i = 0; i < libs.Length(); i++) { | 6235 for (int i = 0; i < libs.Length(); i++) { |
| 6210 lib ^= libs.At(i); | 6236 lib |= libs.At(i); |
| 6211 lib_url = lib.url(); | 6237 lib_url = lib.url(); |
| 6212 if (lib_url.Equals(url)) { | 6238 if (lib_url.Equals(url)) { |
| 6213 return lib.raw(); | 6239 return lib.raw(); |
| 6214 } | 6240 } |
| 6215 } | 6241 } |
| 6216 return Library::null(); | 6242 return Library::null(); |
| 6217 } | 6243 } |
| 6218 | 6244 |
| 6219 | 6245 |
| 6220 RawError* Library::Patch(const Script& script) const { | 6246 RawError* Library::Patch(const Script& script) const { |
| 6221 ASSERT(script.kind() == RawScript::kPatchTag); | 6247 ASSERT(script.kind() == RawScript::kPatchTag); |
| 6222 return Compiler::Compile(*this, script); | 6248 return Compiler::Compile(*this, script); |
| 6223 } | 6249 } |
| 6224 | 6250 |
| 6225 | 6251 |
| 6226 bool Library::IsKeyUsed(intptr_t key) { | 6252 bool Library::IsKeyUsed(intptr_t key) { |
| 6227 intptr_t lib_key; | 6253 intptr_t lib_key; |
| 6228 const GrowableObjectArray& libs = GrowableObjectArray::Handle( | 6254 const GrowableObjectArray& libs = GrowableObjectArray::Handle( |
| 6229 Isolate::Current()->object_store()->libraries()); | 6255 Isolate::Current()->object_store()->libraries()); |
| 6230 Library& lib = Library::Handle(); | 6256 Library& lib = Library::Handle(); |
| 6231 String& lib_url = String::Handle(); | 6257 String& lib_url = String::Handle(); |
| 6232 for (int i = 0; i < libs.Length(); i++) { | 6258 for (int i = 0; i < libs.Length(); i++) { |
| 6233 lib ^= libs.At(i); | 6259 lib |= libs.At(i); |
| 6234 lib_url ^= lib.url(); | 6260 lib_url |= lib.url(); |
| 6235 lib_key = lib_url.Hash(); | 6261 lib_key = lib_url.Hash(); |
| 6236 if (lib_key == key) { | 6262 if (lib_key == key) { |
| 6237 return true; | 6263 return true; |
| 6238 } | 6264 } |
| 6239 } | 6265 } |
| 6240 return false; | 6266 return false; |
| 6241 } | 6267 } |
| 6242 | 6268 |
| 6243 | 6269 |
| 6244 static bool IsPrivate(const String& name) { | 6270 static bool IsPrivate(const String& name) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6388 imports.SetAt(num_current_imports, import); | 6414 imports.SetAt(num_current_imports, import); |
| 6389 set_num_imports(num_current_imports + 1); | 6415 set_num_imports(num_current_imports + 1); |
| 6390 } | 6416 } |
| 6391 | 6417 |
| 6392 | 6418 |
| 6393 RawClass* LibraryPrefix::LookupLocalClass(const String& class_name) const { | 6419 RawClass* LibraryPrefix::LookupLocalClass(const String& class_name) const { |
| 6394 Array& imports = Array::Handle(this->imports()); | 6420 Array& imports = Array::Handle(this->imports()); |
| 6395 Object& obj = Object::Handle(); | 6421 Object& obj = Object::Handle(); |
| 6396 Namespace& import = Namespace::Handle(); | 6422 Namespace& import = Namespace::Handle(); |
| 6397 for (intptr_t i = 0; i < num_imports(); i++) { | 6423 for (intptr_t i = 0; i < num_imports(); i++) { |
| 6398 import ^= imports.At(i); | 6424 import |= imports.At(i); |
| 6399 obj = import.Lookup(class_name); | 6425 obj = import.Lookup(class_name); |
| 6400 if (!obj.IsNull() && obj.IsClass()) { | 6426 if (!obj.IsNull() && obj.IsClass()) { |
| 6401 // TODO(hausner): | 6427 // TODO(hausner): |
| 6402 return Class::Cast(obj).raw(); | 6428 return Class::Cast(obj).raw(); |
| 6403 } | 6429 } |
| 6404 } | 6430 } |
| 6405 return Class::null(); | 6431 return Class::null(); |
| 6406 } | 6432 } |
| 6407 | 6433 |
| 6408 | 6434 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6462 } | 6488 } |
| 6463 | 6489 |
| 6464 | 6490 |
| 6465 bool Namespace::HidesName(const String& name) const { | 6491 bool Namespace::HidesName(const String& name) const { |
| 6466 // Check whether the name is in the list of explicitly hidden names. | 6492 // Check whether the name is in the list of explicitly hidden names. |
| 6467 if (hide_names() != Array::null()) { | 6493 if (hide_names() != Array::null()) { |
| 6468 const Array& names = Array::Handle(hide_names()); | 6494 const Array& names = Array::Handle(hide_names()); |
| 6469 String& hidden = String::Handle(); | 6495 String& hidden = String::Handle(); |
| 6470 intptr_t num_names = names.Length(); | 6496 intptr_t num_names = names.Length(); |
| 6471 for (intptr_t i = 0; i < num_names; i++) { | 6497 for (intptr_t i = 0; i < num_names; i++) { |
| 6472 hidden ^= names.At(i); | 6498 hidden |= names.At(i); |
| 6473 if (name.Equals(hidden)) { | 6499 if (name.Equals(hidden)) { |
| 6474 return true; | 6500 return true; |
| 6475 } | 6501 } |
| 6476 } | 6502 } |
| 6477 } | 6503 } |
| 6478 // The name is not explicitly hidden. Now check whether it is in the | 6504 // The name is not explicitly hidden. Now check whether it is in the |
| 6479 // list of explicitly visible names, if there is one. | 6505 // list of explicitly visible names, if there is one. |
| 6480 if (show_names() != Array::null()) { | 6506 if (show_names() != Array::null()) { |
| 6481 const Array& names = Array::Handle(show_names()); | 6507 const Array& names = Array::Handle(show_names()); |
| 6482 String& shown = String::Handle(); | 6508 String& shown = String::Handle(); |
| 6483 intptr_t num_names = names.Length(); | 6509 intptr_t num_names = names.Length(); |
| 6484 for (intptr_t i = 0; i < num_names; i++) { | 6510 for (intptr_t i = 0; i < num_names; i++) { |
| 6485 shown ^= names.At(i); | 6511 shown |= names.At(i); |
| 6486 if (name.Equals(shown)) { | 6512 if (name.Equals(shown)) { |
| 6487 return false; | 6513 return false; |
| 6488 } | 6514 } |
| 6489 } | 6515 } |
| 6490 // There is a list of visible names. The name we're looking for is not | 6516 // There is a list of visible names. The name we're looking for is not |
| 6491 // contained in the list, so it is hidden. | 6517 // contained in the list, so it is hidden. |
| 6492 return true; | 6518 return true; |
| 6493 } | 6519 } |
| 6494 // The name is not filtered out. | 6520 // The name is not filtered out. |
| 6495 return false; | 6521 return false; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6534 } | 6560 } |
| 6535 | 6561 |
| 6536 | 6562 |
| 6537 RawError* Library::CompileAll() { | 6563 RawError* Library::CompileAll() { |
| 6538 Error& error = Error::Handle(); | 6564 Error& error = Error::Handle(); |
| 6539 const GrowableObjectArray& libs = GrowableObjectArray::Handle( | 6565 const GrowableObjectArray& libs = GrowableObjectArray::Handle( |
| 6540 Isolate::Current()->object_store()->libraries()); | 6566 Isolate::Current()->object_store()->libraries()); |
| 6541 Library& lib = Library::Handle(); | 6567 Library& lib = Library::Handle(); |
| 6542 Class& cls = Class::Handle(); | 6568 Class& cls = Class::Handle(); |
| 6543 for (int i = 0; i < libs.Length(); i++) { | 6569 for (int i = 0; i < libs.Length(); i++) { |
| 6544 lib ^= libs.At(i); | 6570 lib |= libs.At(i); |
| 6545 ClassDictionaryIterator it(lib); | 6571 ClassDictionaryIterator it(lib); |
| 6546 while (it.HasNext()) { | 6572 while (it.HasNext()) { |
| 6547 cls ^= it.GetNextClass(); | 6573 cls |= it.GetNextClass(); |
| 6548 error = Compiler::CompileAllFunctions(cls); | 6574 error = Compiler::CompileAllFunctions(cls); |
| 6549 if (!error.IsNull()) { | 6575 if (!error.IsNull()) { |
| 6550 return error.raw(); | 6576 return error.raw(); |
| 6551 } | 6577 } |
| 6552 } | 6578 } |
| 6553 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); | 6579 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); |
| 6554 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { | 6580 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { |
| 6555 cls ^= anon_classes.At(i); | 6581 cls |= anon_classes.At(i); |
| 6556 error = Compiler::CompileAllFunctions(cls); | 6582 error = Compiler::CompileAllFunctions(cls); |
| 6557 if (!error.IsNull()) { | 6583 if (!error.IsNull()) { |
| 6558 return error.raw(); | 6584 return error.raw(); |
| 6559 } | 6585 } |
| 6560 } | 6586 } |
| 6561 } | 6587 } |
| 6562 return error.raw(); | 6588 return error.raw(); |
| 6563 } | 6589 } |
| 6564 | 6590 |
| 6565 | 6591 |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7287 | 7313 |
| 7288 | 7314 |
| 7289 RawFunction* Code::GetStaticCallTargetFunctionAt(uword pc) const { | 7315 RawFunction* Code::GetStaticCallTargetFunctionAt(uword pc) const { |
| 7290 RawObject* raw_code_offset = | 7316 RawObject* raw_code_offset = |
| 7291 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); | 7317 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); |
| 7292 const Array& array = | 7318 const Array& array = |
| 7293 Array::Handle(raw_ptr()->static_calls_target_table_); | 7319 Array::Handle(raw_ptr()->static_calls_target_table_); |
| 7294 for (intptr_t i = 0; i < array.Length(); i += kSCallTableEntryLength) { | 7320 for (intptr_t i = 0; i < array.Length(); i += kSCallTableEntryLength) { |
| 7295 if (array.At(i) == raw_code_offset) { | 7321 if (array.At(i) == raw_code_offset) { |
| 7296 Function& function = Function::Handle(); | 7322 Function& function = Function::Handle(); |
| 7297 function ^= array.At(i + kSCallTableFunctionEntry); | 7323 function |= array.At(i + kSCallTableFunctionEntry); |
| 7298 return function.raw(); | 7324 return function.raw(); |
| 7299 } | 7325 } |
| 7300 } | 7326 } |
| 7301 return Function::null(); | 7327 return Function::null(); |
| 7302 } | 7328 } |
| 7303 | 7329 |
| 7304 | 7330 |
| 7305 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { | 7331 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { |
| 7306 RawObject* raw_code_offset = | 7332 RawObject* raw_code_offset = |
| 7307 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); | 7333 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); |
| (...skipping 5287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12595 } | 12621 } |
| 12596 return result.raw(); | 12622 return result.raw(); |
| 12597 } | 12623 } |
| 12598 | 12624 |
| 12599 | 12625 |
| 12600 const char* WeakProperty::ToCString() const { | 12626 const char* WeakProperty::ToCString() const { |
| 12601 return "_WeakProperty"; | 12627 return "_WeakProperty"; |
| 12602 } | 12628 } |
| 12603 | 12629 |
| 12604 } // namespace dart | 12630 } // namespace dart |
| OLD | NEW |