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

Side by Side Diff: vm/object.cc

Issue 12052033: Added macros OBJECT_IMPLEMENTATION and FINAL_OBJECT_IMPLEMENTATION (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/object.h ('k') | vm/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // TODO(iposva): NoGCScope needs to be added here. 237 // TODO(iposva): NoGCScope needs to be added here.
238 ASSERT(class_class() == null_); 238 ASSERT(class_class() == null_);
239 // Initialize the static vtable values. 239 // Initialize the static vtable values.
240 { 240 {
241 Object fake_object; 241 Object fake_object;
242 Smi fake_smi; 242 Smi fake_smi;
243 Object::handle_vtable_ = fake_object.vtable(); 243 Object::handle_vtable_ = fake_object.vtable();
244 Smi::handle_vtable_ = fake_smi.vtable(); 244 Smi::handle_vtable_ = fake_smi.vtable();
245 } 245 }
246 246
247 // Allocate the read only object handles here.
248 empty_array_ = reinterpret_cast<Array*>(Dart::AllocateReadOnlyHandle());
249 sentinel_ = reinterpret_cast<Instance*>(Dart::AllocateReadOnlyHandle());
250 transition_sentinel_ =
251 reinterpret_cast<Instance*>(Dart::AllocateReadOnlyHandle());
252 bool_true_ = reinterpret_cast<Bool*>(Dart::AllocateReadOnlyHandle());
253 bool_false_ = reinterpret_cast<Bool*>(Dart::AllocateReadOnlyHandle());
254
255 Isolate* isolate = Isolate::Current(); 247 Isolate* isolate = Isolate::Current();
256 Heap* heap = isolate->heap(); 248 Heap* heap = isolate->heap();
249
250 // Allocate the read only object handles here.
251 empty_array_ = Array::ReadOnlyHandle(isolate);
252 sentinel_ = Instance::ReadOnlyHandle(isolate);
253 transition_sentinel_ = Instance::ReadOnlyHandle(isolate);
254 bool_true_ = Bool::ReadOnlyHandle(isolate);
255 bool_false_ = Bool::ReadOnlyHandle(isolate);
256
257 // Allocate and initialize the null instance. 257 // Allocate and initialize the null instance.
258 // 'null_' must be the first object allocated as it is used in allocation to 258 // 'null_' must be the first object allocated as it is used in allocation to
259 // clear the object. 259 // clear the object.
260 { 260 {
261 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); 261 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld);
262 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); 262 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag);
263 // The call below is using 'null_' to initialize itself. 263 // The call below is using 'null_' to initialize itself.
264 InitializeObject(address, kNullCid, Instance::InstanceSize()); 264 InitializeObject(address, kNullCid, Instance::InstanceSize());
265 } 265 }
266 266
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw()); 1443 StorePointer(&raw_ptr()->canonical_types_, Object::empty_array().raw());
1444 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw()); 1444 StorePointer(&raw_ptr()->functions_, Object::empty_array().raw());
1445 StorePointer(&raw_ptr()->fields_, Object::empty_array().raw()); 1445 StorePointer(&raw_ptr()->fields_, Object::empty_array().raw());
1446 } 1446 }
1447 1447
1448 1448
1449 bool Class::HasInstanceFields() const { 1449 bool Class::HasInstanceFields() const {
1450 const Array& field_array = Array::Handle(fields()); 1450 const Array& field_array = Array::Handle(fields());
1451 Field& field = Field::Handle(); 1451 Field& field = Field::Handle();
1452 for (intptr_t i = 0; i < field_array.Length(); ++i) { 1452 for (intptr_t i = 0; i < field_array.Length(); ++i) {
1453 field |= field_array.At(i); 1453 field ^= field_array.At(i);
1454 if (!field.is_static()) { 1454 if (!field.is_static()) {
1455 return true; 1455 return true;
1456 } 1456 }
1457 } 1457 }
1458 return false; 1458 return false;
1459 } 1459 }
1460 1460
1461 1461
1462 void Class::SetFunctions(const Array& value) const { 1462 void Class::SetFunctions(const Array& value) const {
1463 ASSERT(!value.IsNull()); 1463 ASSERT(!value.IsNull());
1464 #if defined(DEBUG) 1464 #if defined(DEBUG)
1465 // Verify that all the functions in the array have this class as owner. 1465 // Verify that all the functions in the array have this class as owner.
1466 Function& func = Function::Handle(); 1466 Function& func = Function::Handle();
1467 intptr_t len = value.Length(); 1467 intptr_t len = value.Length();
1468 for (intptr_t i = 0; i < len; i++) { 1468 for (intptr_t i = 0; i < len; i++) {
1469 func |= value.At(i); 1469 func ^= value.At(i);
1470 ASSERT(func.Owner() == raw()); 1470 ASSERT(func.Owner() == raw());
1471 } 1471 }
1472 #endif 1472 #endif
1473 StorePointer(&raw_ptr()->functions_, value.raw()); 1473 StorePointer(&raw_ptr()->functions_, value.raw());
1474 } 1474 }
1475 1475
1476 1476
1477 void Class::AddFunction(const Function& function) const { 1477 void Class::AddFunction(const Function& function) const {
1478 const Array& arr = Array::Handle(functions()); 1478 const Array& arr = Array::Handle(functions());
1479 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1)); 1479 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1));
(...skipping 19 matching lines...) Expand all
1499 if (raw_ptr()->closure_functions_ == GrowableObjectArray::null()) { 1499 if (raw_ptr()->closure_functions_ == GrowableObjectArray::null()) {
1500 return Function::null(); 1500 return Function::null();
1501 } 1501 }
1502 const GrowableObjectArray& closures = 1502 const GrowableObjectArray& closures =
1503 GrowableObjectArray::Handle(raw_ptr()->closure_functions_); 1503 GrowableObjectArray::Handle(raw_ptr()->closure_functions_);
1504 Function& closure = Function::Handle(); 1504 Function& closure = Function::Handle();
1505 intptr_t num_closures = closures.Length(); 1505 intptr_t num_closures = closures.Length();
1506 intptr_t best_fit_token_pos = -1; 1506 intptr_t best_fit_token_pos = -1;
1507 intptr_t best_fit_index = -1; 1507 intptr_t best_fit_index = -1;
1508 for (intptr_t i = 0; i < num_closures; i++) { 1508 for (intptr_t i = 0; i < num_closures; i++) {
1509 closure |= closures.At(i); 1509 closure ^= closures.At(i);
1510 ASSERT(!closure.IsNull()); 1510 ASSERT(!closure.IsNull());
1511 if ((closure.token_pos() <= token_pos) && 1511 if ((closure.token_pos() <= token_pos) &&
1512 (token_pos < closure.end_token_pos()) && 1512 (token_pos < closure.end_token_pos()) &&
1513 (best_fit_token_pos < closure.token_pos())) { 1513 (best_fit_token_pos < closure.token_pos())) {
1514 best_fit_index = i; 1514 best_fit_index = i;
1515 best_fit_token_pos = closure.token_pos(); 1515 best_fit_token_pos = closure.token_pos();
1516 } 1516 }
1517 } 1517 }
1518 closure = Function::null(); 1518 closure = Function::null();
1519 if (best_fit_index >= 0) { 1519 if (best_fit_index >= 0) {
1520 closure |= closures.At(best_fit_index); 1520 closure ^= closures.At(best_fit_index);
1521 } 1521 }
1522 return closure.raw(); 1522 return closure.raw();
1523 } 1523 }
1524 1524
1525 1525
1526 void Class::set_signature_function(const Function& value) const { 1526 void Class::set_signature_function(const Function& value) const {
1527 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction()); 1527 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction());
1528 StorePointer(&raw_ptr()->signature_function_, value.raw()); 1528 StorePointer(&raw_ptr()->signature_function_, value.raw());
1529 } 1529 }
1530 1530
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 // The instance needs a type_arguments field. 1667 // The instance needs a type_arguments field.
1668 type_args_field_offset = offset; 1668 type_args_field_offset = offset;
1669 offset += kWordSize; 1669 offset += kWordSize;
1670 } 1670 }
1671 } 1671 }
1672 set_type_arguments_field_offset(type_args_field_offset); 1672 set_type_arguments_field_offset(type_args_field_offset);
1673 ASSERT(offset != 0); 1673 ASSERT(offset != 0);
1674 Field& field = Field::Handle(); 1674 Field& field = Field::Handle();
1675 intptr_t len = flds.Length(); 1675 intptr_t len = flds.Length();
1676 for (intptr_t i = 0; i < len; i++) { 1676 for (intptr_t i = 0; i < len; i++) {
1677 field |= flds.At(i); 1677 field ^= flds.At(i);
1678 // Offset is computed only for instance fields. 1678 // Offset is computed only for instance fields.
1679 if (!field.is_static()) { 1679 if (!field.is_static()) {
1680 ASSERT(field.Offset() == 0); 1680 ASSERT(field.Offset() == 0);
1681 field.SetOffset(offset); 1681 field.SetOffset(offset);
1682 offset += kWordSize; 1682 offset += kWordSize;
1683 } 1683 }
1684 } 1684 }
1685 set_instance_size(RoundedAllocationSize(offset)); 1685 set_instance_size(RoundedAllocationSize(offset));
1686 set_next_field_offset(offset); 1686 set_next_field_offset(offset);
1687 } 1687 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 Array& patch_list = Array::Handle(patch.functions()); 1723 Array& patch_list = Array::Handle(patch.functions());
1724 intptr_t patch_len = patch_list.Length(); 1724 intptr_t patch_len = patch_list.Length();
1725 1725
1726 // TODO(iposva): Verify that only patching existing methods and adding only 1726 // TODO(iposva): Verify that only patching existing methods and adding only
1727 // new private methods. 1727 // new private methods.
1728 Function& func = Function::Handle(); 1728 Function& func = Function::Handle();
1729 Function& orig_func = Function::Handle(); 1729 Function& orig_func = Function::Handle();
1730 const GrowableObjectArray& new_functions = GrowableObjectArray::Handle( 1730 const GrowableObjectArray& new_functions = GrowableObjectArray::Handle(
1731 GrowableObjectArray::New(orig_len)); 1731 GrowableObjectArray::New(orig_len));
1732 for (intptr_t i = 0; i < orig_len; i++) { 1732 for (intptr_t i = 0; i < orig_len; i++) {
1733 orig_func |= orig_list.At(i); 1733 orig_func ^= orig_list.At(i);
1734 member_name = orig_func.name(); 1734 member_name ^= orig_func.name();
1735 func = patch.LookupFunction(member_name); 1735 func = patch.LookupFunction(member_name);
1736 if (func.IsNull()) { 1736 if (func.IsNull()) {
1737 // Non-patched function is preserved, all patched functions are added in 1737 // Non-patched function is preserved, all patched functions are added in
1738 // the loop below. 1738 // the loop below.
1739 new_functions.Add(orig_func); 1739 new_functions.Add(orig_func);
1740 } else if (!func.HasCompatibleParametersWith(orig_func) && 1740 } else if (!func.HasCompatibleParametersWith(orig_func) &&
1741 !(func.IsFactory() && orig_func.IsConstructor() && 1741 !(func.IsFactory() && orig_func.IsConstructor() &&
1742 (func.num_fixed_parameters() + 1 == 1742 (func.num_fixed_parameters() + 1 ==
1743 orig_func.num_fixed_parameters()))) { 1743 orig_func.num_fixed_parameters()))) {
1744 return FormatPatchError("mismatched parameters: %s", member_name); 1744 return FormatPatchError("mismatched parameters: %s", member_name);
1745 } 1745 }
1746 } 1746 }
1747 for (intptr_t i = 0; i < patch_len; i++) { 1747 for (intptr_t i = 0; i < patch_len; i++) {
1748 func |= patch_list.At(i); 1748 func ^= patch_list.At(i);
1749 func.set_owner(patch_class); 1749 func.set_owner(patch_class);
1750 new_functions.Add(func); 1750 new_functions.Add(func);
1751 } 1751 }
1752 Array& new_list = Array::Handle(Array::MakeArray(new_functions)); 1752 Array& new_list = Array::Handle(Array::MakeArray(new_functions));
1753 SetFunctions(new_list); 1753 SetFunctions(new_list);
1754 1754
1755 // Merge the two list of fields. Raise an error when duplicates are found or 1755 // Merge the two list of fields. Raise an error when duplicates are found or
1756 // when a public field is being added. 1756 // when a public field is being added.
1757 orig_list = fields(); 1757 orig_list = fields();
1758 orig_len = orig_list.Length(); 1758 orig_len = orig_list.Length();
1759 patch_list = patch.fields(); 1759 patch_list = patch.fields();
1760 patch_len = patch_list.Length(); 1760 patch_len = patch_list.Length();
1761 1761
1762 Field& field = Field::Handle(); 1762 Field& field = Field::Handle();
1763 Field& orig_field = Field::Handle(); 1763 Field& orig_field = Field::Handle();
1764 new_list = Array::New(patch_len + orig_len); 1764 new_list = Array::New(patch_len + orig_len);
1765 for (intptr_t i = 0; i < patch_len; i++) { 1765 for (intptr_t i = 0; i < patch_len; i++) {
1766 field |= patch_list.At(i); 1766 field ^= patch_list.At(i);
1767 field.set_owner(*this); 1767 field.set_owner(*this);
1768 member_name = field.name(); 1768 member_name = field.name();
1769 // TODO(iposva): Verify non-public fields only. 1769 // TODO(iposva): Verify non-public fields only.
1770 1770
1771 // Verify no duplicate additions. 1771 // Verify no duplicate additions.
1772 orig_field = LookupField(member_name); 1772 orig_field ^= LookupField(member_name);
1773 if (!orig_field.IsNull()) { 1773 if (!orig_field.IsNull()) {
1774 return FormatPatchError("duplicate field: %s", member_name); 1774 return FormatPatchError("duplicate field: %s", member_name);
1775 } 1775 }
1776 new_list.SetAt(i, field); 1776 new_list.SetAt(i, field);
1777 } 1777 }
1778 for (intptr_t i = 0; i < orig_len; i++) { 1778 for (intptr_t i = 0; i < orig_len; i++) {
1779 field |= orig_list.At(i); 1779 field ^= orig_list.At(i);
1780 new_list.SetAt(patch_len + i, field); 1780 new_list.SetAt(patch_len + i, field);
1781 } 1781 }
1782 SetFields(new_list); 1782 SetFields(new_list);
1783 return NULL; 1783 return NULL;
1784 } 1784 }
1785 1785
1786 1786
1787 void Class::SetFields(const Array& value) const { 1787 void Class::SetFields(const Array& value) const {
1788 ASSERT(!value.IsNull()); 1788 ASSERT(!value.IsNull());
1789 #if defined(DEBUG) 1789 #if defined(DEBUG)
1790 // Verify that all the fields in the array have this class as owner. 1790 // Verify that all the fields in the array have this class as owner.
1791 Field& field = Field::Handle(); 1791 Field& field = Field::Handle();
1792 intptr_t len = value.Length(); 1792 intptr_t len = value.Length();
1793 for (intptr_t i = 0; i < len; i++) { 1793 for (intptr_t i = 0; i < len; i++) {
1794 field |= value.At(i); 1794 field ^= value.At(i);
1795 ASSERT(field.owner() == raw()); 1795 ASSERT(field.owner() == raw());
1796 } 1796 }
1797 #endif 1797 #endif
1798 // The value of static fields is already initialized to null. 1798 // The value of static fields is already initialized to null.
1799 StorePointer(&raw_ptr()->fields_, value.raw()); 1799 StorePointer(&raw_ptr()->fields_, value.raw());
1800 } 1800 }
1801 1801
1802 1802
1803 template <class FakeInstance> 1803 template <class FakeInstance>
1804 RawClass* Class::New(intptr_t index) { 1804 RawClass* Class::New(intptr_t index) {
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 if (funcs.IsNull()) { 2315 if (funcs.IsNull()) {
2316 // This can occur, e.g., for Null classes. 2316 // This can occur, e.g., for Null classes.
2317 return Function::null(); 2317 return Function::null();
2318 } 2318 }
2319 Function& function = Function::Handle(isolate, Function::null()); 2319 Function& function = Function::Handle(isolate, Function::null());
2320 const intptr_t len = funcs.Length(); 2320 const intptr_t len = funcs.Length();
2321 if (name.IsSymbol()) { 2321 if (name.IsSymbol()) {
2322 // Quick Symbol compare. 2322 // Quick Symbol compare.
2323 NoGCScope no_gc; 2323 NoGCScope no_gc;
2324 for (intptr_t i = 0; i < len; i++) { 2324 for (intptr_t i = 0; i < len; i++) {
2325 function |= funcs.At(i); 2325 function ^= funcs.At(i);
2326 if (function.name() == name.raw()) { 2326 if (function.name() == name.raw()) {
2327 return function.raw(); 2327 return function.raw();
2328 } 2328 }
2329 } 2329 }
2330 } else { 2330 } else {
2331 String& function_name = String::Handle(isolate, String::null()); 2331 String& function_name = String::Handle(isolate, String::null());
2332 for (intptr_t i = 0; i < len; i++) { 2332 for (intptr_t i = 0; i < len; i++) {
2333 function |= funcs.At(i); 2333 function ^= funcs.At(i);
2334 function_name |= function.name(); 2334 function_name ^= function.name();
2335 if (function_name.Equals(name)) { 2335 if (function_name.Equals(name)) {
2336 return function.raw(); 2336 return function.raw();
2337 } 2337 }
2338 } 2338 }
2339 } 2339 }
2340 // No function found. 2340 // No function found.
2341 return Function::null(); 2341 return Function::null();
2342 } 2342 }
2343 2343
2344 2344
2345 RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const { 2345 RawFunction* Class::LookupFunctionAllowPrivate(const String& name) const {
2346 Isolate* isolate = Isolate::Current(); 2346 Isolate* isolate = Isolate::Current();
2347 ASSERT(name.IsOneByteString()); 2347 ASSERT(name.IsOneByteString());
2348 Array& funcs = Array::Handle(isolate, functions()); 2348 Array& funcs = Array::Handle(isolate, functions());
2349 if (funcs.IsNull()) { 2349 if (funcs.IsNull()) {
2350 // This can occur, e.g., for Null classes. 2350 // This can occur, e.g., for Null classes.
2351 return Function::null(); 2351 return Function::null();
2352 } 2352 }
2353 Function& function = Function::Handle(isolate, Function::null()); 2353 Function& function = Function::Handle(isolate, Function::null());
2354 String& function_name = String::Handle(isolate, String::null()); 2354 String& function_name = String::Handle(isolate, String::null());
2355 intptr_t len = funcs.Length(); 2355 intptr_t len = funcs.Length();
2356 for (intptr_t i = 0; i < len; i++) { 2356 for (intptr_t i = 0; i < len; i++) {
2357 function |= funcs.At(i); 2357 function ^= funcs.At(i);
2358 function_name |= function.name(); 2358 function_name ^= function.name();
2359 if (OneByteString::EqualsIgnoringPrivateKey(function_name, name)) { 2359 if (OneByteString::EqualsIgnoringPrivateKey(function_name, name)) {
2360 return function.raw(); 2360 return function.raw();
2361 } 2361 }
2362 } 2362 }
2363 // No function found. 2363 // No function found.
2364 return Function::null(); 2364 return Function::null();
2365 } 2365 }
2366 2366
2367 2367
2368 RawFunction* Class::LookupGetterFunction(const String& name) const { 2368 RawFunction* Class::LookupGetterFunction(const String& name) const {
2369 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name); 2369 return LookupAccessorFunction(kGetterPrefix, kGetterPrefixLength, name);
2370 } 2370 }
2371 2371
2372 2372
2373 RawFunction* Class::LookupSetterFunction(const String& name) const { 2373 RawFunction* Class::LookupSetterFunction(const String& name) const {
2374 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name); 2374 return LookupAccessorFunction(kSetterPrefix, kSetterPrefixLength, name);
2375 } 2375 }
2376 2376
2377 2377
2378 RawFunction* Class::LookupAccessorFunction(const char* prefix, 2378 RawFunction* Class::LookupAccessorFunction(const char* prefix,
2379 intptr_t prefix_length, 2379 intptr_t prefix_length,
2380 const String& name) const { 2380 const String& name) const {
2381 Isolate* isolate = Isolate::Current(); 2381 Isolate* isolate = Isolate::Current();
2382 Array& funcs = Array::Handle(isolate, functions()); 2382 Array& funcs = Array::Handle(isolate, functions());
2383 Function& function = Function::Handle(isolate, Function::null()); 2383 Function& function = Function::Handle(isolate, Function::null());
2384 String& function_name = String::Handle(isolate, String::null()); 2384 String& function_name = String::Handle(isolate, String::null());
2385 intptr_t len = funcs.Length(); 2385 intptr_t len = funcs.Length();
2386 for (intptr_t i = 0; i < len; i++) { 2386 for (intptr_t i = 0; i < len; i++) {
2387 function |= funcs.At(i); 2387 function ^= funcs.At(i);
2388 function_name |= function.name(); 2388 function_name ^= function.name();
2389 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) { 2389 if (MatchesAccessorName(function_name, prefix, prefix_length, name)) {
2390 return function.raw(); 2390 return function.raw();
2391 } 2391 }
2392 } 2392 }
2393 2393
2394 // No function found. 2394 // No function found.
2395 return Function::null(); 2395 return Function::null();
2396 } 2396 }
2397 2397
2398 2398
2399 RawFunction* Class::LookupFunctionAtToken(intptr_t token_pos) const { 2399 RawFunction* Class::LookupFunctionAtToken(intptr_t token_pos) const {
2400 // TODO(hausner): we can shortcut the negative case if we knew the 2400 // TODO(hausner): we can shortcut the negative case if we knew the
2401 // beginning and end token position of the class. 2401 // beginning and end token position of the class.
2402 Function& func = Function::Handle(); 2402 Function& func = Function::Handle();
2403 func = LookupClosureFunction(token_pos); 2403 func = LookupClosureFunction(token_pos);
2404 if (!func.IsNull()) { 2404 if (!func.IsNull()) {
2405 return func.raw(); 2405 return func.raw();
2406 } 2406 }
2407 Array& funcs = Array::Handle(functions()); 2407 Array& funcs = Array::Handle(functions());
2408 intptr_t len = funcs.Length(); 2408 intptr_t len = funcs.Length();
2409 for (intptr_t i = 0; i < len; i++) { 2409 for (intptr_t i = 0; i < len; i++) {
2410 func |= funcs.At(i); 2410 func ^= funcs.At(i);
2411 if ((func.token_pos() <= token_pos) && 2411 if ((func.token_pos() <= token_pos) &&
2412 (token_pos <= func.end_token_pos())) { 2412 (token_pos <= func.end_token_pos())) {
2413 return func.raw(); 2413 return func.raw();
2414 } 2414 }
2415 } 2415 }
2416 // No function found. 2416 // No function found.
2417 return Function::null(); 2417 return Function::null();
2418 } 2418 }
2419 2419
2420 2420
(...skipping 28 matching lines...) Expand all
2449 2449
2450 2450
2451 RawField* Class::LookupField(const String& name) const { 2451 RawField* Class::LookupField(const String& name) const {
2452 Isolate* isolate = Isolate::Current(); 2452 Isolate* isolate = Isolate::Current();
2453 ASSERT(name.IsOneByteString()); 2453 ASSERT(name.IsOneByteString());
2454 const Array& flds = Array::Handle(isolate, fields()); 2454 const Array& flds = Array::Handle(isolate, fields());
2455 Field& field = Field::Handle(isolate, Field::null()); 2455 Field& field = Field::Handle(isolate, Field::null());
2456 String& field_name = String::Handle(isolate, String::null()); 2456 String& field_name = String::Handle(isolate, String::null());
2457 intptr_t len = flds.Length(); 2457 intptr_t len = flds.Length();
2458 for (intptr_t i = 0; i < len; i++) { 2458 for (intptr_t i = 0; i < len; i++) {
2459 field |= flds.At(i); 2459 field ^= flds.At(i);
2460 field_name |= field.name(); 2460 field_name ^= field.name();
2461 if (OneByteString::EqualsIgnoringPrivateKey(field_name, name)) { 2461 if (OneByteString::EqualsIgnoringPrivateKey(field_name, name)) {
2462 return field.raw(); 2462 return field.raw();
2463 } 2463 }
2464 } 2464 }
2465 // No field found. 2465 // No field found.
2466 return Field::null(); 2466 return Field::null();
2467 } 2467 }
2468 2468
2469 2469
2470 RawLibraryPrefix* Class::LookupLibraryPrefix(const String& name) const { 2470 RawLibraryPrefix* Class::LookupLibraryPrefix(const String& name) const {
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
3001 static void InsertIntoCanonicalTypeArguments(Isolate* isolate, 3001 static void InsertIntoCanonicalTypeArguments(Isolate* isolate,
3002 const Array& table, 3002 const Array& table,
3003 const TypeArguments& arguments, 3003 const TypeArguments& arguments,
3004 intptr_t index) { 3004 intptr_t index) {
3005 arguments.SetCanonical(); // Mark object as being canonical. 3005 arguments.SetCanonical(); // Mark object as being canonical.
3006 table.SetAt(index, arguments); // Remember the new element. 3006 table.SetAt(index, arguments); // Remember the new element.
3007 // Update used count. 3007 // Update used count.
3008 // Last element of the array is the number of used elements. 3008 // Last element of the array is the number of used elements.
3009 intptr_t table_size = table.Length() - 1; 3009 intptr_t table_size = table.Length() - 1;
3010 Smi& used = Smi::Handle(isolate); 3010 Smi& used = Smi::Handle(isolate);
3011 used |= table.At(table_size); 3011 used ^= table.At(table_size);
3012 intptr_t used_elements = used.Value() + 1; 3012 intptr_t used_elements = used.Value() + 1;
3013 used = Smi::New(used_elements); 3013 used = Smi::New(used_elements);
3014 table.SetAt(table_size, used); 3014 table.SetAt(table_size, used);
3015 3015
3016 // Rehash if table is 75% full. 3016 // Rehash if table is 75% full.
3017 if (used_elements > ((table_size / 4) * 3)) { 3017 if (used_elements > ((table_size / 4) * 3)) {
3018 GrowCanonicalTypeArguments(isolate, table); 3018 GrowCanonicalTypeArguments(isolate, table);
3019 } 3019 }
3020 } 3020 }
3021 3021
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
3504 3504
3505 3505
3506 void Function::set_parameter_types(const Array& value) const { 3506 void Function::set_parameter_types(const Array& value) const {
3507 StorePointer(&raw_ptr()->parameter_types_, value.raw()); 3507 StorePointer(&raw_ptr()->parameter_types_, value.raw());
3508 } 3508 }
3509 3509
3510 3510
3511 RawString* Function::ParameterNameAt(intptr_t index) const { 3511 RawString* Function::ParameterNameAt(intptr_t index) const {
3512 const Array& parameter_names = Array::Handle(raw_ptr()->parameter_names_); 3512 const Array& parameter_names = Array::Handle(raw_ptr()->parameter_names_);
3513 String& parameter_name = String::Handle(); 3513 String& parameter_name = String::Handle();
3514 parameter_name |= parameter_names.At(index); 3514 parameter_name ^= parameter_names.At(index);
3515 return parameter_name.raw(); 3515 return parameter_name.raw();
3516 } 3516 }
3517 3517
3518 3518
3519 void Function::SetParameterNameAt(intptr_t index, const String& value) const { 3519 void Function::SetParameterNameAt(intptr_t index, const String& value) const {
3520 ASSERT(!value.IsNull() && value.IsSymbol()); 3520 ASSERT(!value.IsNull() && value.IsSymbol());
3521 const Array& parameter_names = Array::Handle(raw_ptr()->parameter_names_); 3521 const Array& parameter_names = Array::Handle(raw_ptr()->parameter_names_);
3522 parameter_names.SetAt(index, value); 3522 parameter_names.SetAt(index, value);
3523 } 3523 }
3524 3524
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3723 argument_names.IsNull() ? 0 : argument_names.Length(); 3723 argument_names.IsNull() ? 0 : argument_names.Length();
3724 if (!AreValidArgumentCounts(num_arguments, 3724 if (!AreValidArgumentCounts(num_arguments,
3725 num_named_arguments, 3725 num_named_arguments,
3726 error_message)) { 3726 error_message)) {
3727 return false; 3727 return false;
3728 } 3728 }
3729 // Verify that all argument names are valid parameter names. 3729 // Verify that all argument names are valid parameter names.
3730 String& argument_name = String::Handle(); 3730 String& argument_name = String::Handle();
3731 String& parameter_name = String::Handle(); 3731 String& parameter_name = String::Handle();
3732 for (int i = 0; i < num_named_arguments; i++) { 3732 for (int i = 0; i < num_named_arguments; i++) {
3733 argument_name |= argument_names.At(i); 3733 argument_name ^= argument_names.At(i);
3734 ASSERT(argument_name.IsSymbol()); 3734 ASSERT(argument_name.IsSymbol());
3735 bool found = false; 3735 bool found = false;
3736 const int num_positional_args = num_arguments - num_named_arguments; 3736 const int num_positional_args = num_arguments - num_named_arguments;
3737 const int num_parameters = NumParameters(); 3737 const int num_parameters = NumParameters();
3738 for (int j = num_positional_args; !found && (j < num_parameters); j++) { 3738 for (int j = num_positional_args; !found && (j < num_parameters); j++) {
3739 parameter_name |= ParameterNameAt(j); 3739 parameter_name = ParameterNameAt(j);
3740 ASSERT(argument_name.IsSymbol()); 3740 ASSERT(argument_name.IsSymbol());
3741 if (argument_name.Equals(parameter_name)) { 3741 if (argument_name.Equals(parameter_name)) {
3742 found = true; 3742 found = true;
3743 } 3743 }
3744 } 3744 }
3745 if (!found) { 3745 if (!found) {
3746 if (error_message != NULL) { 3746 if (error_message != NULL) {
3747 const intptr_t kMessageBufferSize = 64; 3747 const intptr_t kMessageBufferSize = 64;
3748 char message_buffer[kMessageBufferSize]; 3748 char message_buffer[kMessageBufferSize];
3749 OS::SNPrint(message_buffer, 3749 OS::SNPrint(message_buffer,
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 } 4089 }
4090 ASSERT(!IsSignatureFunction() && !IsClosureFunction()); 4090 ASSERT(!IsSignatureFunction() && !IsClosureFunction());
4091 // Create closure function. 4091 // Create closure function.
4092 const String& closure_name = String::Handle(name()); 4092 const String& closure_name = String::Handle(name());
4093 const Function& closure_function = Function::Handle( 4093 const Function& closure_function = Function::Handle(
4094 NewClosureFunction(closure_name, *this, token_pos())); 4094 NewClosureFunction(closure_name, *this, token_pos()));
4095 4095
4096 // Set closure function's context scope. 4096 // Set closure function's context scope.
4097 ContextScope& context_scope = ContextScope::Handle(); 4097 ContextScope& context_scope = ContextScope::Handle();
4098 if (is_static()) { 4098 if (is_static()) {
4099 context_scope |= ContextScope::New(0); 4099 context_scope = ContextScope::New(0);
4100 } else { 4100 } else {
4101 context_scope |= LocalScope::CreateImplicitClosureScope(*this); 4101 context_scope = LocalScope::CreateImplicitClosureScope(*this);
4102 } 4102 }
4103 closure_function.set_context_scope(context_scope); 4103 closure_function.set_context_scope(context_scope);
4104 4104
4105 // Set closure function's result type to this result type. 4105 // Set closure function's result type to this result type.
4106 closure_function.set_result_type(AbstractType::Handle(result_type())); 4106 closure_function.set_result_type(AbstractType::Handle(result_type()));
4107 4107
4108 // Set closure function's formal parameters to this formal parameters, 4108 // Set closure function's formal parameters to this formal parameters,
4109 // removing the receiver if this is an instance method and adding the closure 4109 // removing the receiver if this is an instance method and adding the closure
4110 // object as first parameter. 4110 // object as first parameter.
4111 const int kClosure = 1; 4111 const int kClosure = 1;
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
5205 Token::Kind kind = static_cast<Token::Kind>( 5205 Token::Kind kind = static_cast<Token::Kind>(
5206 Smi::Value(reinterpret_cast<RawSmi*>(obj.raw()))); 5206 Smi::Value(reinterpret_cast<RawSmi*>(obj.raw())));
5207 ASSERT(kind < Token::kNumTokens); 5207 ASSERT(kind < Token::kNumTokens);
5208 if (Token::IsPseudoKeyword(kind) || Token::IsKeyword(kind)) { 5208 if (Token::IsPseudoKeyword(kind) || Token::IsKeyword(kind)) {
5209 Isolate* isolate = Isolate::Current(); 5209 Isolate* isolate = Isolate::Current();
5210 ObjectStore* object_store = isolate->object_store(); 5210 ObjectStore* object_store = isolate->object_store();
5211 String& str = String::Handle(isolate, String::null()); 5211 String& str = String::Handle(isolate, String::null());
5212 const Array& symbols = Array::Handle(isolate, 5212 const Array& symbols = Array::Handle(isolate,
5213 object_store->keyword_symbols()); 5213 object_store->keyword_symbols());
5214 ASSERT(!symbols.IsNull()); 5214 ASSERT(!symbols.IsNull());
5215 str |= symbols.At(kind - Token::kFirstKeyword); 5215 str ^= symbols.At(kind - Token::kFirstKeyword);
5216 ASSERT(!str.IsNull()); 5216 ASSERT(!str.IsNull());
5217 return str.raw(); 5217 return str.raw();
5218 } 5218 }
5219 return Symbols::New(Token::Str(kind)); 5219 return Symbols::New(Token::Str(kind));
5220 } else { 5220 } else {
5221 ASSERT(obj.IsLiteralToken()); // Must be a literal token. 5221 ASSERT(obj.IsLiteralToken()); // Must be a literal token.
5222 const LiteralToken& literal_token = LiteralToken::Cast(obj); 5222 const LiteralToken& literal_token = LiteralToken::Cast(obj);
5223 return literal_token.literal(); 5223 return literal_token.literal();
5224 } 5224 }
5225 } 5225 }
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
5588 entry = dict.At(index); 5588 entry = dict.At(index);
5589 // An empty spot will be found because we keep the hash set at most 75% full. 5589 // An empty spot will be found because we keep the hash set at most 75% full.
5590 while (!entry.IsNull()) { 5590 while (!entry.IsNull()) {
5591 index = (index + 1) % dict_size; 5591 index = (index + 1) % dict_size;
5592 entry = dict.At(index); 5592 entry = dict.At(index);
5593 } 5593 }
5594 5594
5595 // Insert the object at the empty slot. 5595 // Insert the object at the empty slot.
5596 dict.SetAt(index, obj); 5596 dict.SetAt(index, obj);
5597 Smi& used = Smi::Handle(); 5597 Smi& used = Smi::Handle();
5598 used |= dict.At(dict_size); 5598 used ^= dict.At(dict_size);
5599 intptr_t used_elements = used.Value() + 1; // One more element added. 5599 intptr_t used_elements = used.Value() + 1; // One more element added.
5600 used = Smi::New(used_elements); 5600 used = Smi::New(used_elements);
5601 dict.SetAt(dict_size, used); // Update used count. 5601 dict.SetAt(dict_size, used); // Update used count.
5602 5602
5603 // Rehash if symbol_table is 75% full. 5603 // Rehash if symbol_table is 75% full.
5604 if (used_elements > ((dict_size / 4) * 3)) { 5604 if (used_elements > ((dict_size / 4) * 3)) {
5605 GrowDictionary(dict, dict_size); 5605 GrowDictionary(dict, dict_size);
5606 } 5606 }
5607 5607
5608 // Invalidate the cache of loaded scripts. 5608 // Invalidate the cache of loaded scripts.
5609 if (loaded_scripts() != Array::null()) { 5609 if (loaded_scripts() != Array::null()) {
5610 StorePointer(&raw_ptr()->loaded_scripts_, Array::null()); 5610 StorePointer(&raw_ptr()->loaded_scripts_, Array::null());
5611 } 5611 }
5612 } 5612 }
5613 5613
5614 5614
5615 // Lookup a name in the library's export namespace. 5615 // Lookup a name in the library's export namespace.
5616 RawObject* Library::LookupExport(const String& name) const { 5616 RawObject* Library::LookupExport(const String& name) const {
5617 if (HasExports()) { 5617 if (HasExports()) {
5618 const Array& exports = Array::Handle(this->exports()); 5618 const Array& exports = Array::Handle(this->exports());
5619 Namespace& ns = Namespace::Handle(); 5619 Namespace& ns = Namespace::Handle();
5620 Object& obj = Object::Handle(); 5620 Object& obj = Object::Handle();
5621 for (int i = 0; i < exports.Length(); i++) { 5621 for (int i = 0; i < exports.Length(); i++) {
5622 ns |= exports.At(i); 5622 ns ^= exports.At(i);
5623 obj = ns.Lookup(name); 5623 obj = ns.Lookup(name);
5624 if (!obj.IsNull()) { 5624 if (!obj.IsNull()) {
5625 return obj.raw(); 5625 return obj.raw();
5626 } 5626 }
5627 } 5627 }
5628 } 5628 }
5629 return Object::null(); 5629 return Object::null();
5630 } 5630 }
5631 5631
5632 5632
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
5694 cls = Field::Cast(entry).owner(); 5694 cls = Field::Cast(entry).owner();
5695 owner_script = cls.script(); 5695 owner_script = cls.script();
5696 } else { 5696 } else {
5697 continue; 5697 continue;
5698 } 5698 }
5699 if (owner_script.IsNull()) { 5699 if (owner_script.IsNull()) {
5700 continue; 5700 continue;
5701 } 5701 }
5702 bool is_unique = true; 5702 bool is_unique = true;
5703 for (int i = 0; i < scripts.Length(); i++) { 5703 for (int i = 0; i < scripts.Length(); i++) {
5704 script_obj |= scripts.At(i); 5704 script_obj ^= scripts.At(i);
5705 if (script_obj.raw() == owner_script.raw()) { 5705 if (script_obj.raw() == owner_script.raw()) {
5706 // We already have a reference to this script. 5706 // We already have a reference to this script.
5707 is_unique = false; 5707 is_unique = false;
5708 break; 5708 break;
5709 } 5709 }
5710 } 5710 }
5711 if (is_unique) { 5711 if (is_unique) {
5712 // Add script to the list of scripts. 5712 // Add script to the list of scripts.
5713 scripts.Add(owner_script); 5713 scripts.Add(owner_script);
5714 } 5714 }
5715 } 5715 }
5716 5716
5717 // Create the array of scripts and cache it in loaded_scripts_. 5717 // Create the array of scripts and cache it in loaded_scripts_.
5718 StorePointer(&raw_ptr()->loaded_scripts_, Array::MakeArray(scripts)); 5718 StorePointer(&raw_ptr()->loaded_scripts_, Array::MakeArray(scripts));
5719 } 5719 }
5720 return loaded_scripts(); 5720 return loaded_scripts();
5721 } 5721 }
5722 5722
5723 5723
5724 // TODO(hausner): we might want to add a script dictionary to the 5724 // TODO(hausner): we might want to add a script dictionary to the
5725 // library class to make this lookup faster. 5725 // library class to make this lookup faster.
5726 RawScript* Library::LookupScript(const String& url) const { 5726 RawScript* Library::LookupScript(const String& url) const {
5727 const Array& scripts = Array::Handle(LoadedScripts()); 5727 const Array& scripts = Array::Handle(LoadedScripts());
5728 Script& script = Script::Handle(); 5728 Script& script = Script::Handle();
5729 String& script_url = String::Handle(); 5729 String& script_url = String::Handle();
5730 intptr_t num_scripts = scripts.Length(); 5730 intptr_t num_scripts = scripts.Length();
5731 for (int i = 0; i < num_scripts; i++) { 5731 for (int i = 0; i < num_scripts; i++) {
5732 script |= scripts.At(i); 5732 script ^= scripts.At(i);
5733 script_url = script.url(); 5733 script_url = script.url();
5734 if (script_url.Equals(url)) { 5734 if (script_url.Equals(url)) {
5735 return script.raw(); 5735 return script.raw();
5736 } 5736 }
5737 } 5737 }
5738 return Script::null(); 5738 return Script::null();
5739 } 5739 }
5740 5740
5741 5741
5742 RawFunction* Library::LookupFunctionInSource(const String& script_url, 5742 RawFunction* Library::LookupFunctionInSource(const String& script_url,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5776 func = cls.LookupFunctionAtToken(token_pos); 5776 func = cls.LookupFunctionAtToken(token_pos);
5777 if (!func.IsNull()) { 5777 if (!func.IsNull()) {
5778 return func.raw(); 5778 return func.raw();
5779 } 5779 }
5780 } 5780 }
5781 } 5781 }
5782 // Look in anonymous classes for toplevel functions. 5782 // Look in anonymous classes for toplevel functions.
5783 Array& anon_classes = Array::Handle(this->raw_ptr()->anonymous_classes_); 5783 Array& anon_classes = Array::Handle(this->raw_ptr()->anonymous_classes_);
5784 intptr_t num_anonymous = raw_ptr()->num_anonymous_; 5784 intptr_t num_anonymous = raw_ptr()->num_anonymous_;
5785 for (int i = 0; i < num_anonymous; i++) { 5785 for (int i = 0; i < num_anonymous; i++) {
5786 cls |= anon_classes.At(i); 5786 cls ^= anon_classes.At(i);
5787 ASSERT(!cls.IsNull()); 5787 ASSERT(!cls.IsNull());
5788 if (script.raw() == cls.script()) { 5788 if (script.raw() == cls.script()) {
5789 func = cls.LookupFunctionAtToken(token_pos); 5789 func = cls.LookupFunctionAtToken(token_pos);
5790 if (!func.IsNull()) { 5790 if (!func.IsNull()) {
5791 return func.raw(); 5791 return func.raw();
5792 } 5792 }
5793 } 5793 }
5794 } 5794 }
5795 return Function::null(); 5795 return Function::null();
5796 } 5796 }
(...skipping 28 matching lines...) Expand all
5825 // Do not look up private names in imported libraries. 5825 // Do not look up private names in imported libraries.
5826 if (ShouldBePrivate(name)) { 5826 if (ShouldBePrivate(name)) {
5827 return Field::null(); 5827 return Field::null();
5828 } 5828 }
5829 5829
5830 // Now check if name is found in any imported libs. 5830 // Now check if name is found in any imported libs.
5831 const Array& imports = Array::Handle(this->imports()); 5831 const Array& imports = Array::Handle(this->imports());
5832 Namespace& import = Namespace::Handle(); 5832 Namespace& import = Namespace::Handle();
5833 Object& obj = Object::Handle(); 5833 Object& obj = Object::Handle();
5834 for (intptr_t j = 0; j < this->num_imports(); j++) { 5834 for (intptr_t j = 0; j < this->num_imports(); j++) {
5835 import |= imports.At(j); 5835 import ^= imports.At(j);
5836 obj = import.Lookup(name); 5836 obj = import.Lookup(name);
5837 if (!obj.IsNull() && obj.IsField()) { 5837 if (!obj.IsNull() && obj.IsField()) {
5838 field |= obj.raw(); 5838 field ^= obj.raw();
5839 return field.raw(); 5839 return field.raw();
5840 } 5840 }
5841 } 5841 }
5842 return Field::null(); 5842 return Field::null();
5843 } 5843 }
5844 5844
5845 5845
5846 RawField* Library::LookupLocalField(const String& name) const { 5846 RawField* Library::LookupLocalField(const String& name) const {
5847 Isolate* isolate = Isolate::Current(); 5847 Isolate* isolate = Isolate::Current();
5848 Field& field = Field::Handle(isolate, Field::null()); 5848 Field& field = Field::Handle(isolate, Field::null());
5849 Object& obj = Object::Handle(isolate, Object::null()); 5849 Object& obj = Object::Handle(isolate, Object::null());
5850 obj = LookupLocalObject(name); 5850 obj = LookupLocalObject(name);
5851 if (obj.IsNull() && ShouldBePrivate(name)) { 5851 if (obj.IsNull() && ShouldBePrivate(name)) {
5852 String& private_name = String::Handle(isolate, PrivateName(name)); 5852 String& private_name = String::Handle(isolate, PrivateName(name));
5853 obj = LookupLocalObject(private_name); 5853 obj = LookupLocalObject(private_name);
5854 } 5854 }
5855 if (!obj.IsNull()) { 5855 if (!obj.IsNull()) {
5856 if (obj.IsField()) { 5856 if (obj.IsField()) {
5857 field |= obj.raw(); 5857 field ^= obj.raw();
5858 return field.raw(); 5858 return field.raw();
5859 } 5859 }
5860 } 5860 }
5861 5861
5862 // No field found. 5862 // No field found.
5863 return Field::null(); 5863 return Field::null();
5864 } 5864 }
5865 5865
5866 5866
5867 RawFunction* Library::LookupFunctionAllowPrivate(const String& name) const { 5867 RawFunction* Library::LookupFunctionAllowPrivate(const String& name) const {
5868 // First check if name is found in the local scope of the library. 5868 // First check if name is found in the local scope of the library.
5869 Function& function = Function::Handle(LookupLocalFunction(name)); 5869 Function& function = Function::Handle(LookupLocalFunction(name));
5870 if (!function.IsNull()) { 5870 if (!function.IsNull()) {
5871 return function.raw(); 5871 return function.raw();
5872 } 5872 }
5873 5873
5874 // Do not look up private names in imported libraries. 5874 // Do not look up private names in imported libraries.
5875 if (ShouldBePrivate(name)) { 5875 if (ShouldBePrivate(name)) {
5876 return Function::null(); 5876 return Function::null();
5877 } 5877 }
5878 5878
5879 // Now check if name is found in any imported libs. 5879 // Now check if name is found in any imported libs.
5880 const Array& imports = Array::Handle(this->imports()); 5880 const Array& imports = Array::Handle(this->imports());
5881 Namespace& import = Namespace::Handle(); 5881 Namespace& import = Namespace::Handle();
5882 Object& obj = Object::Handle(); 5882 Object& obj = Object::Handle();
5883 for (intptr_t j = 0; j < this->num_imports(); j++) { 5883 for (intptr_t j = 0; j < this->num_imports(); j++) {
5884 import |= imports.At(j); 5884 import ^= imports.At(j);
5885 obj = import.Lookup(name); 5885 obj = import.Lookup(name);
5886 if (!obj.IsNull() && obj.IsFunction()) { 5886 if (!obj.IsNull() && obj.IsFunction()) {
5887 function |= obj.raw(); 5887 function ^= obj.raw();
5888 return function.raw(); 5888 return function.raw();
5889 } 5889 }
5890 } 5890 }
5891 return Function::null(); 5891 return Function::null();
5892 } 5892 }
5893 5893
5894 5894
5895 RawFunction* Library::LookupLocalFunction(const String& name) const { 5895 RawFunction* Library::LookupLocalFunction(const String& name) const {
5896 Isolate* isolate = Isolate::Current(); 5896 Isolate* isolate = Isolate::Current();
5897 Object& obj = Object::Handle(isolate, Object::null()); 5897 Object& obj = Object::Handle(isolate, Object::null());
(...skipping 14 matching lines...) Expand all
5912 RawObject* Library::LookupObject(const String& name) const { 5912 RawObject* Library::LookupObject(const String& name) const {
5913 // First check if name is found in the local scope of the library. 5913 // First check if name is found in the local scope of the library.
5914 Object& obj = Object::Handle(LookupLocalObject(name)); 5914 Object& obj = Object::Handle(LookupLocalObject(name));
5915 if (!obj.IsNull()) { 5915 if (!obj.IsNull()) {
5916 return obj.raw(); 5916 return obj.raw();
5917 } 5917 }
5918 // Now check if name is found in any imported libs. 5918 // Now check if name is found in any imported libs.
5919 const Array& imports = Array::Handle(this->imports()); 5919 const Array& imports = Array::Handle(this->imports());
5920 Namespace& import = Namespace::Handle(); 5920 Namespace& import = Namespace::Handle();
5921 for (intptr_t j = 0; j < this->num_imports(); j++) { 5921 for (intptr_t j = 0; j < this->num_imports(); j++) {
5922 import |= imports.At(j); 5922 import ^= imports.At(j);
5923 obj = import.Lookup(name); 5923 obj = import.Lookup(name);
5924 if (!obj.IsNull()) { 5924 if (!obj.IsNull()) {
5925 return obj.raw(); 5925 return obj.raw();
5926 } 5926 }
5927 } 5927 }
5928 return Object::null(); 5928 return Object::null();
5929 } 5929 }
5930 5930
5931 5931
5932 RawClass* Library::LookupClass(const String& name) const { 5932 RawClass* Library::LookupClass(const String& name) const {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
6001 return import.library(); 6001 return import.library();
6002 } 6002 }
6003 6003
6004 6004
6005 RawNamespace* Library::ImportAt(intptr_t index) const { 6005 RawNamespace* Library::ImportAt(intptr_t index) const {
6006 if ((index < 0) || index >= num_imports()) { 6006 if ((index < 0) || index >= num_imports()) {
6007 return Namespace::null(); 6007 return Namespace::null();
6008 } 6008 }
6009 const Array& import_list = Array::Handle(imports()); 6009 const Array& import_list = Array::Handle(imports());
6010 Namespace& import = Namespace::Handle(); 6010 Namespace& import = Namespace::Handle();
6011 import |= import_list.At(index); 6011 import ^= import_list.At(index);
6012 return import.raw(); 6012 return import.raw();
6013 } 6013 }
6014 6014
6015 6015
6016 bool Library::ImportsCorelib() const { 6016 bool Library::ImportsCorelib() const {
6017 Isolate* isolate = Isolate::Current(); 6017 Isolate* isolate = Isolate::Current();
6018 Library& imported = Library::Handle(isolate); 6018 Library& imported = Library::Handle(isolate);
6019 intptr_t count = num_imports(); 6019 intptr_t count = num_imports();
6020 for (int i = 0; i < count; i++) { 6020 for (int i = 0; i < count; i++) {
6021 imported = ImportLibraryAt(i); 6021 imported = ImportLibraryAt(i);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
6282 } 6282 }
6283 6283
6284 6284
6285 RawLibrary* Library::LookupLibrary(const String &url) { 6285 RawLibrary* Library::LookupLibrary(const String &url) {
6286 Isolate* isolate = Isolate::Current(); 6286 Isolate* isolate = Isolate::Current();
6287 Library& lib = Library::Handle(isolate, Library::null()); 6287 Library& lib = Library::Handle(isolate, Library::null());
6288 String& lib_url = String::Handle(isolate, String::null()); 6288 String& lib_url = String::Handle(isolate, String::null());
6289 GrowableObjectArray& libs = GrowableObjectArray::Handle( 6289 GrowableObjectArray& libs = GrowableObjectArray::Handle(
6290 isolate, isolate->object_store()->libraries()); 6290 isolate, isolate->object_store()->libraries());
6291 for (int i = 0; i < libs.Length(); i++) { 6291 for (int i = 0; i < libs.Length(); i++) {
6292 lib |= libs.At(i); 6292 lib ^= libs.At(i);
6293 lib_url = lib.url(); 6293 lib_url ^= lib.url();
6294 if (lib_url.Equals(url)) { 6294 if (lib_url.Equals(url)) {
6295 return lib.raw(); 6295 return lib.raw();
6296 } 6296 }
6297 } 6297 }
6298 return Library::null(); 6298 return Library::null();
6299 } 6299 }
6300 6300
6301 6301
6302 RawError* Library::Patch(const Script& script) const { 6302 RawError* Library::Patch(const Script& script) const {
6303 ASSERT(script.kind() == RawScript::kPatchTag); 6303 ASSERT(script.kind() == RawScript::kPatchTag);
6304 return Compiler::Compile(*this, script); 6304 return Compiler::Compile(*this, script);
6305 } 6305 }
6306 6306
6307 6307
6308 bool Library::IsKeyUsed(intptr_t key) { 6308 bool Library::IsKeyUsed(intptr_t key) {
6309 intptr_t lib_key; 6309 intptr_t lib_key;
6310 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 6310 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
6311 Isolate::Current()->object_store()->libraries()); 6311 Isolate::Current()->object_store()->libraries());
6312 Library& lib = Library::Handle(); 6312 Library& lib = Library::Handle();
6313 String& lib_url = String::Handle(); 6313 String& lib_url = String::Handle();
6314 for (int i = 0; i < libs.Length(); i++) { 6314 for (int i = 0; i < libs.Length(); i++) {
6315 lib |= libs.At(i); 6315 lib ^= libs.At(i);
6316 lib_url |= lib.url(); 6316 lib_url ^= lib.url();
6317 lib_key = lib_url.Hash(); 6317 lib_key = lib_url.Hash();
6318 if (lib_key == key) { 6318 if (lib_key == key) {
6319 return true; 6319 return true;
6320 } 6320 }
6321 } 6321 }
6322 return false; 6322 return false;
6323 } 6323 }
6324 6324
6325 6325
6326 static bool IsPrivate(const String& name) { 6326 static bool IsPrivate(const String& name) {
6327 if (ShouldBePrivate(name)) return true; 6327 if (ShouldBePrivate(name)) return true;
6328 // Factory names: List._fromLiteral. 6328 // Factory names: List._fromLiteral.
6329 for (intptr_t i = 1; i < name.Length() - 1; i++) { 6329 for (intptr_t i = 1; i < name.Length() - 1; i++) {
6330 if (name.CharAt(i) == '.') { 6330 if (name.CharAt(i) == '.') {
6331 if (name.CharAt(i + 1) == '_') { 6331 if (name.CharAt(i + 1) == '_') {
6332 return true; 6332 return true;
6333 } 6333 }
6334 } 6334 }
6335 } 6335 }
6336 return false; 6336 return false;
6337 } 6337 }
6338 6338
6339 6339
6340 // Cannot handle qualified names properly as it only appends private key to 6340 // Cannot handle qualified names properly as it only appends private key to
6341 // the end (e.g. _Alfa.foo -> _Alfa.foo@...). 6341 // the end (e.g. _Alfa.foo -> _Alfa.foo@...).
6342 RawString* Library::PrivateName(const String& name) const { 6342 RawString* Library::PrivateName(const String& name) const {
6343 ASSERT(IsPrivate(name)); 6343 ASSERT(IsPrivate(name));
6344 // ASSERT(strchr(name, '@') == NULL); 6344 // ASSERT(strchr(name, '@') == NULL);
6345 String& str = String::Handle(); 6345 String& str = String::Handle();
6346 str |= name.raw(); 6346 str = name.raw();
6347 str = String::Concat(str, String::Handle(this->private_key())); 6347 str = String::Concat(str, String::Handle(this->private_key()));
6348 str = Symbols::New(str); 6348 str = Symbols::New(str);
6349 return str.raw(); 6349 return str.raw();
6350 } 6350 }
6351 6351
6352 6352
6353 RawLibrary* Library::GetLibrary(intptr_t index) { 6353 RawLibrary* Library::GetLibrary(intptr_t index) {
6354 Isolate* isolate = Isolate::Current(); 6354 Isolate* isolate = Isolate::Current();
6355 const GrowableObjectArray& libs = 6355 const GrowableObjectArray& libs =
6356 GrowableObjectArray::Handle(isolate->object_store()->libraries()); 6356 GrowableObjectArray::Handle(isolate->object_store()->libraries());
6357 ASSERT(!libs.IsNull()); 6357 ASSERT(!libs.IsNull());
6358 if ((0 <= index) && (index < libs.Length())) { 6358 if ((0 <= index) && (index < libs.Length())) {
6359 Library& lib = Library::Handle(); 6359 Library& lib = Library::Handle();
6360 lib |= libs.At(index); 6360 lib ^= libs.At(index);
6361 return lib.raw(); 6361 return lib.raw();
6362 } 6362 }
6363 return Library::null(); 6363 return Library::null();
6364 } 6364 }
6365 6365
6366 6366
6367 void Library::Register() const { 6367 void Library::Register() const {
6368 ASSERT(Library::LookupLibrary(String::Handle(url())) == Library::null()); 6368 ASSERT(Library::LookupLibrary(String::Handle(url())) == Library::null());
6369 ObjectStore* object_store = Isolate::Current()->object_store(); 6369 ObjectStore* object_store = Isolate::Current()->object_store();
6370 GrowableObjectArray& libs = 6370 GrowableObjectArray& libs =
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6427 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 6427 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
6428 OS::SNPrint(chars, len, kFormat, name.ToCString()); 6428 OS::SNPrint(chars, len, kFormat, name.ToCString());
6429 return chars; 6429 return chars;
6430 } 6430 }
6431 6431
6432 6432
6433 RawLibrary* LibraryPrefix::GetLibrary(int index) const { 6433 RawLibrary* LibraryPrefix::GetLibrary(int index) const {
6434 if ((index >= 0) || (index < num_imports())) { 6434 if ((index >= 0) || (index < num_imports())) {
6435 const Array& imports = Array::Handle(this->imports()); 6435 const Array& imports = Array::Handle(this->imports());
6436 Namespace& import = Namespace::Handle(); 6436 Namespace& import = Namespace::Handle();
6437 import |= imports.At(index); 6437 import ^= imports.At(index);
6438 return import.library(); 6438 return import.library();
6439 } 6439 }
6440 return Library::null(); 6440 return Library::null();
6441 } 6441 }
6442 6442
6443 6443
6444 bool LibraryPrefix::ContainsLibrary(const Library& library) const { 6444 bool LibraryPrefix::ContainsLibrary(const Library& library) const {
6445 intptr_t num_current_imports = num_imports(); 6445 intptr_t num_current_imports = num_imports();
6446 if (num_current_imports > 0) { 6446 if (num_current_imports > 0) {
6447 Library& lib = Library::Handle(); 6447 Library& lib = Library::Handle();
(...skipping 27 matching lines...) Expand all
6475 imports.SetAt(num_current_imports, import); 6475 imports.SetAt(num_current_imports, import);
6476 set_num_imports(num_current_imports + 1); 6476 set_num_imports(num_current_imports + 1);
6477 } 6477 }
6478 6478
6479 6479
6480 RawClass* LibraryPrefix::LookupLocalClass(const String& class_name) const { 6480 RawClass* LibraryPrefix::LookupLocalClass(const String& class_name) const {
6481 Array& imports = Array::Handle(this->imports()); 6481 Array& imports = Array::Handle(this->imports());
6482 Object& obj = Object::Handle(); 6482 Object& obj = Object::Handle();
6483 Namespace& import = Namespace::Handle(); 6483 Namespace& import = Namespace::Handle();
6484 for (intptr_t i = 0; i < num_imports(); i++) { 6484 for (intptr_t i = 0; i < num_imports(); i++) {
6485 import |= imports.At(i); 6485 import ^= imports.At(i);
6486 obj = import.Lookup(class_name); 6486 obj = import.Lookup(class_name);
6487 if (!obj.IsNull() && obj.IsClass()) { 6487 if (!obj.IsNull() && obj.IsClass()) {
6488 // TODO(hausner): 6488 // TODO(hausner):
6489 return Class::Cast(obj).raw(); 6489 return Class::Cast(obj).raw();
6490 } 6490 }
6491 } 6491 }
6492 return Class::null(); 6492 return Class::null();
6493 } 6493 }
6494 6494
6495 6495
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
6549 } 6549 }
6550 6550
6551 6551
6552 bool Namespace::HidesName(const String& name) const { 6552 bool Namespace::HidesName(const String& name) const {
6553 // Check whether the name is in the list of explicitly hidden names. 6553 // Check whether the name is in the list of explicitly hidden names.
6554 if (hide_names() != Array::null()) { 6554 if (hide_names() != Array::null()) {
6555 const Array& names = Array::Handle(hide_names()); 6555 const Array& names = Array::Handle(hide_names());
6556 String& hidden = String::Handle(); 6556 String& hidden = String::Handle();
6557 intptr_t num_names = names.Length(); 6557 intptr_t num_names = names.Length();
6558 for (intptr_t i = 0; i < num_names; i++) { 6558 for (intptr_t i = 0; i < num_names; i++) {
6559 hidden |= names.At(i); 6559 hidden ^= names.At(i);
6560 if (name.Equals(hidden)) { 6560 if (name.Equals(hidden)) {
6561 return true; 6561 return true;
6562 } 6562 }
6563 } 6563 }
6564 } 6564 }
6565 // The name is not explicitly hidden. Now check whether it is in the 6565 // The name is not explicitly hidden. Now check whether it is in the
6566 // list of explicitly visible names, if there is one. 6566 // list of explicitly visible names, if there is one.
6567 if (show_names() != Array::null()) { 6567 if (show_names() != Array::null()) {
6568 const Array& names = Array::Handle(show_names()); 6568 const Array& names = Array::Handle(show_names());
6569 String& shown = String::Handle(); 6569 String& shown = String::Handle();
6570 intptr_t num_names = names.Length(); 6570 intptr_t num_names = names.Length();
6571 for (intptr_t i = 0; i < num_names; i++) { 6571 for (intptr_t i = 0; i < num_names; i++) {
6572 shown |= names.At(i); 6572 shown ^= names.At(i);
6573 if (name.Equals(shown)) { 6573 if (name.Equals(shown)) {
6574 return false; 6574 return false;
6575 } 6575 }
6576 } 6576 }
6577 // There is a list of visible names. The name we're looking for is not 6577 // There is a list of visible names. The name we're looking for is not
6578 // contained in the list, so it is hidden. 6578 // contained in the list, so it is hidden.
6579 return true; 6579 return true;
6580 } 6580 }
6581 // The name is not filtered out. 6581 // The name is not filtered out.
6582 return false; 6582 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
6621 } 6621 }
6622 6622
6623 6623
6624 RawError* Library::CompileAll() { 6624 RawError* Library::CompileAll() {
6625 Error& error = Error::Handle(); 6625 Error& error = Error::Handle();
6626 const GrowableObjectArray& libs = GrowableObjectArray::Handle( 6626 const GrowableObjectArray& libs = GrowableObjectArray::Handle(
6627 Isolate::Current()->object_store()->libraries()); 6627 Isolate::Current()->object_store()->libraries());
6628 Library& lib = Library::Handle(); 6628 Library& lib = Library::Handle();
6629 Class& cls = Class::Handle(); 6629 Class& cls = Class::Handle();
6630 for (int i = 0; i < libs.Length(); i++) { 6630 for (int i = 0; i < libs.Length(); i++) {
6631 lib |= libs.At(i); 6631 lib ^= libs.At(i);
6632 ClassDictionaryIterator it(lib); 6632 ClassDictionaryIterator it(lib);
6633 while (it.HasNext()) { 6633 while (it.HasNext()) {
6634 cls |= it.GetNextClass(); 6634 cls = it.GetNextClass();
6635 error = Compiler::CompileAllFunctions(cls); 6635 error = Compiler::CompileAllFunctions(cls);
6636 if (!error.IsNull()) { 6636 if (!error.IsNull()) {
6637 return error.raw(); 6637 return error.raw();
6638 } 6638 }
6639 } 6639 }
6640 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_); 6640 Array& anon_classes = Array::Handle(lib.raw_ptr()->anonymous_classes_);
6641 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) { 6641 for (int i = 0; i < lib.raw_ptr()->num_anonymous_; i++) {
6642 cls |= anon_classes.At(i); 6642 cls ^= anon_classes.At(i);
6643 error = Compiler::CompileAllFunctions(cls); 6643 error = Compiler::CompileAllFunctions(cls);
6644 if (!error.IsNull()) { 6644 if (!error.IsNull()) {
6645 return error.raw(); 6645 return error.raw();
6646 } 6646 }
6647 } 6647 }
6648 } 6648 }
6649 return error.raw(); 6649 return error.raw();
6650 } 6650 }
6651 6651
6652 6652
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
6961 return chars; 6961 return chars;
6962 } 6962 }
6963 } 6963 }
6964 6964
6965 6965
6966 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const { 6966 RawString* LocalVarDescriptors::GetName(intptr_t var_index) const {
6967 ASSERT(var_index < Length()); 6967 ASSERT(var_index < Length());
6968 const Array& names = Array::Handle(raw_ptr()->names_); 6968 const Array& names = Array::Handle(raw_ptr()->names_);
6969 ASSERT(Length() == names.Length()); 6969 ASSERT(Length() == names.Length());
6970 String& name = String::Handle(); 6970 String& name = String::Handle();
6971 name |= names.At(var_index); 6971 name ^= names.At(var_index);
6972 return name.raw(); 6972 return name.raw();
6973 } 6973 }
6974 6974
6975 6975
6976 void LocalVarDescriptors::SetVar(intptr_t var_index, 6976 void LocalVarDescriptors::SetVar(intptr_t var_index,
6977 const String& name, 6977 const String& name,
6978 RawLocalVarDescriptors::VarInfo* info) const { 6978 RawLocalVarDescriptors::VarInfo* info) const {
6979 ASSERT(var_index < Length()); 6979 ASSERT(var_index < Length());
6980 const Array& names = Array::Handle(raw_ptr()->names_); 6980 const Array& names = Array::Handle(raw_ptr()->names_);
6981 ASSERT(Length() == names.Length()); 6981 ASSERT(Length() == names.Length());
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
7294 intptr_t Code::Comments::Length() const { 7294 intptr_t Code::Comments::Length() const {
7295 if (comments_.IsNull()) { 7295 if (comments_.IsNull()) {
7296 return 0; 7296 return 0;
7297 } 7297 }
7298 return comments_.Length() / kNumberOfEntries; 7298 return comments_.Length() / kNumberOfEntries;
7299 } 7299 }
7300 7300
7301 7301
7302 intptr_t Code::Comments::PCOffsetAt(intptr_t idx) const { 7302 intptr_t Code::Comments::PCOffsetAt(intptr_t idx) const {
7303 Smi& result = Smi::Handle(); 7303 Smi& result = Smi::Handle();
7304 result |= comments_.At(idx * kNumberOfEntries + kPCOffsetEntry); 7304 result ^= comments_.At(idx * kNumberOfEntries + kPCOffsetEntry);
7305 return result.Value(); 7305 return result.Value();
7306 } 7306 }
7307 7307
7308 7308
7309 void Code::Comments::SetPCOffsetAt(intptr_t idx, intptr_t pc) { 7309 void Code::Comments::SetPCOffsetAt(intptr_t idx, intptr_t pc) {
7310 comments_.SetAt(idx * kNumberOfEntries + kPCOffsetEntry, 7310 comments_.SetAt(idx * kNumberOfEntries + kPCOffsetEntry,
7311 Smi::Handle(Smi::New(pc))); 7311 Smi::Handle(Smi::New(pc)));
7312 } 7312 }
7313 7313
7314 7314
7315 RawString* Code::Comments::CommentAt(intptr_t idx) const { 7315 RawString* Code::Comments::CommentAt(intptr_t idx) const {
7316 String& result = String::Handle(); 7316 String& result = String::Handle();
7317 result |= comments_.At(idx * kNumberOfEntries + kCommentEntry); 7317 result ^= comments_.At(idx * kNumberOfEntries + kCommentEntry);
7318 return result.raw(); 7318 return result.raw();
7319 } 7319 }
7320 7320
7321 7321
7322 void Code::Comments::SetCommentAt(intptr_t idx, const String& comment) { 7322 void Code::Comments::SetCommentAt(intptr_t idx, const String& comment) {
7323 comments_.SetAt(idx * kNumberOfEntries + kCommentEntry, comment); 7323 comments_.SetAt(idx * kNumberOfEntries + kCommentEntry, comment);
7324 } 7324 }
7325 7325
7326 7326
7327 Code::Comments::Comments(const Array& comments) 7327 Code::Comments::Comments(const Array& comments)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
7374 7374
7375 7375
7376 RawFunction* Code::GetStaticCallTargetFunctionAt(uword pc) const { 7376 RawFunction* Code::GetStaticCallTargetFunctionAt(uword pc) const {
7377 RawObject* raw_code_offset = 7377 RawObject* raw_code_offset =
7378 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); 7378 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint()));
7379 const Array& array = 7379 const Array& array =
7380 Array::Handle(raw_ptr()->static_calls_target_table_); 7380 Array::Handle(raw_ptr()->static_calls_target_table_);
7381 for (intptr_t i = 0; i < array.Length(); i += kSCallTableEntryLength) { 7381 for (intptr_t i = 0; i < array.Length(); i += kSCallTableEntryLength) {
7382 if (array.At(i) == raw_code_offset) { 7382 if (array.At(i) == raw_code_offset) {
7383 Function& function = Function::Handle(); 7383 Function& function = Function::Handle();
7384 function |= array.At(i + kSCallTableFunctionEntry); 7384 function ^= array.At(i + kSCallTableFunctionEntry);
7385 return function.raw(); 7385 return function.raw();
7386 } 7386 }
7387 } 7387 }
7388 return Function::null(); 7388 return Function::null();
7389 } 7389 }
7390 7390
7391 7391
7392 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const { 7392 void Code::SetStaticCallTargetCodeAt(uword pc, const Code& code) const {
7393 RawObject* raw_code_offset = 7393 RawObject* raw_code_offset =
7394 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint())); 7394 reinterpret_cast<RawObject*>(Smi::New(pc - EntryPoint()));
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
7659 if (stackmaps() == Array::null()) { 7659 if (stackmaps() == Array::null()) {
7660 // No stack maps are present in the code object which means this 7660 // No stack maps are present in the code object which means this
7661 // frame relies on tagged pointers. 7661 // frame relies on tagged pointers.
7662 return Stackmap::null(); 7662 return Stackmap::null();
7663 } 7663 }
7664 // A stack map is present in the code object, use the stack map to visit 7664 // A stack map is present in the code object, use the stack map to visit
7665 // frame slots which are marked as having objects. 7665 // frame slots which are marked as having objects.
7666 *maps = stackmaps(); 7666 *maps = stackmaps();
7667 *map = Stackmap::null(); 7667 *map = Stackmap::null();
7668 for (intptr_t i = 0; i < maps->Length(); i++) { 7668 for (intptr_t i = 0; i < maps->Length(); i++) {
7669 *map |= maps->At(i); 7669 *map ^= maps->At(i);
7670 ASSERT(!map->IsNull()); 7670 ASSERT(!map->IsNull());
7671 if (map->PC() == pc) { 7671 if (map->PC() == pc) {
7672 return map->raw(); // We found a stack map for this frame. 7672 return map->raw(); // We found a stack map for this frame.
7673 } 7673 }
7674 } 7674 }
7675 // If the code has stackmaps, it must have them for all safepoints. 7675 // If the code has stackmaps, it must have them for all safepoints.
7676 UNREACHABLE(); 7676 UNREACHABLE();
7677 return Stackmap::null(); 7677 return Stackmap::null();
7678 } 7678 }
7679 7679
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
7974 GrowableArray<intptr_t>* class_ids, 7974 GrowableArray<intptr_t>* class_ids,
7975 Function* target) const { 7975 Function* target) const {
7976 ASSERT(index < NumberOfChecks()); 7976 ASSERT(index < NumberOfChecks());
7977 ASSERT(class_ids != NULL); 7977 ASSERT(class_ids != NULL);
7978 ASSERT(target != NULL); 7978 ASSERT(target != NULL);
7979 class_ids->Clear(); 7979 class_ids->Clear();
7980 const Array& data = Array::Handle(ic_data()); 7980 const Array& data = Array::Handle(ic_data());
7981 intptr_t data_pos = index * TestEntryLength(); 7981 intptr_t data_pos = index * TestEntryLength();
7982 Smi& smi = Smi::Handle(); 7982 Smi& smi = Smi::Handle();
7983 for (intptr_t i = 0; i < num_args_tested(); i++) { 7983 for (intptr_t i = 0; i < num_args_tested(); i++) {
7984 smi |= data.At(data_pos++); 7984 smi ^= data.At(data_pos++);
7985 class_ids->Add(smi.Value()); 7985 class_ids->Add(smi.Value());
7986 } 7986 }
7987 (*target) |= data.At(data_pos++); 7987 (*target) ^= data.At(data_pos++);
7988 } 7988 }
7989 7989
7990 7990
7991 void ICData::GetOneClassCheckAt(intptr_t index, 7991 void ICData::GetOneClassCheckAt(intptr_t index,
7992 intptr_t* class_id, 7992 intptr_t* class_id,
7993 Function* target) const { 7993 Function* target) const {
7994 ASSERT(class_id != NULL); 7994 ASSERT(class_id != NULL);
7995 ASSERT(target != NULL); 7995 ASSERT(target != NULL);
7996 ASSERT(num_args_tested() == 1); 7996 ASSERT(num_args_tested() == 1);
7997 const Array& data = Array::Handle(ic_data()); 7997 const Array& data = Array::Handle(ic_data());
7998 intptr_t data_pos = index * TestEntryLength(); 7998 intptr_t data_pos = index * TestEntryLength();
7999 Smi& smi = Smi::Handle(); 7999 Smi& smi = Smi::Handle();
8000 smi |= data.At(data_pos); 8000 smi ^= data.At(data_pos);
8001 *class_id = smi.Value(); 8001 *class_id = smi.Value();
8002 *target |= data.At(data_pos + 1); 8002 *target ^= data.At(data_pos + 1);
8003 } 8003 }
8004 8004
8005 8005
8006 intptr_t ICData::GetClassIdAt(intptr_t index, intptr_t arg_nr) const { 8006 intptr_t ICData::GetClassIdAt(intptr_t index, intptr_t arg_nr) const {
8007 GrowableArray<intptr_t> class_ids; 8007 GrowableArray<intptr_t> class_ids;
8008 Function& target = Function::Handle(); 8008 Function& target = Function::Handle();
8009 GetCheckAt(index, &class_ids, &target); 8009 GetCheckAt(index, &class_ids, &target);
8010 return class_ids[arg_nr]; 8010 return class_ids[arg_nr];
8011 } 8011 }
8012 8012
8013 8013
8014 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const { 8014 intptr_t ICData::GetReceiverClassIdAt(intptr_t index) const {
8015 ASSERT(index < NumberOfChecks()); 8015 ASSERT(index < NumberOfChecks());
8016 const Array& data = Array::Handle(ic_data()); 8016 const Array& data = Array::Handle(ic_data());
8017 const intptr_t data_pos = index * TestEntryLength(); 8017 const intptr_t data_pos = index * TestEntryLength();
8018 Smi& smi = Smi::Handle(); 8018 Smi& smi = Smi::Handle();
8019 smi |= data.At(data_pos); 8019 smi ^= data.At(data_pos);
8020 return smi.Value(); 8020 return smi.Value();
8021 } 8021 }
8022 8022
8023 8023
8024 RawFunction* ICData::GetTargetAt(intptr_t index) const { 8024 RawFunction* ICData::GetTargetAt(intptr_t index) const {
8025 const Array& data = Array::Handle(ic_data()); 8025 const Array& data = Array::Handle(ic_data());
8026 const intptr_t data_pos = index * TestEntryLength() + num_args_tested(); 8026 const intptr_t data_pos = index * TestEntryLength() + num_args_tested();
8027 ASSERT(Object::Handle(data.At(data_pos)).IsFunction()); 8027 ASSERT(Object::Handle(data.At(data_pos)).IsFunction());
8028 return reinterpret_cast<RawFunction*>(data.At(data_pos)); 8028 return reinterpret_cast<RawFunction*>(data.At(data_pos));
8029 } 8029 }
8030 8030
8031 8031
8032 intptr_t ICData::GetCountAt(intptr_t index) const { 8032 intptr_t ICData::GetCountAt(intptr_t index) const {
8033 const Array& data = Array::Handle(ic_data()); 8033 const Array& data = Array::Handle(ic_data());
8034 const intptr_t data_pos = index * TestEntryLength() + 8034 const intptr_t data_pos = index * TestEntryLength() +
8035 CountIndexFor(num_args_tested()); 8035 CountIndexFor(num_args_tested());
8036 Smi& smi = Smi::Handle(); 8036 Smi& smi = Smi::Handle();
8037 smi |= data.At(data_pos); 8037 smi ^= data.At(data_pos);
8038 return smi.Value(); 8038 return smi.Value();
8039 } 8039 }
8040 8040
8041 8041
8042 intptr_t ICData::AggregateCount() const { 8042 intptr_t ICData::AggregateCount() const {
8043 const intptr_t len = NumberOfChecks(); 8043 const intptr_t len = NumberOfChecks();
8044 intptr_t count = 0; 8044 intptr_t count = 0;
8045 for (intptr_t i = 0; i < len; i++) { 8045 for (intptr_t i = 0; i < len; i++) {
8046 count += GetCountAt(i); 8046 count += GetCountAt(i);
8047 } 8047 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
8259 Isolate::Current()->megamorphic_cache_table()->miss_handler()); 8259 Isolate::Current()->megamorphic_cache_table()->miss_handler());
8260 for (intptr_t i = 0; i < new_capacity; ++i) { 8260 for (intptr_t i = 0; i < new_capacity; ++i) {
8261 SetEntry(new_buckets, i, class_id, target); 8261 SetEntry(new_buckets, i, class_id, target);
8262 } 8262 }
8263 set_buckets(new_buckets); 8263 set_buckets(new_buckets);
8264 set_mask(new_capacity - 1); 8264 set_mask(new_capacity - 1);
8265 set_filled_entry_count(0); 8265 set_filled_entry_count(0);
8266 8266
8267 // Rehash the valid entries. 8267 // Rehash the valid entries.
8268 for (intptr_t i = 0; i < old_capacity; ++i) { 8268 for (intptr_t i = 0; i < old_capacity; ++i) {
8269 class_id |= GetClassId(old_buckets, i); 8269 class_id ^= GetClassId(old_buckets, i);
8270 if (class_id.Value() != kIllegalCid) { 8270 if (class_id.Value() != kIllegalCid) {
8271 target |= GetTargetFunction(old_buckets, i); 8271 target ^= GetTargetFunction(old_buckets, i);
8272 Insert(class_id, target); 8272 Insert(class_id, target);
8273 } 8273 }
8274 } 8274 }
8275 } 8275 }
8276 } 8276 }
8277 8277
8278 8278
8279 void MegamorphicCache::Insert(const Smi& class_id, 8279 void MegamorphicCache::Insert(const Smi& class_id,
8280 const Function& target) const { 8280 const Function& target) const {
8281 ASSERT(static_cast<double>(filled_entry_count() + 1) <= 8281 ASSERT(static_cast<double>(filled_entry_count() + 1) <=
8282 (kLoadFactor * static_cast<double>(mask() + 1))); 8282 (kLoadFactor * static_cast<double>(mask() + 1)));
8283 const Array& backing_array = Array::Handle(buckets()); 8283 const Array& backing_array = Array::Handle(buckets());
8284 intptr_t id_mask = mask(); 8284 intptr_t id_mask = mask();
8285 intptr_t index = class_id.Value() & id_mask; 8285 intptr_t index = class_id.Value() & id_mask;
8286 Smi& probe = Smi::Handle(); 8286 Smi& probe = Smi::Handle();
8287 intptr_t i = index; 8287 intptr_t i = index;
8288 do { 8288 do {
8289 probe |= GetClassId(backing_array, i); 8289 probe ^= GetClassId(backing_array, i);
8290 if (probe.Value() == kIllegalCid) { 8290 if (probe.Value() == kIllegalCid) {
8291 SetEntry(backing_array, i, class_id, target); 8291 SetEntry(backing_array, i, class_id, target);
8292 set_filled_entry_count(filled_entry_count() + 1); 8292 set_filled_entry_count(filled_entry_count() + 1);
8293 return; 8293 return;
8294 } 8294 }
8295 i = (i + 1) & id_mask; 8295 i = (i + 1) & id_mask;
8296 } while (i != index); 8296 } while (i != index);
8297 UNREACHABLE(); 8297 UNREACHABLE();
8298 } 8298 }
8299 8299
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
8354 8354
8355 void SubtypeTestCache::GetCheck( 8355 void SubtypeTestCache::GetCheck(
8356 intptr_t ix, 8356 intptr_t ix,
8357 intptr_t* instance_class_id, 8357 intptr_t* instance_class_id,
8358 AbstractTypeArguments* instance_type_arguments, 8358 AbstractTypeArguments* instance_type_arguments,
8359 AbstractTypeArguments* instantiator_type_arguments, 8359 AbstractTypeArguments* instantiator_type_arguments,
8360 Bool* test_result) const { 8360 Bool* test_result) const {
8361 Array& data = Array::Handle(cache()); 8361 Array& data = Array::Handle(cache());
8362 intptr_t data_pos = ix * kTestEntryLength; 8362 intptr_t data_pos = ix * kTestEntryLength;
8363 Smi& instance_class_id_handle = Smi::Handle(); 8363 Smi& instance_class_id_handle = Smi::Handle();
8364 instance_class_id_handle |= data.At(data_pos + kInstanceClassId); 8364 instance_class_id_handle ^= data.At(data_pos + kInstanceClassId);
8365 *instance_class_id = instance_class_id_handle.Value(); 8365 *instance_class_id = instance_class_id_handle.Value();
8366 *instance_type_arguments ^= data.At(data_pos + kInstanceTypeArguments); 8366 *instance_type_arguments ^= data.At(data_pos + kInstanceTypeArguments);
8367 *instantiator_type_arguments ^= 8367 *instantiator_type_arguments ^=
8368 data.At(data_pos + kInstantiatorTypeArguments); 8368 data.At(data_pos + kInstantiatorTypeArguments);
8369 *test_result |= data.At(data_pos + kTestResult); 8369 *test_result ^= data.At(data_pos + kTestResult);
8370 } 8370 }
8371 8371
8372 8372
8373 const char* SubtypeTestCache::ToCString() const { 8373 const char* SubtypeTestCache::ToCString() const {
8374 return "SubtypeTestCache"; 8374 return "SubtypeTestCache";
8375 } 8375 }
8376 8376
8377 8377
8378 const char* Error::ToErrorCString() const { 8378 const char* Error::ToErrorCString() const {
8379 UNREACHABLE(); 8379 UNREACHABLE();
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
9675 int Integer::CompareWith(const Integer& other) const { 9675 int Integer::CompareWith(const Integer& other) const {
9676 UNIMPLEMENTED(); 9676 UNIMPLEMENTED();
9677 return 0; 9677 return 0;
9678 } 9678 }
9679 9679
9680 9680
9681 RawInteger* Integer::AsValidInteger() const { 9681 RawInteger* Integer::AsValidInteger() const {
9682 if (IsSmi()) return raw(); 9682 if (IsSmi()) return raw();
9683 if (IsMint()) { 9683 if (IsMint()) {
9684 Mint& mint = Mint::Handle(); 9684 Mint& mint = Mint::Handle();
9685 mint |= raw(); 9685 mint ^= raw();
9686 if (Smi::IsValid64(mint.value())) { 9686 if (Smi::IsValid64(mint.value())) {
9687 return Smi::New(mint.value()); 9687 return Smi::New(mint.value());
9688 } else { 9688 } else {
9689 return raw(); 9689 return raw();
9690 } 9690 }
9691 } 9691 }
9692 ASSERT(IsBigint()); 9692 ASSERT(IsBigint());
9693 Bigint& big_value = Bigint::Handle(); 9693 Bigint& big_value = Bigint::Handle();
9694 big_value |= raw(); 9694 big_value ^= raw();
9695 if (BigintOperations::FitsIntoSmi(big_value)) { 9695 if (BigintOperations::FitsIntoSmi(big_value)) {
9696 return BigintOperations::ToSmi(big_value); 9696 return BigintOperations::ToSmi(big_value);
9697 } else if (BigintOperations::FitsIntoMint(big_value)) { 9697 } else if (BigintOperations::FitsIntoMint(big_value)) {
9698 return Mint::New(BigintOperations::ToMint(big_value)); 9698 return Mint::New(BigintOperations::ToMint(big_value));
9699 } else { 9699 } else {
9700 return big_value.raw(); 9700 return big_value.raw();
9701 } 9701 }
9702 } 9702 }
9703 9703
9704 9704
9705 RawInteger* Integer::ArithmeticOp(Token::Kind operation, 9705 RawInteger* Integer::ArithmeticOp(Token::Kind operation,
9706 const Integer& other) const { 9706 const Integer& other) const {
9707 // In 32-bit mode, the result of any operation between two Smis will fit in a 9707 // In 32-bit mode, the result of any operation between two Smis will fit in a
9708 // 32-bit signed result, except the product of two Smis, which will be 64-bit. 9708 // 32-bit signed result, except the product of two Smis, which will be 64-bit.
9709 // In 64-bit mode, the result of any operation between two Smis will fit in a 9709 // In 64-bit mode, the result of any operation between two Smis will fit in a
9710 // 64-bit signed result, except the product of two Smis (unless the Smis are 9710 // 64-bit signed result, except the product of two Smis (unless the Smis are
9711 // 32-bit or less). 9711 // 32-bit or less).
9712 if (IsSmi() && other.IsSmi()) { 9712 if (IsSmi() && other.IsSmi()) {
9713 Smi& left_smi = Smi::Handle(); 9713 Smi& left_smi = Smi::Handle();
9714 Smi& right_smi = Smi::Handle(); 9714 Smi& right_smi = Smi::Handle();
9715 left_smi |= raw(); 9715 left_smi ^= raw();
9716 right_smi |= other.raw(); 9716 right_smi ^= other.raw();
9717 const intptr_t left_value = left_smi.Value(); 9717 const intptr_t left_value = left_smi.Value();
9718 const intptr_t right_value = right_smi.Value(); 9718 const intptr_t right_value = right_smi.Value();
9719 switch (operation) { 9719 switch (operation) {
9720 case Token::kADD: 9720 case Token::kADD:
9721 return Integer::New(left_value + right_value); 9721 return Integer::New(left_value + right_value);
9722 case Token::kSUB: 9722 case Token::kSUB:
9723 return Integer::New(left_value - right_value); 9723 return Integer::New(left_value - right_value);
9724 case Token::kMUL: { 9724 case Token::kMUL: {
9725 if (Smi::kBits < 32) { 9725 if (Smi::kBits < 32) {
9726 // In 32-bit mode, the product of two Smis fits in a 64-bit result. 9726 // In 32-bit mode, the product of two Smis fits in a 64-bit result.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
9803 9803
9804 static bool Are64bitOperands(const Integer& op1, const Integer& op2) { 9804 static bool Are64bitOperands(const Integer& op1, const Integer& op2) {
9805 return !op1.IsBigint() && !op2.IsBigint(); 9805 return !op1.IsBigint() && !op2.IsBigint();
9806 } 9806 }
9807 9807
9808 9808
9809 RawInteger* Integer::BitOp(Token::Kind kind, const Integer& other) const { 9809 RawInteger* Integer::BitOp(Token::Kind kind, const Integer& other) const {
9810 if (IsSmi() && other.IsSmi()) { 9810 if (IsSmi() && other.IsSmi()) {
9811 Smi& op1 = Smi::Handle(); 9811 Smi& op1 = Smi::Handle();
9812 Smi& op2 = Smi::Handle(); 9812 Smi& op2 = Smi::Handle();
9813 op1 |= raw(); 9813 op1 ^= raw();
9814 op2 |= other.raw(); 9814 op2 ^= other.raw();
9815 intptr_t result = 0; 9815 intptr_t result = 0;
9816 switch (kind) { 9816 switch (kind) {
9817 case Token::kBIT_AND: 9817 case Token::kBIT_AND:
9818 result = op1.Value() & op2.Value(); 9818 result = op1.Value() & op2.Value();
9819 break; 9819 break;
9820 case Token::kBIT_OR: 9820 case Token::kBIT_OR:
9821 result = op1.Value() | op2.Value(); 9821 result = op1.Value() | op2.Value();
9822 break; 9822 break;
9823 case Token::kBIT_XOR: 9823 case Token::kBIT_XOR:
9824 result = op1.Value() ^ op2.Value(); 9824 result = op1.Value() ^ op2.Value();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
9998 ASSERT(!Smi::IsValid64(value)); 9998 ASSERT(!Smi::IsValid64(value));
9999 const Class& cls = 9999 const Class& cls =
10000 Class::Handle(Isolate::Current()->object_store()->mint_class()); 10000 Class::Handle(Isolate::Current()->object_store()->mint_class());
10001 const Array& constants = Array::Handle(cls.constants()); 10001 const Array& constants = Array::Handle(cls.constants());
10002 const intptr_t constants_len = constants.Length(); 10002 const intptr_t constants_len = constants.Length();
10003 // Linear search to see whether this value is already present in the 10003 // Linear search to see whether this value is already present in the
10004 // list of canonicalized constants. 10004 // list of canonicalized constants.
10005 Mint& canonical_value = Mint::Handle(); 10005 Mint& canonical_value = Mint::Handle();
10006 intptr_t index = 0; 10006 intptr_t index = 0;
10007 while (index < constants_len) { 10007 while (index < constants_len) {
10008 canonical_value |= constants.At(index); 10008 canonical_value ^= constants.At(index);
10009 if (canonical_value.IsNull()) { 10009 if (canonical_value.IsNull()) {
10010 break; 10010 break;
10011 } 10011 }
10012 if (canonical_value.value() == value) { 10012 if (canonical_value.value() == value) {
10013 return canonical_value.raw(); 10013 return canonical_value.raw();
10014 } 10014 }
10015 index++; 10015 index++;
10016 } 10016 }
10017 // The value needs to be added to the constants list. Grow the list if 10017 // The value needs to be added to the constants list. Grow the list if
10018 // it is full. 10018 // it is full.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
10152 RawDouble* Double::NewCanonical(double value) { 10152 RawDouble* Double::NewCanonical(double value) {
10153 const Class& cls = 10153 const Class& cls =
10154 Class::Handle(Isolate::Current()->object_store()->double_class()); 10154 Class::Handle(Isolate::Current()->object_store()->double_class());
10155 const Array& constants = Array::Handle(cls.constants()); 10155 const Array& constants = Array::Handle(cls.constants());
10156 const intptr_t constants_len = constants.Length(); 10156 const intptr_t constants_len = constants.Length();
10157 // Linear search to see whether this value is already present in the 10157 // Linear search to see whether this value is already present in the
10158 // list of canonicalized constants. 10158 // list of canonicalized constants.
10159 Double& canonical_value = Double::Handle(); 10159 Double& canonical_value = Double::Handle();
10160 intptr_t index = 0; 10160 intptr_t index = 0;
10161 while (index < constants_len) { 10161 while (index < constants_len) {
10162 canonical_value |= constants.At(index); 10162 canonical_value ^= constants.At(index);
10163 if (canonical_value.IsNull()) { 10163 if (canonical_value.IsNull()) {
10164 break; 10164 break;
10165 } 10165 }
10166 if (canonical_value.EqualsToDouble(value)) { 10166 if (canonical_value.EqualsToDouble(value)) {
10167 return canonical_value.raw(); 10167 return canonical_value.raw();
10168 } 10168 }
10169 index++; 10169 index++;
10170 } 10170 }
10171 // The value needs to be added to the constants list. Grow the list if 10171 // The value needs to be added to the constants list. Grow the list if
10172 // it is full. 10172 // it is full.
(...skipping 25 matching lines...) Expand all
10198 buffer[kBufferSize - 1] = '\0'; 10198 buffer[kBufferSize - 1] = '\0';
10199 DoubleToCString(value(), buffer, kBufferSize); 10199 DoubleToCString(value(), buffer, kBufferSize);
10200 return buffer; 10200 return buffer;
10201 } 10201 }
10202 10202
10203 10203
10204 RawBigint* Integer::AsBigint() const { 10204 RawBigint* Integer::AsBigint() const {
10205 ASSERT(!IsNull()); 10205 ASSERT(!IsNull());
10206 if (IsSmi()) { 10206 if (IsSmi()) {
10207 Smi& smi = Smi::Handle(); 10207 Smi& smi = Smi::Handle();
10208 smi |= raw(); 10208 smi ^= raw();
10209 return BigintOperations::NewFromSmi(smi); 10209 return BigintOperations::NewFromSmi(smi);
10210 } else if (IsMint()) { 10210 } else if (IsMint()) {
10211 Mint& mint = Mint::Handle(); 10211 Mint& mint = Mint::Handle();
10212 mint |= raw(); 10212 mint ^= raw();
10213 return BigintOperations::NewFromInt64(mint.value()); 10213 return BigintOperations::NewFromInt64(mint.value());
10214 } else { 10214 } else {
10215 ASSERT(IsBigint()); 10215 ASSERT(IsBigint());
10216 Bigint& big = Bigint::Handle(); 10216 Bigint& big = Bigint::Handle();
10217 big |= raw(); 10217 big ^= raw();
10218 ASSERT(!BigintOperations::FitsIntoSmi(big)); 10218 ASSERT(!BigintOperations::FitsIntoSmi(big));
10219 return big.raw(); 10219 return big.raw();
10220 } 10220 }
10221 } 10221 }
10222 10222
10223 10223
10224 RawBigint* Bigint::ArithmeticOp(Token::Kind operation, 10224 RawBigint* Bigint::ArithmeticOp(Token::Kind operation,
10225 const Bigint& other) const { 10225 const Bigint& other) const {
10226 switch (operation) { 10226 switch (operation) {
10227 case Token::kADD: 10227 case Token::kADD:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
10285 ASSERT(!BigintOperations::FitsIntoMint(value)); 10285 ASSERT(!BigintOperations::FitsIntoMint(value));
10286 const Class& cls = 10286 const Class& cls =
10287 Class::Handle(Isolate::Current()->object_store()->bigint_class()); 10287 Class::Handle(Isolate::Current()->object_store()->bigint_class());
10288 const Array& constants = Array::Handle(cls.constants()); 10288 const Array& constants = Array::Handle(cls.constants());
10289 const intptr_t constants_len = constants.Length(); 10289 const intptr_t constants_len = constants.Length();
10290 // Linear search to see whether this value is already present in the 10290 // Linear search to see whether this value is already present in the
10291 // list of canonicalized constants. 10291 // list of canonicalized constants.
10292 Bigint& canonical_value = Bigint::Handle(); 10292 Bigint& canonical_value = Bigint::Handle();
10293 intptr_t index = 0; 10293 intptr_t index = 0;
10294 while (index < constants_len) { 10294 while (index < constants_len) {
10295 canonical_value |= constants.At(index); 10295 canonical_value ^= constants.At(index);
10296 if (canonical_value.IsNull()) { 10296 if (canonical_value.IsNull()) {
10297 break; 10297 break;
10298 } 10298 }
10299 if (canonical_value.Equals(value)) { 10299 if (canonical_value.Equals(value)) {
10300 return canonical_value.raw(); 10300 return canonical_value.raw();
10301 } 10301 }
10302 index++; 10302 index++;
10303 } 10303 }
10304 // The value needs to be added to the constants list. Grow the list if 10304 // The value needs to be added to the constants list. Grow the list if
10305 // it is full. 10305 // it is full.
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
10681 10681
10682 RawString* String::New(const String& str, Heap::Space space) { 10682 RawString* String::New(const String& str, Heap::Space space) {
10683 // Currently this just creates a copy of the string in the correct space. 10683 // Currently this just creates a copy of the string in the correct space.
10684 // Once we have external string support, this will also create a heap copy of 10684 // Once we have external string support, this will also create a heap copy of
10685 // the string if necessary. Some optimizations are possible, such as not 10685 // the string if necessary. Some optimizations are possible, such as not
10686 // copying internal strings into the same space. 10686 // copying internal strings into the same space.
10687 intptr_t len = str.Length(); 10687 intptr_t len = str.Length();
10688 String& result = String::Handle(); 10688 String& result = String::Handle();
10689 intptr_t char_size = str.CharSize(); 10689 intptr_t char_size = str.CharSize();
10690 if (char_size == kOneByteChar) { 10690 if (char_size == kOneByteChar) {
10691 result |= OneByteString::New(len, space); 10691 result = OneByteString::New(len, space);
10692 } else { 10692 } else {
10693 ASSERT(char_size == kTwoByteChar); 10693 ASSERT(char_size == kTwoByteChar);
10694 result |= TwoByteString::New(len, space); 10694 result = TwoByteString::New(len, space);
10695 } 10695 }
10696 String::Copy(result, 0, str, 0, len); 10696 String::Copy(result, 0, str, 0, len);
10697 return result.raw(); 10697 return result.raw();
10698 } 10698 }
10699 10699
10700 10700
10701 RawString* String::NewExternal(const uint8_t* characters, 10701 RawString* String::NewExternal(const uint8_t* characters,
10702 intptr_t len, 10702 intptr_t len,
10703 void* peer, 10703 void* peer,
10704 Dart_PeerFinalizer callback, 10704 Dart_PeerFinalizer callback,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
10853 10853
10854 10854
10855 RawString* String::ConcatAll(const Array& strings, 10855 RawString* String::ConcatAll(const Array& strings,
10856 Heap::Space space) { 10856 Heap::Space space) {
10857 ASSERT(!strings.IsNull()); 10857 ASSERT(!strings.IsNull());
10858 intptr_t result_len = 0; 10858 intptr_t result_len = 0;
10859 intptr_t strings_len = strings.Length(); 10859 intptr_t strings_len = strings.Length();
10860 String& str = String::Handle(); 10860 String& str = String::Handle();
10861 intptr_t char_size = kOneByteChar; 10861 intptr_t char_size = kOneByteChar;
10862 for (intptr_t i = 0; i < strings_len; i++) { 10862 for (intptr_t i = 0; i < strings_len; i++) {
10863 str |= strings.At(i); 10863 str ^= strings.At(i);
10864 result_len += str.Length(); 10864 result_len += str.Length();
10865 char_size = Utils::Maximum(char_size, str.CharSize()); 10865 char_size = Utils::Maximum(char_size, str.CharSize());
10866 } 10866 }
10867 if (char_size == kOneByteChar) { 10867 if (char_size == kOneByteChar) {
10868 return OneByteString::ConcatAll(strings, result_len, space); 10868 return OneByteString::ConcatAll(strings, result_len, space);
10869 } 10869 }
10870 ASSERT(char_size == kTwoByteChar); 10870 ASSERT(char_size == kTwoByteChar);
10871 return TwoByteString::ConcatAll(strings, result_len, space); 10871 return TwoByteString::ConcatAll(strings, result_len, space);
10872 } 10872 }
10873 10873
(...skipping 27 matching lines...) Expand all
10901 intptr_t char_size = str.CharSize(); 10901 intptr_t char_size = str.CharSize();
10902 if (char_size == kTwoByteChar) { 10902 if (char_size == kTwoByteChar) {
10903 for (intptr_t i = begin_index; i < begin_index + length; ++i) { 10903 for (intptr_t i = begin_index; i < begin_index + length; ++i) {
10904 if (!Utf::IsLatin1(str.CharAt(i))) { 10904 if (!Utf::IsLatin1(str.CharAt(i))) {
10905 is_one_byte_string = false; 10905 is_one_byte_string = false;
10906 break; 10906 break;
10907 } 10907 }
10908 } 10908 }
10909 } 10909 }
10910 if (is_one_byte_string) { 10910 if (is_one_byte_string) {
10911 result |= OneByteString::New(length, space); 10911 result = OneByteString::New(length, space);
10912 } else { 10912 } else {
10913 result |= TwoByteString::New(length, space); 10913 result = TwoByteString::New(length, space);
10914 } 10914 }
10915 String::Copy(result, 0, str, begin_index, length); 10915 String::Copy(result, 0, str, begin_index, length);
10916 return result.raw(); 10916 return result.raw();
10917 } 10917 }
10918 10918
10919 10919
10920 const char* String::ToCString() const { 10920 const char* String::ToCString() const {
10921 intptr_t len = Utf8::Length(*this); 10921 intptr_t len = Utf8::Length(*this);
10922 Zone* zone = Isolate::Current()->current_zone(); 10922 Zone* zone = Isolate::Current()->current_zone();
10923 uint8_t* result = zone->Alloc<uint8_t>(len + 1); 10923 uint8_t* result = zone->Alloc<uint8_t>(len + 1);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
11265 11265
11266 11266
11267 RawOneByteString* OneByteString::ConcatAll(const Array& strings, 11267 RawOneByteString* OneByteString::ConcatAll(const Array& strings,
11268 intptr_t len, 11268 intptr_t len,
11269 Heap::Space space) { 11269 Heap::Space space) {
11270 const String& result = String::Handle(OneByteString::New(len, space)); 11270 const String& result = String::Handle(OneByteString::New(len, space));
11271 String& str = String::Handle(); 11271 String& str = String::Handle();
11272 intptr_t strings_len = strings.Length(); 11272 intptr_t strings_len = strings.Length();
11273 intptr_t pos = 0; 11273 intptr_t pos = 0;
11274 for (intptr_t i = 0; i < strings_len; i++) { 11274 for (intptr_t i = 0; i < strings_len; i++) {
11275 str |= strings.At(i); 11275 str ^= strings.At(i);
11276 intptr_t str_len = str.Length(); 11276 intptr_t str_len = str.Length();
11277 String::Copy(result, pos, str, 0, str_len); 11277 String::Copy(result, pos, str, 0, str_len);
11278 pos += str_len; 11278 pos += str_len;
11279 } 11279 }
11280 return OneByteString::raw(result); 11280 return OneByteString::raw(result);
11281 } 11281 }
11282 11282
11283 11283
11284 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch), 11284 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch),
11285 const String& str, 11285 const String& str,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
11434 11434
11435 11435
11436 RawTwoByteString* TwoByteString::ConcatAll(const Array& strings, 11436 RawTwoByteString* TwoByteString::ConcatAll(const Array& strings,
11437 intptr_t len, 11437 intptr_t len,
11438 Heap::Space space) { 11438 Heap::Space space) {
11439 const String& result = String::Handle(TwoByteString::New(len, space)); 11439 const String& result = String::Handle(TwoByteString::New(len, space));
11440 String& str = String::Handle(); 11440 String& str = String::Handle();
11441 intptr_t strings_len = strings.Length(); 11441 intptr_t strings_len = strings.Length();
11442 intptr_t pos = 0; 11442 intptr_t pos = 0;
11443 for (intptr_t i = 0; i < strings_len; i++) { 11443 for (intptr_t i = 0; i < strings_len; i++) {
11444 str |= strings.At(i); 11444 str ^= strings.At(i);
11445 intptr_t str_len = str.Length(); 11445 intptr_t str_len = str.Length();
11446 String::Copy(result, pos, str, 0, str_len); 11446 String::Copy(result, pos, str, 0, str_len);
11447 pos += str_len; 11447 pos += str_len;
11448 } 11448 }
11449 return TwoByteString::raw(result); 11449 return TwoByteString::raw(result);
11450 } 11450 }
11451 11451
11452 11452
11453 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch), 11453 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch),
11454 const String& str, 11454 const String& str,
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after
12618 12618
12619 void* JSRegExp::GetDataStartAddress() const { 12619 void* JSRegExp::GetDataStartAddress() const {
12620 intptr_t addr = reinterpret_cast<intptr_t>(raw_ptr()); 12620 intptr_t addr = reinterpret_cast<intptr_t>(raw_ptr());
12621 return reinterpret_cast<void*>(addr + sizeof(RawJSRegExp)); 12621 return reinterpret_cast<void*>(addr + sizeof(RawJSRegExp));
12622 } 12622 }
12623 12623
12624 12624
12625 RawJSRegExp* JSRegExp::FromDataStartAddress(void* data) { 12625 RawJSRegExp* JSRegExp::FromDataStartAddress(void* data) {
12626 JSRegExp& regexp = JSRegExp::Handle(); 12626 JSRegExp& regexp = JSRegExp::Handle();
12627 intptr_t addr = reinterpret_cast<intptr_t>(data) - sizeof(RawJSRegExp); 12627 intptr_t addr = reinterpret_cast<intptr_t>(data) - sizeof(RawJSRegExp);
12628 regexp |= RawObject::FromAddr(addr); 12628 regexp ^= RawObject::FromAddr(addr);
12629 return regexp.raw(); 12629 return regexp.raw();
12630 } 12630 }
12631 12631
12632 12632
12633 const char* JSRegExp::Flags() const { 12633 const char* JSRegExp::Flags() const {
12634 switch (raw_ptr()->flags_) { 12634 switch (raw_ptr()->flags_) {
12635 case kGlobal | kIgnoreCase | kMultiLine : 12635 case kGlobal | kIgnoreCase | kMultiLine :
12636 case kIgnoreCase | kMultiLine : 12636 case kIgnoreCase | kMultiLine :
12637 return "im"; 12637 return "im";
12638 case kGlobal | kIgnoreCase : 12638 case kGlobal | kIgnoreCase :
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
12695 } 12695 }
12696 return result.raw(); 12696 return result.raw();
12697 } 12697 }
12698 12698
12699 12699
12700 const char* WeakProperty::ToCString() const { 12700 const char* WeakProperty::ToCString() const {
12701 return "_WeakProperty"; 12701 return "_WeakProperty";
12702 } 12702 }
12703 12703
12704 } // namespace dart 12704 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698