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

Side by Side Diff: src/objects-inl.h

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 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 | « src/objects-debug.cc ('k') | src/objects-printer.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 String::cast(this)->IsAsciiRepresentation(); 219 String::cast(this)->IsAsciiRepresentation();
220 } 220 }
221 221
222 222
223 bool Object::IsExternalTwoByteString() { 223 bool Object::IsExternalTwoByteString() {
224 if (!IsString()) return false; 224 if (!IsString()) return false;
225 return StringShape(String::cast(this)).IsExternal() && 225 return StringShape(String::cast(this)).IsExternal() &&
226 String::cast(this)->IsTwoByteRepresentation(); 226 String::cast(this)->IsTwoByteRepresentation();
227 } 227 }
228 228
229 bool Object::HasValidElements() {
230 // Dictionary is covered under FixedArray.
231 return IsFixedArray() || IsFixedDoubleArray() || IsExternalArray();
232 }
229 233
230 StringShape::StringShape(String* str) 234 StringShape::StringShape(String* str)
231 : type_(str->map()->instance_type()) { 235 : type_(str->map()->instance_type()) {
232 set_valid(); 236 set_valid();
233 ASSERT((type_ & kIsNotStringMask) == kStringTag); 237 ASSERT((type_ & kIsNotStringMask) == kStringTag);
234 } 238 }
235 239
236 240
237 StringShape::StringShape(Map* map) 241 StringShape::StringShape(Map* map)
238 : type_(map->instance_type()) { 242 : type_(map->instance_type()) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return !IsFailure() && ToObjectUnchecked()->IsTheHole(); 465 return !IsFailure() && ToObjectUnchecked()->IsTheHole();
462 } 466 }
463 467
464 468
465 Failure* Failure::cast(MaybeObject* obj) { 469 Failure* Failure::cast(MaybeObject* obj) {
466 ASSERT(HAS_FAILURE_TAG(obj)); 470 ASSERT(HAS_FAILURE_TAG(obj));
467 return reinterpret_cast<Failure*>(obj); 471 return reinterpret_cast<Failure*>(obj);
468 } 472 }
469 473
470 474
475 bool Object::IsJSReceiver() {
476 return IsHeapObject() &&
477 HeapObject::cast(this)->map()->instance_type() >= FIRST_JS_RECEIVER_TYPE;
478 }
479
480
471 bool Object::IsJSObject() { 481 bool Object::IsJSObject() {
472 return IsHeapObject() 482 return IsJSReceiver() && !IsJSProxy();
473 && HeapObject::cast(this)->map()->instance_type() >= FIRST_JS_OBJECT_TYPE; 483 }
484
485
486 bool Object::IsJSProxy() {
487 return Object::IsHeapObject() &&
488 (HeapObject::cast(this)->map()->instance_type() == JS_PROXY_TYPE ||
489 HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_PROXY_TYPE);
490 }
491
492
493 bool Object::IsJSFunctionProxy() {
494 return Object::IsHeapObject() &&
495 HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_PROXY_TYPE;
474 } 496 }
475 497
476 498
477 bool Object::IsJSContextExtensionObject() { 499 bool Object::IsJSContextExtensionObject() {
478 return IsHeapObject() 500 return IsHeapObject()
479 && (HeapObject::cast(this)->map()->instance_type() == 501 && (HeapObject::cast(this)->map()->instance_type() ==
480 JS_CONTEXT_EXTENSION_OBJECT_TYPE); 502 JS_CONTEXT_EXTENSION_OBJECT_TYPE);
481 } 503 }
482 504
483 505
484 bool Object::IsMap() { 506 bool Object::IsMap() {
485 return Object::IsHeapObject() 507 return Object::IsHeapObject()
486 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE; 508 && HeapObject::cast(this)->map()->instance_type() == MAP_TYPE;
487 } 509 }
488 510
489 511
490 bool Object::IsFixedArray() { 512 bool Object::IsFixedArray() {
491 return Object::IsHeapObject() 513 return Object::IsHeapObject()
492 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE; 514 && HeapObject::cast(this)->map()->instance_type() == FIXED_ARRAY_TYPE;
493 } 515 }
494 516
495 517
518 bool Object::IsFixedDoubleArray() {
519 return Object::IsHeapObject()
520 && HeapObject::cast(this)->map()->instance_type() ==
521 FIXED_DOUBLE_ARRAY_TYPE;
522 }
523
524
496 bool Object::IsDescriptorArray() { 525 bool Object::IsDescriptorArray() {
497 return IsFixedArray(); 526 return IsFixedArray();
498 } 527 }
499 528
500 529
501 bool Object::IsDeoptimizationInputData() { 530 bool Object::IsDeoptimizationInputData() {
502 // Must be a fixed array. 531 // Must be a fixed array.
503 if (!IsFixedArray()) return false; 532 if (!IsFixedArray()) return false;
504 533
505 // There's no sure way to detect the difference between a fixed array and 534 // There's no sure way to detect the difference between a fixed array and
(...skipping 14 matching lines...) Expand all
520 // There's actually no way to see the difference between a fixed array and 549 // There's actually no way to see the difference between a fixed array and
521 // a deoptimization data array. Since this is used for asserts we can check 550 // a deoptimization data array. Since this is used for asserts we can check
522 // that the length is plausible though. 551 // that the length is plausible though.
523 if (FixedArray::cast(this)->length() % 2 != 0) return false; 552 if (FixedArray::cast(this)->length() % 2 != 0) return false;
524 return true; 553 return true;
525 } 554 }
526 555
527 556
528 bool Object::IsContext() { 557 bool Object::IsContext() {
529 if (Object::IsHeapObject()) { 558 if (Object::IsHeapObject()) {
530 Heap* heap = HeapObject::cast(this)->GetHeap(); 559 Map* map = HeapObject::cast(this)->map();
531 return (HeapObject::cast(this)->map() == heap->context_map() || 560 Heap* heap = map->GetHeap();
532 HeapObject::cast(this)->map() == heap->catch_context_map() || 561 return (map == heap->function_context_map() ||
533 HeapObject::cast(this)->map() == heap->global_context_map()); 562 map == heap->catch_context_map() ||
563 map == heap->with_context_map() ||
564 map == heap->global_context_map());
534 } 565 }
535 return false; 566 return false;
536 } 567 }
537 568
538 569
539 bool Object::IsCatchContext() {
540 return Object::IsHeapObject() &&
541 HeapObject::cast(this)->map() ==
542 HeapObject::cast(this)->GetHeap()->catch_context_map();
543 }
544
545
546 bool Object::IsGlobalContext() { 570 bool Object::IsGlobalContext() {
547 return Object::IsHeapObject() && 571 return Object::IsHeapObject() &&
548 HeapObject::cast(this)->map() == 572 HeapObject::cast(this)->map() ==
549 HeapObject::cast(this)->GetHeap()->global_context_map(); 573 HeapObject::cast(this)->GetHeap()->global_context_map();
550 } 574 }
551 575
552 576
553 bool Object::IsJSFunction() { 577 bool Object::IsJSFunction() {
554 return Object::IsHeapObject() 578 return Object::IsHeapObject()
555 && HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_TYPE; 579 && HeapObject::cast(this)->map()->instance_type() == JS_FUNCTION_TYPE;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 && (HeapObject::cast(this)->map()->instance_type() == 622 && (HeapObject::cast(this)->map()->instance_type() ==
599 JS_MESSAGE_OBJECT_TYPE); 623 JS_MESSAGE_OBJECT_TYPE);
600 } 624 }
601 625
602 626
603 bool Object::IsStringWrapper() { 627 bool Object::IsStringWrapper() {
604 return IsJSValue() && JSValue::cast(this)->value()->IsString(); 628 return IsJSValue() && JSValue::cast(this)->value()->IsString();
605 } 629 }
606 630
607 631
608 bool Object::IsJSProxy() {
609 return Object::IsHeapObject()
610 && HeapObject::cast(this)->map()->instance_type() == JS_PROXY_TYPE;
611 }
612
613
614 bool Object::IsForeign() { 632 bool Object::IsForeign() {
615 return Object::IsHeapObject() 633 return Object::IsHeapObject()
616 && HeapObject::cast(this)->map()->instance_type() == FOREIGN_TYPE; 634 && HeapObject::cast(this)->map()->instance_type() == FOREIGN_TYPE;
617 } 635 }
618 636
619 637
620 bool Object::IsBoolean() { 638 bool Object::IsBoolean() {
621 return IsOddball() && 639 return IsOddball() &&
622 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0); 640 ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0);
623 } 641 }
(...skipping 17 matching lines...) Expand all
641 659
642 660
643 bool Object::IsHashTable() { 661 bool Object::IsHashTable() {
644 return Object::IsHeapObject() && 662 return Object::IsHeapObject() &&
645 HeapObject::cast(this)->map() == 663 HeapObject::cast(this)->map() ==
646 HeapObject::cast(this)->GetHeap()->hash_table_map(); 664 HeapObject::cast(this)->GetHeap()->hash_table_map();
647 } 665 }
648 666
649 667
650 bool Object::IsDictionary() { 668 bool Object::IsDictionary() {
651 return IsHashTable() && this != 669 return IsHashTable() &&
652 HeapObject::cast(this)->GetHeap()->symbol_table(); 670 this != HeapObject::cast(this)->GetHeap()->symbol_table();
653 } 671 }
654 672
655 673
656 bool Object::IsSymbolTable() { 674 bool Object::IsSymbolTable() {
657 return IsHashTable() && this == 675 return IsHashTable() && this ==
658 HeapObject::cast(this)->GetHeap()->raw_unchecked_symbol_table(); 676 HeapObject::cast(this)->GetHeap()->raw_unchecked_symbol_table();
659 } 677 }
660 678
661 679
662 bool Object::IsJSFunctionResultCache() { 680 bool Object::IsJSFunctionResultCache() {
(...skipping 27 matching lines...) Expand all
690 bool Object::IsCompilationCacheTable() { 708 bool Object::IsCompilationCacheTable() {
691 return IsHashTable(); 709 return IsHashTable();
692 } 710 }
693 711
694 712
695 bool Object::IsCodeCacheHashTable() { 713 bool Object::IsCodeCacheHashTable() {
696 return IsHashTable(); 714 return IsHashTable();
697 } 715 }
698 716
699 717
718 bool Object::IsPolymorphicCodeCacheHashTable() {
719 return IsHashTable();
720 }
721
722
700 bool Object::IsMapCache() { 723 bool Object::IsMapCache() {
701 return IsHashTable(); 724 return IsHashTable();
702 } 725 }
703 726
704 727
705 bool Object::IsPrimitive() { 728 bool Object::IsPrimitive() {
706 return IsOddball() || IsNumber() || IsString(); 729 return IsOddball() || IsNumber() || IsString();
707 } 730 }
708 731
709 732
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 if (heap->InNewSpace(value)) { \ 894 if (heap->InNewSpace(value)) { \
872 heap->RecordWrite(object->address(), offset); \ 895 heap->RecordWrite(object->address(), offset); \
873 } 896 }
874 897
875 #ifndef V8_TARGET_ARCH_MIPS 898 #ifndef V8_TARGET_ARCH_MIPS
876 #define READ_DOUBLE_FIELD(p, offset) \ 899 #define READ_DOUBLE_FIELD(p, offset) \
877 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset))) 900 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)))
878 #else // V8_TARGET_ARCH_MIPS 901 #else // V8_TARGET_ARCH_MIPS
879 // Prevent gcc from using load-double (mips ldc1) on (possibly) 902 // Prevent gcc from using load-double (mips ldc1) on (possibly)
880 // non-64-bit aligned HeapNumber::value. 903 // non-64-bit aligned HeapNumber::value.
881 static inline double read_double_field(HeapNumber* p, int offset) { 904 static inline double read_double_field(void* p, int offset) {
882 union conversion { 905 union conversion {
883 double d; 906 double d;
884 uint32_t u[2]; 907 uint32_t u[2];
885 } c; 908 } c;
886 c.u[0] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset))); 909 c.u[0] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)));
887 c.u[1] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset + 4))); 910 c.u[1] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset + 4)));
888 return c.d; 911 return c.d;
889 } 912 }
890 #define READ_DOUBLE_FIELD(p, offset) read_double_field(p, offset) 913 #define READ_DOUBLE_FIELD(p, offset) read_double_field(p, offset)
891 #endif // V8_TARGET_ARCH_MIPS 914 #endif // V8_TARGET_ARCH_MIPS
892 915
893 916
894 #define READ_DOUBLE_FIELD(p, offset) \ 917 #define READ_DOUBLE_FIELD(p, offset) \
895 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset))) 918 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)))
896 919
897 920
898 #ifndef V8_TARGET_ARCH_MIPS 921 #ifndef V8_TARGET_ARCH_MIPS
899 #define WRITE_DOUBLE_FIELD(p, offset, value) \ 922 #define WRITE_DOUBLE_FIELD(p, offset, value) \
900 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value) 923 (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value)
901 #else // V8_TARGET_ARCH_MIPS 924 #else // V8_TARGET_ARCH_MIPS
902 // Prevent gcc from using store-double (mips sdc1) on (possibly) 925 // Prevent gcc from using store-double (mips sdc1) on (possibly)
903 // non-64-bit aligned HeapNumber::value. 926 // non-64-bit aligned HeapNumber::value.
904 static inline void write_double_field(HeapNumber* p, int offset, 927 static inline void write_double_field(void* p, int offset,
905 double value) { 928 double value) {
906 union conversion { 929 union conversion {
907 double d; 930 double d;
908 uint32_t u[2]; 931 uint32_t u[2];
909 } c; 932 } c;
910 c.d = value; 933 c.d = value;
911 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset))) = c.u[0]; 934 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset))) = c.u[0];
912 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset + 4))) = c.u[1]; 935 (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset + 4))) = c.u[1];
913 } 936 }
914 #define WRITE_DOUBLE_FIELD(p, offset, value) \ 937 #define WRITE_DOUBLE_FIELD(p, offset, value) \
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 int HeapNumber::get_sign() { 1207 int HeapNumber::get_sign() {
1185 return READ_INT_FIELD(this, kExponentOffset) & kSignMask; 1208 return READ_INT_FIELD(this, kExponentOffset) & kSignMask;
1186 } 1209 }
1187 1210
1188 1211
1189 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset) 1212 ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset)
1190 1213
1191 1214
1192 HeapObject* JSObject::elements() { 1215 HeapObject* JSObject::elements() {
1193 Object* array = READ_FIELD(this, kElementsOffset); 1216 Object* array = READ_FIELD(this, kElementsOffset);
1194 // In the assert below Dictionary is covered under FixedArray. 1217 ASSERT(array->HasValidElements());
1195 ASSERT(array->IsFixedArray() || array->IsExternalArray());
1196 return reinterpret_cast<HeapObject*>(array); 1218 return reinterpret_cast<HeapObject*>(array);
1197 } 1219 }
1198 1220
1199 1221
1200 void JSObject::set_elements(HeapObject* value, WriteBarrierMode mode) { 1222 void JSObject::set_elements(HeapObject* value, WriteBarrierMode mode) {
1201 ASSERT(map()->has_fast_elements() == 1223 ASSERT(map()->has_fast_elements() ==
1202 (value->map() == GetHeap()->fixed_array_map() || 1224 (value->map() == GetHeap()->fixed_array_map() ||
1203 value->map() == GetHeap()->fixed_cow_array_map())); 1225 value->map() == GetHeap()->fixed_cow_array_map()));
1204 // In the assert below Dictionary is covered under FixedArray. 1226 ASSERT(value->HasValidElements());
1205 ASSERT(value->IsFixedArray() || value->IsExternalArray());
1206 WRITE_FIELD(this, kElementsOffset, value); 1227 WRITE_FIELD(this, kElementsOffset, value);
1207 WRITE_BARRIER(GetHeap(), this, kElementsOffset, value); 1228 WRITE_BARRIER(GetHeap(), this, kElementsOffset, value);
1208 } 1229 }
1209 1230
1210 1231
1211 void JSObject::initialize_properties() { 1232 void JSObject::initialize_properties() {
1212 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array())); 1233 ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
1213 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array()); 1234 WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array());
1214 } 1235 }
1215 1236
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 JSValue* js_value = JSValue::cast(this); 1466 JSValue* js_value = JSValue::cast(this);
1446 if (!js_value->value()->IsString()) return false; 1467 if (!js_value->value()->IsString()) return false;
1447 1468
1448 String* str = String::cast(js_value->value()); 1469 String* str = String::cast(js_value->value());
1449 if (index >= (uint32_t)str->length()) return false; 1470 if (index >= (uint32_t)str->length()) return false;
1450 1471
1451 return true; 1472 return true;
1452 } 1473 }
1453 1474
1454 1475
1476 FixedArrayBase* FixedArrayBase::cast(Object* object) {
1477 ASSERT(object->IsFixedArray() || object->IsFixedDoubleArray());
1478 return reinterpret_cast<FixedArrayBase*>(object);
1479 }
1480
1481
1455 Object* FixedArray::get(int index) { 1482 Object* FixedArray::get(int index) {
1456 ASSERT(index >= 0 && index < this->length()); 1483 ASSERT(index >= 0 && index < this->length());
1457 return READ_FIELD(this, kHeaderSize + index * kPointerSize); 1484 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
1458 } 1485 }
1459 1486
1460 1487
1461 void FixedArray::set(int index, Smi* value) { 1488 void FixedArray::set(int index, Smi* value) {
1462 ASSERT(map() != HEAP->fixed_cow_array_map()); 1489 ASSERT(map() != HEAP->fixed_cow_array_map());
1463 ASSERT(reinterpret_cast<Object*>(value)->IsSmi()); 1490 ASSERT(reinterpret_cast<Object*>(value)->IsSmi());
1464 int offset = kHeaderSize + index * kPointerSize; 1491 int offset = kHeaderSize + index * kPointerSize;
1465 WRITE_FIELD(this, offset, value); 1492 WRITE_FIELD(this, offset, value);
1466 } 1493 }
1467 1494
1468 1495
1469 void FixedArray::set(int index, Object* value) { 1496 void FixedArray::set(int index, Object* value) {
1470 ASSERT(map() != HEAP->fixed_cow_array_map()); 1497 ASSERT(map() != HEAP->fixed_cow_array_map());
1471 ASSERT(index >= 0 && index < this->length()); 1498 ASSERT(index >= 0 && index < this->length());
1472 int offset = kHeaderSize + index * kPointerSize; 1499 int offset = kHeaderSize + index * kPointerSize;
1473 WRITE_FIELD(this, offset, value); 1500 WRITE_FIELD(this, offset, value);
1474 WRITE_BARRIER(GetHeap(), this, offset, value); 1501 WRITE_BARRIER(GetHeap(), this, offset, value);
1475 } 1502 }
1476 1503
1477 1504
1505 double FixedDoubleArray::get(int index) {
1506 ASSERT(map() != HEAP->fixed_cow_array_map() &&
1507 map() != HEAP->fixed_array_map());
1508 ASSERT(index >= 0 && index < this->length());
1509 double result = READ_DOUBLE_FIELD(this, kHeaderSize + index * kDoubleSize);
1510 ASSERT(!is_the_hole_nan(result));
1511 return result;
1512 }
1513
1514
1515 void FixedDoubleArray::set(int index, double value) {
1516 ASSERT(map() != HEAP->fixed_cow_array_map() &&
1517 map() != HEAP->fixed_array_map());
1518 int offset = kHeaderSize + index * kDoubleSize;
1519 if (isnan(value)) value = canonical_not_the_hole_nan_as_double();
1520 WRITE_DOUBLE_FIELD(this, offset, value);
1521 }
1522
1523
1524 void FixedDoubleArray::set_the_hole(int index) {
1525 ASSERT(map() != HEAP->fixed_cow_array_map() &&
1526 map() != HEAP->fixed_array_map());
1527 int offset = kHeaderSize + index * kDoubleSize;
1528 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1529 }
1530
1531
1532 bool FixedDoubleArray::is_the_hole(int index) {
1533 int offset = kHeaderSize + index * kDoubleSize;
1534 return is_the_hole_nan(READ_DOUBLE_FIELD(this, offset));
1535 }
1536
1537
1538 void FixedDoubleArray::Initialize(FixedDoubleArray* from) {
1539 int old_length = from->length();
1540 ASSERT(old_length < length());
1541 OS::MemCopy(FIELD_ADDR(this, kHeaderSize),
1542 FIELD_ADDR(from, kHeaderSize),
1543 old_length * kDoubleSize);
1544 int offset = kHeaderSize + old_length * kDoubleSize;
1545 for (int current = from->length(); current < length(); ++current) {
1546 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1547 offset += kDoubleSize;
1548 }
1549 }
1550
1551
1552 void FixedDoubleArray::Initialize(FixedArray* from) {
1553 int old_length = from->length();
1554 ASSERT(old_length < length());
1555 for (int i = 0; i < old_length; i++) {
1556 Object* hole_or_object = from->get(i);
1557 if (hole_or_object->IsTheHole()) {
1558 set_the_hole(i);
1559 } else {
1560 set(i, hole_or_object->Number());
1561 }
1562 }
1563 int offset = kHeaderSize + old_length * kDoubleSize;
1564 for (int current = from->length(); current < length(); ++current) {
1565 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1566 offset += kDoubleSize;
1567 }
1568 }
1569
1570
1571 void FixedDoubleArray::Initialize(NumberDictionary* from) {
1572 int offset = kHeaderSize;
1573 for (int current = 0; current < length(); ++current) {
1574 WRITE_DOUBLE_FIELD(this, offset, hole_nan_as_double());
1575 offset += kDoubleSize;
1576 }
1577 for (int i = 0; i < from->Capacity(); i++) {
1578 Object* key = from->KeyAt(i);
1579 if (key->IsNumber()) {
1580 uint32_t entry = static_cast<uint32_t>(key->Number());
1581 set(entry, from->ValueAt(i)->Number());
1582 }
1583 }
1584 }
1585
1586
1478 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) { 1587 WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) {
1479 if (GetHeap()->InNewSpace(this)) return SKIP_WRITE_BARRIER; 1588 if (GetHeap()->InNewSpace(this)) return SKIP_WRITE_BARRIER;
1480 return UPDATE_WRITE_BARRIER; 1589 return UPDATE_WRITE_BARRIER;
1481 } 1590 }
1482 1591
1483 1592
1484 void FixedArray::set(int index, 1593 void FixedArray::set(int index,
1485 Object* value, 1594 Object* value,
1486 WriteBarrierMode mode) { 1595 WriteBarrierMode mode) {
1487 ASSERT(map() != HEAP->fixed_cow_array_map()); 1596 ASSERT(map() != HEAP->fixed_cow_array_map());
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 void NumberDictionary::set_requires_slow_elements() { 1881 void NumberDictionary::set_requires_slow_elements() {
1773 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask)); 1882 set(kMaxNumberKeyIndex, Smi::FromInt(kRequiresSlowElementsMask));
1774 } 1883 }
1775 1884
1776 1885
1777 // ------------------------------------ 1886 // ------------------------------------
1778 // Cast operations 1887 // Cast operations
1779 1888
1780 1889
1781 CAST_ACCESSOR(FixedArray) 1890 CAST_ACCESSOR(FixedArray)
1891 CAST_ACCESSOR(FixedDoubleArray)
1782 CAST_ACCESSOR(DescriptorArray) 1892 CAST_ACCESSOR(DescriptorArray)
1783 CAST_ACCESSOR(DeoptimizationInputData) 1893 CAST_ACCESSOR(DeoptimizationInputData)
1784 CAST_ACCESSOR(DeoptimizationOutputData) 1894 CAST_ACCESSOR(DeoptimizationOutputData)
1785 CAST_ACCESSOR(SymbolTable) 1895 CAST_ACCESSOR(SymbolTable)
1786 CAST_ACCESSOR(JSFunctionResultCache) 1896 CAST_ACCESSOR(JSFunctionResultCache)
1787 CAST_ACCESSOR(NormalizedMapCache) 1897 CAST_ACCESSOR(NormalizedMapCache)
1788 CAST_ACCESSOR(CompilationCacheTable) 1898 CAST_ACCESSOR(CompilationCacheTable)
1789 CAST_ACCESSOR(CodeCacheHashTable) 1899 CAST_ACCESSOR(CodeCacheHashTable)
1900 CAST_ACCESSOR(PolymorphicCodeCacheHashTable)
1790 CAST_ACCESSOR(MapCache) 1901 CAST_ACCESSOR(MapCache)
1791 CAST_ACCESSOR(String) 1902 CAST_ACCESSOR(String)
1792 CAST_ACCESSOR(SeqString) 1903 CAST_ACCESSOR(SeqString)
1793 CAST_ACCESSOR(SeqAsciiString) 1904 CAST_ACCESSOR(SeqAsciiString)
1794 CAST_ACCESSOR(SeqTwoByteString) 1905 CAST_ACCESSOR(SeqTwoByteString)
1795 CAST_ACCESSOR(ConsString) 1906 CAST_ACCESSOR(ConsString)
1796 CAST_ACCESSOR(ExternalString) 1907 CAST_ACCESSOR(ExternalString)
1797 CAST_ACCESSOR(ExternalAsciiString) 1908 CAST_ACCESSOR(ExternalAsciiString)
1798 CAST_ACCESSOR(ExternalTwoByteString) 1909 CAST_ACCESSOR(ExternalTwoByteString)
1910 CAST_ACCESSOR(JSReceiver)
1799 CAST_ACCESSOR(JSObject) 1911 CAST_ACCESSOR(JSObject)
1800 CAST_ACCESSOR(Smi) 1912 CAST_ACCESSOR(Smi)
1801 CAST_ACCESSOR(HeapObject) 1913 CAST_ACCESSOR(HeapObject)
1802 CAST_ACCESSOR(HeapNumber) 1914 CAST_ACCESSOR(HeapNumber)
1803 CAST_ACCESSOR(Oddball) 1915 CAST_ACCESSOR(Oddball)
1804 CAST_ACCESSOR(JSGlobalPropertyCell) 1916 CAST_ACCESSOR(JSGlobalPropertyCell)
1805 CAST_ACCESSOR(SharedFunctionInfo) 1917 CAST_ACCESSOR(SharedFunctionInfo)
1806 CAST_ACCESSOR(Map) 1918 CAST_ACCESSOR(Map)
1807 CAST_ACCESSOR(JSFunction) 1919 CAST_ACCESSOR(JSFunction)
1808 CAST_ACCESSOR(GlobalObject) 1920 CAST_ACCESSOR(GlobalObject)
1809 CAST_ACCESSOR(JSGlobalProxy) 1921 CAST_ACCESSOR(JSGlobalProxy)
1810 CAST_ACCESSOR(JSGlobalObject) 1922 CAST_ACCESSOR(JSGlobalObject)
1811 CAST_ACCESSOR(JSBuiltinsObject) 1923 CAST_ACCESSOR(JSBuiltinsObject)
1812 CAST_ACCESSOR(Code) 1924 CAST_ACCESSOR(Code)
1813 CAST_ACCESSOR(JSArray) 1925 CAST_ACCESSOR(JSArray)
1814 CAST_ACCESSOR(JSRegExp) 1926 CAST_ACCESSOR(JSRegExp)
1815 CAST_ACCESSOR(JSProxy) 1927 CAST_ACCESSOR(JSProxy)
1928 CAST_ACCESSOR(JSFunctionProxy)
1816 CAST_ACCESSOR(Foreign) 1929 CAST_ACCESSOR(Foreign)
1817 CAST_ACCESSOR(ByteArray) 1930 CAST_ACCESSOR(ByteArray)
1818 CAST_ACCESSOR(FreeSpace) 1931 CAST_ACCESSOR(FreeSpace)
1819 CAST_ACCESSOR(ExternalArray) 1932 CAST_ACCESSOR(ExternalArray)
1820 CAST_ACCESSOR(ExternalByteArray) 1933 CAST_ACCESSOR(ExternalByteArray)
1821 CAST_ACCESSOR(ExternalUnsignedByteArray) 1934 CAST_ACCESSOR(ExternalUnsignedByteArray)
1822 CAST_ACCESSOR(ExternalShortArray) 1935 CAST_ACCESSOR(ExternalShortArray)
1823 CAST_ACCESSOR(ExternalUnsignedShortArray) 1936 CAST_ACCESSOR(ExternalUnsignedShortArray)
1824 CAST_ACCESSOR(ExternalIntArray) 1937 CAST_ACCESSOR(ExternalIntArray)
1825 CAST_ACCESSOR(ExternalUnsignedIntArray) 1938 CAST_ACCESSOR(ExternalUnsignedIntArray)
1826 CAST_ACCESSOR(ExternalFloatArray) 1939 CAST_ACCESSOR(ExternalFloatArray)
1827 CAST_ACCESSOR(ExternalDoubleArray) 1940 CAST_ACCESSOR(ExternalDoubleArray)
1828 CAST_ACCESSOR(ExternalPixelArray) 1941 CAST_ACCESSOR(ExternalPixelArray)
1829 CAST_ACCESSOR(Struct) 1942 CAST_ACCESSOR(Struct)
1830 1943
1831 1944
1832 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name) 1945 #define MAKE_STRUCT_CAST(NAME, Name, name) CAST_ACCESSOR(Name)
1833 STRUCT_LIST(MAKE_STRUCT_CAST) 1946 STRUCT_LIST(MAKE_STRUCT_CAST)
1834 #undef MAKE_STRUCT_CAST 1947 #undef MAKE_STRUCT_CAST
1835 1948
1836 1949
1837 template <typename Shape, typename Key> 1950 template <typename Shape, typename Key>
1838 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) { 1951 HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) {
1839 ASSERT(obj->IsHashTable()); 1952 ASSERT(obj->IsHashTable());
1840 return reinterpret_cast<HashTable*>(obj); 1953 return reinterpret_cast<HashTable*>(obj);
1841 } 1954 }
1842 1955
1843 1956
1844 SMI_ACCESSORS(FixedArray, length, kLengthOffset) 1957 SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
1845 SMI_ACCESSORS(ByteArray, length, kLengthOffset) 1958 SMI_ACCESSORS(ByteArray, length, kLengthOffset)
1846 SMI_ACCESSORS(FreeSpace, size, kSizeOffset) 1959 SMI_ACCESSORS(FreeSpace, size, kSizeOffset)
1847 1960
1961 // TODO(1493): Investigate if it's possible to s/INT/SMI/ here (and
1962 // subsequently unify H{Fixed,External}ArrayLength).
1848 INT_ACCESSORS(ExternalArray, length, kLengthOffset) 1963 INT_ACCESSORS(ExternalArray, length, kLengthOffset)
1849 1964
1850 1965
1851 SMI_ACCESSORS(String, length, kLengthOffset) 1966 SMI_ACCESSORS(String, length, kLengthOffset)
1852 1967
1853 1968
1854 uint32_t String::hash_field() { 1969 uint32_t String::hash_field() {
1855 return READ_UINT32_FIELD(this, kHashFieldOffset); 1970 return READ_UINT32_FIELD(this, kHashFieldOffset);
1856 } 1971 }
1857 1972
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 if (instance_type == BYTE_ARRAY_TYPE) { 2412 if (instance_type == BYTE_ARRAY_TYPE) {
2298 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); 2413 return reinterpret_cast<ByteArray*>(this)->ByteArraySize();
2299 } 2414 }
2300 if (instance_type == FREE_SPACE_TYPE) { 2415 if (instance_type == FREE_SPACE_TYPE) {
2301 return reinterpret_cast<FreeSpace*>(this)->size(); 2416 return reinterpret_cast<FreeSpace*>(this)->size();
2302 } 2417 }
2303 if (instance_type == STRING_TYPE) { 2418 if (instance_type == STRING_TYPE) {
2304 return SeqTwoByteString::SizeFor( 2419 return SeqTwoByteString::SizeFor(
2305 reinterpret_cast<SeqTwoByteString*>(this)->length()); 2420 reinterpret_cast<SeqTwoByteString*>(this)->length());
2306 } 2421 }
2422 if (instance_type == FIXED_DOUBLE_ARRAY_TYPE) {
2423 return FixedDoubleArray::SizeFor(
2424 reinterpret_cast<FixedDoubleArray*>(this)->length());
2425 }
2307 ASSERT(instance_type == CODE_TYPE); 2426 ASSERT(instance_type == CODE_TYPE);
2308 return reinterpret_cast<Code*>(this)->CodeSize(); 2427 return reinterpret_cast<Code*>(this)->CodeSize();
2309 } 2428 }
2310 2429
2311 2430
2312 void Map::set_instance_size(int value) { 2431 void Map::set_instance_size(int value) {
2313 ASSERT_EQ(0, value & (kPointerSize - 1)); 2432 ASSERT_EQ(0, value & (kPointerSize - 1));
2314 value >>= kPointerSizeLog2; 2433 value >>= kPointerSizeLog2;
2315 ASSERT(0 <= value && value < 256); 2434 ASSERT(0 <= value && value < 256);
2316 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value)); 2435 WRITE_BYTE_FIELD(this, kInstanceSizeOffset, static_cast<byte>(value));
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2612 return static_cast<CheckType>(type); 2731 return static_cast<CheckType>(type);
2613 } 2732 }
2614 2733
2615 2734
2616 void Code::set_check_type(CheckType value) { 2735 void Code::set_check_type(CheckType value) {
2617 ASSERT(is_call_stub() || is_keyed_call_stub()); 2736 ASSERT(is_call_stub() || is_keyed_call_stub());
2618 WRITE_BYTE_FIELD(this, kCheckTypeOffset, value); 2737 WRITE_BYTE_FIELD(this, kCheckTypeOffset, value);
2619 } 2738 }
2620 2739
2621 2740
2622 ExternalArrayType Code::external_array_type() {
2623 ASSERT(is_keyed_load_stub() || is_keyed_store_stub());
2624 byte type = READ_BYTE_FIELD(this, kExternalArrayTypeOffset);
2625 return static_cast<ExternalArrayType>(type);
2626 }
2627
2628
2629 void Code::set_external_array_type(ExternalArrayType value) {
2630 ASSERT(is_keyed_load_stub() || is_keyed_store_stub());
2631 WRITE_BYTE_FIELD(this, kExternalArrayTypeOffset, value);
2632 }
2633
2634
2635 byte Code::unary_op_type() { 2741 byte Code::unary_op_type() {
2636 ASSERT(is_unary_op_stub()); 2742 ASSERT(is_unary_op_stub());
2637 return READ_BYTE_FIELD(this, kUnaryOpTypeOffset); 2743 return READ_BYTE_FIELD(this, kUnaryOpTypeOffset);
2638 } 2744 }
2639 2745
2640 2746
2641 void Code::set_unary_op_type(byte value) { 2747 void Code::set_unary_op_type(byte value) {
2642 ASSERT(is_unary_op_stub()); 2748 ASSERT(is_unary_op_stub());
2643 WRITE_BYTE_FIELD(this, kUnaryOpTypeOffset, value); 2749 WRITE_BYTE_FIELD(this, kUnaryOpTypeOffset, value);
2644 } 2750 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize); 2899 FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
2794 } 2900 }
2795 2901
2796 2902
2797 Object* Map::prototype() { 2903 Object* Map::prototype() {
2798 return READ_FIELD(this, kPrototypeOffset); 2904 return READ_FIELD(this, kPrototypeOffset);
2799 } 2905 }
2800 2906
2801 2907
2802 void Map::set_prototype(Object* value, WriteBarrierMode mode) { 2908 void Map::set_prototype(Object* value, WriteBarrierMode mode) {
2803 ASSERT(value->IsNull() || value->IsJSObject()); 2909 ASSERT(value->IsNull() || value->IsJSReceiver());
2804 WRITE_FIELD(this, kPrototypeOffset, value); 2910 WRITE_FIELD(this, kPrototypeOffset, value);
2805 WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value); 2911 WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, value);
2806 } 2912 }
2807 2913
2808 2914
2809 MaybeObject* Map::GetFastElementsMap() { 2915 MaybeObject* Map::GetFastElementsMap() {
2810 if (has_fast_elements()) return this; 2916 if (has_fast_elements()) return this;
2811 Object* obj; 2917 Object* obj;
2812 { MaybeObject* maybe_obj = CopyDropTransitions(); 2918 { MaybeObject* maybe_obj = CopyDropTransitions();
2813 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2919 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2814 } 2920 }
2815 Map* new_map = Map::cast(obj); 2921 Map* new_map = Map::cast(obj);
2816 new_map->set_has_fast_elements(true); 2922 new_map->set_elements_kind(JSObject::FAST_ELEMENTS);
2817 GetIsolate()->counters()->map_slow_to_fast_elements()->Increment(); 2923 GetHeap()->isolate()->counters()->map_to_fast_elements()->Increment();
2924 return new_map;
2925 }
2926
2927
2928 MaybeObject* Map::GetFastDoubleElementsMap() {
2929 if (has_fast_double_elements()) return this;
2930 Object* obj;
2931 { MaybeObject* maybe_obj = CopyDropTransitions();
2932 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2933 }
2934 Map* new_map = Map::cast(obj);
2935 new_map->set_elements_kind(JSObject::FAST_DOUBLE_ELEMENTS);
2936 GetHeap()->isolate()->counters()->map_to_fast_double_elements()->Increment();
2818 return new_map; 2937 return new_map;
2819 } 2938 }
2820 2939
2821 2940
2822 MaybeObject* Map::GetSlowElementsMap() { 2941 MaybeObject* Map::GetSlowElementsMap() {
2823 if (!has_fast_elements()) return this; 2942 if (!has_fast_elements() && !has_fast_double_elements()) return this;
2824 Object* obj; 2943 Object* obj;
2825 { MaybeObject* maybe_obj = CopyDropTransitions(); 2944 { MaybeObject* maybe_obj = CopyDropTransitions();
2826 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 2945 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2827 } 2946 }
2828 Map* new_map = Map::cast(obj); 2947 Map* new_map = Map::cast(obj);
2829 new_map->set_has_fast_elements(false); 2948 new_map->set_elements_kind(JSObject::DICTIONARY_ELEMENTS);
2830 GetIsolate()->counters()->map_fast_to_slow_elements()->Increment(); 2949 GetHeap()->isolate()->counters()->map_to_slow_elements()->Increment();
2831 return new_map; 2950 return new_map;
2832 } 2951 }
2833 2952
2834 2953
2835 DescriptorArray* Map::instance_descriptors() { 2954 DescriptorArray* Map::instance_descriptors() {
2836 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset); 2955 Object* object = READ_FIELD(this, kInstanceDescriptorsOrBitField3Offset);
2837 if (object->IsSmi()) { 2956 if (object->IsSmi()) {
2838 return HEAP->empty_descriptor_array(); 2957 return HEAP->empty_descriptor_array();
2839 } else { 2958 } else {
2840 return DescriptorArray::cast(object); 2959 return DescriptorArray::cast(object);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 if (object->IsSmi()) { 3018 if (object->IsSmi()) {
2900 WRITE_FIELD(this, 3019 WRITE_FIELD(this,
2901 kInstanceDescriptorsOrBitField3Offset, 3020 kInstanceDescriptorsOrBitField3Offset,
2902 Smi::FromInt(value)); 3021 Smi::FromInt(value));
2903 } else { 3022 } else {
2904 DescriptorArray::cast(object)->set_bit_field3_storage(value); 3023 DescriptorArray::cast(object)->set_bit_field3_storage(value);
2905 } 3024 }
2906 } 3025 }
2907 3026
2908 3027
3028 FixedArray* Map::unchecked_prototype_transitions() {
3029 return reinterpret_cast<FixedArray*>(
3030 READ_FIELD(this, kPrototypeTransitionsOffset));
3031 }
3032
3033
2909 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset) 3034 ACCESSORS(Map, code_cache, Object, kCodeCacheOffset)
2910 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset) 3035 ACCESSORS(Map, prototype_transitions, FixedArray, kPrototypeTransitionsOffset)
2911 ACCESSORS(Map, constructor, Object, kConstructorOffset) 3036 ACCESSORS(Map, constructor, Object, kConstructorOffset)
2912 3037
2913 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) 3038 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
2914 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset) 3039 ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset)
2915 ACCESSORS(JSFunction, 3040 ACCESSORS(JSFunction,
2916 next_function_link, 3041 next_function_link,
2917 Object, 3042 Object,
2918 kNextFunctionLinkOffset) 3043 kNextFunctionLinkOffset)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 kIndexedPropertyHandlerOffset) 3084 kIndexedPropertyHandlerOffset)
2960 ACCESSORS(FunctionTemplateInfo, instance_template, Object, 3085 ACCESSORS(FunctionTemplateInfo, instance_template, Object,
2961 kInstanceTemplateOffset) 3086 kInstanceTemplateOffset)
2962 ACCESSORS(FunctionTemplateInfo, class_name, Object, kClassNameOffset) 3087 ACCESSORS(FunctionTemplateInfo, class_name, Object, kClassNameOffset)
2963 ACCESSORS(FunctionTemplateInfo, signature, Object, kSignatureOffset) 3088 ACCESSORS(FunctionTemplateInfo, signature, Object, kSignatureOffset)
2964 ACCESSORS(FunctionTemplateInfo, instance_call_handler, Object, 3089 ACCESSORS(FunctionTemplateInfo, instance_call_handler, Object,
2965 kInstanceCallHandlerOffset) 3090 kInstanceCallHandlerOffset)
2966 ACCESSORS(FunctionTemplateInfo, access_check_info, Object, 3091 ACCESSORS(FunctionTemplateInfo, access_check_info, Object,
2967 kAccessCheckInfoOffset) 3092 kAccessCheckInfoOffset)
2968 ACCESSORS(FunctionTemplateInfo, flag, Smi, kFlagOffset) 3093 ACCESSORS(FunctionTemplateInfo, flag, Smi, kFlagOffset)
3094 ACCESSORS(FunctionTemplateInfo, prototype_attributes, Smi,
3095 kPrototypeAttributesOffset)
2969 3096
2970 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) 3097 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset)
2971 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, 3098 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object,
2972 kInternalFieldCountOffset) 3099 kInternalFieldCountOffset)
2973 3100
2974 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) 3101 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset)
2975 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) 3102 ACCESSORS(SignatureInfo, args, Object, kArgsOffset)
2976 3103
2977 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) 3104 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset)
2978 3105
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 3144
3018 BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype, 3145 BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype,
3019 kHiddenPrototypeBit) 3146 kHiddenPrototypeBit)
3020 BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit) 3147 BOOL_ACCESSORS(FunctionTemplateInfo, flag, undetectable, kUndetectableBit)
3021 BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check, 3148 BOOL_ACCESSORS(FunctionTemplateInfo, flag, needs_access_check,
3022 kNeedsAccessCheckBit) 3149 kNeedsAccessCheckBit)
3023 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, 3150 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression,
3024 kIsExpressionBit) 3151 kIsExpressionBit)
3025 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel, 3152 BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
3026 kIsTopLevelBit) 3153 kIsTopLevelBit)
3027 BOOL_GETTER(SharedFunctionInfo, compiler_hints, 3154 BOOL_GETTER(SharedFunctionInfo,
3155 compiler_hints,
3028 has_only_simple_this_property_assignments, 3156 has_only_simple_this_property_assignments,
3029 kHasOnlySimpleThisPropertyAssignments) 3157 kHasOnlySimpleThisPropertyAssignments)
3030 BOOL_ACCESSORS(SharedFunctionInfo, 3158 BOOL_ACCESSORS(SharedFunctionInfo,
3031 compiler_hints, 3159 compiler_hints,
3032 allows_lazy_compilation, 3160 allows_lazy_compilation,
3033 kAllowLazyCompilation) 3161 kAllowLazyCompilation)
3162 BOOL_ACCESSORS(SharedFunctionInfo,
3163 compiler_hints,
3164 uses_arguments,
3165 kUsesArguments)
3166 BOOL_ACCESSORS(SharedFunctionInfo,
3167 compiler_hints,
3168 has_duplicate_parameters,
3169 kHasDuplicateParameters)
3034 3170
3035 3171
3036 #if V8_HOST_ARCH_32_BIT 3172 #if V8_HOST_ARCH_32_BIT
3037 SMI_ACCESSORS(SharedFunctionInfo, length, kLengthOffset) 3173 SMI_ACCESSORS(SharedFunctionInfo, length, kLengthOffset)
3038 SMI_ACCESSORS(SharedFunctionInfo, formal_parameter_count, 3174 SMI_ACCESSORS(SharedFunctionInfo, formal_parameter_count,
3039 kFormalParameterCountOffset) 3175 kFormalParameterCountOffset)
3040 SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties, 3176 SMI_ACCESSORS(SharedFunctionInfo, expected_nof_properties,
3041 kExpectedNofPropertiesOffset) 3177 kExpectedNofPropertiesOffset)
3042 SMI_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset) 3178 SMI_ACCESSORS(SharedFunctionInfo, num_literals, kNumLiteralsOffset)
3043 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type, 3179 SMI_ACCESSORS(SharedFunctionInfo, start_position_and_type,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 return READ_BYTE_FIELD(this, kConstructionCountOffset); 3243 return READ_BYTE_FIELD(this, kConstructionCountOffset);
3108 } 3244 }
3109 3245
3110 3246
3111 void SharedFunctionInfo::set_construction_count(int value) { 3247 void SharedFunctionInfo::set_construction_count(int value) {
3112 ASSERT(0 <= value && value < 256); 3248 ASSERT(0 <= value && value < 256);
3113 WRITE_BYTE_FIELD(this, kConstructionCountOffset, static_cast<byte>(value)); 3249 WRITE_BYTE_FIELD(this, kConstructionCountOffset, static_cast<byte>(value));
3114 } 3250 }
3115 3251
3116 3252
3117 bool SharedFunctionInfo::live_objects_may_exist() { 3253 BOOL_ACCESSORS(SharedFunctionInfo,
3118 return (compiler_hints() & (1 << kLiveObjectsMayExist)) != 0; 3254 compiler_hints,
3119 } 3255 live_objects_may_exist,
3120 3256 kLiveObjectsMayExist)
3121
3122 void SharedFunctionInfo::set_live_objects_may_exist(bool value) {
3123 if (value) {
3124 set_compiler_hints(compiler_hints() | (1 << kLiveObjectsMayExist));
3125 } else {
3126 set_compiler_hints(compiler_hints() & ~(1 << kLiveObjectsMayExist));
3127 }
3128 }
3129 3257
3130 3258
3131 bool SharedFunctionInfo::IsInobjectSlackTrackingInProgress() { 3259 bool SharedFunctionInfo::IsInobjectSlackTrackingInProgress() {
3132 return initial_map() != HEAP->undefined_value(); 3260 return initial_map() != HEAP->undefined_value();
3133 } 3261 }
3134 3262
3135 3263
3136 bool SharedFunctionInfo::optimization_disabled() { 3264 BOOL_GETTER(SharedFunctionInfo,
3137 return BooleanBit::get(compiler_hints(), kOptimizationDisabled); 3265 compiler_hints,
3138 } 3266 optimization_disabled,
3267 kOptimizationDisabled)
3139 3268
3140 3269
3141 void SharedFunctionInfo::set_optimization_disabled(bool disable) { 3270 void SharedFunctionInfo::set_optimization_disabled(bool disable) {
3142 set_compiler_hints(BooleanBit::set(compiler_hints(), 3271 set_compiler_hints(BooleanBit::set(compiler_hints(),
3143 kOptimizationDisabled, 3272 kOptimizationDisabled,
3144 disable)); 3273 disable));
3145 // If disabling optimizations we reflect that in the code object so 3274 // If disabling optimizations we reflect that in the code object so
3146 // it will not be counted as optimizable code. 3275 // it will not be counted as optimizable code.
3147 if ((code()->kind() == Code::FUNCTION) && disable) { 3276 if ((code()->kind() == Code::FUNCTION) && disable) {
3148 code()->set_optimizable(false); 3277 code()->set_optimizable(false);
3149 } 3278 }
3150 } 3279 }
3151 3280
3152 3281
3153 bool SharedFunctionInfo::strict_mode() { 3282 BOOL_ACCESSORS(SharedFunctionInfo,
3154 return BooleanBit::get(compiler_hints(), kStrictModeFunction); 3283 compiler_hints,
3284 strict_mode,
3285 kStrictModeFunction)
3286
3287
3288 bool SharedFunctionInfo::native() {
3289 return BooleanBit::get(compiler_hints(), kNative);
3155 } 3290 }
3156 3291
3157 3292
3158 void SharedFunctionInfo::set_strict_mode(bool value) { 3293 void SharedFunctionInfo::set_native(bool value) {
3159 set_compiler_hints(BooleanBit::set(compiler_hints(), 3294 set_compiler_hints(BooleanBit::set(compiler_hints(),
3160 kStrictModeFunction, 3295 kNative,
3161 value)); 3296 value));
3162 } 3297 }
3163 3298
3164 3299
3165 bool SharedFunctionInfo::es5_native() { 3300 bool SharedFunctionInfo::bound() {
3166 return BooleanBit::get(compiler_hints(), kES5Native); 3301 return BooleanBit::get(compiler_hints(), kBoundFunction);
3167 } 3302 }
3168 3303
3169 3304
3170 void SharedFunctionInfo::set_es5_native(bool value) { 3305 void SharedFunctionInfo::set_bound(bool value) {
3171 set_compiler_hints(BooleanBit::set(compiler_hints(), 3306 set_compiler_hints(BooleanBit::set(compiler_hints(),
3172 kES5Native, 3307 kBoundFunction,
3173 value)); 3308 value));
3174 } 3309 }
3175 3310
3176 3311
3177 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset) 3312 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset)
3178 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset) 3313 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset)
3179 3314
3315 ACCESSORS(PolymorphicCodeCache, cache, Object, kCacheOffset)
3316
3180 bool Script::HasValidSource() { 3317 bool Script::HasValidSource() {
3181 Object* src = this->source(); 3318 Object* src = this->source();
3182 if (!src->IsString()) return true; 3319 if (!src->IsString()) return true;
3183 String* src_str = String::cast(src); 3320 String* src_str = String::cast(src);
3184 if (!StringShape(src_str).IsExternal()) return true; 3321 if (!StringShape(src_str).IsExternal()) return true;
3185 if (src_str->IsAsciiRepresentation()) { 3322 if (src_str->IsAsciiRepresentation()) {
3186 return ExternalAsciiString::cast(src)->resource() != NULL; 3323 return ExternalAsciiString::cast(src)->resource() != NULL;
3187 } else if (src_str->IsTwoByteRepresentation()) { 3324 } else if (src_str->IsTwoByteRepresentation()) {
3188 return ExternalTwoByteString::cast(src)->resource() != NULL; 3325 return ExternalTwoByteString::cast(src)->resource() != NULL;
3189 } 3326 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3573 3710
3574 3711
3575 JSRegExp::Type JSRegExp::TypeTag() { 3712 JSRegExp::Type JSRegExp::TypeTag() {
3576 Object* data = this->data(); 3713 Object* data = this->data();
3577 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED; 3714 if (data->IsUndefined()) return JSRegExp::NOT_COMPILED;
3578 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex)); 3715 Smi* smi = Smi::cast(FixedArray::cast(data)->get(kTagIndex));
3579 return static_cast<JSRegExp::Type>(smi->value()); 3716 return static_cast<JSRegExp::Type>(smi->value());
3580 } 3717 }
3581 3718
3582 3719
3720 JSRegExp::Type JSRegExp::TypeTagUnchecked() {
3721 Smi* smi = Smi::cast(DataAtUnchecked(kTagIndex));
3722 return static_cast<JSRegExp::Type>(smi->value());
3723 }
3724
3725
3583 int JSRegExp::CaptureCount() { 3726 int JSRegExp::CaptureCount() {
3584 switch (TypeTag()) { 3727 switch (TypeTag()) {
3585 case ATOM: 3728 case ATOM:
3586 return 0; 3729 return 0;
3587 case IRREGEXP: 3730 case IRREGEXP:
3588 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value(); 3731 return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value();
3589 default: 3732 default:
3590 UNREACHABLE(); 3733 UNREACHABLE();
3591 return -1; 3734 return -1;
3592 } 3735 }
(...skipping 15 matching lines...) Expand all
3608 return pattern; 3751 return pattern;
3609 } 3752 }
3610 3753
3611 3754
3612 Object* JSRegExp::DataAt(int index) { 3755 Object* JSRegExp::DataAt(int index) {
3613 ASSERT(TypeTag() != NOT_COMPILED); 3756 ASSERT(TypeTag() != NOT_COMPILED);
3614 return FixedArray::cast(data())->get(index); 3757 return FixedArray::cast(data())->get(index);
3615 } 3758 }
3616 3759
3617 3760
3761 Object* JSRegExp::DataAtUnchecked(int index) {
3762 FixedArray* fa = reinterpret_cast<FixedArray*>(data());
3763 int offset = FixedArray::kHeaderSize + index * kPointerSize;
3764 return READ_FIELD(fa, offset);
3765 }
3766
3767
3618 void JSRegExp::SetDataAt(int index, Object* value) { 3768 void JSRegExp::SetDataAt(int index, Object* value) {
3619 ASSERT(TypeTag() != NOT_COMPILED); 3769 ASSERT(TypeTag() != NOT_COMPILED);
3620 ASSERT(index >= kDataIndex); // Only implementation data can be set this way. 3770 ASSERT(index >= kDataIndex); // Only implementation data can be set this way.
3621 FixedArray::cast(data())->set(index, value); 3771 FixedArray::cast(data())->set(index, value);
3622 } 3772 }
3623 3773
3624 3774
3775 void JSRegExp::SetDataAtUnchecked(int index, Object* value, Heap* heap) {
3776 ASSERT(index >= kDataIndex); // Only implementation data can be set this way.
3777 FixedArray* fa = reinterpret_cast<FixedArray*>(data());
3778 if (value->IsSmi()) {
3779 fa->set_unchecked(index, Smi::cast(value));
3780 } else {
3781 fa->set_unchecked(heap, index, value, SKIP_WRITE_BARRIER);
3782 }
3783 }
3784
3785
3625 JSObject::ElementsKind JSObject::GetElementsKind() { 3786 JSObject::ElementsKind JSObject::GetElementsKind() {
3626 if (map()->has_fast_elements()) { 3787 ElementsKind kind = map()->elements_kind();
3627 ASSERT(elements()->map() == GetHeap()->fixed_array_map() || 3788 ASSERT((kind == FAST_ELEMENTS &&
3628 elements()->map() == GetHeap()->fixed_cow_array_map()); 3789 (elements()->map() == GetHeap()->fixed_array_map() ||
3629 return FAST_ELEMENTS; 3790 elements()->map() == GetHeap()->fixed_cow_array_map())) ||
3630 } 3791 (kind == FAST_DOUBLE_ELEMENTS &&
3631 HeapObject* array = elements(); 3792 elements()->IsFixedDoubleArray()) ||
3632 if (array->IsFixedArray()) { 3793 (kind == DICTIONARY_ELEMENTS &&
3633 // FAST_ELEMENTS or DICTIONARY_ELEMENTS are both stored in a 3794 elements()->IsFixedArray() &&
3634 // FixedArray, but FAST_ELEMENTS is already handled above. 3795 elements()->IsDictionary()) ||
3635 ASSERT(array->IsDictionary()); 3796 (kind > DICTIONARY_ELEMENTS));
3636 return DICTIONARY_ELEMENTS; 3797 return kind;
3637 }
3638 ASSERT(!map()->has_fast_elements());
3639 if (array->IsExternalArray()) {
3640 switch (array->map()->instance_type()) {
3641 case EXTERNAL_BYTE_ARRAY_TYPE:
3642 return EXTERNAL_BYTE_ELEMENTS;
3643 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
3644 return EXTERNAL_UNSIGNED_BYTE_ELEMENTS;
3645 case EXTERNAL_SHORT_ARRAY_TYPE:
3646 return EXTERNAL_SHORT_ELEMENTS;
3647 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE:
3648 return EXTERNAL_UNSIGNED_SHORT_ELEMENTS;
3649 case EXTERNAL_INT_ARRAY_TYPE:
3650 return EXTERNAL_INT_ELEMENTS;
3651 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
3652 return EXTERNAL_UNSIGNED_INT_ELEMENTS;
3653 case EXTERNAL_FLOAT_ARRAY_TYPE:
3654 return EXTERNAL_FLOAT_ELEMENTS;
3655 case EXTERNAL_DOUBLE_ARRAY_TYPE:
3656 return EXTERNAL_DOUBLE_ELEMENTS;
3657 case EXTERNAL_PIXEL_ARRAY_TYPE:
3658 return EXTERNAL_PIXEL_ELEMENTS;
3659 default:
3660 break;
3661 }
3662 }
3663 UNREACHABLE();
3664 return DICTIONARY_ELEMENTS;
3665 } 3798 }
3666 3799
3667 3800
3668 bool JSObject::HasFastElements() { 3801 bool JSObject::HasFastElements() {
3669 return GetElementsKind() == FAST_ELEMENTS; 3802 return GetElementsKind() == FAST_ELEMENTS;
3670 } 3803 }
3671 3804
3672 3805
3806 bool JSObject::HasFastDoubleElements() {
3807 return GetElementsKind() == FAST_DOUBLE_ELEMENTS;
3808 }
3809
3810
3673 bool JSObject::HasDictionaryElements() { 3811 bool JSObject::HasDictionaryElements() {
3674 return GetElementsKind() == DICTIONARY_ELEMENTS; 3812 return GetElementsKind() == DICTIONARY_ELEMENTS;
3675 } 3813 }
3676 3814
3677 3815
3678 bool JSObject::HasExternalArrayElements() { 3816 bool JSObject::HasExternalArrayElements() {
3679 HeapObject* array = elements(); 3817 HeapObject* array = elements();
3680 ASSERT(array != NULL); 3818 ASSERT(array != NULL);
3681 return array->IsExternalArray(); 3819 return array->IsExternalArray();
3682 } 3820 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3856 3994
3857 bool String::AsArrayIndex(uint32_t* index) { 3995 bool String::AsArrayIndex(uint32_t* index) {
3858 uint32_t field = hash_field(); 3996 uint32_t field = hash_field();
3859 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) { 3997 if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) {
3860 return false; 3998 return false;
3861 } 3999 }
3862 return SlowAsArrayIndex(index); 4000 return SlowAsArrayIndex(index);
3863 } 4001 }
3864 4002
3865 4003
3866 Object* JSObject::GetPrototype() { 4004 Object* JSReceiver::GetPrototype() {
3867 return JSObject::cast(this)->map()->prototype(); 4005 return HeapObject::cast(this)->map()->prototype();
3868 } 4006 }
3869 4007
3870 4008
3871 PropertyAttributes JSObject::GetPropertyAttribute(String* key) { 4009 PropertyAttributes JSReceiver::GetPropertyAttribute(String* key) {
3872 return GetPropertyAttributeWithReceiver(this, key); 4010 return GetPropertyAttributeWithReceiver(this, key);
3873 } 4011 }
3874 4012
3875 // TODO(504): this may be useful in other places too where JSGlobalProxy 4013 // TODO(504): this may be useful in other places too where JSGlobalProxy
3876 // is used. 4014 // is used.
3877 Object* JSObject::BypassGlobalProxy() { 4015 Object* JSObject::BypassGlobalProxy() {
3878 if (IsJSGlobalProxy()) { 4016 if (IsJSGlobalProxy()) {
3879 Object* proto = GetPrototype(); 4017 Object* proto = GetPrototype();
3880 if (proto->IsNull()) return GetHeap()->undefined_value(); 4018 if (proto->IsNull()) return GetHeap()->undefined_value();
3881 ASSERT(proto->IsJSGlobalObject()); 4019 ASSERT(proto->IsJSGlobalObject());
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4174 #undef WRITE_INT_FIELD 4312 #undef WRITE_INT_FIELD
4175 #undef READ_SHORT_FIELD 4313 #undef READ_SHORT_FIELD
4176 #undef WRITE_SHORT_FIELD 4314 #undef WRITE_SHORT_FIELD
4177 #undef READ_BYTE_FIELD 4315 #undef READ_BYTE_FIELD
4178 #undef WRITE_BYTE_FIELD 4316 #undef WRITE_BYTE_FIELD
4179 4317
4180 4318
4181 } } // namespace v8::internal 4319 } } // namespace v8::internal
4182 4320
4183 #endif // V8_OBJECTS_INL_H_ 4321 #endif // V8_OBJECTS_INL_H_
OLDNEW
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698